Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_ | |
| 7 | |
| 8 #include <deque> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 13 | |
| 14 class MockRenderWidgetHost; | |
| 15 | |
| 16 using WebKit::WebGestureEvent; | |
|
sky
2012/08/09 21:42:52
No using in headers.
rjkroege
2012/08/10 15:12:19
Done.
| |
| 17 using WebKit::WebInputEvent; | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 class RenderWidgetHostImpl; | |
| 22 class TapSuppressionController; | |
| 23 | |
| 24 // Manages a queue of in-progress |WebGestureEvent| instances filtering, | |
| 25 // coalescing or discarding them as required to maximize the chance that | |
| 26 // the event stream can be handled entirely by the compositor thread. | |
| 27 class GestureEventFilter { | |
| 28 public: | |
| 29 explicit GestureEventFilter(RenderWidgetHostImpl*); | |
| 30 ~GestureEventFilter(); | |
| 31 | |
| 32 // Returns |true| if the caller should immediately forward the provided | |
| 33 // |WebGestureEvent| argument to the renderer. | |
| 34 bool ShouldForward(const WebGestureEvent&); | |
| 35 | |
| 36 // Indicate that calling RenderWidgetHostImpl has received an acknowledgement | |
| 37 // from the renderer with state |processed| and event |type|. May send events | |
| 38 // if the queue is not empty. | |
| 39 void ProcessGestureAck(bool processed, int type); | |
| 40 | |
| 41 // Reset the state of the filter as would be needed when the Renderer exits. | |
| 42 void Reset(); | |
| 43 | |
| 44 // Set the state of the |fling_in_progress_| field to indicate that a fling is | |
| 45 // definitely not in progress. | |
| 46 void FlingHasBeenHalted(); | |
| 47 | |
| 48 // Return the |TapSuppressionController| instance. | |
| 49 TapSuppressionController* GetTapSuppressionController(); | |
| 50 | |
| 51 private: | |
| 52 friend class ::MockRenderWidgetHost; | |
| 53 | |
| 54 // Returns |true| if the given GestureFlingCancel should be discarded | |
| 55 // as unnecessary. | |
| 56 bool ShouldDiscardFlingCancelEvent( | |
| 57 const WebKit::WebGestureEvent& gesture_event); | |
| 58 | |
| 59 // Only a RenderWidgetHostViewImpl can own an instance. | |
| 60 RenderWidgetHostImpl* render_widget_host_; | |
| 61 | |
| 62 // True if a GestureFlingStart is in progress on the renderer. | |
| 63 bool fling_in_progress_; | |
| 64 | |
| 65 // (Similar to |mouse_wheel_pending_|.). True if gesture event was sent and | |
| 66 // we are waiting for a corresponding ack. | |
| 67 bool gesture_event_pending_; | |
| 68 | |
| 69 // An object tracking the state of touchpad action on the delivery of mouse | |
| 70 // events to the renderer to filter mouse actiosn immediately after a touchpad | |
| 71 // fling canceling tap. | |
| 72 scoped_ptr<TapSuppressionController> tap_suppression_controller_; | |
| 73 | |
| 74 typedef std::deque<WebKit::WebGestureEvent> GestureEventQueue; | |
| 75 | |
| 76 // (Similar to |coalesced_mouse_wheel_events_|.) GestureScrollUpdate events | |
| 77 // are coalesced by merging deltas in a similar fashion as wheel events. | |
| 78 GestureEventQueue coalesced_gesture_events_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(GestureEventFilter); | |
| 81 }; | |
| 82 | |
| 83 } // namespace content | |
| 84 | |
| 85 #endif // CONTENT_BROWSER_RENDERER_HOST_GESTURE_EVENT_FILTER_H_ | |
| OLD | NEW |