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

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: Add back accidentally removed line 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..c095f3d804eaaf8e82e7c0a55017f83fd0e0a302
--- /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)
+{
+ // 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:
+ 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:
+ break;
+ }
+
+ return false;
+}
+
+void TouchActionFilter::OnSetTouchAction(
+ int touch_id,
+ content::TouchAction touchAction)
+{
+ // For multiple fingers, we take the intersection of the touch actions for
+ // all fingers that have gone down during this action.
+ // TODO(rbyers): Get some agreed upon multi-finger semantic for touch-action
+ // included in the pointer events specification. crbug.com/241964
+ if (touchAction == content::TOUCH_ACTION_NONE)
+ allowed_touch_action_ = content::TOUCH_ACTION_NONE;
+}
+
+}

Powered by Google App Engine
This is Rietveld 408576698