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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 return DID_HANDLE; | 790 return DID_HANDLE; |
791 } | 791 } |
792 case cc::InputHandler::SCROLL_UNKNOWN: | 792 case cc::InputHandler::SCROLL_UNKNOWN: |
793 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { | 793 case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { |
794 TRACE_EVENT_INSTANT0("input,rail", | 794 TRACE_EVENT_INSTANT0("input,rail", |
795 "InputHandlerProxy::HandleGestureFling::" | 795 "InputHandlerProxy::HandleGestureFling::" |
796 "scroll_on_main_thread", | 796 "scroll_on_main_thread", |
797 TRACE_EVENT_SCOPE_THREAD); | 797 TRACE_EVENT_SCOPE_THREAD); |
798 gesture_scroll_on_impl_thread_ = false; | 798 gesture_scroll_on_impl_thread_ = false; |
799 fling_may_be_active_on_main_thread_ = true; | 799 fling_may_be_active_on_main_thread_ = true; |
800 client_->DidStartFlinging(); | |
801 return DID_NOT_HANDLE; | 800 return DID_NOT_HANDLE; |
802 } | 801 } |
803 case cc::InputHandler::SCROLL_IGNORED: { | 802 case cc::InputHandler::SCROLL_IGNORED: { |
804 TRACE_EVENT_INSTANT0( | 803 TRACE_EVENT_INSTANT0( |
805 "input,rail", | 804 "input,rail", |
806 "InputHandlerProxy::HandleGestureFling::ignored", | 805 "InputHandlerProxy::HandleGestureFling::ignored", |
807 TRACE_EVENT_SCOPE_THREAD); | 806 TRACE_EVENT_SCOPE_THREAD); |
808 gesture_scroll_on_impl_thread_ = false; | 807 gesture_scroll_on_impl_thread_ = false; |
809 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { | 808 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { |
810 // We still pass the curve to the main thread if there's nothing | 809 // We still pass the curve to the main thread if there's nothing |
811 // scrollable, in case something | 810 // scrollable, in case something |
812 // registers a handler before the curve is over. | 811 // registers a handler before the curve is over. |
813 return DID_NOT_HANDLE; | 812 return DID_NOT_HANDLE; |
814 } | 813 } |
815 return DROP_EVENT; | 814 return DROP_EVENT; |
816 } | 815 } |
817 } | 816 } |
818 return DID_NOT_HANDLE; | 817 return DID_NOT_HANDLE; |
819 } | 818 } |
820 | 819 |
821 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart( | 820 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart( |
822 const blink::WebTouchEvent& touch_event) { | 821 const blink::WebTouchEvent& touch_event) { |
823 EventDisposition result = DROP_EVENT; | 822 EventDisposition result = DROP_EVENT; |
| 823 cc::InputHandler::TouchStartHitResult hit_result = |
| 824 cc::InputHandler::TouchStartHitResult::SAME_LAYER; |
824 for (size_t i = 0; i < touch_event.touchesLength; ++i) { | 825 for (size_t i = 0; i < touch_event.touchesLength; ++i) { |
825 if (touch_event.touches[i].state != WebTouchPoint::StatePressed) | 826 if (touch_event.touches[i].state != WebTouchPoint::StatePressed) |
826 continue; | 827 continue; |
827 if (input_handler_->DoTouchEventsBlockScrollAt( | 828 hit_result = input_handler_->DoTouchEventsBlockScrollAt(gfx::Point( |
828 gfx::Point(touch_event.touches[i].position.x, | 829 touch_event.touches[i].position.x, touch_event.touches[i].position.y)); |
829 touch_event.touches[i].position.y))) { | 830 if (hit_result != cc::InputHandler::HANDLER) { |
830 result = DID_NOT_HANDLE; | 831 result = DID_NOT_HANDLE; |
831 break; | 832 break; |
832 } | 833 } |
833 } | 834 } |
834 | 835 |
835 // If |result| is DROP_EVENT it wasn't processed above. | 836 // If |result| is DROP_EVENT it wasn't processed above. |
836 if (result == DROP_EVENT) { | 837 if (result == DROP_EVENT) { |
837 switch (input_handler_->GetEventListenerProperties( | 838 switch (input_handler_->GetEventListenerProperties( |
838 cc::EventListenerClass::kTouchStartOrMove)) { | 839 cc::EventListenerClass::kTouchStartOrMove)) { |
839 case cc::EventListenerProperties::kPassive: | 840 case cc::EventListenerProperties::kPassive: |
(...skipping 29 matching lines...) Expand all Loading... |
869 // If |result| is still DROP_EVENT look at the touch end handler as | 870 // If |result| is still DROP_EVENT look at the touch end handler as |
870 // we may not want to discard the entire touch sequence. Note this | 871 // we may not want to discard the entire touch sequence. Note this |
871 // code is explicitly after the assignment of the |touch_start_result_| | 872 // code is explicitly after the assignment of the |touch_start_result_| |
872 // so the touch moves are not sent to the main thread un-necessarily. | 873 // so the touch moves are not sent to the main thread un-necessarily. |
873 if (result == DROP_EVENT && | 874 if (result == DROP_EVENT && |
874 input_handler_->GetEventListenerProperties( | 875 input_handler_->GetEventListenerProperties( |
875 cc::EventListenerClass::kTouchEndOrCancel) != | 876 cc::EventListenerClass::kTouchEndOrCancel) != |
876 cc::EventListenerProperties::kNone) { | 877 cc::EventListenerProperties::kNone) { |
877 result = DID_HANDLE_NON_BLOCKING; | 878 result = DID_HANDLE_NON_BLOCKING; |
878 } | 879 } |
| 880 bool is_fling_on_impl = fling_curve_ && !fling_may_be_active_on_main_thread_; |
| 881 bool touch_on_active_scroll_layer = |
| 882 hit_result == cc::InputHandler::TouchStartHitResult::SAME_LAYER; |
879 | 883 |
| 884 if (result == DID_NOT_HANDLE && touch_on_active_scroll_layer && |
| 885 is_fling_on_impl) { |
| 886 result = DID_NOT_HANDLE_NON_BLOCKING; |
| 887 } |
880 return result; | 888 return result; |
881 } | 889 } |
882 | 890 |
883 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove( | 891 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove( |
884 const blink::WebTouchEvent& touch_event) { | 892 const blink::WebTouchEvent& touch_event) { |
885 if (touch_start_result_ != kEventDispositionUndefined) | 893 if (touch_start_result_ != kEventDispositionUndefined) |
886 return static_cast<EventDisposition>(touch_start_result_); | 894 return static_cast<EventDisposition>(touch_start_result_); |
887 return DID_NOT_HANDLE; | 895 return DID_NOT_HANDLE; |
888 } | 896 } |
889 | 897 |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 return false; | 1302 return false; |
1295 } | 1303 } |
1296 | 1304 |
1297 switch (disposition) { | 1305 switch (disposition) { |
1298 case DID_HANDLE: | 1306 case DID_HANDLE: |
1299 case DID_HANDLE_NON_BLOCKING: | 1307 case DID_HANDLE_NON_BLOCKING: |
1300 return true; | 1308 return true; |
1301 case DROP_EVENT: | 1309 case DROP_EVENT: |
1302 break; | 1310 break; |
1303 case DID_NOT_HANDLE: | 1311 case DID_NOT_HANDLE: |
| 1312 case DID_NOT_HANDLE_NON_BLOCKING: |
1304 TRACE_EVENT_INSTANT0("input", | 1313 TRACE_EVENT_INSTANT0("input", |
1305 "InputHandlerProxy::scrollBy::AbortFling", | 1314 "InputHandlerProxy::scrollBy::AbortFling", |
1306 TRACE_EVENT_SCOPE_THREAD); | 1315 TRACE_EVENT_SCOPE_THREAD); |
1307 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the | 1316 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the |
1308 // main thread. In this case we need to schedule a commit and transfer the | 1317 // main thread. In this case we need to schedule a commit and transfer the |
1309 // fling curve over to the main thread and run the rest of the wheels from | 1318 // fling curve over to the main thread and run the rest of the wheels from |
1310 // there. This can happen when flinging a page that contains a scrollable | 1319 // there. This can happen when flinging a page that contains a scrollable |
1311 // subarea that we can't scroll on the thread if the fling starts outside | 1320 // subarea that we can't scroll on the thread if the fling starts outside |
1312 // the subarea but then is flung "under" the pointer. | 1321 // the subarea but then is flung "under" the pointer. |
1313 client_->TransferActiveWheelFlingAnimation(fling_parameters_); | 1322 client_->TransferActiveWheelFlingAnimation(fling_parameters_); |
1314 fling_may_be_active_on_main_thread_ = true; | 1323 fling_may_be_active_on_main_thread_ = true; |
1315 client_->DidStartFlinging(); | |
1316 CancelCurrentFlingWithoutNotifyingClient(); | 1324 CancelCurrentFlingWithoutNotifyingClient(); |
1317 break; | 1325 break; |
1318 } | 1326 } |
1319 | 1327 |
1320 return false; | 1328 return false; |
1321 } | 1329 } |
1322 | 1330 |
1323 bool InputHandlerProxy::scrollBy(const WebFloatSize& increment, | 1331 bool InputHandlerProxy::scrollBy(const WebFloatSize& increment, |
1324 const WebFloatSize& velocity) { | 1332 const WebFloatSize& velocity) { |
1325 WebFloatSize clipped_increment; | 1333 WebFloatSize clipped_increment; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 // is made asynchronously, to minimize divergence between main thread and | 1404 // is made asynchronously, to minimize divergence between main thread and |
1397 // impl thread event handling paths. | 1405 // impl thread event handling paths. |
1398 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1406 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1399 FROM_HERE, | 1407 FROM_HERE, |
1400 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, | 1408 base::Bind(&InputScrollElasticityController::ObserveGestureEventAndResult, |
1401 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, | 1409 scroll_elasticity_controller_->GetWeakPtr(), gesture_event, |
1402 scroll_result)); | 1410 scroll_result)); |
1403 } | 1411 } |
1404 | 1412 |
1405 } // namespace ui | 1413 } // namespace ui |
OLD | NEW |