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

Unified Diff: content/browser/renderer_host/gesture_event_filter.h

Issue 10823262: Refactoring: Extract gesture event filtering into helper class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more review comments Created 8 years, 4 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
« no previous file with comments | « no previous file | content/browser/renderer_host/gesture_event_filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/gesture_event_filter.h
diff --git a/content/browser/renderer_host/gesture_event_filter.h b/content/browser/renderer_host/gesture_event_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..aff3b318e35ebde4b9d0f5e3cb36b530e6634750
--- /dev/null
+++ b/content/browser/renderer_host/gesture_event_filter.h
@@ -0,0 +1,82 @@
+// Copyright (c) 2012 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.
+
+#ifndef CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_
+#define CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_
+
+#include <deque>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
+
+class MockRenderWidgetHost;
+
+namespace content {
+
+class RenderWidgetHostImpl;
+class TapSuppressionController;
+
+// Manages a queue of in-progress |WebGestureEvent| instances filtering,
+// coalescing or discarding them as required to maximize the chance that
+// the event stream can be handled entirely by the compositor thread.
+class GestureEventFilter {
+ public:
+ explicit GestureEventFilter(RenderWidgetHostImpl*);
+ ~GestureEventFilter();
+
+ // Returns |true| if the caller should immediately forward the provided
+ // |WebGestureEvent| argument to the renderer.
+ bool ShouldForward(const WebKit::WebGestureEvent&);
+
+ // Indicate that calling RenderWidgetHostImpl has received an acknowledgement
+ // from the renderer with state |processed| and event |type|. May send events
+ // if the queue is not empty.
+ void ProcessGestureAck(bool processed, int type);
+
+ // Reset the state of the filter as would be needed when the Renderer exits.
+ void Reset();
+
+ // Set the state of the |fling_in_progress_| field to indicate that a fling is
+ // definitely not in progress.
+ void FlingHasBeenHalted();
+
+ // Return the |TapSuppressionController| instance.
+ TapSuppressionController* GetTapSuppressionController();
+
+ private:
+ friend class ::MockRenderWidgetHost;
+
+ // Returns |true| if the given GestureFlingCancel should be discarded
+ // as unnecessary.
+ bool ShouldDiscardFlingCancelEvent(
+ const WebKit::WebGestureEvent& gesture_event);
+
+ // Only a RenderWidgetHostViewImpl can own an instance.
+ RenderWidgetHostImpl* render_widget_host_;
+
+ // True if a GestureFlingStart is in progress on the renderer.
+ bool fling_in_progress_;
+
+ // (Similar to |mouse_wheel_pending_|.). True if gesture event was sent and
+ // we are waiting for a corresponding ack.
+ bool gesture_event_pending_;
+
+ // An object tracking the state of touchpad action on the delivery of mouse
+ // events to the renderer to filter mouse actiosn immediately after a touchpad
+ // fling canceling tap.
+ scoped_ptr<TapSuppressionController> tap_suppression_controller_;
+
+ typedef std::deque<WebKit::WebGestureEvent> GestureEventQueue;
+
+ // (Similar to |coalesced_mouse_wheel_events_|.) GestureScrollUpdate events
+ // are coalesced by merging deltas in a similar fashion as wheel events.
+ GestureEventQueue coalesced_gesture_events_;
+
+ DISALLOW_COPY_AND_ASSIGN(GestureEventFilter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_
« no previous file with comments | « no previous file | content/browser/renderer_host/gesture_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698