| Index: content/browser/renderer_host/input/base_gesture_event_filter.h
|
| diff --git a/content/browser/renderer_host/input/gesture_event_filter.h b/content/browser/renderer_host/input/base_gesture_event_filter.h
|
| similarity index 58%
|
| rename from content/browser/renderer_host/input/gesture_event_filter.h
|
| rename to content/browser/renderer_host/input/base_gesture_event_filter.h
|
| index 62949fbb2720457067343d52e5f57b423cff5d2b..bd08f60d07253dce30898206f4aa49a991c87cc6 100644
|
| --- a/content/browser/renderer_host/input/gesture_event_filter.h
|
| +++ b/content/browser/renderer_host/input/base_gesture_event_filter.h
|
| @@ -2,14 +2,15 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_FILTER_H_
|
| -#define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_FILTER_H_
|
| +#ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_BASE_GESTURE_EVENT_FILTER_H_
|
| +#define CONTENT_BROWSER_RENDERER_HOST_INPUT_BASE_GESTURE_EVENT_FILTER_H_
|
|
|
| #include <deque>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/timer/timer.h"
|
| +#include "content/browser/renderer_host/input/gesture_event_filter_client.h"
|
| #include "content/common/content_export.h"
|
| #include "content/port/browser/event_with_latency_info.h"
|
| #include "content/port/common/input_event_ack_state.h"
|
| @@ -20,37 +21,14 @@ namespace content {
|
| class GestureEventFilterTest;
|
| class InputRouter;
|
| class MockRenderWidgetHost;
|
| -class TouchpadTapSuppressionController;
|
| -class TouchpadTapSuppressionControllerClient;
|
| -class TouchscreenTapSuppressionController;
|
| -
|
| -// Interface with which the GestureEventFilter can forward gesture events, and
|
| -// dispatch gesture event responses.
|
| -class CONTENT_EXPORT GestureEventFilterClient {
|
| - public:
|
| - virtual ~GestureEventFilterClient() {}
|
| -
|
| - virtual void SendGestureEventImmediately(
|
| - const GestureEventWithLatencyInfo& event) = 0;
|
| -
|
| - virtual void OnGestureEventAck(
|
| - const GestureEventWithLatencyInfo& event,
|
| - InputEventAckState ack_result) = 0;
|
| -};
|
|
|
| // Maintains WebGestureEvents in a queue before forwarding them to the renderer
|
| // to apply a sequence of filters on them:
|
| -// 1. Zero-velocity fling-starts from touchpad are filtered.
|
| -// 2. The sequence is filtered for bounces. A bounce is when the finger lifts
|
| +// 1. The sequence is filtered for bounces. A bounce is when the finger lifts
|
| // from the screen briefly during an in-progress scroll. Ifco this happens,
|
| // non-GestureScrollUpdate events are queued until the de-bounce interval
|
| // passes or another GestureScrollUpdate event occurs.
|
| -// 3. Unnecessary GestureFlingCancel events are filtered. These are
|
| -// GestureFlingCancels that have no corresponding GestureFlingStart in the
|
| -// queue.
|
| -// 4. Taps immediately after a GestureFlingCancel (caused by the same tap) are
|
| -// filtered.
|
| -// 5. Whenever possible, events in the queue are coalesced to have as few events
|
| +// 2. Whenever possible, events in the queue are coalesced to have as few events
|
| // as possible and therefore maximize the chance that the event stream can be
|
| // handled entirely by the compositor thread.
|
| // Events in the queue are forwarded to the renderer one by one; i.e., each
|
| @@ -59,58 +37,68 @@ class CONTENT_EXPORT GestureEventFilterClient {
|
| // sent together.
|
| // TODO(rjkroege): Possibly refactor into a filter chain:
|
| // http://crbug.com/148443.
|
| -class CONTENT_EXPORT GestureEventFilter {
|
| +class CONTENT_EXPORT BaseGestureEventFilter {
|
| public:
|
| - // Both |client| and |touchpad_client| must outlive the GestureEventFilter.
|
| - GestureEventFilter(GestureEventFilterClient* client,
|
| - TouchpadTapSuppressionControllerClient* touchpad_client);
|
| - ~GestureEventFilter();
|
| + // |client| must outlive the BaseGestureEventFilter.
|
| + explicit BaseGestureEventFilter(GestureEventFilterClient* client);
|
| + virtual ~BaseGestureEventFilter();
|
|
|
| // Returns |true| if the caller should immediately forward the provided
|
| // |GestureEventWithLatencyInfo| argument to the renderer.
|
| - bool ShouldForward(const GestureEventWithLatencyInfo&);
|
| + virtual bool ShouldForward(const GestureEventWithLatencyInfo&);
|
|
|
| // Indicates that the caller has received an acknowledgement from the renderer
|
| // with state |ack_result| and event |type|. May send events if the queue is
|
| // not empty.
|
| - void ProcessGestureAck(InputEventAckState ack_result,
|
| - WebKit::WebInputEvent::Type type,
|
| - const ui::LatencyInfo& latency);
|
| -
|
| - // Sets the state of the |fling_in_progress_| field to indicate that a fling
|
| - // is definitely not in progress.
|
| - void FlingHasBeenHalted();
|
| -
|
| - // Returns the |TouchpadTapSuppressionController| instance.
|
| - TouchpadTapSuppressionController* GetTouchpadTapSuppressionController();
|
| + virtual void ProcessGestureAck(InputEventAckState ack_result,
|
| + WebKit::WebInputEvent::Type type,
|
| + const ui::LatencyInfo& latency);
|
|
|
| // Returns whether there are any gesture event in the queue.
|
| bool HasQueuedGestureEvents() const;
|
|
|
| void ForwardGestureEvent(const GestureEventWithLatencyInfo& gesture_event);
|
|
|
| - private:
|
| - friend class MockRenderWidgetHost;
|
| - friend class GestureEventFilterTest;
|
| -
|
| + protected:
|
| static bool ShouldIgnoreAckForGestureType(WebKit::WebInputEvent::Type type);
|
|
|
| + // Sub-filter for removing bounces from in-progress scrolls.
|
| + virtual bool ShouldForwardForBounceReduction(
|
| + const GestureEventWithLatencyInfo& gesture_event);
|
| +
|
| + // Puts the events in a queue to forward them one by one; i.e., forward them
|
| + // whenever ACK for previous event is received. This queue also tries to
|
| + // coalesce events as much as possible.
|
| + virtual bool ShouldForwardForCoalescing(
|
| + const GestureEventWithLatencyInfo& gesture_event);
|
| +
|
| + virtual bool ShouldForwardScrollEndingEvent(
|
| + const GestureEventWithLatencyInfo& event);
|
| +
|
| // Returns the last gesture event that was sent to the renderer.
|
| const GestureEventWithLatencyInfo& GetGestureEventAwaitingAck() const;
|
|
|
| - // TODO(mohsen): There are a bunch of ShouldForward.../ShouldDiscard...
|
| - // methods that are getting confusing. This should be somehow fixed. Maybe
|
| - // while refactoring GEF: http://crbug.com/148443.
|
| + // The receiver of all forwarded gesture events.
|
| + GestureEventFilterClient* client_;
|
| +
|
| + typedef std::deque<GestureEventWithLatencyInfo> GestureEventQueue;
|
| +
|
| + // Queue of coalesced gesture events not yet sent to the renderer. If
|
| + // |ignore_next_ack_| is false, then the event at the front of the queue has
|
| + // been sent and is awaiting an ACK, and all other events have yet to be sent.
|
| + // If |ignore_next_ack_| is true, then the two events at the front of the
|
| + // queue have been sent, and the second is awaiting an ACK. All other events
|
| + // have yet to be sent.
|
| + GestureEventQueue coalesced_gesture_events_;
|
| +
|
| + private:
|
| + friend class MockRenderWidgetHost;
|
| + friend class GestureEventFilterTest;
|
|
|
| // Inovked on the expiration of the debounce interval to release
|
| // deferred events.
|
| void SendScrollEndingEventsNow();
|
|
|
| - // Returns |true| if the given GestureFlingCancel should be discarded
|
| - // as unnecessary.
|
| - bool ShouldDiscardFlingCancelEvent(
|
| - const GestureEventWithLatencyInfo& gesture_event) const;
|
| -
|
| // Returns |true| if the only event in the queue is the current event and
|
| // hence that event should be handled now.
|
| bool ShouldHandleEventNow() const;
|
| @@ -120,28 +108,6 @@ class CONTENT_EXPORT GestureEventFilter {
|
| void MergeOrInsertScrollAndPinchEvent(
|
| const GestureEventWithLatencyInfo& gesture_event);
|
|
|
| - // Sub-filter for removing zero-velocity fling-starts from touchpad.
|
| - bool ShouldForwardForZeroVelocityFlingStart(
|
| - const GestureEventWithLatencyInfo& gesture_event) const;
|
| -
|
| - // Sub-filter for removing bounces from in-progress scrolls.
|
| - bool ShouldForwardForBounceReduction(
|
| - const GestureEventWithLatencyInfo& gesture_event);
|
| -
|
| - // Sub-filter for removing unnecessary GestureFlingCancels.
|
| - bool ShouldForwardForGFCFiltering(
|
| - const GestureEventWithLatencyInfo& gesture_event) const;
|
| -
|
| - // Sub-filter for suppressing taps immediately after a GestureFlingCancel.
|
| - bool ShouldForwardForTapSuppression(
|
| - const GestureEventWithLatencyInfo& gesture_event);
|
| -
|
| - // Puts the events in a queue to forward them one by one; i.e., forward them
|
| - // whenever ACK for previous event is received. This queue also tries to
|
| - // coalesce events as much as possible.
|
| - bool ShouldForwardForCoalescing(
|
| - const GestureEventWithLatencyInfo& gesture_event);
|
| -
|
| // Whether the event_in_queue is GesturePinchUpdate or
|
| // GestureScrollUpdate and it has the same modifiers as the
|
| // new event.
|
| @@ -164,13 +130,6 @@ class CONTENT_EXPORT GestureEventFilter {
|
| // accumulation of |combined_scroll_pinch_|.
|
| void EnqueueEvent(const GestureEventWithLatencyInfo& gesture_event);
|
|
|
| - // The receiver of all forwarded gesture events.
|
| - GestureEventFilterClient* client_;
|
| -
|
| - // True if a GestureFlingStart is in progress on the renderer or
|
| - // queued without a subsequent queued GestureFlingCancel event.
|
| - bool fling_in_progress_;
|
| -
|
| // True if a GestureScrollUpdate sequence is in progress.
|
| bool scrolling_in_progress_;
|
|
|
| @@ -182,32 +141,8 @@ class CONTENT_EXPORT GestureEventFilter {
|
| // scroll-pinch sequence at the end of the queue.
|
| gfx::Transform combined_scroll_pinch_;
|
|
|
| - // An object tracking the state of touchpad on the delivery of mouse events to
|
| - // the renderer to filter mouse immediately after a touchpad fling canceling
|
| - // tap.
|
| - // TODO(mohsen): Move touchpad tap suppression out of GestureEventFilter since
|
| - // GEF is meant to only be used for touchscreen gesture events.
|
| - scoped_ptr<TouchpadTapSuppressionController>
|
| - touchpad_tap_suppression_controller_;
|
| -
|
| - // An object tracking the state of touchscreen on the delivery of gesture tap
|
| - // events to the renderer to filter taps immediately after a touchscreen fling
|
| - // canceling tap.
|
| - scoped_ptr<TouchscreenTapSuppressionController>
|
| - touchscreen_tap_suppression_controller_;
|
| -
|
| - typedef std::deque<GestureEventWithLatencyInfo> GestureEventQueue;
|
| -
|
| - // Queue of coalesced gesture events not yet sent to the renderer. If
|
| - // |ignore_next_ack_| is false, then the event at the front of the queue has
|
| - // been sent and is awaiting an ACK, and all other events have yet to be sent.
|
| - // If |ignore_next_ack_| is true, then the two events at the front of the
|
| - // queue have been sent, and the second is awaiting an ACK. All other events
|
| - // have yet to be sent.
|
| - GestureEventQueue coalesced_gesture_events_;
|
| -
|
| // Timer to release a previously deferred gesture event.
|
| - base::OneShotTimer<GestureEventFilter> debounce_deferring_timer_;
|
| + base::OneShotTimer<BaseGestureEventFilter> debounce_deferring_timer_;
|
|
|
| // Queue of events that have been deferred for debounce.
|
| GestureEventQueue debouncing_deferral_queue_;
|
| @@ -216,9 +151,9 @@ class CONTENT_EXPORT GestureEventFilter {
|
| // TODO(rjkroege): Make this dynamically configurable.
|
| int debounce_interval_time_ms_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(GestureEventFilter);
|
| + DISALLOW_COPY_AND_ASSIGN(BaseGestureEventFilter);
|
| };
|
|
|
| } // namespace content
|
|
|
| -#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_FILTER_H_
|
| +#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_BASE_GESTURE_EVENT_FILTER_H_
|
|
|