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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // If no GSB has been sent, it will be a non-synthetic GSB. | 173 // If no GSB has been sent, it will be a non-synthetic GSB. |
174 SendScrollBegin(scroll_update, false); | 174 SendScrollBegin(scroll_update, false); |
175 } else if (has_phase_info && !enable_scroll_latching_) { | 175 } else if (has_phase_info && !enable_scroll_latching_) { |
176 // If a GSB has been sent, generate a synthetic GSB if we have phase | 176 // If a GSB has been sent, generate a synthetic GSB if we have phase |
177 // information. This should be removed once crbug.com/526463 is fully | 177 // information. This should be removed once crbug.com/526463 is fully |
178 // implemented. | 178 // implemented. |
179 SendScrollBegin(scroll_update, true); | 179 SendScrollBegin(scroll_update, true); |
180 } | 180 } |
181 | 181 |
182 if (needs_update) { | 182 if (needs_update) { |
183 ui::LatencyInfo latency = ui::LatencyInfo(); | 183 ui::LatencyInfo latency = ui::LatencyInfo(ui::SourceEventType::WHEEL); |
184 latency.AddLatencyNumber( | 184 latency.AddLatencyNumber( |
185 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 185 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
186 0); | 186 0); |
187 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); | 187 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); |
188 } | 188 } |
189 | 189 |
190 if (current_phase_ended) { | 190 if (current_phase_ended) { |
191 // Non-synthetic GSEs are sent when the current phase is canceled or | 191 // Non-synthetic GSEs are sent when the current phase is canceled or |
192 // ended. | 192 // ended. |
193 SendScrollEnd(scroll_update, false); | 193 SendScrollEnd(scroll_update, false); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 scroll_end.data.scrollEnd.deltaUnits = | 261 scroll_end.data.scrollEnd.deltaUnits = |
262 update_event.data.scrollUpdate.deltaUnits; | 262 update_event.data.scrollUpdate.deltaUnits; |
263 | 263 |
264 if (!synthetic) { | 264 if (!synthetic) { |
265 needs_scroll_begin_ = true; | 265 needs_scroll_begin_ = true; |
266 needs_scroll_end_ = false; | 266 needs_scroll_end_ = false; |
267 | 267 |
268 if (scroll_end_timer_.IsRunning()) | 268 if (scroll_end_timer_.IsRunning()) |
269 scroll_end_timer_.Reset(); | 269 scroll_end_timer_.Reset(); |
270 } | 270 } |
271 client_->ForwardGestureEventWithLatencyInfo(scroll_end, ui::LatencyInfo()); | 271 client_->ForwardGestureEventWithLatencyInfo( |
| 272 scroll_end, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
272 } | 273 } |
273 | 274 |
274 void MouseWheelEventQueue::SendScrollBegin( | 275 void MouseWheelEventQueue::SendScrollBegin( |
275 const WebGestureEvent& gesture_update, | 276 const WebGestureEvent& gesture_update, |
276 bool synthetic) { | 277 bool synthetic) { |
277 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); | 278 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); |
278 | 279 |
279 WebGestureEvent scroll_begin(gesture_update); | 280 WebGestureEvent scroll_begin(gesture_update); |
280 scroll_begin.type = WebInputEvent::GestureScrollBegin; | 281 scroll_begin.type = WebInputEvent::GestureScrollBegin; |
281 scroll_begin.data.scrollBegin.synthetic = synthetic; | 282 scroll_begin.data.scrollBegin.synthetic = synthetic; |
282 scroll_begin.data.scrollBegin.inertialPhase = | 283 scroll_begin.data.scrollBegin.inertialPhase = |
283 gesture_update.data.scrollUpdate.inertialPhase; | 284 gesture_update.data.scrollUpdate.inertialPhase; |
284 scroll_begin.data.scrollBegin.deltaXHint = | 285 scroll_begin.data.scrollBegin.deltaXHint = |
285 gesture_update.data.scrollUpdate.deltaX; | 286 gesture_update.data.scrollUpdate.deltaX; |
286 scroll_begin.data.scrollBegin.deltaYHint = | 287 scroll_begin.data.scrollBegin.deltaYHint = |
287 gesture_update.data.scrollUpdate.deltaY; | 288 gesture_update.data.scrollUpdate.deltaY; |
288 scroll_begin.data.scrollBegin.targetViewport = false; | 289 scroll_begin.data.scrollBegin.targetViewport = false; |
289 scroll_begin.data.scrollBegin.deltaHintUnits = | 290 scroll_begin.data.scrollBegin.deltaHintUnits = |
290 gesture_update.data.scrollUpdate.deltaUnits; | 291 gesture_update.data.scrollUpdate.deltaUnits; |
291 | 292 |
292 needs_scroll_begin_ = false; | 293 needs_scroll_begin_ = false; |
293 needs_scroll_end_ = true; | 294 needs_scroll_end_ = true; |
294 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 295 client_->ForwardGestureEventWithLatencyInfo( |
| 296 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
295 } | 297 } |
296 | 298 |
297 } // namespace content | 299 } // namespace content |
OLD | NEW |