OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ | 6 #define CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "cc/input/input_handler.h" | 11 #include "cc/input/input_handler.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h" | |
14 #include "third_party/WebKit/public/web/WebInputEvent.h" | 13 #include "third_party/WebKit/public/web/WebInputEvent.h" |
15 #include "third_party/WebKit/public/platform/WebGestureCurve.h" | |
16 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h" | |
17 | 14 |
18 namespace content { | 15 namespace content { |
19 | 16 |
20 class InputHandlerProxyClient; | 17 class InputHandlerProxyClient; |
21 | 18 |
22 // This class is a proxy between the content input event filtering and the | 19 // This class is a proxy between the content input event filtering and the |
23 // compositor's input handling logic. InputHandlerProxy instances live entirely | 20 // compositor's input handling logic. InputHandlerProxy instances live entirely |
24 // on the compositor thread. Each InputHandler instance handles input events | 21 // on the compositor thread. Each InputHandler instance handles input events |
25 // intended for a specific WebWidget. | 22 // intended for a specific WebWidget. |
26 class CONTENT_EXPORT InputHandlerProxy | 23 class CONTENT_EXPORT InputHandlerProxy |
27 : public cc::InputHandlerClient, | 24 : public cc::InputHandlerClient { |
28 public NON_EXPORTED_BASE(WebKit::WebGestureCurveTarget) { | |
29 public: | 25 public: |
30 explicit InputHandlerProxy(cc::InputHandler* input_handler); | 26 explicit InputHandlerProxy(cc::InputHandler* input_handler); |
31 virtual ~InputHandlerProxy(); | 27 virtual ~InputHandlerProxy(); |
32 | 28 |
33 void SetClient(InputHandlerProxyClient* client); | 29 void SetClient(InputHandlerProxyClient* client); |
34 | 30 |
35 enum EventDisposition { | 31 enum EventDisposition { |
36 DID_HANDLE, | 32 DID_HANDLE, |
37 DID_NOT_HANDLE, | 33 DID_NOT_HANDLE, |
38 DROP_EVENT | 34 DROP_EVENT |
39 }; | 35 }; |
40 EventDisposition HandleInputEventWithLatencyInfo( | 36 EventDisposition HandleInputEventWithLatencyInfo( |
41 const WebKit::WebInputEvent& event, | 37 const WebKit::WebInputEvent& event, |
42 const ui::LatencyInfo& latency_info); | 38 const ui::LatencyInfo& latency_info); |
43 EventDisposition HandleInputEvent(const WebKit::WebInputEvent& event); | 39 EventDisposition HandleInputEvent(const WebKit::WebInputEvent& event); |
44 | 40 |
45 // cc::InputHandlerClient implementation. | 41 // cc::InputHandlerClient implementation. |
46 virtual void WillShutdown() OVERRIDE; | 42 virtual void WillShutdown() OVERRIDE; |
47 virtual void Animate(base::TimeTicks time) OVERRIDE; | 43 virtual void Animate(base::TimeTicks time) OVERRIDE; |
48 virtual void MainThreadHasStoppedFlinging() OVERRIDE; | |
49 virtual void DidOverscroll(const cc::DidOverscrollParams& params) OVERRIDE; | 44 virtual void DidOverscroll(const cc::DidOverscrollParams& params) OVERRIDE; |
50 | 45 |
51 // WebKit::WebGestureCurveTarget implementation. | |
52 virtual void scrollBy(const WebKit::WebFloatSize& offset); | |
53 virtual void notifyCurrentFlingVelocity(const WebKit::WebFloatSize& velocity); | |
54 | |
55 bool gesture_scroll_on_impl_thread_for_testing() const { | 46 bool gesture_scroll_on_impl_thread_for_testing() const { |
56 return gesture_scroll_on_impl_thread_; | 47 return gesture_scroll_on_impl_thread_; |
57 } | 48 } |
58 | 49 |
59 private: | 50 private: |
60 EventDisposition HandleGestureFling(const WebKit::WebGestureEvent& event); | |
61 | |
62 // Returns true if we scrolled by the increment. | |
63 bool TouchpadFlingScroll(const WebKit::WebFloatSize& increment); | |
64 | |
65 // Returns true if we actually had an active fling to cancel. | |
66 bool CancelCurrentFling(); | |
67 | |
68 scoped_ptr<WebKit::WebGestureCurve> fling_curve_; | |
69 // Parameters for the active fling animation, stored in case we need to | |
70 // transfer it out later. | |
71 WebKit::WebActiveWheelFlingParameters fling_parameters_; | |
72 | |
73 InputHandlerProxyClient* client_; | 51 InputHandlerProxyClient* client_; |
74 cc::InputHandler* input_handler_; | 52 cc::InputHandler* input_handler_; |
75 | 53 |
76 #ifndef NDEBUG | 54 #ifndef NDEBUG |
77 bool expect_scroll_update_end_; | 55 bool expect_scroll_update_end_; |
78 bool expect_pinch_update_end_; | 56 bool expect_pinch_update_end_; |
79 #endif | 57 #endif |
80 bool gesture_scroll_on_impl_thread_; | 58 bool gesture_scroll_on_impl_thread_; |
81 bool gesture_pinch_on_impl_thread_; | 59 bool gesture_pinch_on_impl_thread_; |
82 // This is always false when there are no flings on the main thread, but | |
83 // conservative in the sense that we might not be actually flinging when it is | |
84 // true. | |
85 bool fling_may_be_active_on_main_thread_; | |
86 // The axes on which the current fling has overshot the bounds of the content. | |
87 bool fling_overscrolled_horizontally_; | |
88 bool fling_overscrolled_vertically_; | |
89 | 60 |
90 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); | 61 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy); |
91 }; | 62 }; |
92 | 63 |
93 } // namespace content | 64 } // namespace content |
94 | 65 |
95 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ | 66 #endif // CONTENT_RENDERER_GPU_INPUT_HANDLER_PROXY_H_ |
OLD | NEW |