Index: content/browser/renderer_host/input/touch_action_filter.cc |
diff --git a/content/browser/renderer_host/input/touch_action_filter.cc b/content/browser/renderer_host/input/touch_action_filter.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e75181d7ccb1d560972e72e95c3f97437b248747 |
--- /dev/null |
+++ b/content/browser/renderer_host/input/touch_action_filter.cc |
@@ -0,0 +1,59 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/browser/renderer_host/input/touch_action_filter.h" |
+ |
+#include "third_party/WebKit/public/web/WebInputEvent.h" |
+ |
+using blink::WebInputEvent; |
+using blink::WebGestureEvent; |
+ |
+namespace content { |
+ |
+bool TouchActionFilter::FilterGestureEvent( |
+ const WebGestureEvent& gesture_event) |
jdduke (slow)
2013/11/20 23:03:02
Nit: Brace on same line.
Rick Byers
2013/11/21 02:37:36
Done.
|
+{ |
+ // Filter for allowable touch actions first (eg. before the TouchEventQueue |
+ // can decide to send a touch cancel event). |
+ // TODO(rbyers): Add touch-action control over for pinch. crbug.com/247566. |
+ switch(gesture_event.type) { |
+ case WebInputEvent::GestureScrollBegin: |
+ if (allowed_touch_action_ == TOUCH_ACTION_NONE) |
+ drop_scroll_gesture_events_ = true; |
+ // FALL THROUGH |
+ case WebInputEvent::GestureScrollUpdate: |
+ case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
sadrul
2013/11/20 23:28:30
I don't believe we actually ever send this event
Rick Byers
2013/11/21 02:37:36
Yeah, looks like it's only ever generated in blink
|
+ if (drop_scroll_gesture_events_) |
+ return true; |
+ break; |
+ |
+ case WebInputEvent::GestureScrollEnd: |
+ case WebInputEvent::GestureFlingStart: |
+ allowed_touch_action_ = content::TOUCH_ACTION_AUTO; |
+ if (drop_scroll_gesture_events_) { |
+ drop_scroll_gesture_events_ = false; |
+ return true; |
+ } |
+ break; |
+ |
+ default: |
sadrul
2013/11/20 23:28:30
NOTREACHED()?
Rick Byers
2013/11/21 02:37:36
Nope - want to return false for all other types of
|
+ break; |
+ } |
+ |
+ return false; |
+} |
+ |
+void TouchActionFilter::OnSetTouchAction( |
+ content::TouchAction touch_action) |
jdduke (slow)
2013/11/20 23:03:02
Same as above.
Rick Byers
2013/11/21 02:37:36
Done.
|
+{ |
+ // For multiple fingers, we take the intersection of the touch actions for |
+ // all fingers that have gone down during this action. |
+ // TODO(rbyers): What exact multi-finger semantic do we want? This is left |
+ // as implementation-defined in the pointer events specification. |
+ // crbug.com/247566. |
+ if (touch_action == content::TOUCH_ACTION_NONE) |
+ allowed_touch_action_ = content::TOUCH_ACTION_NONE; |
+} |
+ |
+} |