OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" | 5 #include "content/browser/renderer_host/input/mouse_wheel_event_queue.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "content/common/input/web_input_event_traits.h" | 10 #include "content/common/input/web_input_event_traits.h" |
11 #include "content/public/common/content_features.h" | |
11 | 12 |
12 using blink::WebGestureEvent; | 13 using blink::WebGestureEvent; |
13 using blink::WebInputEvent; | 14 using blink::WebInputEvent; |
14 using blink::WebMouseWheelEvent; | 15 using blink::WebMouseWheelEvent; |
15 using ui::LatencyInfo; | 16 using ui::LatencyInfo; |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 // This class represents a single queued mouse wheel event. Its main use | 20 // This class represents a single queued mouse wheel event. Its main use |
20 // is that it is reported via trace events. | 21 // is that it is reported via trace events. |
(...skipping 13 matching lines...) Expand all Loading... | |
34 }; | 35 }; |
35 | 36 |
36 MouseWheelEventQueue::MouseWheelEventQueue(MouseWheelEventQueueClient* client, | 37 MouseWheelEventQueue::MouseWheelEventQueue(MouseWheelEventQueueClient* client, |
37 int64_t scroll_transaction_ms) | 38 int64_t scroll_transaction_ms) |
38 : client_(client), | 39 : client_(client), |
39 needs_scroll_begin_(true), | 40 needs_scroll_begin_(true), |
40 needs_scroll_end_(false), | 41 needs_scroll_end_(false), |
41 scroll_transaction_ms_(scroll_transaction_ms), | 42 scroll_transaction_ms_(scroll_transaction_ms), |
42 scrolling_device_(blink::WebGestureDeviceUninitialized) { | 43 scrolling_device_(blink::WebGestureDeviceUninitialized) { |
43 DCHECK(client); | 44 DCHECK(client); |
45 touchpad_scroll_latching_ = | |
46 base::FeatureList::IsEnabled(features::kTouchpadScrollLatching); | |
dtapuska
2016/07/19 17:41:31
I don't think this will build on mac. It is a litt
sahel
2016/07/19 22:47:03
Done.
| |
47 if (touchpad_scroll_latching_) | |
48 kDefaultWheelScrollTransactionMs = 100; | |
49 else | |
50 kDefaultWheelScrollTransactionMs = 0; | |
44 } | 51 } |
45 | 52 |
46 MouseWheelEventQueue::~MouseWheelEventQueue() { | 53 MouseWheelEventQueue::~MouseWheelEventQueue() { |
47 if (!wheel_queue_.empty()) | 54 if (!wheel_queue_.empty()) |
48 STLDeleteElements(&wheel_queue_); | 55 STLDeleteElements(&wheel_queue_); |
49 } | 56 } |
50 | 57 |
51 void MouseWheelEventQueue::QueueEvent( | 58 void MouseWheelEventQueue::QueueEvent( |
52 const MouseWheelEventWithLatencyInfo& event) { | 59 const MouseWheelEventWithLatencyInfo& event) { |
53 TRACE_EVENT0("input", "MouseWheelEventQueue::QueueEvent"); | 60 TRACE_EVENT0("input", "MouseWheelEventQueue::QueueEvent"); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 // because the events generated will be a GSB (non-synthetic) and GSE | 169 // because the events generated will be a GSB (non-synthetic) and GSE |
163 // (non-synthetic). This situation arises when OSX generates double | 170 // (non-synthetic). This situation arises when OSX generates double |
164 // phase end information. | 171 // phase end information. |
165 bool empty_sequence = | 172 bool empty_sequence = |
166 !needs_update && needs_scroll_begin_ && current_phase_ended; | 173 !needs_update && needs_scroll_begin_ && current_phase_ended; |
167 | 174 |
168 if (needs_update || !empty_sequence) { | 175 if (needs_update || !empty_sequence) { |
169 if (needs_scroll_begin_) { | 176 if (needs_scroll_begin_) { |
170 // If no GSB has been sent, it will be a non-synthetic GSB. | 177 // If no GSB has been sent, it will be a non-synthetic GSB. |
171 SendScrollBegin(scroll_update, false); | 178 SendScrollBegin(scroll_update, false); |
172 } else if (has_phase_info) { | 179 } else if (has_phase_info && !touchpad_scroll_latching_) { |
dtapuska
2016/07/19 17:41:31
Is it always scroll_transaction_ms_ is 0 then touc
sahel
2016/07/19 22:47:03
I kept the boolean value, but calculated it based
| |
173 // If a GSB has been sent, generate a synthetic GSB if we have phase | 180 // If a GSB has been sent, generate a synthetic GSB if we have phase |
174 // information. This should be removed once crbug.com/526463 is fully | 181 // information. This should be removed once crbug.com/526463 is fully |
175 // implemented. | 182 // implemented. |
176 SendScrollBegin(scroll_update, true); | 183 SendScrollBegin(scroll_update, true); |
177 } | 184 } |
178 | 185 |
179 if (needs_update) { | 186 if (needs_update) { |
180 ui::LatencyInfo latency = ui::LatencyInfo(); | 187 ui::LatencyInfo latency = ui::LatencyInfo(); |
181 latency.AddLatencyNumber( | 188 latency.AddLatencyNumber( |
182 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 189 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
183 0); | 190 0); |
184 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); | 191 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); |
185 } | 192 } |
186 | 193 |
187 if (current_phase_ended) { | 194 if (current_phase_ended) { |
188 // Non-synthetic GSEs are sent when the current phase is canceled or | 195 // Non-synthetic GSEs are sent when the current phase is canceled or |
189 // ended. | 196 // ended. |
190 SendScrollEnd(scroll_update, false); | 197 SendScrollEnd(scroll_update, false); |
191 } else if (has_phase_info) { | 198 } else if (has_phase_info) { |
192 // Generate a synthetic GSE for every update to force hit testing so | 199 // Generate a synthetic GSE for every update to force hit testing so |
193 // that the non-latching behavior is preserved. Remove once | 200 // that the non-latching behavior is preserved. Remove once |
194 // crbug.com/526463 is fully implemented. | 201 // crbug.com/526463 is fully implemented. |
195 SendScrollEnd(scroll_update, true); | 202 if (!touchpad_scroll_latching_) |
203 SendScrollEnd(scroll_update, true); | |
196 } else { | 204 } else { |
197 scroll_end_timer_.Start( | 205 scroll_end_timer_.Start( |
198 FROM_HERE, | 206 FROM_HERE, |
199 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), | 207 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), |
200 base::Bind(&MouseWheelEventQueue::SendScrollEnd, | 208 base::Bind(&MouseWheelEventQueue::SendScrollEnd, |
201 base::Unretained(this), scroll_update, false)); | 209 base::Unretained(this), scroll_update, false)); |
202 } | 210 } |
203 } | 211 } |
204 } | 212 } |
205 | 213 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 scroll_begin.data.scrollBegin.targetViewport = false; | 292 scroll_begin.data.scrollBegin.targetViewport = false; |
285 scroll_begin.data.scrollBegin.deltaHintUnits = | 293 scroll_begin.data.scrollBegin.deltaHintUnits = |
286 gesture_update.data.scrollUpdate.deltaUnits; | 294 gesture_update.data.scrollUpdate.deltaUnits; |
287 | 295 |
288 needs_scroll_begin_ = false; | 296 needs_scroll_begin_ = false; |
289 needs_scroll_end_ = true; | 297 needs_scroll_end_ = true; |
290 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 298 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
291 } | 299 } |
292 | 300 |
293 } // namespace content | 301 } // namespace content |
OLD | NEW |