Title: [143774] branches/chromium/1410/Source/WebKit/chromium
Revision
143774
Author
ael...@chromium.org
Date
2013-02-22 12:31:26 -0800 (Fri, 22 Feb 2013)

Log Message

Merge 142571
> [chromium] Apply page scale to all WebInputEvent types
> https://bugs.webkit.org/show_bug.cgi?id=109370
> 
> Reviewed by James Robinson.
> 
> Previously we only adjusted a few common input event types by page
> scale, but in fact almost every position and size in WebInputEvents
> requires it.
> 
> I also took the opportunity to change some WebGestureEvent members to
> floats (which I checked causes no warnings in Chromium-side code with
> GCC or Clang).
> 
> New WebInputEventConversionTest: InputEventsScaling
> 
> * public/WebInputEvent.h:
> (WebKit::WebGestureEvent::WebGestureEvent):
> * src/WebInputEventConversion.cpp:
> (WebKit::widgetScaleFactor):
> (WebKit):
> (WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
> (WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
> (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
> (WebKit::PlatformTouchPointBuilder::PlatformTouchPointBuilder):
> (WebKit::updateWebMouseEventFromWebCoreMouseEvent):
> (WebKit::WebMouseEventBuilder::WebMouseEventBuilder):
> (WebKit::addTouchPoints):
> (WebKit::WebTouchEventBuilder::WebTouchEventBuilder):
> (WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
> * src/WebViewImpl.cpp:
> (WebKit::WebViewImpl::handleGestureEvent):
> (WebKit::WebViewImpl::hasTouchEventHandlersAt):
> (WebKit::WebViewImpl::handleInputEvent):
> * tests/WebInputEventConversionTest.cpp:
> (WebCore::TEST):
> (WebCore):
> 

TBR=ael...@chromium.org
Review URL: https://codereview.chromium.org/12319074

Modified Paths

Diff

Modified: branches/chromium/1410/Source/WebKit/chromium/ChangeLog (143773 => 143774)


--- branches/chromium/1410/Source/WebKit/chromium/ChangeLog	2013-02-22 20:30:58 UTC (rev 143773)
+++ branches/chromium/1410/Source/WebKit/chromium/ChangeLog	2013-02-22 20:31:26 UTC (rev 143774)
@@ -1,3 +1,192 @@
+2013-02-11  Alexandre Elias  <ael...@chromium.org>
+
+        [chromium] Apply page scale to all WebInputEvent types
+        https://bugs.webkit.org/show_bug.cgi?id=109370
+
+        Reviewed by James Robinson.
+
+        Previously we only adjusted a few common input event types by page
+        scale, but in fact almost every position and size in WebInputEvents
+        requires it.
+
+        I also took the opportunity to change some WebGestureEvent members to
+        floats (which I checked causes no warnings in Chromium-side code with
+        GCC or Clang).
+
+        New WebInputEventConversionTest: InputEventsScaling
+
+        * public/WebInputEvent.h:
+        (WebKit::WebGestureEvent::WebGestureEvent):
+        * src/WebInputEventConversion.cpp:
+        (WebKit::widgetScaleFactor):
+        (WebKit):
+        (WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder):
+        (WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder):
+        (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
+        (WebKit::PlatformTouchPointBuilder::PlatformTouchPointBuilder):
+        (WebKit::updateWebMouseEventFromWebCoreMouseEvent):
+        (WebKit::WebMouseEventBuilder::WebMouseEventBuilder):
+        (WebKit::addTouchPoints):
+        (WebKit::WebTouchEventBuilder::WebTouchEventBuilder):
+        (WebKit::WebGestureEventBuilder::WebGestureEventBuilder):
+        * src/WebViewImpl.cpp:
+        (WebKit::WebViewImpl::handleGestureEvent):
+        (WebKit::WebViewImpl::hasTouchEventHandlersAt):
+        (WebKit::WebViewImpl::handleInputEvent):
+        * tests/WebInputEventConversionTest.cpp:
+        (WebCore::TEST):
+        (WebCore):
+
+2013-02-11  Sheriff Bot  <webkit.review....@gmail.com>
+
+        Unreviewed, rolling out r142568.
+        http://trac.webkit.org/changeset/142568
+        https://bugs.webkit.org/show_bug.cgi?id=109541
+
+        Broke the build, won't compile. (Requested by alancutter on
+        #webkit).
+
+        * tests/GraphicsLayerChromiumTest.cpp:
+        (WebKit::GraphicsLayerChromiumTest::GraphicsLayerChromiumTest):
+        * tests/ScrollingCoordinatorChromiumTest.cpp:
+        (WebKit::FakeWebViewClient::initializeLayerTreeView):
+
+2013-02-11  James Robinson  <jam...@chromium.org>
+
+        [chromium] Add WebUnitTestSupport::createLayerTreeViewForTesting for webkit_unit_tests
+        https://bugs.webkit.org/show_bug.cgi?id=109403
+
+        Reviewed by Adam Barth.
+
+        * tests/GraphicsLayerChromiumTest.cpp:
+        (WebKit::GraphicsLayerChromiumTest::GraphicsLayerChromiumTest):
+        * tests/ScrollingCoordinatorChromiumTest.cpp:
+        (WebKit::FakeWebViewClient::initializeLayerTreeView):
+
+2013-02-11  Sheriff Bot  <webkit.review....@gmail.com>
+
+        Unreviewed.  Rolled Chromium DEPS to r181817.  Requested by
+        "James Robinson" <jam...@chromium.org> via sheriffbot.
+
+        * DEPS:
+
+2013-02-11  David Grogan  <dgro...@chromium.org>
+
+        IndexedDB: Add UnknownError to WebIDBDatabaseException
+        https://bugs.webkit.org/show_bug.cgi?id=109519
+
+        Reviewed by Adam Barth.
+
+        * public/WebIDBDatabaseException.h:
+        * src/AssertMatchingEnums.cpp:
+
+2013-02-11  Sheriff Bot  <webkit.review....@gmail.com>
+
+        Unreviewed.  Rolled Chromium DEPS to r181787.  Requested by
+        thakis_ via sheriffbot.
+
+        * DEPS:
+
+2013-02-11  Nico Weber  <tha...@chromium.org>
+
+        Remove web intents code
+        https://bugs.webkit.org/show_bug.cgi?id=109501
+
+        Reviewed by Eric Seidel.
+
+        See thread "Removing ENABLE(WEB_INTENTS) code" on webkit-dev.
+
+        * WebKit.gyp:
+        * features.gypi:
+        * public/WebDeliveredIntentClient.h: Removed.
+        * public/WebFrame.h:
+        (WebKit):
+        (WebFrame):
+        * public/WebFrameClient.h:
+        (WebKit):
+        * public/WebIntent.h: Removed.
+        * public/WebIntentRequest.h: Removed.
+        * public/WebIntentServiceInfo.h: Removed.
+        * public/WebRuntimeFeatures.h:
+        (WebRuntimeFeatures):
+        * src/DeliveredIntentClientImpl.cpp: Removed.
+        * src/DeliveredIntentClientImpl.h: Removed.
+        * src/FrameLoaderClientImpl.cpp:
+        * src/FrameLoaderClientImpl.h:
+        (FrameLoaderClientImpl):
+        * src/WebFrameImpl.cpp:
+        * src/WebFrameImpl.h:
+        (WebKit):
+        (WebFrameImpl):
+        * src/WebIntent.cpp: Removed.
+        * src/WebIntentRequest.cpp: Removed.
+        * src/WebIntentServiceInfo.cpp: Removed.
+        * src/WebRuntimeFeatures.cpp:
+
+2013-02-11  Florin Malita  <fmal...@chromium.org>
+
+        Unreviewed.  Rolled Chromium DEPS to r181770.
+
+        * DEPS:
+
+2013-02-11  Sheriff Bot  <webkit.review....@gmail.com>
+
+        Unreviewed.  Rolled Chromium DEPS to r181742.  Requested by
+        fmalita_ via sheriffbot.
+
+        * DEPS:
+
+2013-02-11  Rouslan Solomakhin  <rous...@chromium.org>
+
+        [Chromium] Replace correct misspelled range in WebKit::WebFrameImpl::replaceMisspelledRange
+        https://bugs.webkit.org/show_bug.cgi?id=108513
+
+        Reviewed by Tony Chang.
+
+        WebKit::WebFrameImpl::replaceMisspelledRange is going to be used by Chromium instead of
+        WebKit::WebFrameImpl::replaceSelection for correcting misspellings. The current implementation
+        of WebKit::WebFrameImpl::replaceMisspelledRange sometimes replaces the wrong range. This change
+        uses Range::create instead of TextIterator::rangeFromLocationAndLength to select the correct
+        range. This change also disables smart replace in WebKit::WebFrameImpl::replaceMisspelledRange
+        to avoid introducing spaces around misspellings.
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::replaceMisspelledRange): Replace correct misspelled range.
+        * tests/WebFrameTest.cpp: Add unit test for WebKit::WebFrameImpl::replaceMisspelledRange method.
+
+2013-02-11  Alexei Filippov  <a...@chromium.org>
+
+        Web Inspector: Split Profiler domain in protocol into Profiler and HeapProfiler
+        https://bugs.webkit.org/show_bug.cgi?id=108653
+
+        Reviewed by Yury Semikhatsky.
+
+        Currently CPU and heap profilers share the same domain 'Profiler' in the protocol.
+        In fact these two profile types have not too much in common. So put each into its own domain.
+        It should also help when Profiles panel gets split into several tools.
+        This is the phase 1 which adds InspectorHeapProfilerAgent but doesn't
+        change the original InspectorProfilerAgent.
+
+        * src/WebDevToolsAgentImpl.cpp:
+        (WebKit::WebDevToolsAgent::shouldInterruptForMessage):
+
+2013-02-11  Abhishek Arya  <infe...@chromium.org>
+
+        Add ASSERT_WITH_SECURITY_IMPLICATION to detect out of bounds access
+        https://bugs.webkit.org/show_bug.cgi?id=108981
+
+        Reviewed by Eric Seidel.
+
+        * src/AutofillPopupMenuClient.cpp:
+        (WebKit::AutofillPopupMenuClient::getSuggestion):
+        (WebKit::AutofillPopupMenuClient::getLabel):
+        (WebKit::AutofillPopupMenuClient::getIcon):
+        (WebKit::AutofillPopupMenuClient::removeSuggestionAtIndex):
+        (WebKit::AutofillPopupMenuClient::valueChanged):
+        (WebKit::AutofillPopupMenuClient::selectionChanged):
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::shouldRunModalDialogDuringPageDismissal):
+
 2013-02-10  James Robinson  <jam...@chromium.org>
 
         [chromium] Enable more of webkit_unit_tests in component builds

Modified: branches/chromium/1410/Source/WebKit/chromium/public/WebInputEvent.h (143773 => 143774)


--- branches/chromium/1410/Source/WebKit/chromium/public/WebInputEvent.h	2013-02-22 20:30:58 UTC (rev 143773)
+++ branches/chromium/1410/Source/WebKit/chromium/public/WebInputEvent.h	2013-02-22 20:31:26 UTC (rev 143774)
@@ -407,23 +407,23 @@
     union {
         struct {
             int tapCount;
-            int width;
-            int height;
+            float width;
+            float height;
         } tap;
 
         struct {
-            int width;
-            int height;
+            float width;
+            float height;
         } tapDown;
 
         struct {
-            int width;
-            int height;
+            float width;
+            float height;
         } longPress;
 
         struct {
-            int firstFingerWidth;
-            int firstFingerHeight;
+            float firstFingerWidth;
+            float firstFingerHeight;
         } twoFingerTap;
 
         struct {
@@ -443,7 +443,7 @@
         struct {
             float scale;
         } pinchUpdate;
-    } data; 
+    } data;
 
     WebGestureEvent(unsigned sizeParam = sizeof(WebGestureEvent))
         : WebInputEvent(sizeParam)
@@ -452,7 +452,7 @@
         , globalX(0)
         , globalY(0)
     {
-      memset(&data, 0, sizeof(data)); 
+        memset(&data, 0, sizeof(data));
     }
 };
 

Modified: branches/chromium/1410/Source/WebKit/chromium/src/WebInputEventConversion.cpp (143773 => 143774)


--- branches/chromium/1410/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2013-02-22 20:30:58 UTC (rev 143773)
+++ branches/chromium/1410/Source/WebKit/chromium/src/WebInputEventConversion.cpp	2013-02-22 20:31:26 UTC (rev 143774)
@@ -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)
 

Modified: branches/chromium/1410/Source/WebKit/chromium/src/WebViewImpl.cpp (143773 => 143774)


--- branches/chromium/1410/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-02-22 20:30:58 UTC (rev 143773)
+++ branches/chromium/1410/Source/WebKit/chromium/src/WebViewImpl.cpp	2013-02-22 20:31:26 UTC (rev 143774)
@@ -755,12 +755,19 @@
         // Don't trigger a disambiguation popup on sites designed for mobile devices.
         // Instead, assume that the page has been designed with big enough buttons and links.
         if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) {
-            IntRect boundingBox(event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, event.data.tap.width, event.data.tap.height);
+            // FIXME: didTapMultipleTargets should just take a rect instead of
+            // an event.
+            WebGestureEvent scaledEvent;
+            scaledEvent.x = event.x / pageScaleFactor();
+            scaledEvent.y = event.y / pageScaleFactor();
+            scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor();
+            scaledEvent.data.tap.height = event.data.tap.height / pageScaleFactor();
+            IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, scaledEvent.data.tap.height);
             Vector<IntRect> goodTargets;
             findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets);
             // FIXME: replace touch adjustment code when numberOfGoodTargets == 1?
             // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101
