Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_input_event_aura.h" | 5 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/input/web_input_event_util.h" | 7 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 8 #include "content/browser/renderer_host/ui_events_helper.h" | 8 #include "content/browser/renderer_host/ui_events_helper.h" |
| 9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 191 |
| 192 // Replace the event's coordinate fields with translated position data from | 192 // Replace the event's coordinate fields with translated position data from |
| 193 // |event|. | 193 // |event|. |
| 194 webkit_event.windowX = webkit_event.x = event.x(); | 194 webkit_event.windowX = webkit_event.x = event.x(); |
| 195 webkit_event.windowY = webkit_event.y = event.y(); | 195 webkit_event.windowY = webkit_event.y = event.y(); |
| 196 | 196 |
| 197 const gfx::Point root_point = event.root_location(); | 197 const gfx::Point root_point = event.root_location(); |
| 198 webkit_event.globalX = root_point.x(); | 198 webkit_event.globalX = root_point.x(); |
| 199 webkit_event.globalY = root_point.y(); | 199 webkit_event.globalY = root_point.y(); |
| 200 | 200 |
| 201 // Scroll events generated from the mouse wheel when the control key is held | |
| 202 // don't trigger scrolling. Instead, they may cause zooming. | |
| 203 bool from_mouse_wheel = !webkit_event.hasPreciseScrollingDeltas; | |
| 204 if ((webkit_event.modifiers & blink::WebInputEvent::ControlKey) && | |
| 205 from_mouse_wheel) { | |
| 206 webkit_event.canScroll = false; | |
| 207 } | |
|
Rick Byers
2014/12/12 22:20:29
I think you could write a unit test for this code
lanwei
2014/12/17 23:16:40
Done.
| |
| 208 | |
| 201 return webkit_event; | 209 return webkit_event; |
| 202 } | 210 } |
| 203 | 211 |
| 204 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { | 212 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { |
| 205 #if defined(OS_WIN) | 213 #if defined(OS_WIN) |
| 206 // Construct an untranslated event from the platform event data. | 214 // Construct an untranslated event from the platform event data. |
| 207 blink::WebMouseWheelEvent webkit_event = | 215 blink::WebMouseWheelEvent webkit_event = |
| 208 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()); | 216 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()); |
| 209 #else | 217 #else |
| 210 blink::WebMouseWheelEvent webkit_event = | 218 blink::WebMouseWheelEvent webkit_event = |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 354 webkit_event.deltaY = event.y_offset(); | 362 webkit_event.deltaY = event.y_offset(); |
| 355 } | 363 } |
| 356 | 364 |
| 357 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; | 365 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; |
| 358 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; | 366 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; |
| 359 | 367 |
| 360 return webkit_event; | 368 return webkit_event; |
| 361 } | 369 } |
| 362 | 370 |
| 363 } // namespace content | 371 } // namespace content |
| OLD | NEW |