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

Side by Side Diff: content/renderer/input/input_handler_proxy.h

Issue 1415953004: Move content/renderer input handling for web input events to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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_RENDERER_INPUT_INPUT_HANDLER_PROXY_H_
6 #define CONTENT_RENDERER_INPUT_INPUT_HANDLER_PROXY_H_
7
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/input/input_handler.h"
12 #include "content/common/content_export.h"
13 #include "content/renderer/input/synchronous_input_handler_proxy.h"
14 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
15 #include "third_party/WebKit/public/platform/WebGestureCurveTarget.h"
16 #include "third_party/WebKit/public/web/WebActiveWheelFlingParameters.h"
17 #include "third_party/WebKit/public/web/WebInputEvent.h"
18
19 namespace content {
20
21 namespace test {
22 class InputHandlerProxyTest;
23 }
24
25 class InputHandlerProxyClient;
26 class InputScrollElasticityController;
27
28 // This class is a proxy between the content input event filtering and the
29 // compositor's input handling logic. InputHandlerProxy instances live entirely
30 // on the compositor thread. Each InputHandler instance handles input events
31 // intended for a specific WebWidget.
32 class CONTENT_EXPORT InputHandlerProxy
33 : public cc::InputHandlerClient,
34 public SynchronousInputHandlerProxy,
35 public NON_EXPORTED_BASE(blink::WebGestureCurveTarget) {
36 public:
37 InputHandlerProxy(cc::InputHandler* input_handler,
38 InputHandlerProxyClient* client);
39 ~InputHandlerProxy() override;
40
41 InputScrollElasticityController* scroll_elasticity_controller() {
42 return scroll_elasticity_controller_.get();
43 }
44
45 enum EventDisposition {
46 DID_HANDLE,
47 DID_NOT_HANDLE,
48 DROP_EVENT
49 };
50 EventDisposition HandleInputEventWithLatencyInfo(
51 const blink::WebInputEvent& event,
52 ui::LatencyInfo* latency_info);
53 EventDisposition HandleInputEvent(const blink::WebInputEvent& event);
54
55 // cc::InputHandlerClient implementation.
56 void WillShutdown() override;
57 void Animate(base::TimeTicks time) override;
58 void MainThreadHasStoppedFlinging() override;
59 void ReconcileElasticOverscrollAndRootScroll() override;
60 void UpdateRootLayerStateForSynchronousInputHandler(
61 const gfx::ScrollOffset& total_scroll_offset,
62 const gfx::ScrollOffset& max_scroll_offset,
63 const gfx::SizeF& scrollable_size,
64 float page_scale_factor,
65 float min_page_scale_factor,
66 float max_page_scale_factor) override;
67
68 // SynchronousInputHandlerProxy implementation.
69 void SetOnlySynchronouslyAnimateRootFlings(
70 SynchronousInputHandler* synchronous_input_handler) override;
71 void SynchronouslyAnimate(base::TimeTicks time) override;
72 void SynchronouslySetRootScrollOffset(
73 const gfx::ScrollOffset& root_offset) override;
74
75 // blink::WebGestureCurveTarget implementation.
76 bool scrollBy(const blink::WebFloatSize& offset,
77 const blink::WebFloatSize& velocity) override;
78
79 bool gesture_scroll_on_impl_thread_for_testing() const {
80 return gesture_scroll_on_impl_thread_;
81 }
82
83 private:
84 friend class test::InputHandlerProxyTest;
85
86 // Helper functions for handling more complicated input events.
87 EventDisposition HandleMouseWheel(
88 const blink::WebMouseWheelEvent& event);
89 EventDisposition HandleGestureScrollBegin(
90 const blink::WebGestureEvent& event);
91 EventDisposition HandleGestureScrollUpdate(
92 const blink::WebGestureEvent& event);
93 EventDisposition HandleGestureScrollEnd(
94 const blink::WebGestureEvent& event);
95 EventDisposition HandleGestureFlingStart(
96 const blink::WebGestureEvent& event);
97 EventDisposition HandleTouchStart(
98 const blink::WebTouchEvent& event);
99
100 // Returns true if the event should be suppressed due to to an active,
101 // boost-enabled fling, in which case further processing should cease.
102 bool FilterInputEventForFlingBoosting(const blink::WebInputEvent& event);
103
104 // Schedule a time in the future after which a boost-enabled fling will
105 // terminate without further momentum from the user (see |Animate()|).
106 void ExtendBoostedFlingTimeout(const blink::WebGestureEvent& event);
107
108 // Returns true if we scrolled by the increment.
109 bool TouchpadFlingScroll(const blink::WebFloatSize& increment);
110
111 // Returns true if we actually had an active fling to cancel, also notifying
112 // the client that the fling has ended. Note that if a boosted fling is active
113 // and suppressing an active scroll sequence, a synthetic GestureScrollBegin
114 // will be injected to resume scrolling.
115 bool CancelCurrentFling();
116
117 // Returns true if we actually had an active fling to cancel.
118 bool CancelCurrentFlingWithoutNotifyingClient();
119
120 // Request a frame of animation from the InputHandler or
121 // SynchronousInputHandler. They can provide that by calling Animate().
122 void RequestAnimation();
123
124 // Used to send overscroll messages to the browser.
125 void HandleOverscroll(
126 const gfx::Point& causal_event_viewport_point,
127 const cc::InputHandlerScrollResult& scroll_result);
128
129 scoped_ptr<blink::WebGestureCurve> fling_curve_;
130 // Parameters for the active fling animation, stored in case we need to
131 // transfer it out later.
132 blink::WebActiveWheelFlingParameters fling_parameters_;
133
134 InputHandlerProxyClient* client_;
135 cc::InputHandler* input_handler_;
136
137 // Time at which an active fling should expire due to a deferred cancellation
138 // event. A call to |Animate()| after this time will end the fling.
139 double deferred_fling_cancel_time_seconds_;
140
141 // The last event that extended the lifetime of the boosted fling. If the
142 // event was a scroll gesture, a GestureScrollBegin will be inserted if the
143 // fling terminates (via |CancelCurrentFling()|).
144 blink::WebGestureEvent last_fling_boost_event_;
145
146 // When present, Animates are not requested to the InputHandler, but to this
147 // SynchronousInputHandler instead. And all Animate() calls are expected to
148 // happen via the SynchronouslyAnimate() call instead of coming directly from
149 // the InputHandler.
150 SynchronousInputHandler* synchronous_input_handler_;
151 bool allow_root_animate_;
152
153 #ifndef NDEBUG
154 bool expect_scroll_update_end_;
155 #endif
156 bool gesture_scroll_on_impl_thread_;
157 bool gesture_pinch_on_impl_thread_;
158 // This is always false when there are no flings on the main thread, but
159 // conservative in the sense that we might not be actually flinging when it is
160 // true.
161 bool fling_may_be_active_on_main_thread_;
162 // The axes on which the current fling is allowed to scroll. If a given fling
163 // has overscrolled on a particular axis, further fling scrolls on that axis
164 // will be disabled.
165 bool disallow_horizontal_fling_scroll_;
166 bool disallow_vertical_fling_scroll_;
167
168 // Whether an active fling has seen an |Animate()| call. This is useful for
169 // determining if the fling start time should be re-initialized.
170 bool has_fling_animation_started_;
171
172 // Non-zero only within the scope of |scrollBy|.
173 gfx::Vector2dF current_fling_velocity_;
174
175 // Used to animate rubber-band over-scroll effect on Mac.
176 scoped_ptr<InputScrollElasticityController> scroll_elasticity_controller_;
177
178 bool smooth_scroll_enabled_;
179
180 bool uma_latency_reporting_enabled_;
181
182 base::TimeTicks last_fling_animate_time_;
183
184 DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy);
185 };
186
187 } // namespace content
188
189 #endif // CONTENT_RENDERER_INPUT_INPUT_HANDLER_PROXY_H_
OLDNEW
« no previous file with comments | « content/renderer/input/input_handler_manager_client.h ('k') | content/renderer/input/input_handler_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698