| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // because the events generated will be a GSB (non-synthetic) and GSE | 176 // because the events generated will be a GSB (non-synthetic) and GSE |
| 177 // (non-synthetic). This situation arises when OSX generates double | 177 // (non-synthetic). This situation arises when OSX generates double |
| 178 // phase end information. | 178 // phase end information. |
| 179 bool empty_sequence = | 179 bool empty_sequence = |
| 180 !needs_update && needs_scroll_begin_ && current_phase_ended; | 180 !needs_update && needs_scroll_begin_ && current_phase_ended; |
| 181 | 181 |
| 182 if (needs_update || !empty_sequence) { | 182 if (needs_update || !empty_sequence) { |
| 183 if (needs_scroll_begin_) { | 183 if (needs_scroll_begin_) { |
| 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) { |
| 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(); | 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); |
| 205 } else if (has_phase_info) { | 205 } else if (has_phase_info) { |
| 206 // Generate a synthetic GSE for every update to force hit testing so | 206 // Generate a synthetic GSE for every update to force hit testing so |
| 207 // that the non-latching behavior is preserved. Remove once | 207 // that the non-latching behavior is preserved. Remove once |
| 208 // crbug.com/526463 is fully implemented. | 208 // crbug.com/526463 is fully implemented. |
| 209 if (!enable_scroll_latching_) | 209 SendScrollEnd(scroll_update, true); |
| 210 SendScrollEnd(scroll_update, true); | |
| 211 } else { | 210 } else { |
| 212 scroll_end_timer_.Start( | 211 scroll_end_timer_.Start( |
| 213 FROM_HERE, | 212 FROM_HERE, |
| 214 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), | 213 base::TimeDelta::FromMilliseconds(scroll_transaction_ms_), |
| 215 base::Bind(&MouseWheelEventQueue::SendScrollEnd, | 214 base::Bind(&MouseWheelEventQueue::SendScrollEnd, |
| 216 base::Unretained(this), scroll_update, false)); | 215 base::Unretained(this), scroll_update, false)); |
| 217 } | 216 } |
| 218 } | 217 } |
| 219 } | 218 } |
| 220 | 219 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 scroll_begin.data.scrollBegin.targetViewport = false; | 298 scroll_begin.data.scrollBegin.targetViewport = false; |
| 300 scroll_begin.data.scrollBegin.deltaHintUnits = | 299 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 301 gesture_update.data.scrollUpdate.deltaUnits; | 300 gesture_update.data.scrollUpdate.deltaUnits; |
| 302 | 301 |
| 303 needs_scroll_begin_ = false; | 302 needs_scroll_begin_ = false; |
| 304 needs_scroll_end_ = true; | 303 needs_scroll_end_ = true; |
| 305 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); | 304 client_->ForwardGestureEventWithLatencyInfo(scroll_begin, ui::LatencyInfo()); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace content | 307 } // namespace content |
| OLD | NEW |