-            if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(event, goodTargets)) {
+            if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(scaledEvent, goodTargets)) {
                 eventSwallowed = true;
                 eventCancelled = true;
                 break;
@@ -1354,6 +1361,7 @@
 
 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point)
 {
+    // FIXME: Implement this. Note that the point must be divided by pageScaleFactor.
     return true;
 }
 
@@ -2083,26 +2091,7 @@
         return true;
     }
 
-    const WebInputEvent* inputEventTransformed = &inputEvent;
-    if (m_page->settings()->applyPageScaleFactorInCompositor()) {
-        WebMouseEvent mouseEvent;
-        WebGestureEvent gestureEvent;
-        if (WebInputEvent::isMouseEventType(inputEvent.type)) {
-            mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
-            mouseEvent.x = mouseEvent.x / pageScaleFactor();
-            mouseEvent.y = mouseEvent.y / pageScaleFactor();
-            inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent);
-        } else if (WebInputEvent::isGestureEventType(inputEvent.type)) {
-            gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent);
-            gestureEvent.x = gestureEvent.x / pageScaleFactor();
-            gestureEvent.y = gestureEvent.y / pageScaleFactor();
-            gestureEvent.data.tap.width /= pageScaleFactor();
-            gestureEvent.data.tap.height /= pageScaleFactor();
-            inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent);
-        }
-    }
-
-    return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed);
+    return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
 }
 
 void WebViewImpl::mouseCaptureLost()

