Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: ui/events/blink/input_handler_proxy.cc

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Set dependency correctly Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 #ifndef NDEBUG 214 #ifndef NDEBUG
215 expect_scroll_update_end_(false), 215 expect_scroll_update_end_(false),
216 #endif 216 #endif
217 gesture_scroll_on_impl_thread_(false), 217 gesture_scroll_on_impl_thread_(false),
218 gesture_pinch_on_impl_thread_(false), 218 gesture_pinch_on_impl_thread_(false),
219 fling_may_be_active_on_main_thread_(false), 219 fling_may_be_active_on_main_thread_(false),
220 disallow_horizontal_fling_scroll_(false), 220 disallow_horizontal_fling_scroll_(false),
221 disallow_vertical_fling_scroll_(false), 221 disallow_vertical_fling_scroll_(false),
222 has_fling_animation_started_(false), 222 has_fling_animation_started_(false),
223 smooth_scroll_enabled_(false), 223 smooth_scroll_enabled_(false),
224 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()) { 224 uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()),
225 scroll_on_mouse_wheel_(false) {
225 DCHECK(client); 226 DCHECK(client);
226 input_handler_->BindToClient(this); 227 input_handler_->BindToClient(this);
227 cc::ScrollElasticityHelper* scroll_elasticity_helper = 228 cc::ScrollElasticityHelper* scroll_elasticity_helper =
228 input_handler_->CreateScrollElasticityHelper(); 229 input_handler_->CreateScrollElasticityHelper();
229 if (scroll_elasticity_helper) { 230 if (scroll_elasticity_helper) {
230 scroll_elasticity_controller_.reset( 231 scroll_elasticity_controller_.reset(
231 new InputScrollElasticityController(scroll_elasticity_helper)); 232 new InputScrollElasticityController(scroll_elasticity_helper));
232 } 233 }
233 } 234 }
234 235
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 static_cast<const WebGestureEvent&>(event)); 282 static_cast<const WebGestureEvent&>(event));
282 283
283 case WebInputEvent::GestureScrollEnd: 284 case WebInputEvent::GestureScrollEnd:
284 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event)); 285 return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event));
285 286
286 case WebInputEvent::GesturePinchBegin: { 287 case WebInputEvent::GesturePinchBegin: {
287 DCHECK(!gesture_pinch_on_impl_thread_); 288 DCHECK(!gesture_pinch_on_impl_thread_);
288 const WebGestureEvent& gesture_event = 289 const WebGestureEvent& gesture_event =
289 static_cast<const WebGestureEvent&>(event); 290 static_cast<const WebGestureEvent&>(event);
290 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && 291 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad &&
291 input_handler_->HaveWheelEventHandlersAt( 292 input_handler_->EffectiveWheelEventListenerPropertiesAt(
292 gfx::Point(gesture_event.x, gesture_event.y))) { 293 gfx::Point(gesture_event.x, gesture_event.y)) !=
294 cc::EventListenerProperties::kNone) {
293 return DID_NOT_HANDLE; 295 return DID_NOT_HANDLE;
294 } else { 296 } else {
295 input_handler_->PinchGestureBegin(); 297 input_handler_->PinchGestureBegin();
296 gesture_pinch_on_impl_thread_ = true; 298 gesture_pinch_on_impl_thread_ = true;
297 return DID_HANDLE; 299 return DID_HANDLE;
298 } 300 }
299 } 301 }
300 302
301 case WebInputEvent::GesturePinchEnd: 303 case WebInputEvent::GesturePinchEnd:
302 if (gesture_pinch_on_impl_thread_) { 304 if (gesture_pinch_on_impl_thread_) {
(...skipping 26 matching lines...) Expand all
329 case WebInputEvent::GestureFlingCancel: 331 case WebInputEvent::GestureFlingCancel:
330 if (CancelCurrentFling()) 332 if (CancelCurrentFling())
331 return DID_HANDLE; 333 return DID_HANDLE;
332 else if (!fling_may_be_active_on_main_thread_) 334 else if (!fling_may_be_active_on_main_thread_)
333 return DROP_EVENT; 335 return DROP_EVENT;
334 return DID_NOT_HANDLE; 336 return DID_NOT_HANDLE;
335 337
336 case WebInputEvent::TouchStart: 338 case WebInputEvent::TouchStart:
337 return HandleTouchStart(static_cast<const WebTouchEvent&>(event)); 339 return HandleTouchStart(static_cast<const WebTouchEvent&>(event));
338 340
341 case WebInputEvent::TouchMove:
342 return HandleTouchMove(static_cast<const WebTouchEvent&>(event));
343
339 case WebInputEvent::MouseMove: { 344 case WebInputEvent::MouseMove: {
340 const WebMouseEvent& mouse_event = 345 const WebMouseEvent& mouse_event =
341 static_cast<const WebMouseEvent&>(event); 346 static_cast<const WebMouseEvent&>(event);
342 // TODO(tony): Ignore when mouse buttons are down? 347 // TODO(tony): Ignore when mouse buttons are down?
343 // TODO(davemoore): This should never happen, but bug #326635 showed some 348 // TODO(davemoore): This should never happen, but bug #326635 showed some
344 // surprising crashes. 349 // surprising crashes.
345 CHECK(input_handler_); 350 CHECK(input_handler_);
346 input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y)); 351 input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y));
347 return DID_NOT_HANDLE; 352 return DID_NOT_HANDLE;
348 } 353 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 #if defined(OS_MACOSX) 417 #if defined(OS_MACOSX)
413 // Mac does not smooth scroll wheel events (crbug.com/574283). 418 // Mac does not smooth scroll wheel events (crbug.com/574283).
414 return false; 419 return false;
415 #else 420 #else
416 return smooth_scroll_enabled_ && !event.hasPreciseScrollingDeltas; 421 return smooth_scroll_enabled_ && !event.hasPreciseScrollingDeltas;
417 #endif 422 #endif
418 } 423 }
419 424
420 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( 425 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
421 const WebMouseWheelEvent& wheel_event) { 426 const WebMouseWheelEvent& wheel_event) {
427 if (!scroll_on_mouse_wheel_) {
428 if (input_handler_->EffectiveWheelEventListenerPropertiesAt(
429 gfx::Point(wheel_event.x, wheel_event.y)) ==
430 cc::EventListenerProperties::kPassive) {
431 return NON_BLOCKING;
432 }
433 return DID_NOT_HANDLE;
434 }
435
422 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; 436 InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE;
423 cc::InputHandlerScrollResult scroll_result; 437 cc::InputHandlerScrollResult scroll_result;
424 438
425 // TODO(ccameron): The rail information should be pushed down into 439 // TODO(ccameron): The rail information should be pushed down into
426 // InputHandler. 440 // InputHandler.
427 gfx::Vector2dF scroll_delta( 441 gfx::Vector2dF scroll_delta(
428 wheel_event.railsMode != WebInputEvent::RailsModeVertical 442 wheel_event.railsMode != WebInputEvent::RailsModeVertical
429 ? -wheel_event.deltaX 443 ? -wheel_event.deltaX
430 : 0, 444 : 0,
431 wheel_event.railsMode != WebInputEvent::RailsModeHorizontal 445 wheel_event.railsMode != WebInputEvent::RailsModeHorizontal
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 return DID_NOT_HANDLE; 727 return DID_NOT_HANDLE;
714 } 728 }
715 return DROP_EVENT; 729 return DROP_EVENT;
716 } 730 }
717 } 731 }
718 return DID_NOT_HANDLE; 732 return DID_NOT_HANDLE;
719 } 733 }
720 734
721 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart( 735 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart(
722 const blink::WebTouchEvent& touch_event) { 736 const blink::WebTouchEvent& touch_event) {
723 for (size_t i = 0; i < touch_event.touchesLength; ++i) { 737 uint32_t properties = cc::EventListenerProperties::kNone;
738 for (size_t i = 0; i < touch_event.touchesLength &&
739 properties != cc::EventListenerProperties::kMax;
740 ++i) {
724 if (touch_event.touches[i].state != WebTouchPoint::StatePressed) 741 if (touch_event.touches[i].state != WebTouchPoint::StatePressed)
725 continue; 742 continue;
726 if (input_handler_->DoTouchEventsBlockScrollAt( 743
727 gfx::Point(touch_event.touches[i].position.x, 744 properties |= input_handler_->EffectiveTouchEventListenerPropertiesAt(
728 touch_event.touches[i].position.y))) { 745 gfx::Point(touch_event.touches[i].position.x,
729 // TODO(rbyers): We should consider still sending the touch events to 746 touch_event.touches[i].position.y));
730 // main asynchronously (crbug.com/455539).
731 return DID_NOT_HANDLE;
732 }
733 } 747 }
734 return DROP_EVENT; 748
749 if (properties == cc::EventListenerProperties::kPassive) {
750 return NON_BLOCKING;
751 }
752 return DID_NOT_HANDLE;
753 }
754
755 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove(
756 const blink::WebTouchEvent& touch_event) {
757 uint32_t properties = cc::EventListenerProperties::kNone;
758 for (size_t i = 0; i < touch_event.touchesLength &&
759 properties != cc::EventListenerProperties::kMax;
760 ++i) {
761 properties |= input_handler_->EffectiveTouchEventListenerPropertiesAt(
762 gfx::Point(touch_event.touches[i].position.x,
763 touch_event.touches[i].position.y));
764 }
765
766 if (properties == cc::EventListenerProperties::kPassive) {
767 return NON_BLOCKING;
768 }
769 return DID_NOT_HANDLE;
735 } 770 }
736 771
737 bool InputHandlerProxy::FilterInputEventForFlingBoosting( 772 bool InputHandlerProxy::FilterInputEventForFlingBoosting(
738 const WebInputEvent& event) { 773 const WebInputEvent& event) {
739 if (!WebInputEvent::isGestureEventType(event.type)) 774 if (!WebInputEvent::isGestureEventType(event.type))
740 return false; 775 return false;
741 776
742 if (!fling_curve_) { 777 if (!fling_curve_) {
743 DCHECK(!deferred_fling_cancel_time_seconds_); 778 DCHECK(!deferred_fling_cancel_time_seconds_);
744 return false; 779 return false;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 synthetic_wheel.globalY = fling_parameters_.globalPoint.y; 1121 synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
1087 synthetic_wheel.modifiers = fling_parameters_.modifiers; 1122 synthetic_wheel.modifiers = fling_parameters_.modifiers;
1088 1123
1089 InputHandlerProxy::EventDisposition disposition = 1124 InputHandlerProxy::EventDisposition disposition =
1090 HandleInputEvent(synthetic_wheel); 1125 HandleInputEvent(synthetic_wheel);
1091 switch (disposition) { 1126 switch (disposition) {
1092 case DID_HANDLE: 1127 case DID_HANDLE:
1093 return true; 1128 return true;
1094 case DROP_EVENT: 1129 case DROP_EVENT:
1095 break; 1130 break;
1131 case NON_BLOCKING:
1132 // TODO(dtapuska): Process the fling on the compositor thread
1133 // but post the events to the main thread; for now just pass it to the
1134 // main thread.
1096 case DID_NOT_HANDLE: 1135 case DID_NOT_HANDLE:
1097 TRACE_EVENT_INSTANT0("input", 1136 TRACE_EVENT_INSTANT0("input",
1098 "InputHandlerProxy::scrollBy::AbortFling", 1137 "InputHandlerProxy::scrollBy::AbortFling",
1099 TRACE_EVENT_SCOPE_THREAD); 1138 TRACE_EVENT_SCOPE_THREAD);
1100 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the 1139 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the
1101 // main thread. In this case we need to schedule a commit and transfer the 1140 // main thread. In this case we need to schedule a commit and transfer the
1102 // fling curve over to the main thread and run the rest of the wheels from 1141 // fling curve over to the main thread and run the rest of the wheels from
1103 // there. This can happen when flinging a page that contains a scrollable 1142 // there. This can happen when flinging a page that contains a scrollable
1104 // subarea that we can't scroll on the thread if the fling starts outside 1143 // subarea that we can't scroll on the thread if the fling starts outside
1105 // the subarea but then is flung "under" the pointer. 1144 // the subarea but then is flung "under" the pointer.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 // trigger a scroll, e.g., with a trivial time delta between fling updates. 1209 // trigger a scroll, e.g., with a trivial time delta between fling updates.
1171 // Return true in this case to prevent early fling termination. 1210 // Return true in this case to prevent early fling termination.
1172 if (std::abs(clipped_increment.width) < kScrollEpsilon && 1211 if (std::abs(clipped_increment.width) < kScrollEpsilon &&
1173 std::abs(clipped_increment.height) < kScrollEpsilon) 1212 std::abs(clipped_increment.height) < kScrollEpsilon)
1174 return true; 1213 return true;
1175 1214
1176 return did_scroll; 1215 return did_scroll;
1177 } 1216 }
1178 1217
1179 } // namespace ui 1218 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698