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 | |
204 return webkit_event; | 196 return webkit_event; |
205 } | 197 } |
206 | 198 |
207 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { | 199 blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ui::ScrollEvent& event) { |
208 #if defined(OS_WIN) | 200 #if defined(OS_WIN) |
209 // Construct an untranslated event from the platform event data. | 201 // Construct an untranslated event from the platform event data. |
210 blink::WebMouseWheelEvent webkit_event = event.native_event().message ? | 202 blink::WebMouseWheelEvent webkit_event = |
211 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()) : | 203 MakeUntranslatedWebMouseWheelEventFromNativeEvent(event.native_event()); |
212 MakeWebMouseWheelEventFromAuraEvent(event); | |
213 #else | 204 #else |
214 blink::WebMouseWheelEvent webkit_event = | 205 blink::WebMouseWheelEvent webkit_event = |
215 MakeWebMouseWheelEventFromAuraEvent(event); | 206 MakeWebMouseWheelEventFromAuraEvent(event); |
216 #endif | 207 #endif |
217 | 208 |
218 // Replace the event's coordinate fields with translated position data from | 209 // Replace the event's coordinate fields with translated position data from |
219 // |event|. | 210 // |event|. |
220 webkit_event.windowX = webkit_event.x = event.x(); | 211 webkit_event.windowX = webkit_event.x = event.x(); |
221 webkit_event.windowY = webkit_event.y = event.y(); | 212 webkit_event.windowY = webkit_event.y = event.y(); |
222 | 213 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 webkit_event.deltaY = event.y_offset(); | 347 webkit_event.deltaY = event.y_offset(); |
357 } | 348 } |
358 | 349 |
359 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; | 350 webkit_event.wheelTicksX = webkit_event.deltaX / kPixelsPerTick; |
360 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; | 351 webkit_event.wheelTicksY = webkit_event.deltaY / kPixelsPerTick; |
361 | 352 |
362 return webkit_event; | 353 return webkit_event; |
363 } | 354 } |
364 | 355 |
365 } // namespace content | 356 } // namespace content |
OLD | NEW |