| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "WebInputEventConversion.h" | 32 #include "WebInputEventConversion.h" |
| 33 | 33 |
| 34 #include "core/dom/Touch.h" | 34 #include "core/dom/Touch.h" |
| 35 #include "core/dom/TouchList.h" | 35 #include "core/dom/TouchList.h" |
| 36 #include "core/events/GestureEvent.h" | 36 #include "core/events/GestureEvent.h" |
| 37 #include "core/events/KeyboardEvent.h" | 37 #include "core/events/KeyboardEvent.h" |
| 38 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
| 39 #include "core/events/TouchEvent.h" | 39 #include "core/events/TouchEvent.h" |
| 40 #include "core/events/WheelEvent.h" | 40 #include "core/events/WheelEvent.h" |
| 41 #include "core/frame/FrameHost.h" |
| 42 #include "core/frame/FrameView.h" |
| 43 #include "core/frame/PinchViewport.h" |
| 44 #include "core/page/Page.h" |
| 41 #include "core/rendering/RenderObject.h" | 45 #include "core/rendering/RenderObject.h" |
| 42 #include "platform/KeyboardCodes.h" | 46 #include "platform/KeyboardCodes.h" |
| 43 #include "platform/Widget.h" | 47 #include "platform/Widget.h" |
| 44 #include "platform/scroll/ScrollView.h" | 48 #include "platform/scroll/ScrollView.h" |
| 45 | 49 |
| 46 using namespace WebCore; | 50 using namespace WebCore; |
| 47 | 51 |
| 48 namespace blink { | 52 namespace blink { |
| 49 | 53 |
| 50 static const double millisPerSecond = 1000.0; | 54 static const double millisPerSecond = 1000.0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 { | 69 { |
| 66 if (!widget) | 70 if (!widget) |
| 67 return IntSize(); | 71 return IntSize(); |
| 68 ScrollView* rootView = toScrollView(widget->root()); | 72 ScrollView* rootView = toScrollView(widget->root()); |
| 69 if (!rootView) | 73 if (!rootView) |
| 70 return IntSize(); | 74 return IntSize(); |
| 71 | 75 |
| 72 return rootView->inputEventsOffsetForEmulation(); | 76 return rootView->inputEventsOffsetForEmulation(); |
| 73 } | 77 } |
| 74 | 78 |
| 79 static IntPoint pinchViewportOffset(const Widget* widget) |
| 80 { |
| 81 // Event position needs to be adjusted by the pinch viewport's offset within
the |
| 82 // main frame before being passed into the widget's convertFromContainingWin
dow. |
| 83 FrameView* rootView = toFrameView(widget->root()); |
| 84 if (!rootView) |
| 85 return IntPoint(); |
| 86 |
| 87 return flooredIntPoint(rootView->page()->frameHost().pinchViewport().visible
Rect().location()); |
| 88 } |
| 89 |
| 75 // MakePlatformMouseEvent ----------------------------------------------------- | 90 // MakePlatformMouseEvent ----------------------------------------------------- |
| 76 | 91 |
| 77 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) | 92 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo
useEvent& e) |
| 78 { | 93 { |
| 79 float scale = widgetInputEventsScaleFactor(widget); | 94 float scale = widgetInputEventsScaleFactor(widget); |
| 80 IntSize offset = widgetInputEventsOffset(widget); | 95 IntSize offset = widgetInputEventsOffset(widget); |
| 96 IntPoint pinchViewport = pinchViewportOffset(widget); |
| 81 | 97 |
| 82 // FIXME: Widget is always toplevel, unless it's a popup. We may be able | 98 // FIXME: Widget is always toplevel, unless it's a popup. We may be able |
| 83 // to get rid of this once we abstract popups into a WebKit API. | 99 // to get rid of this once we abstract popups into a WebKit API. |
| 84 m_position = widget->convertFromContainingWindow(IntPoint((e.x - offset.widt
h()) / scale, (e.y - offset.height()) / scale)); | 100 m_position = widget->convertFromContainingWindow( |
| 101 IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offs
et.height()) / scale + pinchViewport.y())); |
| 85 m_globalPosition = IntPoint(e.globalX, e.globalY); | 102 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 86 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); | 103 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); |
| 87 m_button = static_cast<MouseButton>(e.button); | 104 m_button = static_cast<MouseButton>(e.button); |
| 88 | 105 |
| 89 m_modifiers = 0; | 106 m_modifiers = 0; |
| 90 if (e.modifiers & WebInputEvent::ShiftKey) | 107 if (e.modifiers & WebInputEvent::ShiftKey) |
| 91 m_modifiers |= PlatformEvent::ShiftKey; | 108 m_modifiers |= PlatformEvent::ShiftKey; |
| 92 if (e.modifiers & WebInputEvent::ControlKey) | 109 if (e.modifiers & WebInputEvent::ControlKey) |
| 93 m_modifiers |= PlatformEvent::CtrlKey; | 110 m_modifiers |= PlatformEvent::CtrlKey; |
| 94 if (e.modifiers & WebInputEvent::AltKey) | 111 if (e.modifiers & WebInputEvent::AltKey) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 118 ASSERT_NOT_REACHED(); | 135 ASSERT_NOT_REACHED(); |
| 119 } | 136 } |
| 120 } | 137 } |
| 121 | 138 |
| 122 // PlatformWheelEventBuilder -------------------------------------------------- | 139 // PlatformWheelEventBuilder -------------------------------------------------- |
| 123 | 140 |
| 124 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) | 141 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo
useWheelEvent& e) |
| 125 { | 142 { |
| 126 float scale = widgetInputEventsScaleFactor(widget); | 143 float scale = widgetInputEventsScaleFactor(widget); |
| 127 IntSize offset = widgetInputEventsOffset(widget); | 144 IntSize offset = widgetInputEventsOffset(widget); |
| 145 IntPoint pinchViewport = pinchViewportOffset(widget); |
| 128 | 146 |
| 129 m_position = widget->convertFromContainingWindow(IntPoint((e.x - offset.widt
h()) / scale, (e.y - offset.height()) / scale)); | 147 m_position = widget->convertFromContainingWindow( |
| 148 IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offs
et.height()) / scale + pinchViewport.y())); |
| 130 m_globalPosition = IntPoint(e.globalX, e.globalY); | 149 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 131 m_deltaX = e.deltaX; | 150 m_deltaX = e.deltaX; |
| 132 m_deltaY = e.deltaY; | 151 m_deltaY = e.deltaY; |
| 133 m_wheelTicksX = e.wheelTicksX; | 152 m_wheelTicksX = e.wheelTicksX; |
| 134 m_wheelTicksY = e.wheelTicksY; | 153 m_wheelTicksY = e.wheelTicksY; |
| 135 m_granularity = e.scrollByPage ? | 154 m_granularity = e.scrollByPage ? |
| 136 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; | 155 ScrollByPageWheelEvent : ScrollByPixelWheelEvent; |
| 137 | 156 |
| 138 m_type = PlatformEvent::Wheel; | 157 m_type = PlatformEvent::Wheel; |
| 139 | 158 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 159 m_canRubberbandRight = e.canRubberbandRight; | 178 m_canRubberbandRight = e.canRubberbandRight; |
| 160 #endif | 179 #endif |
| 161 } | 180 } |
| 162 | 181 |
| 163 // PlatformGestureEventBuilder -------------------------------------------------
- | 182 // PlatformGestureEventBuilder -------------------------------------------------
- |
| 164 | 183 |
| 165 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
ebGestureEvent& e) | 184 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const W
ebGestureEvent& e) |
| 166 { | 185 { |
| 167 float scale = widgetInputEventsScaleFactor(widget); | 186 float scale = widgetInputEventsScaleFactor(widget); |
| 168 IntSize offset = widgetInputEventsOffset(widget); | 187 IntSize offset = widgetInputEventsOffset(widget); |
| 188 IntPoint pinchViewport = pinchViewportOffset(widget); |
| 169 | 189 |
| 170 switch (e.type) { | 190 switch (e.type) { |
| 171 case WebInputEvent::GestureScrollBegin: | 191 case WebInputEvent::GestureScrollBegin: |
| 172 m_type = PlatformEvent::GestureScrollBegin; | 192 m_type = PlatformEvent::GestureScrollBegin; |
| 173 break; | 193 break; |
| 174 case WebInputEvent::GestureScrollEnd: | 194 case WebInputEvent::GestureScrollEnd: |
| 175 m_type = PlatformEvent::GestureScrollEnd; | 195 m_type = PlatformEvent::GestureScrollEnd; |
| 176 break; | 196 break; |
| 177 case WebInputEvent::GestureFlingStart: | 197 case WebInputEvent::GestureFlingStart: |
| 178 m_type = PlatformEvent::GestureFlingStart; | 198 m_type = PlatformEvent::GestureFlingStart; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 case WebInputEvent::GesturePinchEnd: | 256 case WebInputEvent::GesturePinchEnd: |
| 237 m_type = PlatformEvent::GesturePinchEnd; | 257 m_type = PlatformEvent::GesturePinchEnd; |
| 238 break; | 258 break; |
| 239 case WebInputEvent::GesturePinchUpdate: | 259 case WebInputEvent::GesturePinchUpdate: |
| 240 m_type = PlatformEvent::GesturePinchUpdate; | 260 m_type = PlatformEvent::GesturePinchUpdate; |
| 241 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; | 261 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; |
| 242 break; | 262 break; |
| 243 default: | 263 default: |
| 244 ASSERT_NOT_REACHED(); | 264 ASSERT_NOT_REACHED(); |
| 245 } | 265 } |
| 246 m_position = widget->convertFromContainingWindow(IntPoint((e.x - offset.widt
h()) / scale, (e.y - offset.height()) / scale)); | 266 m_position = widget->convertFromContainingWindow( |
| 267 IntPoint((e.x - offset.width()) / scale + pinchViewport.x(), (e.y - offs
et.height()) / scale + pinchViewport.y())); |
| 247 m_globalPosition = IntPoint(e.globalX, e.globalY); | 268 m_globalPosition = IntPoint(e.globalX, e.globalY); |
| 248 m_timestamp = e.timeStampSeconds; | 269 m_timestamp = e.timeStampSeconds; |
| 249 | 270 |
| 250 m_modifiers = 0; | 271 m_modifiers = 0; |
| 251 if (e.modifiers & WebInputEvent::ShiftKey) | 272 if (e.modifiers & WebInputEvent::ShiftKey) |
| 252 m_modifiers |= PlatformEvent::ShiftKey; | 273 m_modifiers |= PlatformEvent::ShiftKey; |
| 253 if (e.modifiers & WebInputEvent::ControlKey) | 274 if (e.modifiers & WebInputEvent::ControlKey) |
| 254 m_modifiers |= PlatformEvent::CtrlKey; | 275 m_modifiers |= PlatformEvent::CtrlKey; |
| 255 if (e.modifiers & WebInputEvent::AltKey) | 276 if (e.modifiers & WebInputEvent::AltKey) |
| 256 m_modifiers |= PlatformEvent::AltKey; | 277 m_modifiers |= PlatformEvent::AltKey; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 return WebTouchPoint::StatePressed; | 419 return WebTouchPoint::StatePressed; |
| 399 if (type == EventTypeNames::touchmove) | 420 if (type == EventTypeNames::touchmove) |
| 400 return WebTouchPoint::StateMoved; | 421 return WebTouchPoint::StateMoved; |
| 401 return WebTouchPoint::StateUndefined; | 422 return WebTouchPoint::StateUndefined; |
| 402 } | 423 } |
| 403 | 424 |
| 404 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) | 425 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTo
uchPoint& point) |
| 405 { | 426 { |
| 406 float scale = widgetInputEventsScaleFactor(widget); | 427 float scale = widgetInputEventsScaleFactor(widget); |
| 407 IntSize offset = widgetInputEventsOffset(widget); | 428 IntSize offset = widgetInputEventsOffset(widget); |
| 429 IntPoint pinchViewport = pinchViewportOffset(widget); |
| 408 m_id = point.id; | 430 m_id = point.id; |
| 409 m_state = toPlatformTouchPointState(point.state); | 431 m_state = toPlatformTouchPointState(point.state); |
| 410 m_pos = widget->convertFromContainingWindow(IntPoint((point.position.x - off
set.width()) / scale, (point.position.y - offset.height()) / scale)); | 432 m_pos = widget->convertFromContainingWindow(IntPoint( |
| 433 (point.position.x - offset.width()) / scale + pinchViewport.x(), |
| 434 (point.position.y - offset.height()) / scale + pinchViewport.y())); |
| 411 m_screenPos = IntPoint(point.screenPosition.x, point.screenPosition.y); | 435 m_screenPos = IntPoint(point.screenPosition.x, point.screenPosition.y); |
| 412 m_radiusY = point.radiusY / scale; | 436 m_radiusY = point.radiusY / scale; |
| 413 m_radiusX = point.radiusX / scale; | 437 m_radiusX = point.radiusX / scale; |
| 414 m_rotationAngle = point.rotationAngle; | 438 m_rotationAngle = point.rotationAngle; |
| 415 m_force = point.force; | 439 m_force = point.force; |
| 416 } | 440 } |
| 417 | 441 |
| 418 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) | 442 PlatformTouchEventBuilder::PlatformTouchEventBuilder(Widget* widget, const WebTo
uchEvent& event) |
| 419 { | 443 { |
| 420 m_type = toPlatformTouchEventType(event.type); | 444 m_type = toPlatformTouchEventType(event.type); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 modifiers = getWebInputModifiers(event); | 789 modifiers = getWebInputModifiers(event); |
| 766 | 790 |
| 767 globalX = event.screenX(); | 791 globalX = event.screenX(); |
| 768 globalY = event.screenY(); | 792 globalY = event.screenY(); |
| 769 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); | 793 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteL
ocation(), *renderObject); |
| 770 x = localPoint.x(); | 794 x = localPoint.x(); |
| 771 y = localPoint.y(); | 795 y = localPoint.y(); |
| 772 } | 796 } |
| 773 | 797 |
| 774 } // namespace blink | 798 } // namespace blink |
| OLD | NEW |