Modified: branches/chromium/1410/Source/WebKit/chromium/tests/WebInputEventConversionTest.cpp (143773 => 143774)


--- branches/chromium/1410/Source/WebKit/chromium/tests/WebInputEventConversionTest.cpp	2013-02-22 20:30:58 UTC (rev 143773)
+++ branches/chromium/1410/Source/WebKit/chromium/tests/WebInputEventConversionTest.cpp	2013-02-22 20:31:26 UTC (rev 143774)
@@ -32,14 +32,23 @@
 
 #include "WebInputEventConversion.h"
 
+#include "Frame.h"
+#include "FrameTestHelpers.h"
+#include "FrameView.h"
+#include "GestureEvent.h"
 #include "KeyboardEvent.h"
+#include "MouseEvent.h"
+#include "Touch.h"
 #include "TouchEvent.h"
+#include "TouchList.h"
+#include "URLTestHelpers.h"
+#include "WebFrame.h"
+#include "WebSettings.h"
+#include "WebViewImpl.h"
 #include <gtest/gtest.h>
 
-using WebKit::WebInputEvent;
-using WebKit::WebKeyboardEvent;
-using WebKit::WebKeyboardEventBuilder;
-using WebKit::WebMouseEventBuilder;
+using namespace WebKit;
+using namespace WebCore;
 
 namespace {
 
@@ -81,4 +90,177 @@
     EXPECT_EQ(WebInputEvent::Undefined, mouse.type);
 }
 
