| 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 | 10 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 if (needs_scroll_begin_) { | 164 if (needs_scroll_begin_) { |
| 165 // If no GSB has been sent, it will be a non-synthetic GSB. | 165 // If no GSB has been sent, it will be a non-synthetic GSB. |
| 166 SendScrollBegin(scroll_update, false); | 166 SendScrollBegin(scroll_update, false); |
| 167 } else if (has_phase_info) { | 167 } else if (has_phase_info) { |
| 168 // If a GSB has been sent, generate a synthetic GSB if we have phase | 168 // If a GSB has been sent, generate a synthetic GSB if we have phase |
| 169 // information. This should be removed once crbug.com/526463 is fully | 169 // information. This should be removed once crbug.com/526463 is fully |
| 170 // implemented. | 170 // implemented. |
| 171 SendScrollBegin(scroll_update, true); | 171 SendScrollBegin(scroll_update, true); |
| 172 } | 172 } |
| 173 | 173 |
| 174 if (needs_update) | 174 if (needs_update) { |
| 175 client_->ForwardGestureEvent(scroll_update); | 175 ui::LatencyInfo latency = ui::LatencyInfo(); |
| 176 latency.AddLatencyNumber( |
| 177 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| 178 0); |
| 179 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); |
| 180 } |
| 176 | 181 |
| 177 if (current_phase_ended) { | 182 if (current_phase_ended) { |
| 178 // Non-synthetic GSEs are sent when the current phase is canceled or | 183 // Non-synthetic GSEs are sent when the current phase is canceled or |
| 179 // ended. | 184 // ended. |
| 180 SendScrollEnd(scroll_update, false); | 185 SendScrollEnd(scroll_update, false); |
| 181 } else if (has_phase_info) { | 186 } else if (has_phase_info) { |
| 182 // Generate a synthetic GSE for every update to force hit testing so | 187 // Generate a synthetic GSE for every update to force hit testing so |
| 183 // that the non-latching behavior is preserved. Remove once | 188 // that the non-latching behavior is preserved. Remove once |
| 184 // crbug.com/526463 is fully implemented. | 189 // crbug.com/526463 is fully implemented. |
| 185 SendScrollEnd(scroll_update, true); | 190 SendScrollEnd(scroll_update, true); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 scroll_end.data.scrollEnd.deltaUnits = | 251 scroll_end.data.scrollEnd.deltaUnits = |
| 247 update_event.data.scrollUpdate.deltaUnits; | 252 update_event.data.scrollUpdate.deltaUnits; |
| 248 | 253 |
| 249 if (!synthetic) { | 254 if (!synthetic) { |
| 250 needs_scroll_begin_ = true; | 255 needs_scroll_begin_ = true; |
| 251 needs_scroll_end_ = false; | 256 needs_scroll_end_ = false; |
| 252 | 257 |
| 253 if (scroll_end_timer_.IsRunning()) | 258 if (scroll_end_timer_.IsRunning()) |
| 254 scroll_end_timer_.Reset(); | 259 scroll_end_timer_.Reset(); |
| 255 } | 260 } |
| 256 client_->ForwardGestureEvent(scroll_end); | 261 client_->ForwardGestureEventWithLatencyInfo(scroll_end, ui::LatencyInfo()); |
| 257 } | 262 } |
| 258 | 263 |
| 259 void MouseWheelEventQueue::SendScrollBegin( | 264 void MouseWheelEventQueue::SendScrollBegin( |
| 260 const WebGestureEvent& gesture_update, | 265 const WebGestureEvent& gesture_update, |
| 261 bool synthetic) { | 266 bool synthetic) { |
| 262 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); | 267 DCHECK((synthetic && !needs_scroll_begin_) || needs_scroll_begin_); |
| 263 | 268 |
| 264 WebGestureEvent scroll_begin(gesture_update); | 269 WebGestureEvent scroll_begin(gesture_update); |
| 265 scroll_begin.type = WebInputEvent::GestureScrollBegin; | 270 scroll_begin.type = WebInputEvent::GestureScrollBegin; |
| 266 scroll_begin.data.scrollBegin.synthetic = synthetic; | 271 scroll_begin.data.scrollBegin.synthetic = synthetic; |
| 267 scroll_begin.data.scrollBegin.inertial = | 272 scroll_begin.data.scrollBegin.inertial = |
| 268 gesture_update.data.scrollUpdate.inertial; | 273 gesture_update.data.scrollUpdate.inertial; |
| 269 scroll_begin.data.scrollBegin.deltaXHint = | 274 scroll_begin.data.scrollBegin.deltaXHint = |
| 270 gesture_update.data.scrollUpdate.deltaX; | 275 gesture_update.data.scrollUpdate.deltaX; |
| 271 scroll_begin.data.scrollBegin.deltaYHint = | 276 scroll_begin.data.scrollBegin.deltaYHint = |
| 272 gesture_update.data.scrollUpdate.deltaY; | 277 gesture_update.data.scrollUpdate.deltaY; |
| 273 scroll_begin.data.scrollBegin.targetViewport = false; | 278 scroll_begin.data.scrollBegin.targetViewport = false; |
| 274 scroll_begin.data.scrollBegin.deltaHintUnits = | 279 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 275 gesture_update.data.scrollUpdate.deltaUnits; | 280 gesture_update.data.scrollUpdate.deltaUnits; |
| 276 | 281 |
| 277 needs_scroll_begin_ = false; | 282 needs_scroll_begin_ = false; |
| 278 needs_scroll_end_ = true; | 283 needs_scroll_end_ = true; |
| 279 client_->ForwardGestureEvent(scroll_begin); | 284 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
| 280 } | 285 } |
| 281 | 286 |
| 282 } // namespace content | 287 } // namespace content |
| OLD | NEW |