| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/gpu/input_handler_proxy.h" | 5 #include "content/renderer/gpu/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/renderer/gpu/input_handler_proxy_client.h" | 9 #include "content/renderer/gpu/input_handler_proxy_client.h" |
| 10 #include "third_party/WebKit/public/platform/Platform.h" | 10 #include "third_party/WebKit/public/platform/Platform.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 void InputHandlerProxy::SetClient(InputHandlerProxyClient* client) { | 46 void InputHandlerProxy::SetClient(InputHandlerProxyClient* client) { |
| 47 DCHECK(!client_ || !client); | 47 DCHECK(!client_ || !client); |
| 48 client_ = client; | 48 client_ = client; |
| 49 } | 49 } |
| 50 | 50 |
| 51 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( | 51 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( |
| 52 const WebInputEvent& event) { | 52 const WebInputEvent& event) { |
| 53 DCHECK(client_); | 53 DCHECK(client_); |
| 54 DCHECK(input_handler_); | 54 DCHECK(input_handler_); |
| 55 | 55 |
| 56 InputHandlerProxy::EventDisposition disposition = | |
| 57 HandleInputEventInternal(event); | |
| 58 if (event.modifiers & WebInputEvent::IsLastInputEventForCurrentVSync) { | |
| 59 input_handler_->DidReceiveLastInputEventForBeginFrame( | |
| 60 base::TimeTicks::FromInternalValue(event.timeStampSeconds * | |
| 61 base::Time::kMicrosecondsPerSecond)); | |
| 62 } | |
| 63 return disposition; | |
| 64 } | |
| 65 | |
| 66 InputHandlerProxy::EventDisposition | |
| 67 InputHandlerProxy::HandleInputEventInternal(const WebInputEvent& event) { | |
| 68 if (event.type == WebInputEvent::MouseWheel) { | 56 if (event.type == WebInputEvent::MouseWheel) { |
| 69 const WebMouseWheelEvent& wheel_event = | 57 const WebMouseWheelEvent& wheel_event = |
| 70 *static_cast<const WebMouseWheelEvent*>(&event); | 58 *static_cast<const WebMouseWheelEvent*>(&event); |
| 71 if (wheel_event.scrollByPage) { | 59 if (wheel_event.scrollByPage) { |
| 72 // TODO(jamesr): We don't properly handle scroll by page in the compositor | 60 // TODO(jamesr): We don't properly handle scroll by page in the compositor |
| 73 // thread, so punt it to the main thread. http://crbug.com/236639 | 61 // thread, so punt it to the main thread. http://crbug.com/236639 |
| 74 return DID_NOT_HANDLE; | 62 return DID_NOT_HANDLE; |
| 75 } | 63 } |
| 76 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( | 64 cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( |
| 77 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); | 65 gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::Wheel); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 synthetic_wheel.deltaX = increment.width; | 323 synthetic_wheel.deltaX = increment.width; |
| 336 synthetic_wheel.deltaY = increment.height; | 324 synthetic_wheel.deltaY = increment.height; |
| 337 synthetic_wheel.hasPreciseScrollingDeltas = true; | 325 synthetic_wheel.hasPreciseScrollingDeltas = true; |
| 338 synthetic_wheel.x = fling_parameters_.point.x; | 326 synthetic_wheel.x = fling_parameters_.point.x; |
| 339 synthetic_wheel.y = fling_parameters_.point.y; | 327 synthetic_wheel.y = fling_parameters_.point.y; |
| 340 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; | 328 synthetic_wheel.globalX = fling_parameters_.globalPoint.x; |
| 341 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; | 329 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; |
| 342 synthetic_wheel.modifiers = fling_parameters_.modifiers; | 330 synthetic_wheel.modifiers = fling_parameters_.modifiers; |
| 343 | 331 |
| 344 InputHandlerProxy::EventDisposition disposition = | 332 InputHandlerProxy::EventDisposition disposition = |
| 345 HandleInputEventInternal(synthetic_wheel); | 333 HandleInputEvent(synthetic_wheel); |
| 346 switch (disposition) { | 334 switch (disposition) { |
| 347 case DID_HANDLE: | 335 case DID_HANDLE: |
| 348 return true; | 336 return true; |
| 349 case DROP_EVENT: | 337 case DROP_EVENT: |
| 350 break; | 338 break; |
| 351 case DID_NOT_HANDLE: | 339 case DID_NOT_HANDLE: |
| 352 TRACE_EVENT_INSTANT0("renderer", | 340 TRACE_EVENT_INSTANT0("renderer", |
| 353 "InputHandlerProxy::scrollBy::AbortFling", | 341 "InputHandlerProxy::scrollBy::AbortFling", |
| 354 TRACE_EVENT_SCOPE_THREAD); | 342 TRACE_EVENT_SCOPE_THREAD); |
| 355 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the | 343 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 TRACE_EVENT2("renderer", | 400 TRACE_EVENT2("renderer", |
| 413 "InputHandlerProxy::notifyCurrentFlingVelocity", | 401 "InputHandlerProxy::notifyCurrentFlingVelocity", |
| 414 "vx", | 402 "vx", |
| 415 velocity.width, | 403 velocity.width, |
| 416 "vy", | 404 "vy", |
| 417 velocity.height); | 405 velocity.height); |
| 418 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); | 406 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); |
| 419 } | 407 } |
| 420 | 408 |
| 421 } // namespace content | 409 } // namespace content |
| OLD | NEW |