+TEST(WebInputEventConversionTest, InputEventsScaling)
+{
+    const std::string baseURL("http://www.test.com/");
+    const std::string fileName("fixed_layout.html");
+
+    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html"));
+    WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true));
+    webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true);
+    webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true);
+    webViewImpl->enableFixedLayoutMode(true);
+    webViewImpl->settings()->setViewportEnabled(true);
+    int pageWidth = 640;
+    int pageHeight = 480;
+    webViewImpl->resize(WebSize(pageWidth, pageHeight));
+    webViewImpl->layout();
+
+    webViewImpl->setPageScaleFactor(2, WebPoint());
+
+    FrameView* view = webViewImpl->page()->mainFrame()->view();
+    RefPtr<Document> document = webViewImpl->page()->mainFrame()->document();
+    DOMWindow* domWindow = webViewImpl->page()->mainFrame()->document()->defaultView();
+    RenderObject* docRenderer = webViewImpl->page()->mainFrame()->document()->renderer();
+
+    {
+        WebMouseEvent webMouseEvent;
+        webMouseEvent.type = WebInputEvent::MouseMove;
+        webMouseEvent.x = 10;
+        webMouseEvent.y = 10;
+        webMouseEvent.windowX = 10;
+        webMouseEvent.windowY = 10;
+        webMouseEvent.globalX = 10;
+        webMouseEvent.globalY = 10;
+        webMouseEvent.movementX = 10;
+        webMouseEvent.movementY = 10;
+
+        PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent);
+        EXPECT_EQ(5, platformMouseBuilder.position().x());
+        EXPECT_EQ(5, platformMouseBuilder.position().y());
+        EXPECT_EQ(10, platformMouseBuilder.globalPosition().x());
+        EXPECT_EQ(10, platformMouseBuilder.globalPosition().y());
+        EXPECT_EQ(5, platformMouseBuilder.movementDelta().x());
+        EXPECT_EQ(5, platformMouseBuilder.movementDelta().y());
+    }
+
+    {
+        WebGestureEvent webGestureEvent;
+        webGestureEvent.type = WebInputEvent::GestureScrollUpdate;
+        webGestureEvent.x = 10;
+        webGestureEvent.y = 10;
+        webGestureEvent.globalX = 10;
+        webGestureEvent.globalY = 10;
+        webGestureEvent.data.scrollUpdate.deltaX = 10;
+        webGestureEvent.data.scrollUpdate.deltaY = 10;
+
+        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
+        EXPECT_EQ(5, platformGestureBuilder.position().x());
+        EXPECT_EQ(5, platformGestureBuilder.position().y());
+        EXPECT_EQ(10, platformGestureBuilder.globalPosition().x());
+        EXPECT_EQ(10, platformGestureBuilder.globalPosition().y());
+        EXPECT_EQ(5, platformGestureBuilder.deltaX());
+        EXPECT_EQ(5, platformGestureBuilder.deltaY());
+    }
+
+    {
+        WebGestureEvent webGestureEvent;
+        webGestureEvent.type = WebInputEvent::GestureTap;
+        webGestureEvent.data.tap.width = 10;
+        webGestureEvent.data.tap.height = 10;
+
+        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
+        EXPECT_EQ(5, platformGestureBuilder.area().width());
+        EXPECT_EQ(5, platformGestureBuilder.area().height());
+    }
+
+    {
+        WebGestureEvent webGestureEvent;
+        webGestureEvent.type = WebInputEvent::GestureTapDown;
+        webGestureEvent.data.tapDown.width = 10;
+        webGestureEvent.data.tapDown.height = 10;
+
+        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
+        EXPECT_EQ(5, platformGestureBuilder.area().width());
+        EXPECT_EQ(5, platformGestureBuilder.area().height());
+    }
+
+    {
+        WebGestureEvent webGestureEvent;
+        webGestureEvent.type = WebInputEvent::GestureLongPress;
+        webGestureEvent.data.longPress.width = 10;
+        webGestureEvent.data.longPress.height = 10;
+
+        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
+        EXPECT_EQ(5, platformGestureBuilder.area().width());
+        EXPECT_EQ(5, platformGestureBuilder.area().height());
+    }
+
+    {
+        WebGestureEvent webGestureEvent;
+        webGestureEvent.type = WebInputEvent::GestureTwoFingerTap;
+        webGestureEvent.data.twoFingerTap.firstFingerWidth = 10;
+        webGestureEvent.data.twoFingerTap.firstFingerHeight = 10;
+
+        PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent);
+        EXPECT_EQ(5, platformGestureBuilder.area().width());
+        EXPECT_EQ(5, platformGestureBuilder.area().height());
+    }
+
+    {
+        WebTouchEvent webTouchEvent;
+        webTouchEvent.type = WebInputEvent::TouchMove;
+        webTouchEvent.touchesLength = 1;
+        webTouchEvent.touches[0].state = WebTouchPoint::StateMoved;
+        webTouchEvent.touches[0].screenPosition.x = 10;
+        webTouchEvent.touches[0].screenPosition.y = 10;
+        webTouchEvent.touches[0].position.x = 10;
+        webTouchEvent.touches[0].position.y = 10;
+        webTouchEvent.touches[0].radiusX = 10;
+        webTouchEvent.touches[0].radiusY = 10;
+
+        PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent);
+        EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().x());
+        EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().y());
+        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().x());
+        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().y());
+        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusX());
+        EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusY());
+    }
+
+    {
+        PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0);
+        RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::eventNames().mousemoveEvent, domWindow, platformMouseEvent, 0, document);
+        WebMouseEventBuilder webMouseBuilder(view, docRenderer, *mouseEvent);
+
+        EXPECT_EQ(20, webMouseBuilder.x);
+        EXPECT_EQ(20, webMouseBuilder.y);
+        EXPECT_EQ(10, webMouseBuilder.globalX);
+        EXPECT_EQ(10, webMouseBuilder.globalY);
+        EXPECT_EQ(20, webMouseBuilder.windowX);
+        EXPECT_EQ(20, webMouseBuilder.windowY);
+    }
+
+    {
+        PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUpdate, IntPoint(10, 10), IntPoint(10, 10), 0, IntSize(10, 10), FloatPoint(10, 10), false, false, false, false);
+        RefPtr<GestureEvent> gestureEvent = GestureEvent::create(domWindow, platformGestureEvent);
+        WebGestureEventBuilder webGestureBuilder(view, docRenderer, *gestureEvent);
+
+        EXPECT_EQ(20, webGestureBuilder.x);
+        EXPECT_EQ(20, webGestureBuilder.y);
+        EXPECT_EQ(10, webGestureBuilder.globalX);
+        EXPECT_EQ(10, webGestureBuilder.globalY);
+        EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaX);
+        EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaY);
+    }
+
+    {
+        RefPtr<Touch> touch = Touch::create(webViewImpl->page()->mainFrame(), document.get(), 0, 10, 10, 10, 10, 10, 10, 0, 0);
+        RefPtr<TouchList> touchList = TouchList::create();
+        touchList->append(touch);
+        RefPtr<TouchEvent> touchEvent = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), WebCore::eventNames().touchmoveEvent, domWindow, 10, 10, 10, 10, false, false, false, false);
+
+        WebTouchEventBuilder webTouchBuilder(view, docRenderer, *touchEvent);
+        ASSERT_EQ(1u, webTouchBuilder.touchesLength);
+        EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x);
+        EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.y);
+        EXPECT_EQ(20, webTouchBuilder.touches[0].position.x);
+        EXPECT_EQ(20, webTouchBuilder.touches[0].position.y);
+        EXPECT_EQ(20, webTouchBuilder.touches[0].radiusX);
+        EXPECT_EQ(20, webTouchBuilder.touches[0].radiusY);
+    }
+
+    webViewImpl->close();
+}
+
 } // anonymous namespace
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to