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

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

Issue 45623005: [NOT FOR REVIEW] Patch demonstrating the changes required for browser side fling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 2 months 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/base_gesture_event_filter.cc
diff --git a/content/browser/renderer_host/input/gesture_event_filter.cc b/content/browser/renderer_host/input/base_gesture_event_filter.cc
similarity index 66%
rename from content/browser/renderer_host/input/gesture_event_filter.cc
rename to content/browser/renderer_host/input/base_gesture_event_filter.cc
index 62fcb9c34fc20f2fefd547b4c3eafde17eb7ff14..eb88ade33b6f780a5aebc06c3dd810de7184e728 100644
--- a/content/browser/renderer_host/input/gesture_event_filter.cc
+++ b/content/browser/renderer_host/input/base_gesture_event_filter.cc
@@ -2,13 +2,11 @@
// 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/gesture_event_filter.h"
+#include "content/browser/renderer_host/input/base_gesture_event_filter.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "content/browser/renderer_host/input/input_router.h"
-#include "content/browser/renderer_host/input/touchpad_tap_suppression_controller.h"
-#include "content/browser/renderer_host/input/touchscreen_tap_suppression_controller.h"
#include "content/public/common/content_switches.h"
using WebKit::WebGestureEvent;
@@ -24,42 +22,19 @@ static const int kDebouncingIntervalTimeMs = 30;
} // namespace
-GestureEventFilter::GestureEventFilter(
- GestureEventFilterClient* client,
- TouchpadTapSuppressionControllerClient* touchpad_client)
+BaseGestureEventFilter::BaseGestureEventFilter(
+ GestureEventFilterClient* client)
: client_(client),
- fling_in_progress_(false),
scrolling_in_progress_(false),
ignore_next_ack_(false),
combined_scroll_pinch_(gfx::Transform()),
- touchpad_tap_suppression_controller_(
- new TouchpadTapSuppressionController(touchpad_client)),
- touchscreen_tap_suppression_controller_(
- new TouchscreenTapSuppressionController(this)),
debounce_interval_time_ms_(kDebouncingIntervalTimeMs) {
DCHECK(client);
- DCHECK(touchpad_tap_suppression_controller_);
}
-GestureEventFilter::~GestureEventFilter() { }
+BaseGestureEventFilter::~BaseGestureEventFilter() { }
-bool GestureEventFilter::ShouldDiscardFlingCancelEvent(
- const GestureEventWithLatencyInfo& gesture_event) const {
- if (coalesced_gesture_events_.empty() && fling_in_progress_)
- return false;
- GestureEventQueue::const_reverse_iterator it =
- coalesced_gesture_events_.rbegin();
- while (it != coalesced_gesture_events_.rend()) {
- if (it->event.type == WebInputEvent::GestureFlingStart)
- return false;
- if (it->event.type == WebInputEvent::GestureFlingCancel)
- return true;
- it++;
- }
- return true;
-}
-
-bool GestureEventFilter::ShouldForwardForBounceReduction(
+bool BaseGestureEventFilter::ShouldForwardForBounceReduction(
const GestureEventWithLatencyInfo& gesture_event) {
if (debounce_interval_time_ms_ == 0)
return true;
@@ -70,7 +45,7 @@ bool GestureEventFilter::ShouldForwardForBounceReduction(
FROM_HERE,
base::TimeDelta::FromMilliseconds(debounce_interval_time_ms_),
this,
- &GestureEventFilter::SendScrollEndingEventsNow);
+ &BaseGestureEventFilter::SendScrollEndingEventsNow);
} else {
// Extend the bounce interval.
debounce_deferring_timer_.Reset();
@@ -96,64 +71,15 @@ bool GestureEventFilter::ShouldForwardForBounceReduction(
}
// NOTE: The filters are applied successively. This simplifies the change.
-bool GestureEventFilter::ShouldForward(
+bool BaseGestureEventFilter::ShouldForward(
const GestureEventWithLatencyInfo& gesture_event) {
- return ShouldForwardForZeroVelocityFlingStart(gesture_event) &&
- ShouldForwardForBounceReduction(gesture_event) &&
- ShouldForwardForGFCFiltering(gesture_event) &&
- ShouldForwardForTapSuppression(gesture_event) &&
+ return ShouldForwardForBounceReduction(gesture_event) &&
ShouldForwardForCoalescing(gesture_event);
}
-bool GestureEventFilter::ShouldForwardForZeroVelocityFlingStart(
- const GestureEventWithLatencyInfo& gesture_event) const {
- return gesture_event.event.type != WebInputEvent::GestureFlingStart ||
- gesture_event.event.sourceDevice != WebGestureEvent::Touchpad ||
- gesture_event.event.data.flingStart.velocityX != 0 ||
- gesture_event.event.data.flingStart.velocityY != 0;
-}
-
-bool GestureEventFilter::ShouldForwardForGFCFiltering(
- const GestureEventWithLatencyInfo& gesture_event) const {
- return gesture_event.event.type != WebInputEvent::GestureFlingCancel ||
- !ShouldDiscardFlingCancelEvent(gesture_event);
-}
-
-bool GestureEventFilter::ShouldForwardForTapSuppression(
+bool BaseGestureEventFilter::ShouldForwardForCoalescing(
const GestureEventWithLatencyInfo& gesture_event) {
switch (gesture_event.event.type) {
- case WebInputEvent::GestureFlingCancel:
- if (gesture_event.event.sourceDevice == WebGestureEvent::Touchscreen)
- touchscreen_tap_suppression_controller_->GestureFlingCancel();
- else
- touchpad_tap_suppression_controller_->GestureFlingCancel();
- return true;
- case WebInputEvent::GestureTapDown:
- return !touchscreen_tap_suppression_controller_->
- ShouldDeferGestureTapDown(gesture_event);
- case WebInputEvent::GestureTapCancel:
- return !touchscreen_tap_suppression_controller_->
- ShouldSuppressGestureTapCancel();
- case WebInputEvent::GestureTap:
- case WebInputEvent::GestureTapUnconfirmed:
- return !touchscreen_tap_suppression_controller_->
- ShouldSuppressGestureTap();
- default:
- return true;
- }
- NOTREACHED();
- return false;
-}
-
-bool GestureEventFilter::ShouldForwardForCoalescing(
- const GestureEventWithLatencyInfo& gesture_event) {
- switch (gesture_event.event.type) {
- case WebInputEvent::GestureFlingCancel:
- fling_in_progress_ = false;
- break;
- case WebInputEvent::GestureFlingStart:
- fling_in_progress_ = true;
- break;
case WebInputEvent::GesturePinchUpdate:
case WebInputEvent::GestureScrollUpdate:
MergeOrInsertScrollAndPinchEvent(gesture_event);
@@ -169,9 +95,9 @@ bool GestureEventFilter::ShouldForwardForCoalescing(
return ShouldHandleEventNow();
}
-void GestureEventFilter::ProcessGestureAck(InputEventAckState ack_result,
- WebInputEvent::Type type,
- const ui::LatencyInfo& latency) {
+void BaseGestureEventFilter::ProcessGestureAck(InputEventAckState ack_result,
+ WebInputEvent::Type type,
+ const ui::LatencyInfo& latency) {
if (ShouldIgnoreAckForGestureType(type))
return;
@@ -188,14 +114,6 @@ void GestureEventFilter::ProcessGestureAck(InputEventAckState ack_result,
event_with_latency.latency.AddNewLatencyFrom(latency);
client_->OnGestureEventAck(event_with_latency, ack_result);
- const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
- if (type == WebInputEvent::GestureFlingCancel) {
- if (coalesced_gesture_events_.front().event.sourceDevice ==
- WebGestureEvent::Touchscreen)
- touchscreen_tap_suppression_controller_->GestureFlingCancelAck(processed);
- else
- touchpad_tap_suppression_controller_->GestureFlingCancelAck(processed);
- }
coalesced_gesture_events_.pop_front();
// If the event which was just ACKed was blocking events ignoring ack, fire
// those events now.
@@ -222,17 +140,12 @@ void GestureEventFilter::ProcessGestureAck(InputEventAckState ack_result,
}
}
-TouchpadTapSuppressionController*
- GestureEventFilter::GetTouchpadTapSuppressionController() {
- return touchpad_tap_suppression_controller_.get();
-}
-
-bool GestureEventFilter::HasQueuedGestureEvents() const {
+bool BaseGestureEventFilter::HasQueuedGestureEvents() const {
return !coalesced_gesture_events_.empty();
}
const GestureEventWithLatencyInfo&
-GestureEventFilter::GetGestureEventAwaitingAck() const {
+BaseGestureEventFilter::GetGestureEventAwaitingAck() const {
DCHECK(!coalesced_gesture_events_.empty());
if (!ignore_next_ack_)
return coalesced_gesture_events_.front();
@@ -240,35 +153,33 @@ GestureEventFilter::GetGestureEventAwaitingAck() const {
return coalesced_gesture_events_.at(1);
}
-void GestureEventFilter::FlingHasBeenHalted() {
- fling_in_progress_ = false;
-}
-
-bool GestureEventFilter::ShouldHandleEventNow() const {
+bool BaseGestureEventFilter::ShouldHandleEventNow() const {
return coalesced_gesture_events_.size() == 1;
}
-void GestureEventFilter::ForwardGestureEvent(
+void BaseGestureEventFilter::ForwardGestureEvent(
const GestureEventWithLatencyInfo& gesture_event) {
if (ShouldForwardForCoalescing(gesture_event))
client_->SendGestureEventImmediately(gesture_event);
}
-void GestureEventFilter::SendScrollEndingEventsNow() {
+bool BaseGestureEventFilter::ShouldForwardScrollEndingEvent(
+ const GestureEventWithLatencyInfo& event) {
+ return ShouldForwardForCoalescing(event);
+}
+
+void BaseGestureEventFilter::SendScrollEndingEventsNow() {
scrolling_in_progress_ = false;
for (GestureEventQueue::const_iterator it =
debouncing_deferral_queue_.begin();
it != debouncing_deferral_queue_.end(); it++) {
- if (ShouldForwardForGFCFiltering(*it) &&
- ShouldForwardForTapSuppression(*it) &&
- ShouldForwardForCoalescing(*it)) {
+ if (ShouldForwardScrollEndingEvent(*it))
client_->SendGestureEventImmediately(*it);
- }
}
debouncing_deferral_queue_.clear();
}
-void GestureEventFilter::MergeOrInsertScrollAndPinchEvent(
+void BaseGestureEventFilter::MergeOrInsertScrollAndPinchEvent(
const GestureEventWithLatencyInfo& gesture_event) {
if (coalesced_gesture_events_.size() <= 1) {
EnqueueEvent(gesture_event);
@@ -335,7 +246,7 @@ void GestureEventFilter::MergeOrInsertScrollAndPinchEvent(
coalesced_gesture_events_.push_back(pinch_event);
}
-bool GestureEventFilter::ShouldTryMerging(
+bool BaseGestureEventFilter::ShouldTryMerging(
const GestureEventWithLatencyInfo& new_event,
const GestureEventWithLatencyInfo& event_in_queue) const {
DLOG_IF(WARNING,
@@ -347,7 +258,7 @@ bool GestureEventFilter::ShouldTryMerging(
event_in_queue.event.modifiers == new_event.event.modifiers;
}
-gfx::Transform GestureEventFilter::GetTransformForEvent(
+gfx::Transform BaseGestureEventFilter::GetTransformForEvent(
const GestureEventWithLatencyInfo& gesture_event) const {
gfx::Transform gesture_transform = gfx::Transform();
if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate) {
@@ -362,11 +273,11 @@ gfx::Transform GestureEventFilter::GetTransformForEvent(
return gesture_transform;
}
-void GestureEventFilter::SendEventsIgnoringAck() {
+void BaseGestureEventFilter::SendEventsIgnoringAck() {
GestureEventWithLatencyInfo gesture_event;
while (!coalesced_gesture_events_.empty()) {
gesture_event = coalesced_gesture_events_.front();
- if (!GestureEventFilter::ShouldIgnoreAckForGestureType(
+ if (!BaseGestureEventFilter::ShouldIgnoreAckForGestureType(
gesture_event.event.type)) {
return;
}
@@ -375,13 +286,13 @@ void GestureEventFilter::SendEventsIgnoringAck() {
}
}
-bool GestureEventFilter::ShouldIgnoreAckForGestureType(
+bool BaseGestureEventFilter::ShouldIgnoreAckForGestureType(
WebInputEvent::Type type) {
return type == WebInputEvent::GestureTapDown ||
type == WebInputEvent::GestureShowPress;
}
-void GestureEventFilter::EnqueueEvent(
+void BaseGestureEventFilter::EnqueueEvent(
const GestureEventWithLatencyInfo& gesture_event) {
coalesced_gesture_events_.push_back(gesture_event);
// Scroll and pinch events contributing to |combined_scroll_pinch_| will be

Powered by Google App Engine
This is Rietveld 408576698