| 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;
|
| +}
|
| +
|
| +}
|
|
|