| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // 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 |
| 166 // (non-synthetic). This situation arises when OSX generates double | 166 // (non-synthetic). This situation arises when OSX generates double |
| 167 // phase end information. | 167 // phase end information. |
| 168 bool empty_sequence = | 168 bool empty_sequence = |
| 169 !needs_update && needs_scroll_begin_ && current_phase_ended; | 169 !needs_update && needs_scroll_begin_ && current_phase_ended; |
| 170 | 170 |
| 171 if (needs_update || !empty_sequence) { | 171 if (needs_update || !empty_sequence) { |
| 172 if (needs_scroll_begin_) { | 172 if (needs_scroll_begin_) { |
| 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) { | 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(); |
| 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); |
| 194 } else if (has_phase_info) { | 194 } else if (has_phase_info) { |
| 195 // 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 |
| 196 // that the non-latching behavior is preserved. Remove once | 196 // that the non-latching behavior is preserved. Remove once |
| 197 // crbug.com/526463 is fully implemented. | 197 // crbug.com/526463 is fully implemented. |
| 198 SendScrollEnd(scroll_update, true); | 198 if (!enable_scroll_latching_) |
| 199 SendScrollEnd(scroll_update, true); |
| 199 } else { | 200 } else { |
| 200 scroll_end_timer_.Start( | 201 scroll_end_timer_.Start( |
| 201 FROM_HERE, | 202 FROM_HERE, |
| 202 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), | 203 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), |
| 203 base::Bind(&MouseWheelEventQueue::SendScrollEnd, | 204 base::Bind(&MouseWheelEventQueue::SendScrollEnd, |
| 204 base::Unretained(this), scroll_update, false)); | 205 base::Unretained(this), scroll_update, false)); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 | 209 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 scroll_begin.data.scrollBegin.targetViewport = false; | 288 scroll_begin.data.scrollBegin.targetViewport = false; |
| 288 scroll_begin.data.scrollBegin.deltaHintUnits = | 289 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 289 gesture_update.data.scrollUpdate.deltaUnits; | 290 gesture_update.data.scrollUpdate.deltaUnits; |
| 290 | 291 |
| 291 needs_scroll_begin_ = false; | 292 needs_scroll_begin_ = false; |
| 292 needs_scroll_end_ = true; | 293 needs_scroll_end_ = true; |
| 293 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 294 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
| 294 } | 295 } |
| 295 | 296 |
| 296 } // namespace content | 297 } // namespace content |
| OLD | NEW |