| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 scroll_update.timeStampSeconds = | 92 scroll_update.timeStampSeconds = |
| 93 event_sent_for_gesture_ack_->event.timeStampSeconds; | 93 event_sent_for_gesture_ack_->event.timeStampSeconds; |
| 94 | 94 |
| 95 scroll_update.x = event_sent_for_gesture_ack_->event.x; | 95 scroll_update.x = event_sent_for_gesture_ack_->event.x; |
| 96 scroll_update.y = event_sent_for_gesture_ack_->event.y; | 96 scroll_update.y = event_sent_for_gesture_ack_->event.y; |
| 97 scroll_update.globalX = event_sent_for_gesture_ack_->event.globalX; | 97 scroll_update.globalX = event_sent_for_gesture_ack_->event.globalX; |
| 98 scroll_update.globalY = event_sent_for_gesture_ack_->event.globalY; | 98 scroll_update.globalY = event_sent_for_gesture_ack_->event.globalY; |
| 99 scroll_update.type = WebInputEvent::GestureScrollUpdate; | 99 scroll_update.type = WebInputEvent::GestureScrollUpdate; |
| 100 scroll_update.sourceDevice = blink::WebGestureDeviceTouchpad; | 100 scroll_update.sourceDevice = blink::WebGestureDeviceTouchpad; |
| 101 scroll_update.resendingPluginId = -1; | 101 scroll_update.resendingPluginId = -1; |
| 102 scroll_update.data.scrollUpdate.deltaX = | 102 |
| 103 event_sent_for_gesture_ack_->event.deltaX; | 103 // Swap X & Y if Shift is down and when there is no horizontal movement. |
| 104 scroll_update.data.scrollUpdate.deltaY = | 104 if ((event_sent_for_gesture_ack_->event.modifiers & |
| 105 event_sent_for_gesture_ack_->event.deltaY; | 105 WebInputEvent::ShiftKey) != 0 && |
| 106 event_sent_for_gesture_ack_->event.deltaX == 0) { |
| 107 scroll_update.data.scrollUpdate.deltaX = |
| 108 event_sent_for_gesture_ack_->event.deltaY; |
| 109 scroll_update.data.scrollUpdate.deltaY = |
| 110 event_sent_for_gesture_ack_->event.deltaX; |
| 111 } else { |
| 112 scroll_update.data.scrollUpdate.deltaX = |
| 113 event_sent_for_gesture_ack_->event.deltaX; |
| 114 scroll_update.data.scrollUpdate.deltaY = |
| 115 event_sent_for_gesture_ack_->event.deltaY; |
| 116 } |
| 106 // Only OSX populates the phase and momentumPhase; so | 117 // Only OSX populates the phase and momentumPhase; so |
| 107 // |inertialPhase| will be UnknownMomentumPhase on all other platforms. | 118 // |inertialPhase| will be UnknownMomentumPhase on all other platforms. |
| 108 if (event_sent_for_gesture_ack_->event.momentumPhase != | 119 if (event_sent_for_gesture_ack_->event.momentumPhase != |
| 109 blink::WebMouseWheelEvent::PhaseNone) { | 120 blink::WebMouseWheelEvent::PhaseNone) { |
| 110 scroll_update.data.scrollUpdate.inertialPhase = | 121 scroll_update.data.scrollUpdate.inertialPhase = |
| 111 WebGestureEvent::MomentumPhase; | 122 WebGestureEvent::MomentumPhase; |
| 112 } else if (event_sent_for_gesture_ack_->event.phase != | 123 } else if (event_sent_for_gesture_ack_->event.phase != |
| 113 blink::WebMouseWheelEvent::PhaseNone) { | 124 blink::WebMouseWheelEvent::PhaseNone) { |
| 114 scroll_update.data.scrollUpdate.inertialPhase = | 125 scroll_update.data.scrollUpdate.inertialPhase = |
| 115 WebGestureEvent::NonMomentumPhase; | 126 WebGestureEvent::NonMomentumPhase; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 scroll_begin.data.scrollBegin.deltaHintUnits = | 301 scroll_begin.data.scrollBegin.deltaHintUnits = |
| 291 gesture_update.data.scrollUpdate.deltaUnits; | 302 gesture_update.data.scrollUpdate.deltaUnits; |
| 292 | 303 |
| 293 needs_scroll_begin_ = false; | 304 needs_scroll_begin_ = false; |
| 294 needs_scroll_end_ = true; | 305 needs_scroll_end_ = true; |
| 295 client_->ForwardGestureEventWithLatencyInfo( | 306 client_->ForwardGestureEventWithLatencyInfo( |
| 296 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); | 307 scroll_begin, ui::LatencyInfo(ui::SourceEventType::WHEEL)); |
| 297 } | 308 } |
| 298 | 309 |
| 299 } // namespace content | 310 } // namespace content |
| OLD | NEW |