| Index: Source/WebKit/chromium/src/WebInputEventConversion.cpp
|
| ===================================================================
|
| --- Source/WebKit/chromium/src/WebInputEventConversion.cpp (revision 143772)
|
| +++ Source/WebKit/chromium/src/WebInputEventConversion.cpp (working copy)
|
| @@ -54,16 +54,29 @@
|
|
|
| static const double millisPerSecond = 1000.0;
|
|
|
| +static float widgetScaleFactor(const Widget* widget)
|
| +{
|
| + if (!widget)
|
| + return 1;
|
| +
|
| + ScrollView* rootView = widget->root();
|
| + if (!rootView)
|
| + return 1;
|
| +
|
| + return rootView->visibleContentScaleFactor();
|
| +}
|
| +
|
| // MakePlatformMouseEvent -----------------------------------------------------
|
|
|
| PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e)
|
| {
|
| + float scale = widgetScaleFactor(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->convertFromContainingWindow(IntPoint(e.x, e.y));
|
| + m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
|
| m_globalPosition = IntPoint(e.globalX, e.globalY);
|
| #if ENABLE(POINTER_LOCK)
|
| - m_movementDelta = IntPoint(e.movementX, e.movementY);
|
| + m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale);
|
| #endif
|
| m_button = static_cast<MouseButton>(e.button);
|
|
|
| @@ -104,7 +117,8 @@
|
|
|
| PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e)
|
| {
|
| - m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
|
| + float scale = widgetScaleFactor(widget);
|
| + m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
|
| m_globalPosition = IntPoint(e.globalX, e.globalY);
|
| m_deltaX = e.deltaX;
|
| m_deltaY = e.deltaY;
|
| @@ -141,6 +155,7 @@
|
| #if ENABLE(GESTURE_EVENTS)
|
| PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e)
|
| {
|
| + float scale = widgetScaleFactor(widget);
|
| switch (e.type) {
|
| case WebInputEvent::GestureScrollBegin:
|
| m_type = PlatformEvent::GestureScrollBegin;
|
| @@ -150,23 +165,23 @@
|
| break;
|
| case WebInputEvent::GestureScrollUpdate:
|
| m_type = PlatformEvent::GestureScrollUpdate;
|
| - m_deltaX = e.data.scrollUpdate.deltaX;
|
| - m_deltaY = e.data.scrollUpdate.deltaY;
|
| + m_deltaX = e.data.scrollUpdate.deltaX / scale;
|
| + m_deltaY = e.data.scrollUpdate.deltaY / scale;
|
| break;
|
| case WebInputEvent::GestureScrollUpdateWithoutPropagation:
|
| m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation;
|
| - m_deltaX = e.data.scrollUpdate.deltaX;
|
| - m_deltaY = e.data.scrollUpdate.deltaY;
|
| + m_deltaX = e.data.scrollUpdate.deltaX / scale;
|
| + m_deltaY = e.data.scrollUpdate.deltaY / scale;
|
| break;
|
| case WebInputEvent::GestureTap:
|
| m_type = PlatformEvent::GestureTap;
|
| - m_area = IntSize(e.data.tap.width, e.data.tap.height);
|
| + m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale));
|
| // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123
|
| m_deltaX = static_cast<int>(e.data.tap.tapCount);
|
| break;
|
| case WebInputEvent::GestureTapDown:
|
| m_type = PlatformEvent::GestureTapDown;
|
| - m_area = IntSize(e.data.tapDown.width, e.data.tapDown.height);
|
| + m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data.tapDown.height / scale));
|
| break;
|
| case WebInputEvent::GestureTapCancel:
|
| m_type = PlatformEvent::GestureTapDownCancel;
|
| @@ -176,15 +191,15 @@
|
| break;
|
| case WebInputEvent::GestureTwoFingerTap:
|
| m_type = PlatformEvent::GestureTwoFingerTap;
|
| - m_area = IntSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight);
|
| + m_area = expandedIntSize(FloatSize(e.data.twoFingerTap.firstFingerWidth / scale, e.data.twoFingerTap.firstFingerHeight / scale));
|
| break;
|
| case WebInputEvent::GestureLongPress:
|
| m_type = PlatformEvent::GestureLongPress;
|
| - m_area = IntSize(e.data.longPress.width, e.data.longPress.height);
|
| + m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
|
| break;
|
| case WebInputEvent::GestureLongTap:
|
| m_type = PlatformEvent::GestureLongTap;
|
| - m_area = IntSize(e.data.longPress.width, e.data.longPress.height);
|
| + m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale));
|
| break;
|
| case WebInputEvent::GesturePinchBegin:
|
| m_type = PlatformEvent::GesturePinchBegin;
|
| @@ -200,7 +215,7 @@
|
| default:
|
| ASSERT_NOT_REACHED();
|
| }
|
| - m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
|
| + m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale));
|
| m_globalPosition = IntPoint(e.globalX, e.globalY);
|
| m_timestamp = e.timeStampSeconds;
|
|
|
| @@ -362,12 +377,13 @@
|
|
|
| PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point)
|
| {
|
| + float scale = widgetScaleFactor(widget);
|
| m_id = point.id;
|
| m_state = toPlatformTouchPointState(point.state);
|
| - m_pos = widget->convertFromContainingWindow(point.position);
|
| + m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scale, point.position.y / scale));
|
| m_screenPos = point.screenPosition;
|
| - m_radiusY = point.radiusY;
|
| - m_radiusX = point.radiusX;
|
| + m_radiusY = point.radiusY / scale;
|
| + m_radiusX = point.radiusX / scale;
|
| m_rotationAngle = point.rotationAngle;
|
| m_force = point.force;
|
| }
|
| @@ -414,18 +430,19 @@
|
|
|
| static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEvent& webEvent)
|
| {
|
| + float scale = widgetScaleFactor(&widget);
|
| webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond;
|
| webEvent.modifiers = getWebInputModifiers(event);
|
|
|
| - ScrollView* view = widget.parent();
|
| + ScrollView* view = widget.root();
|
| IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y()));
|
| webEvent.globalX = event.screenX();
|
| webEvent.globalY = event.screenY();
|
| - webEvent.windowX = windowPoint.x();
|
| - webEvent.windowY = windowPoint.y();
|
| + webEvent.windowX = windowPoint.x() * scale;
|
| + webEvent.windowY = windowPoint.y() * scale;
|
| IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), renderObject);
|
| - webEvent.x = localPoint.x();
|
| - webEvent.y = localPoint.y();
|
| + webEvent.x = localPoint.x() * scale;
|
| + webEvent.y = localPoint.y() * scale;
|
| }
|
|
|
| WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const MouseEvent& event)
|
| @@ -472,14 +489,16 @@
|
| }
|
| }
|
| #if ENABLE(POINTER_LOCK)
|
| - movementX = event.webkitMovementX();
|
| - movementY = event.webkitMovementY();
|
| + float scale = widgetScaleFactor(widget);
|
| + movementX = event.webkitMovementX() * scale;
|
| + movementY = event.webkitMovementY() * scale;
|
| #endif
|
| clickCount = event.detail();
|
| }
|
|
|
| WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event)
|
| {
|
| + float scale = widgetScaleFactor(widget);
|
| if (!event.touches())
|
| return;
|
| if (event.touches()->length() != 1) {
|
| @@ -507,8 +526,8 @@
|
| clickCount = (type == MouseDown || type == MouseUp);
|
|
|
| IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
|
| - x = localPoint.x();
|
| - y = localPoint.y();
|
| + x = localPoint.x() * scale;
|
| + y = localPoint.y() * scale;
|
| }
|
|
|
| WebMouseWheelEventBuilder::WebMouseWheelEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const WheelEvent& event)
|
| @@ -562,8 +581,9 @@
|
|
|
| #if ENABLE(TOUCH_EVENTS)
|
|
|
| -static void addTouchPoints(const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject)
|
| +static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject)
|
| {
|
| + float scale = widgetScaleFactor(widget);
|
| unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap));
|
| for (unsigned i = 0; i < numberOfTouches; ++i) {
|
| const Touch* touch = touches->item(i);
|
| @@ -572,8 +592,10 @@
|
| point.id = touch->identifier();
|
| point.screenPosition = WebPoint(touch->screenX(), touch->screenY());
|
| point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject);
|
| - point.radiusX = touch->webkitRadiusX();
|
| - point.radiusY = touch->webkitRadiusY();
|
| + point.position.x *= scale;
|
| + point.position.y *= scale;
|
| + point.radiusX = touch->webkitRadiusX() * scale;
|
| + point.radiusY = touch->webkitRadiusY() * scale;
|
| point.rotationAngle = touch->webkitRotationAngle();
|
| point.force = touch->webkitForce();
|
| point.state = toWebTouchPointState(touchType);
|
| @@ -602,9 +624,9 @@
|
| modifiers = getWebInputModifiers(event);
|
| timeStampSeconds = event.timeStamp() / millisPerSecond;
|
|
|
| - addTouchPoints(event.type(), event.touches(), touches, &touchesLength, renderObject);
|
| - addTouchPoints(event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
|
| - addTouchPoints(event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
|
| + addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject);
|
| + addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);
|
| + addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);
|
| }
|
|
|
| #endif // ENABLE(TOUCH_EVENTS)
|
| @@ -612,6 +634,7 @@
|
| #if ENABLE(GESTURE_EVENTS)
|
| WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event)
|
| {
|
| + float scale = widgetScaleFactor(widget);
|
| if (event.type() == eventNames().gesturetapEvent)
|
| type = GestureTap;
|
| else if (event.type() == eventNames().gesturetapdownEvent)
|
| @@ -622,8 +645,8 @@
|
| type = GestureScrollEnd;
|
| else if (event.type() == eventNames().gesturescrollupdateEvent) {
|
| type = GestureScrollUpdate;
|
| - data.scrollUpdate.deltaX = event.deltaX();
|
| - data.scrollUpdate.deltaY = event.deltaY();
|
| + data.scrollUpdate.deltaX = event.deltaX() * scale;
|
| + data.scrollUpdate.deltaY = event.deltaY() * scale;
|
| }
|
|
|
| timeStampSeconds = event.timeStamp() / millisPerSecond;
|
| @@ -632,8 +655,8 @@
|
| globalX = event.screenX();
|
| globalY = event.screenY();
|
| IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), *renderObject);
|
| - x = localPoint.x();
|
| - y = localPoint.y();
|
| + x = localPoint.x() * scale;
|
| + y = localPoint.y() * scale;
|
| }
|
| #endif // ENABLE(GESTURE_EVENTS)
|
|
|
|
|