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

Unified 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: Fix last touch sequence start to be last touch start 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/blink/input_handler_proxy.cc
diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc
index cecf7df0c2f157963876234ebb086176ad7efd08..4fdf37cf37403339e932a4b445b8eee232152e65 100644
--- a/ui/events/blink/input_handler_proxy.cc
+++ b/ui/events/blink/input_handler_proxy.cc
@@ -35,6 +35,8 @@ using blink::WebTouchPoint;
namespace {
+const int32_t kEventDispositionUndefined = -1;
+
// Maximum time between a fling event's timestamp and the first |Animate| call
// for the fling curve to use the fling timestamp as the initial animation time.
// Two frames allows a minor delay between event creation and the first animate.
@@ -221,7 +223,9 @@ InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler,
disallow_vertical_fling_scroll_(false),
has_fling_animation_started_(false),
smooth_scroll_enabled_(false),
- uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()) {
+ uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()),
+ use_gesture_events_for_mouse_wheel_(true),
+ touch_start_result_(kEventDispositionUndefined) {
DCHECK(client);
input_handler_->BindToClient(this);
cc::ScrollElasticityHelper* scroll_elasticity_helper =
@@ -337,6 +341,12 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
case WebInputEvent::TouchStart:
return HandleTouchStart(static_cast<const WebTouchEvent&>(event));
+ case WebInputEvent::TouchMove:
+ return HandleTouchMove(static_cast<const WebTouchEvent&>(event));
+
+ case WebInputEvent::TouchEnd:
+ return HandleTouchEnd(static_cast<const WebTouchEvent&>(event));
+
case WebInputEvent::MouseMove: {
const WebMouseEvent& mouse_event =
static_cast<const WebMouseEvent&>(event);
@@ -420,6 +430,28 @@ bool InputHandlerProxy::ShouldAnimate(
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
const WebMouseWheelEvent& wheel_event) {
+ if (use_gesture_events_for_mouse_wheel_) {
+ cc::EventListenerProperties properties =
+ input_handler_->GetEventListenerProperties(
+ cc::EventListenerClass::kMouseWheel);
+ switch (properties) {
+ case cc::EventListenerProperties::kPassive:
+ return NON_BLOCKING;
+ case cc::EventListenerProperties::kBlockingAndPassive:
+ case cc::EventListenerProperties::kBlocking:
+ return DID_NOT_HANDLE;
+ case cc::EventListenerProperties::kNone:
+ return DROP_EVENT;
+ default:
+ NOTREACHED();
+ return DROP_EVENT;
+ }
+ }
+ return ScrollByMouseWheel(wheel_event);
+}
+
+InputHandlerProxy::EventDisposition InputHandlerProxy::ScrollByMouseWheel(
+ const WebMouseWheelEvent& wheel_event) {
InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE;
cc::InputHandlerScrollResult scroll_result;
@@ -720,18 +752,68 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart(
InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart(
const blink::WebTouchEvent& touch_event) {
- for (size_t i = 0; i < touch_event.touchesLength; ++i) {
- if (touch_event.touches[i].state != WebTouchPoint::StatePressed)
+ EventDisposition result = DROP_EVENT;
+ size_t touch_index = 0;
+ for (; touch_index < touch_event.touchesLength; ++touch_index) {
+ if (touch_event.touches[touch_index].state != WebTouchPoint::StatePressed)
continue;
if (input_handler_->DoTouchEventsBlockScrollAt(
- gfx::Point(touch_event.touches[i].position.x,
- touch_event.touches[i].position.y))) {
- // TODO(rbyers): We should consider still sending the touch events to
- // main asynchronously (crbug.com/455539).
- return DID_NOT_HANDLE;
+ gfx::Point(touch_event.touches[touch_index].position.x,
+ touch_event.touches[touch_index].position.y))) {
+ result = DID_NOT_HANDLE;
+ break;
+ }
+ }
+
+ // If |touch_index| has incremented to the length; it wasn't processed.
+ if (touch_index == touch_event.touchesLength) {
tdresser 2016/02/10 19:37:17 Would it be more straight forward to just check if
dtapuska 2016/02/10 22:05:22 Done.
+ switch (input_handler_->GetEventListenerProperties(
+ cc::EventListenerClass::kTouch)) {
+ case cc::EventListenerProperties::kPassive:
+ result = NON_BLOCKING;
+ break;
+ case cc::EventListenerProperties::kBlocking:
+ // The touch area rects above already have checked whether it hits
+ // a blocking region. Since it does not the event can be dropped.
+ result = DROP_EVENT;
+ break;
+ case cc::EventListenerProperties::kBlockingAndPassive:
+ // There is at least one passive listener that needs to possibly
+ // be notified so it can't be dropped.
+ result = NON_BLOCKING;
+ break;
+ case cc::EventListenerProperties::kNone:
+ result = DROP_EVENT;
+ break;
+ default:
+ NOTREACHED();
+ result = DROP_EVENT;
+ break;
}
}
- return DROP_EVENT;
+
+ // Update |touch_start_result_| if |result| generates a higher level
+ // of blocking.
tdresser 2016/02/10 19:37:17 This is a bit hard to read - maybe add a comment w
dtapuska 2016/02/10 22:05:22 Done.
+ if (touch_start_result_ == kEventDispositionUndefined ||
+ result == DID_NOT_HANDLE ||
+ (result == NON_BLOCKING && touch_start_result_ == DROP_EVENT))
+ touch_start_result_ = result;
tdresser 2016/02/10 19:37:17 Is this also correct? if (touch_start_result_ ==
dtapuska 2016/02/10 22:05:22 Done.
+
+ return result;
+}
+
+InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove(
+ const blink::WebTouchEvent& touch_event) {
+ if (touch_start_result_ != kEventDispositionUndefined)
+ return static_cast<EventDisposition>(touch_start_result_);
+ return DID_NOT_HANDLE;
+}
+
+InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchEnd(
+ const blink::WebTouchEvent& touch_event) {
+ if (touch_event.touchesLength == 1)
+ touch_start_result_ = kEventDispositionUndefined;
+ return DID_NOT_HANDLE;
tdresser 2016/02/10 19:37:17 Is this DID_NOT_HANDLE correct?
dtapuska 2016/02/10 22:05:22 Yes; HandleTouchEnd was in the default block befor
tdresser 2016/02/11 14:24:01 Acknowledged.
}
bool InputHandlerProxy::FilterInputEventForFlingBoosting(
@@ -1075,25 +1157,47 @@ void InputHandlerProxy::RequestAnimation() {
bool InputHandlerProxy::TouchpadFlingScroll(
const WebFloatSize& increment) {
- WebMouseWheelEvent synthetic_wheel;
- synthetic_wheel.type = WebInputEvent::MouseWheel;
- synthetic_wheel.timeStampSeconds = InSecondsF(base::TimeTicks::Now());
- synthetic_wheel.deltaX = increment.width;
- synthetic_wheel.deltaY = increment.height;
- synthetic_wheel.hasPreciseScrollingDeltas = true;
- synthetic_wheel.x = fling_parameters_.point.x;
- synthetic_wheel.y = fling_parameters_.point.y;
- synthetic_wheel.globalX = fling_parameters_.globalPoint.x;
- synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
- synthetic_wheel.modifiers = fling_parameters_.modifiers;
-
- InputHandlerProxy::EventDisposition disposition =
- HandleInputEvent(synthetic_wheel);
+ InputHandlerProxy::EventDisposition disposition;
+ cc::EventListenerProperties properties =
+ input_handler_->GetEventListenerProperties(
+ cc::EventListenerClass::kMouseWheel);
+ switch (properties) {
+ case cc::EventListenerProperties::kPassive:
+ disposition = NON_BLOCKING;
+ break;
+ case cc::EventListenerProperties::kBlocking:
+ disposition = DID_NOT_HANDLE;
+ break;
+ case cc::EventListenerProperties::kNone: {
+ WebMouseWheelEvent synthetic_wheel;
+ synthetic_wheel.type = WebInputEvent::MouseWheel;
+ synthetic_wheel.timeStampSeconds = InSecondsF(base::TimeTicks::Now());
+ synthetic_wheel.deltaX = increment.width;
+ synthetic_wheel.deltaY = increment.height;
+ synthetic_wheel.hasPreciseScrollingDeltas = true;
+ synthetic_wheel.x = fling_parameters_.point.x;
+ synthetic_wheel.y = fling_parameters_.point.y;
+ synthetic_wheel.globalX = fling_parameters_.globalPoint.x;
+ synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
+ synthetic_wheel.modifiers = fling_parameters_.modifiers;
+
+ disposition = ScrollByMouseWheel(synthetic_wheel);
+ break;
+ }
+ default:
+ NOTREACHED();
+ return false;
+ }
+
switch (disposition) {
case DID_HANDLE:
return true;
case DROP_EVENT:
break;
+ case NON_BLOCKING:
+ // TODO(dtapuska): Process the fling on the compositor thread
+ // but post the events to the main thread; for now just pass it to the
+ // main thread.
case DID_NOT_HANDLE:
TRACE_EVENT_INSTANT0("input",
"InputHandlerProxy::scrollBy::AbortFling",

Powered by Google App Engine
This is Rietveld 408576698