| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 // Replace the event's coordinate fields with translated position data from | 187 // Replace the event's coordinate fields with translated position data from |
| 188 // |event|. | 188 // |event|. |
| 189 webkit_event.windowX = webkit_event.x = event.x(); | 189 webkit_event.windowX = webkit_event.x = event.x(); |
| 190 webkit_event.windowY = webkit_event.y = event.y(); | 190 webkit_event.windowY = webkit_event.y = event.y(); |
| 191 | 191 |
| 192 const gfx::Point root_point = event.root_location(); | 192 const gfx::Point root_point = event.root_location(); |
| 193 webkit_event.globalX = root_point.x(); | 193 webkit_event.globalX = root_point.x(); |
| 194 webkit_event.globalY = root_point.y(); | 194 webkit_event.globalY = root_point.y(); |
| 195 | 195 |
| 196 // Scroll events generated from the mouse wheel when the control key is held |
| 197 // don't trigger scrolling. Instead, they may cause zooming. |
| 198 bool from_mouse_wheel = !webkit_event.hasPreciseScrollingDeltas; |
| 199 if ((webkit_event.modifiers & blink::WebInputEvent::ControlKey) && |
| 200 from_mouse_wheel) { |
| 201 webkit_event.canScroll = false; |
| 202 } |
| 203 |
| 196 return webkit_event; | 204 return webkit_event; |
| 197 } | 205 } |
| 198 | 206 |
| 199 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { | 207 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { |
| 200 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
| 201 // Construct an untranslated event from the platform event data. | 209 // Construct an untranslated event from the platform event data. |
| 202 blink::WebMouseWheelEvent webkit_event = | 210 blink::WebMouseWheelEvent webkit_event = event.native_event().message ? |
| 203 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()); | 211 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()) : |
| 212 MakeWebMouseWheelEventFromAuraEvent(event); |
| 204 #else | 213 #else |
| 205 blink::WebMouseWheelEvent webkit_event = | 214 blink::WebMouseWheelEvent webkit_event = |
| 206 MakeWebMouseWheelEventFromAuraEvent(event); | 215 MakeWebMouseWheelEventFromAuraEvent(event); |
| 207 #endif | 216 #endif |
| 208 | 217 |
| 209 // Replace the event's coordinate fields with translated position data from | 218 // Replace the event's coordinate fields with translated position data from |
| 210 // |event|. | 219 // |event|. |
| 211 webkit_event.windowX = webkit_event.x = event.x(); | 220 webkit_event.windowX = webkit_event.x = event.x(); |
| 212 webkit_event.windowY = webkit_event.y = event.y(); | 221 webkit_event.windowY = webkit_event.y = event.y(); |
| 213 | 222 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 webkit_event.deltaY = event.y_offset(); | 356 webkit_event.deltaY = event.y_offset(); |
| 348 } | 357 } |
| 349 | 358 |
| 350 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; | 359 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; |
| 351 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; | 360 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; |
| 352 | 361 |
| 353 return webkit_event; | 362 return webkit_event; |
| 354 } | 363 } |
| 355 | 364 |
| 356 } // namespace content | 365 } // namespace content |
| OLD | NEW |