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

Unified Diff: content/browser/renderer_host/input/touch_action_filter.cc

Issue 67383002: Initial browser-side implementation for touch-action (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for new blink API - no touch ID for now Created 7 years, 1 month 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/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;
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698