Chromium Code Reviews| Index: content/browser/renderer_host/touchscreen_tap_suppression_controller.cc |
| diff --git a/content/browser/renderer_host/touchscreen_tap_suppression_controller.cc b/content/browser/renderer_host/touchscreen_tap_suppression_controller.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..65250e09770fea75b2971295249ec1316619e69f |
| --- /dev/null |
| +++ b/content/browser/renderer_host/touchscreen_tap_suppression_controller.cc |
| @@ -0,0 +1,85 @@ |
| +// Copyright (c) 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/touchscreen_tap_suppression_controller.h" |
| + |
| +#include "content/browser/renderer_host/gesture_event_filter.h" |
| +#include "content/browser/renderer_host/tap_suppression_controller.h" |
| +#include "ui/base/gestures/gesture_configuration.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| + |
| +#if !defined(USE_AURA) && !defined(OS_WIN) |
|
mohsen
2013/03/07 22:31:41
These parameters should normally be read from Gest
rjkroege
2013/03/14 19:48:06
Find a better way. Like not including this code in
mohsen
2013/03/17 23:09:01
Done. This code is now only included on Aura and W
|
| +// GestureConfiguration is not available on platforms other than Aura and |
| +// Windows. So, we use following constants for parameters we need. |
| +static const int kMaxCancelToDownTimeMs = 400; |
| +static const int kMaxTapGapTimeMs = 400; |
| +#endif |
| + |
| +} // namespace |
| + |
| +TouchscreenTapSuppressionController::TouchscreenTapSuppressionController( |
| + GestureEventFilter* gef) |
| + : gesture_event_filter_(gef), |
| + controller_(new TapSuppressionController(this)) { |
| +} |
| + |
| +TouchscreenTapSuppressionController::~TouchscreenTapSuppressionController() {} |
| + |
| +void TouchscreenTapSuppressionController::GestureFlingCancel() { |
| + controller_->GestureFlingCancel(); |
| +} |
| + |
| +void TouchscreenTapSuppressionController::GestureFlingCancelAck( |
| + bool processed) { |
| + controller_->GestureFlingCancelAck(processed, base::TimeTicks::Now()); |
| +} |
| + |
| +bool TouchscreenTapSuppressionController::ShouldDeferGestureTapDown( |
| + const WebKit::WebGestureEvent& event) { |
| + bool should_defer = controller_->ShouldDeferTapDown(base::TimeTicks::Now()); |
| + if (should_defer) |
| + stashed_tap_down_ = event; |
| + return should_defer; |
| +} |
| + |
| +bool TouchscreenTapSuppressionController::ShouldSuppressGestureTap() { |
| + return controller_->ShouldSuppressTapUp(); |
| +} |
| + |
| +bool TouchscreenTapSuppressionController::ShouldSuppressGestureTapCancel() { |
| + return controller_->ShouldSuppressTapCancel(); |
| +} |
| + |
| +int TouchscreenTapSuppressionController::MaxCancelToDownTimeInMs() { |
| +#if !defined(USE_AURA) && !defined(OS_WIN) |
| + return kMaxCancelToDownTimeMs; |
| +#else |
| + return ui::GestureConfiguration::fling_max_cancel_to_down_time_in_ms(); |
| +#endif |
| +} |
| + |
| +int TouchscreenTapSuppressionController::MaxTapGapTimeInMs() { |
| +#if !defined(USE_AURA) && !defined(OS_WIN) |
| + return kMaxTapGapTimeMs; |
| +#else |
| + return static_cast<int>( |
| + ui::GestureConfiguration::semi_long_press_time_in_seconds() * 1000); |
| +#endif |
| +} |
| + |
| +void TouchscreenTapSuppressionController::DropStashedTapDown() { |
| +} |
| + |
| +void TouchscreenTapSuppressionController::ForwardStashedTapDownForDeferral() { |
| + gesture_event_filter_->ForwardGestureEventForDeferral(stashed_tap_down_); |
| +} |
| + |
| +void TouchscreenTapSuppressionController::ForwardStashedTapDownSkipDeferral() { |
| + gesture_event_filter_->ForwardGestureEventSkipDeferral(stashed_tap_down_); |
| +} |
| + |
| +} // namespace content |