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

Unified Diff: content/browser/renderer_host/render_widget_host_input_event_router.cc

Issue 2186983002: Re-route Touchscreen GesturePinch events to root view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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: content/browser/renderer_host/render_widget_host_input_event_router.cc
diff --git a/content/browser/renderer_host/render_widget_host_input_event_router.cc b/content/browser/renderer_host/render_widget_host_input_event_router.cc
index 9786dad6d20708b7de81d7cef93b633ac84dfe5b..a6e4b27770303bc2f7f46e227d7c6cf1d4e77026 100644
--- a/content/browser/renderer_host/render_widget_host_input_event_router.cc
+++ b/content/browser/renderer_host/render_widget_host_input_event_router.cc
@@ -95,7 +95,7 @@ bool RenderWidgetHostInputEventRouter::HittestDelegate::AcceptHitTarget(
}
RenderWidgetHostInputEventRouter::RenderWidgetHostInputEventRouter()
- : active_touches_(0) {}
+ : active_touches_(0), in_touchscreen_gesture_pinch_(false) {}
RenderWidgetHostInputEventRouter::~RenderWidgetHostInputEventRouter() {
// We may be destroyed before some of the owners in the map, so we must
@@ -312,7 +312,8 @@ void RenderWidgetHostInputEventRouter::BubbleScrollEvent(
void RenderWidgetHostInputEventRouter::SendGestureScrollBegin(
RenderWidgetHostViewBase* view,
const blink::WebGestureEvent& event) {
- DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate);
+ DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate ||
+ event.type == blink::WebInputEvent::GesturePinchBegin);
blink::WebGestureEvent scroll_begin(event);
scroll_begin.type = blink::WebInputEvent::GestureScrollBegin;
scroll_begin.data.scrollBegin.deltaXHint = event.data.scrollUpdate.deltaX;
@@ -325,7 +326,8 @@ void RenderWidgetHostInputEventRouter::SendGestureScrollBegin(
void RenderWidgetHostInputEventRouter::SendGestureScrollEnd(
RenderWidgetHostViewBase* view,
const blink::WebGestureEvent& event) {
- DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate);
+ DCHECK(event.type == blink::WebInputEvent::GestureScrollUpdate ||
+ event.type == blink::WebInputEvent::GesturePinchEnd);
blink::WebGestureEvent scroll_end(event);
scroll_end.type = blink::WebInputEvent::GestureScrollEnd;
scroll_end.timeStampSeconds =
@@ -386,6 +388,28 @@ void RenderWidgetHostInputEventRouter::RouteTouchscreenGestureEvent(
const ui::LatencyInfo& latency) {
DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice);
+ if (event->type == blink::WebInputEvent::GesturePinchBegin) {
+ in_touchscreen_gesture_pinch_ = true;
+ // If the root view wasn't already receiving the gesture stream, then we
+ // need to wrap the diverted pinch events in a GestureScrollBegin/End.
+ // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can
+ // revisit how this code should work.
kenrb 2016/07/27 21:49:49 nit: Add the bug number that this depends on, 5264
wjmaclean 2016/07/28 13:22:11 Done.
+ if (root_view != touchscreen_gesture_target_.target)
+ SendGestureScrollBegin(root_view, *event);
+ }
+
+ if (in_touchscreen_gesture_pinch_) {
+ root_view->ProcessGestureEvent(*event, latency);
+ if (event->type == blink::WebInputEvent::GesturePinchEnd) {
+ in_touchscreen_gesture_pinch_ = false;
+ // If the root view wasn't already receiving the gesture stream, then we
+ // need to wrap the diverted pinch events in a GestureScrollBegin/End.
+ if (root_view != touchscreen_gesture_target_.target)
+ SendGestureScrollEnd(root_view, *event);
+ }
+ return;
+ }
+
// We use GestureTapDown to detect the start of a gesture sequence since there
// is no WebGestureEvent equivalent for ET_GESTURE_BEGIN. Note that this
// means the GestureFlingCancel that always comes between ET_GESTURE_BEGIN and

Powered by Google App Engine
This is Rietveld 408576698