| Index: sky/engine/web/WebInputEventConversion.cpp
|
| diff --git a/sky/engine/web/WebInputEventConversion.cpp b/sky/engine/web/WebInputEventConversion.cpp
|
| index d23a75f3dcba0774e10cbe1be98339d8bdb790cb..77fd0d16fda8d9d08e04b9c82e120cbc5cd0548c 100644
|
| --- a/sky/engine/web/WebInputEventConversion.cpp
|
| +++ b/sky/engine/web/WebInputEventConversion.cpp
|
| @@ -35,9 +35,7 @@
|
| #include "sky/engine/core/dom/TouchList.h"
|
| #include "sky/engine/core/events/GestureEvent.h"
|
| #include "sky/engine/core/events/KeyboardEvent.h"
|
| -#include "sky/engine/core/events/MouseEvent.h"
|
| #include "sky/engine/core/events/TouchEvent.h"
|
| -#include "sky/engine/core/events/WheelEvent.h"
|
| #include "sky/engine/core/frame/FrameHost.h"
|
| #include "sky/engine/core/frame/FrameView.h"
|
| #include "sky/engine/core/page/Page.h"
|
| @@ -72,85 +70,6 @@ static IntSize widgetInputEventsOffset(const Widget* widget)
|
| return rootView->inputEventsOffsetForEmulation();
|
| }
|
|
|
| -// MakePlatformMouseEvent -----------------------------------------------------
|
| -
|
| -PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
|
| -{
|
| - float scale = widgetInputEventsScaleFactor(widget);
|
| - IntSize offset = widgetInputEventsOffset(widget);
|
| -
|
| - // FIXME: Widget is always toplevel, unless it's a popup. We may be able
|
| - // to get rid of this once we abstract popups into a WebKit API.
|
| - m_position = widget->convertFromContainingView(
|
| - IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale));
|
| - m_globalPosition = IntPoint(e.globalX, e.globalY);
|
| - m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
|
| - m_button = static_cast<MouseButton>(e.button);
|
| -
|
| - m_modifiers = 0;
|
| - if (e.modifiers & WebInputEvent::ShiftKey)
|
| - m_modifiers |= PlatformEvent::ShiftKey;
|
| - if (e.modifiers & WebInputEvent::ControlKey)
|
| - m_modifiers |= PlatformEvent::CtrlKey;
|
| - if (e.modifiers & WebInputEvent::AltKey)
|
| - m_modifiers |= PlatformEvent::AltKey;
|
| - if (e.modifiers & WebInputEvent::MetaKey)
|
| - m_modifiers |= PlatformEvent::MetaKey;
|
| -
|
| - m_modifierFlags = e.modifiers;
|
| - m_timestamp = e.timeStampSeconds;
|
| - m_clickCount = e.clickCount;
|
| -
|
| - switch (e.type) {
|
| - case WebInputEvent::MouseMove:
|
| - case WebInputEvent::MouseLeave: // synthesize a move event
|
| - m_type = PlatformEvent::MouseMoved;
|
| - break;
|
| -
|
| - case WebInputEvent::MouseDown:
|
| - m_type = PlatformEvent::MousePressed;
|
| - break;
|
| -
|
| - case WebInputEvent::MouseUp:
|
| - m_type = PlatformEvent::MouseReleased;
|
| - break;
|
| -
|
| - default:
|
| - ASSERT_NOT_REACHED();
|
| - }
|
| -}
|
| -
|
| -// PlatformWheelEventBuilder --------------------------------------------------
|
| -
|
| -PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e)
|
| -{
|
| - float scale = widgetInputEventsScaleFactor(widget);
|
| - IntSize offset = widgetInputEventsOffset(widget);
|
| -
|
| - m_position = widget->convertFromContainingView(
|
| - IntPoint((e.x - offset.width()) / scale, (e.y - offset.height()) / scale));
|
| - m_globalPosition = IntPoint(e.globalX, e.globalY);
|
| - m_deltaX = e.deltaX;
|
| - m_deltaY = e.deltaY;
|
| - m_wheelTicksX = e.wheelTicksX;
|
| - m_wheelTicksY = e.wheelTicksY;
|
| - m_granularity = e.scrollByPage ?
|
| - ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
|
| -
|
| - m_type = PlatformEvent::Wheel;
|
| -
|
| - m_modifiers = 0;
|
| - if (e.modifiers & WebInputEvent::ShiftKey)
|
| - m_modifiers |= PlatformEvent::ShiftKey;
|
| - if (e.modifiers & WebInputEvent::ControlKey)
|
| - m_modifiers |= PlatformEvent::CtrlKey;
|
| - if (e.modifiers & WebInputEvent::AltKey)
|
| - m_modifiers |= PlatformEvent::AltKey;
|
| - if (e.modifiers & WebInputEvent::MetaKey)
|
| - m_modifiers |= PlatformEvent::MetaKey;
|
| -
|
| - m_hasPreciseScrollingDeltas = e.hasPreciseScrollingDeltas;
|
| -}
|
|
|
| // PlatformGestureEventBuilder --------------------------------------------------
|
|
|
| @@ -456,171 +375,6 @@ static IntPoint convertAbsoluteLocationForRenderObject(const LayoutPoint& locati
|
| return roundedIntPoint(convertAbsoluteLocationForRenderObjectFloat(location, renderObject));
|
| }
|
|
|
| -static void updateWebMouseEventFromCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const RenderObject& renderObject, WebMouseEvent& webEvent)
|
| -{
|
| - webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond;
|
| - webEvent.modifiers = getWebInputModifiers(event);
|
| -
|
| - IntPoint windowPoint = IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y());
|
| - windowPoint = widget.convertToContainingView(windowPoint);
|
| - webEvent.globalX = event.screenX();
|
| - webEvent.globalY = event.screenY();
|
| - webEvent.windowX = windowPoint.x();
|
| - webEvent.windowY = windowPoint.y();
|
| - IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), renderObject);
|
| - webEvent.x = localPoint.x();
|
| - webEvent.y = localPoint.y();
|
| -}
|
| -
|
| -WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObject* renderObject, const MouseEvent& event)
|
| -{
|
| - if (event.type() == EventTypeNames::mousemove)
|
| - type = WebInputEvent::MouseMove;
|
| - else if (event.type() == EventTypeNames::mouseout)
|
| - type = WebInputEvent::MouseLeave;
|
| - else if (event.type() == EventTypeNames::mouseover)
|
| - type = WebInputEvent::MouseEnter;
|
| - else if (event.type() == EventTypeNames::mousedown)
|
| - type = WebInputEvent::MouseDown;
|
| - else if (event.type() == EventTypeNames::mouseup)
|
| - type = WebInputEvent::MouseUp;
|
| - else
|
| - return; // Skip all other mouse events.
|
| -
|
| - updateWebMouseEventFromCoreMouseEvent(event, *widget, *renderObject, *this);
|
| -
|
| - switch (event.button()) {
|
| - case LeftButton:
|
| - button = WebMouseEvent::ButtonLeft;
|
| - break;
|
| - case MiddleButton:
|
| - button = WebMouseEvent::ButtonMiddle;
|
| - break;
|
| - case RightButton:
|
| - button = WebMouseEvent::ButtonRight;
|
| - break;
|
| - }
|
| - if (event.buttonDown()) {
|
| - switch (event.button()) {
|
| - case LeftButton:
|
| - modifiers |= WebInputEvent::LeftButtonDown;
|
| - break;
|
| - case MiddleButton:
|
| - modifiers |= WebInputEvent::MiddleButtonDown;
|
| - break;
|
| - case RightButton:
|
| - modifiers |= WebInputEvent::RightButtonDown;
|
| - break;
|
| - }
|
| - } else
|
| - button = WebMouseEvent::ButtonNone;
|
| - movementX = event.movementX();
|
| - movementY = event.movementY();
|
| - clickCount = event.detail();
|
| -}
|
| -
|
| -// Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a mouse
|
| -// with touch input for plugins that don't support touch input).
|
| -WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const RenderObject* renderObject, const TouchEvent& event)
|
| -{
|
| - if (!event.touches())
|
| - return;
|
| - if (event.touches()->length() != 1) {
|
| - if (event.touches()->length() || event.type() != EventTypeNames::touchend || !event.changedTouches() || event.changedTouches()->length() != 1)
|
| - return;
|
| - }
|
| -
|
| - const Touch* touch = event.touches()->length() == 1 ? event.touches()->item(0) : event.changedTouches()->item(0);
|
| - if (touch->identifier())
|
| - return;
|
| -
|
| - if (event.type() == EventTypeNames::touchstart)
|
| - type = MouseDown;
|
| - else if (event.type() == EventTypeNames::touchmove)
|
| - type = MouseMove;
|
| - else if (event.type() == EventTypeNames::touchend)
|
| - type = MouseUp;
|
| - else
|
| - return;
|
| -
|
| - timeStampSeconds = event.timeStamp() / millisPerSecond;
|
| - modifiers = getWebInputModifiers(event);
|
| -
|
| - // The mouse event co-ordinates should be generated from the co-ordinates of the touch point.
|
| - IntPoint windowPoint = roundedIntPoint(touch->absoluteLocation());
|
| - windowPoint = widget->convertToContainingView(windowPoint);
|
| - IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
|
| - globalX = screenPoint.x();
|
| - globalY = screenPoint.y();
|
| - windowX = windowPoint.x();
|
| - windowY = windowPoint.y();
|
| -
|
| - button = WebMouseEvent::ButtonLeft;
|
| - modifiers |= WebInputEvent::LeftButtonDown;
|
| - clickCount = (type == MouseDown || type == MouseUp);
|
| -
|
| - IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
|
| - x = localPoint.x();
|
| - y = localPoint.y();
|
| -}
|
| -
|
| -WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const PlatformMouseEvent& event)
|
| -{
|
| - switch (event.type()) {
|
| - case PlatformEvent::MouseMoved:
|
| - type = MouseMove;
|
| - break;
|
| - case PlatformEvent::MousePressed:
|
| - type = MouseDown;
|
| - break;
|
| - case PlatformEvent::MouseReleased:
|
| - type = MouseUp;
|
| - break;
|
| - default:
|
| - ASSERT_NOT_REACHED();
|
| - type = Undefined;
|
| - return;
|
| - }
|
| -
|
| - modifiers = 0;
|
| - if (event.modifiers() & PlatformEvent::ShiftKey)
|
| - modifiers |= ShiftKey;
|
| - if (event.modifiers() & PlatformEvent::CtrlKey)
|
| - modifiers |= ControlKey;
|
| - if (event.modifiers() & PlatformEvent::AltKey)
|
| - modifiers |= AltKey;
|
| - if (event.modifiers() & PlatformEvent::MetaKey)
|
| - modifiers |= MetaKey;
|
| -
|
| - timeStampSeconds = event.timestamp();
|
| -
|
| - IntPoint position = event.position();
|
| - float scale = widgetInputEventsScaleFactor(widget);
|
| - position.scale(scale, scale);
|
| - x = position.x();
|
| - y = position.y();
|
| - globalX = event.globalPosition().x();
|
| - globalY = event.globalPosition().y();
|
| - movementX = event.movementDelta().x() * scale;
|
| - movementY = event.movementDelta().y() * scale;
|
| -
|
| - button = static_cast<Button>(event.button());
|
| - clickCount = event.clickCount();
|
| -}
|
| -
|
| -WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const RenderObject* renderObject, const WheelEvent& event)
|
| -{
|
| - if (event.type() != EventTypeNames::wheel && event.type() != EventTypeNames::mousewheel)
|
| - return;
|
| - type = WebInputEvent::MouseWheel;
|
| - updateWebMouseEventFromCoreMouseEvent(event, *widget, *renderObject, *this);
|
| - deltaX = -event.deltaX();
|
| - deltaY = -event.deltaY();
|
| - wheelTicksX = event.ticksX();
|
| - wheelTicksY = event.ticksY();
|
| - scrollByPage = event.deltaMode() == WheelEvent::DOM_DELTA_PAGE;
|
| -}
|
| -
|
| WebKeyboardEventBuilder::WebKeyboardEventBuilder(const KeyboardEvent& event)
|
| {
|
| if (event.type() == EventTypeNames::keydown)
|
|
|