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 "ui/events/blink/web_input_event_traits.h" | 10 #include "ui/events/blink/web_input_event_traits.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // If no GSB has been sent, it will be a non-synthetic GSB. | 184 // If no GSB has been sent, it will be a non-synthetic GSB. |
185 SendScrollBegin(scroll_update, false); | 185 SendScrollBegin(scroll_update, false); |
186 } else if (has_phase_info && !enable_scroll_latching_) { | 186 } else if (has_phase_info && !enable_scroll_latching_) { |
187 // If a GSB has been sent, generate a synthetic GSB if we have phase | 187 // If a GSB has been sent, generate a synthetic GSB if we have phase |
188 // information. This should be removed once crbug.com/526463 is fully | 188 // information. This should be removed once crbug.com/526463 is fully |
189 // implemented. | 189 // implemented. |
190 SendScrollBegin(scroll_update, true); | 190 SendScrollBegin(scroll_update, true); |
191 } | 191 } |
192 | 192 |
193 if (needs_update) { | 193 if (needs_update) { |
194 ui::LatencyInfo latency = ui::LatencyInfo(); | 194 ui::LatencyInfo latency = ui::LatencyInfo(ui::SourceEventType::WHEEL); |
195 latency.AddLatencyNumber( | 195 latency.AddLatencyNumber( |
196 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 196 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
197 0); | 197 0); |
198 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); | 198 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); |
199 } | 199 } |
200 | 200 |
201 if (current_phase_ended) { | 201 if (current_phase_ended) { |
202 // Non-synthetic GSEs are sent when the current phase is canceled or | 202 // Non-synthetic GSEs are sent when the current phase is canceled or |
203 // ended. | 203 // ended. |
204 SendScrollEnd(scroll_update, false); | 204 SendScrollEnd(scroll_update, false); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 scroll_end.data.scrollEnd.deltaUnits = | 272 scroll_end.data.scrollEnd.deltaUnits = |
273 update_event.data.scrollUpdate.deltaUnits; | 273 update_event.data.scrollUpdate.deltaUnits; |
274 | 274 |
275 if (!synthetic) { | 275 if (!synthetic) { |
276 needs_scroll_begin_ = true; | 276 needs_scroll_begin_ = true; |
277 needs_scroll_end_ = false; | 277 needs_scroll_end_ = false; |
278 | 278 |
279 if (scroll_end_timer_.IsRunning()) | 279 if (scroll_end_timer_.IsRunning()) |
280 scroll_end_timer_.Reset(); | 280 scroll_end_timer_.Reset(); |
281 } | 281 } |
282 client_->ForwardGestureEventWithLatencyInfo(scroll_end, ui::LatencyInfo()); | 282 client_->ForwardGestureEventWithLatencyInfo( |
| 283 scroll_end, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
283 } | 284 } |
284 | 285 |
285 void MouseWheelEventQueue::SendScrollBegin( | 286 void MouseWheelEventQueue::SendScrollBegin( |
286 const WebGestureEvent& gesture_update, | 287 const WebGestureEvent& gesture_update, |
287 bool synthetic) { | 288 bool synthetic) { |
288 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); | 289 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); |
289 | 290 |
290 WebGestureEvent scroll_begin(gesture_update); | 291 WebGestureEvent scroll_begin(gesture_update); |
291 scroll_begin.type = WebInputEvent::GestureScrollBegin; | 292 scroll_begin.type = WebInputEvent::GestureScrollBegin; |
292 scroll_begin.data.scrollBegin.synthetic = synthetic; | 293 scroll_begin.data.scrollBegin.synthetic = synthetic; |
293 scroll_begin.data.scrollBegin.inertialPhase = | 294 scroll_begin.data.scrollBegin.inertialPhase = |
294 gesture_update.data.scrollUpdate.inertialPhase; | 295 gesture_update.data.scrollUpdate.inertialPhase; |
295 scroll_begin.data.scrollBegin.deltaXHint = | 296 scroll_begin.data.scrollBegin.deltaXHint = |
296 gesture_update.data.scrollUpdate.deltaX; | 297 gesture_update.data.scrollUpdate.deltaX; |
297 scroll_begin.data.scrollBegin.deltaYHint = | 298 scroll_begin.data.scrollBegin.deltaYHint = |
298 gesture_update.data.scrollUpdate.deltaY; | 299 gesture_update.data.scrollUpdate.deltaY; |
299 scroll_begin.data.scrollBegin.targetViewport = false; | 300 scroll_begin.data.scrollBegin.targetViewport = false; |
300 scroll_begin.data.scrollBegin.deltaHintUnits = | 301 scroll_begin.data.scrollBegin.deltaHintUnits = |
301 gesture_update.data.scrollUpdate.deltaUnits; | 302 gesture_update.data.scrollUpdate.deltaUnits; |
302 | 303 |
303 needs_scroll_begin_ = false; | 304 needs_scroll_begin_ = false; |
304 needs_scroll_end_ = true; | 305 needs_scroll_end_ = true; |
305 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 306 client_->ForwardGestureEventWithLatencyInfo( |
| 307 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
306 } | 308 } |
307 | 309 |
308 } // namespace content | 310 } // namespace content |
OLD | NEW |