Chromium Code Reviews| 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" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 | 27 |
| 28 ~QueuedWebMouseWheelEvent() { | 28 ~QueuedWebMouseWheelEvent() { |
| 29 TRACE_EVENT_ASYNC_END0("input", "MouseWheelEventQueue::QueueEvent", this); | 29 TRACE_EVENT_ASYNC_END0("input", "MouseWheelEventQueue::QueueEvent", this); |
| 30 } | 30 } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(QueuedWebMouseWheelEvent); | 33 DISALLOW_COPY_AND_ASSIGN(QueuedWebMouseWheelEvent); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 MouseWheelEventQueue::MouseWheelEventQueue(MouseWheelEventQueueClient* client, | 36 MouseWheelEventQueue::MouseWheelEventQueue(MouseWheelEventQueueClient* client, |
| 37 int64_t scroll_transaction_ms) | 37 bool touchpad_scroll_latching) |
| 38 : client_(client), | 38 : client_(client), |
| 39 needs_scroll_begin_(true), | 39 needs_scroll_begin_(true), |
| 40 needs_scroll_end_(false), | 40 needs_scroll_end_(false), |
| 41 scroll_transaction_ms_(scroll_transaction_ms), | 41 touchpad_scroll_latching_(touchpad_scroll_latching), |
| 42 scrolling_device_(blink::WebGestureDeviceUninitialized) { | 42 scrolling_device_(blink::WebGestureDeviceUninitialized) { |
| 43 DCHECK(client); | 43 DCHECK(client); |
| 44 scroll_transaction_ms_ = touchpad_scroll_latching | |
| 45 ? kDefaultWheelScrollLatchingTransactionMs | |
| 46 : kDefaultWheelScrollTransactionMs; | |
|
tdresser
2016/07/22 15:43:15
I'm a bit confused here. Scroll transactions only
sahel
2016/07/25 15:54:53
If the flag is enabled, wheel scroll latching will
| |
| 44 } | 47 } |
| 45 | 48 |
| 46 MouseWheelEventQueue::~MouseWheelEventQueue() { | 49 MouseWheelEventQueue::~MouseWheelEventQueue() { |
| 47 if (!wheel_queue_.empty()) | 50 if (!wheel_queue_.empty()) |
| 48 STLDeleteElements(&wheel_queue_); | 51 STLDeleteElements(&wheel_queue_); |
| 49 } | 52 } |
| 50 | 53 |
| 51 void MouseWheelEventQueue::QueueEvent( | 54 void MouseWheelEventQueue::QueueEvent( |
| 52 const MouseWheelEventWithLatencyInfo& event) { | 55 const MouseWheelEventWithLatencyInfo& event) { |
| 53 TRACE_EVENT0("input", "MouseWheelEventQueue::QueueEvent"); | 56 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 | 165 // because the events generated will be a GSB (non-synthetic) and GSE |
| 163 // (non-synthetic). This situation arises when OSX generates double | 166 // (non-synthetic). This situation arises when OSX generates double |
| 164 // phase end information. | 167 // phase end information. |
| 165 bool empty_sequence = | 168 bool empty_sequence = |
| 166 !needs_update && needs_scroll_begin_ && current_phase_ended; | 169 !needs_update && needs_scroll_begin_ && current_phase_ended; |
| 167 | 170 |
| 168 if (needs_update || !empty_sequence) { | 171 if (needs_update || !empty_sequence) { |
| 169 if (needs_scroll_begin_) { | 172 if (needs_scroll_begin_) { |
| 170 // 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. |
| 171 SendScrollBegin(scroll_update, false); | 174 SendScrollBegin(scroll_update, false); |
| 172 } else if (has_phase_info) { | 175 } else if (has_phase_info && !touchpad_scroll_latching_) { |
| 173 // 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 |
| 174 // information. This should be removed once crbug.com/526463 is fully | 177 // information. This should be removed once crbug.com/526463 is fully |
| 175 // implemented. | 178 // implemented. |
| 176 SendScrollBegin(scroll_update, true); | 179 SendScrollBegin(scroll_update, true); |
| 177 } | 180 } |
| 178 | 181 |
| 179 if (needs_update) { | 182 if (needs_update) { |
| 180 ui::LatencyInfo latency = ui::LatencyInfo(); | 183 ui::LatencyInfo latency = ui::LatencyInfo(); |
| 181 latency.AddLatencyNumber( | 184 latency.AddLatencyNumber( |
| 182 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, | 185 ui::INPUT_EVENT_LATENCY_GENERATE_SCROLL_UPDATE_FROM_MOUSE_WHEEL, 0, |
| 183 0); | 186 0); |
| 184 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); | 187 client_->ForwardGestureEventWithLatencyInfo(scroll_update, latency); |
| 185 } | 188 } |
| 186 | 189 |
| 187 if (current_phase_ended) { | 190 if (current_phase_ended) { |
| 188 // 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 |
| 189 // ended. | 192 // ended. |
| 190 SendScrollEnd(scroll_update, false); | 193 SendScrollEnd(scroll_update, false); |
| 191 } else if (has_phase_info) { | 194 } else if (has_phase_info) { |
| 192 // Generate a synthetic GSE for every update to force hit testing so | 195 // Generate a synthetic GSE for every update to force hit testing so |
| 193 // that the non-latching behavior is preserved. Remove once | 196 // that the non-latching behavior is preserved. Remove once |
| 194 // crbug.com/526463 is fully implemented. | 197 // crbug.com/526463 is fully implemented. |
| 195 SendScrollEnd(scroll_update, true); | 198 if (!touchpad_scroll_latching_) |
| 199 SendScrollEnd(scroll_update, true); | |
| 196 } else { | 200 } else { |
| 197 scroll_end_timer_.Start( | 201 scroll_end_timer_.Start( |
| 198 FROM_HERE, | 202 FROM_HERE, |
| 199 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), | 203 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), |
| 200 base::Bind(&MouseWheelEventQueue::SendScrollEnd, | 204 base::Bind(&MouseWheelEventQueue::SendScrollEnd, |
| 201 base::Unretained(this), scroll_update, false)); | 205 base::Unretained(this), scroll_update, false)); |
| 202 } | 206 } |
| 203 } | 207 } |
| 204 } | 208 } |
| 205 | 209 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 scroll_begin.data.scrollBegin.targetViewport = false; | 288 scroll_begin.data.scrollBegin.targetViewport = false; |
| 285 scroll_begin.data.scrollBegin.deltaHintUnits = | 289 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 286 gesture_update.data.scrollUpdate.deltaUnits; | 290 gesture_update.data.scrollUpdate.deltaUnits; |
| 287 | 291 |
| 288 needs_scroll_begin_ = false; | 292 needs_scroll_begin_ = false; |
| 289 needs_scroll_end_ = true; | 293 needs_scroll_end_ = true; |
| 290 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 294 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
| 291 } | 295 } |
| 292 | 296 |
| 293 } // namespace content | 297 } // namespace content |
| OLD | NEW |