| 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(ui::SourceEventType::WHEEL); | 194 ui::LatencyInfo latency = ui::LatencyInfo(); |
| 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( | 282 client_->ForwardGestureEventWithLatencyInfo(scroll_end, ui::LatencyInfo()); |
| 283 scroll_end, ui::LatencyInfo(ui::SourceEventType::WHEEL)); | |
| 284 } | 283 } |
| 285 | 284 |
| 286 void MouseWheelEventQueue::SendScrollBegin( | 285 void MouseWheelEventQueue::SendScrollBegin( |
| 287 const WebGestureEvent& gesture_update, | 286 const WebGestureEvent& gesture_update, |
| 288 bool synthetic) { | 287 bool synthetic) { |
| 289 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); | 288 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); |
| 290 | 289 |
| 291 WebGestureEvent scroll_begin(gesture_update); | 290 WebGestureEvent scroll_begin(gesture_update); |
| 292 scroll_begin.type = WebInputEvent::GestureScrollBegin; | 291 scroll_begin.type = WebInputEvent::GestureScrollBegin; |
| 293 scroll_begin.data.scrollBegin.synthetic = synthetic; | 292 scroll_begin.data.scrollBegin.synthetic = synthetic; |
| 294 scroll_begin.data.scrollBegin.inertialPhase = | 293 scroll_begin.data.scrollBegin.inertialPhase = |
| 295 gesture_update.data.scrollUpdate.inertialPhase; | 294 gesture_update.data.scrollUpdate.inertialPhase; |
| 296 scroll_begin.data.scrollBegin.deltaXHint = | 295 scroll_begin.data.scrollBegin.deltaXHint = |
| 297 gesture_update.data.scrollUpdate.deltaX; | 296 gesture_update.data.scrollUpdate.deltaX; |
| 298 scroll_begin.data.scrollBegin.deltaYHint = | 297 scroll_begin.data.scrollBegin.deltaYHint = |
| 299 gesture_update.data.scrollUpdate.deltaY; | 298 gesture_update.data.scrollUpdate.deltaY; |
| 300 scroll_begin.data.scrollBegin.targetViewport = false; | 299 scroll_begin.data.scrollBegin.targetViewport = false; |
| 301 scroll_begin.data.scrollBegin.deltaHintUnits = | 300 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 302 gesture_update.data.scrollUpdate.deltaUnits; | 301 gesture_update.data.scrollUpdate.deltaUnits; |
| 303 | 302 |
| 304 needs_scroll_begin_ = false; | 303 needs_scroll_begin_ = false; |
| 305 needs_scroll_end_ = true; | 304 needs_scroll_end_ = true; |
| 306 client_->ForwardGestureEventWithLatencyInfo( | 305 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
| 307 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); | |
| 308 } | 306 } |
| 309 | 307 |
| 310 } // namespace content | 308 } // namespace content |
| OLD | NEW |