| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "ui/events/blink/input_handler_proxy.h" | 5 #include "ui/events/blink/input_handler_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 ReportInputEventLatencyUma(event, *latency_info); | 268 ReportInputEventLatencyUma(event, *latency_info); |
| 269 | 269 |
| 270 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 270 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
| 271 "LatencyInfo.Flow", | 271 "LatencyInfo.Flow", |
| 272 TRACE_ID_DONT_MANGLE(latency_info->trace_id()), | 272 TRACE_ID_DONT_MANGLE(latency_info->trace_id()), |
| 273 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 273 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
| 274 "step", "HandleInputEventImpl"); | 274 "step", "HandleInputEventImpl"); |
| 275 | 275 |
| 276 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = | 276 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = |
| 277 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); | 277 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); |
| 278 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); | 278 InputHandlerProxy::EventDisposition disposition = |
| 279 HandleInputEvent(event, latency_info); |
| 279 return disposition; | 280 return disposition; |
| 280 } | 281 } |
| 281 | 282 |
| 282 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( | 283 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( |
| 283 const WebInputEvent& event) { | 284 const WebInputEvent& event, |
| 285 ui::LatencyInfo* latency_info) { |
| 284 DCHECK(input_handler_); | 286 DCHECK(input_handler_); |
| 285 | 287 |
| 286 if (FilterInputEventForFlingBoosting(event)) | 288 if (FilterInputEventForFlingBoosting(event)) |
| 287 return DID_HANDLE; | 289 return DID_HANDLE; |
| 288 | 290 |
| 289 switch (event.type) { | 291 switch (event.type) { |
| 290 case WebInputEvent::MouseWheel: | 292 case WebInputEvent::MouseWheel: |
| 291 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); | 293 return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); |
| 292 | 294 |
| 293 case WebInputEvent::GestureScrollBegin: | 295 case WebInputEvent::GestureScrollBegin: |
| 294 return HandleGestureScrollBegin( | 296 return HandleGestureScrollBegin( |
| 295 static_cast<const WebGestureEvent&>(event)); | 297 static_cast<const WebGestureEvent&>(event)); |
| 296 | 298 |
| 297 case WebInputEvent::GestureScrollUpdate: | 299 case WebInputEvent::GestureScrollUpdate: |
| 298 return HandleGestureScrollUpdate( | 300 return HandleGestureScrollUpdate( |
| 299 static_cast<const WebGestureEvent&>(event)); | 301 static_cast<const WebGestureEvent&>(event), latency_info); |
| 300 | 302 |
| 301 case WebInputEvent::GestureScrollEnd: | 303 case WebInputEvent::GestureScrollEnd: |
| 302 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event)); | 304 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event)); |
| 303 | 305 |
| 304 case WebInputEvent::GesturePinchBegin: { | 306 case WebInputEvent::GesturePinchBegin: { |
| 305 DCHECK(!gesture_pinch_on_impl_thread_); | 307 DCHECK(!gesture_pinch_on_impl_thread_); |
| 306 const WebGestureEvent& gesture_event = | 308 const WebGestureEvent& gesture_event = |
| 307 static_cast<const WebGestureEvent&>(event); | 309 static_cast<const WebGestureEvent&>(event); |
| 308 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && | 310 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && |
| 309 input_handler_->GetEventListenerProperties( | 311 input_handler_->GetEventListenerProperties( |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 blink::WebGestureDeviceTouchpad, | 491 blink::WebGestureDeviceTouchpad, |
| 490 cc::MainThreadScrollingReason::kPageBasedScrolling); | 492 cc::MainThreadScrollingReason::kPageBasedScrolling); |
| 491 | 493 |
| 492 } else if (!wheel_event.canScroll) { | 494 } else if (!wheel_event.canScroll) { |
| 493 // Wheel events with |canScroll| == false will not trigger scrolling, | 495 // Wheel events with |canScroll| == false will not trigger scrolling, |
| 494 // only event handlers. Forward to the main thread. | 496 // only event handlers. Forward to the main thread. |
| 495 result = DID_NOT_HANDLE; | 497 result = DID_NOT_HANDLE; |
| 496 } else if (ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)) { | 498 } else if (ShouldAnimate(wheel_event.hasPreciseScrollingDeltas)) { |
| 497 cc::InputHandler::ScrollStatus scroll_status = | 499 cc::InputHandler::ScrollStatus scroll_status = |
| 498 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y), | 500 input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y), |
| 499 scroll_delta); | 501 scroll_delta, nullptr); |
| 500 | 502 |
| 501 RecordMainThreadScrollingReasons( | 503 RecordMainThreadScrollingReasons( |
| 502 blink::WebGestureDeviceTouchpad, | 504 blink::WebGestureDeviceTouchpad, |
| 503 scroll_status.main_thread_scrolling_reasons); | 505 scroll_status.main_thread_scrolling_reasons); |
| 504 | 506 |
| 505 switch (scroll_status.thread) { | 507 switch (scroll_status.thread) { |
| 506 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: | 508 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: |
| 507 result = DID_HANDLE; | 509 result = DID_HANDLE; |
| 508 break; | 510 break; |
| 509 case cc::InputHandler::SCROLL_IGNORED: | 511 case cc::InputHandler::SCROLL_IGNORED: |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 638 } |
| 637 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) | 639 if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) |
| 638 HandleScrollElasticityOverscroll(gesture_event, | 640 HandleScrollElasticityOverscroll(gesture_event, |
| 639 cc::InputHandlerScrollResult()); | 641 cc::InputHandlerScrollResult()); |
| 640 | 642 |
| 641 return result; | 643 return result; |
| 642 } | 644 } |
| 643 | 645 |
| 644 InputHandlerProxy::EventDisposition | 646 InputHandlerProxy::EventDisposition |
| 645 InputHandlerProxy::HandleGestureScrollUpdate( | 647 InputHandlerProxy::HandleGestureScrollUpdate( |
| 646 const WebGestureEvent& gesture_event) { | 648 const WebGestureEvent& gesture_event, |
| 649 ui::LatencyInfo* latency_info) { |
| 647 #ifndef NDEBUG | 650 #ifndef NDEBUG |
| 648 DCHECK(expect_scroll_update_end_); | 651 DCHECK(expect_scroll_update_end_); |
| 649 #endif | 652 #endif |
| 650 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 653 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 651 return DID_NOT_HANDLE; | 654 return DID_NOT_HANDLE; |
| 652 | 655 |
| 653 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); | 656 cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event); |
| 654 gfx::Point scroll_point(gesture_event.x, gesture_event.y); | 657 gfx::Point scroll_point(gesture_event.x, gesture_event.y); |
| 655 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, | 658 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, |
| 656 -gesture_event.data.scrollUpdate.deltaY); | 659 -gesture_event.data.scrollUpdate.deltaY); |
| 657 | 660 |
| 658 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != | 661 if (ShouldAnimate(gesture_event.data.scrollUpdate.deltaUnits != |
| 659 blink::WebGestureEvent::ScrollUnits::Pixels)) { | 662 blink::WebGestureEvent::ScrollUnits::Pixels)) { |
| 660 switch (input_handler_->ScrollAnimated(scroll_point, scroll_delta).thread) { | 663 switch ( |
| 664 input_handler_->ScrollAnimated(scroll_point, scroll_delta, latency_info) |
| 665 .thread) { |
| 661 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: | 666 case cc::InputHandler::SCROLL_ON_IMPL_THREAD: |
| 662 return DID_HANDLE; | 667 return DID_HANDLE; |
| 663 case cc::InputHandler::SCROLL_IGNORED: | 668 case cc::InputHandler::SCROLL_IGNORED: |
| 664 return DROP_EVENT; | 669 return DROP_EVENT; |
| 665 default: | 670 default: |
| 666 return DID_NOT_HANDLE; | 671 return DID_NOT_HANDLE; |
| 667 } | 672 } |
| 668 } | 673 } |
| 669 cc::InputHandlerScrollResult scroll_result = | 674 cc::InputHandlerScrollResult scroll_result = |
| 670 input_handler_->ScrollBy(&scroll_state); | 675 input_handler_->ScrollBy(&scroll_state); |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 // is made asynchronously, to minimize divergence between main thread and | 1364 // is made asynchronously, to minimize divergence between main thread and |
| 1360 // impl thread event handling paths. | 1365 // impl thread event handling paths. |
| 1361 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1366 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1362 FROM_HERE, | 1367 FROM_HERE, |
| 1363 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, | 1368 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, |
| 1364 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | 1369 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, |
| 1365 scroll_result)); | 1370 scroll_result)); |
| 1366 } | 1371 } |
| 1367 | 1372 |
| 1368 } // namespace ui | 1373 } // namespace ui |
| OLD | NEW |