Title: [102540] trunk
Revision
102540
Author
kl...@webkit.org
Date
2011-12-11 11:38:49 -0800 (Sun, 11 Dec 2011)

Log Message

WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.
<http://webkit.org/b/74209> and <rdar://problem/10438197>

Reviewed by Anders Carlsson.

Source/WebCore: 

* WebCore.exp.in: Export AffineTransform::scale(double).

Source/WebKit2: 

* Shared/WebEvent.h:
* Shared/WebMouseEvent.cpp:

    Remove the WebMouseEvent "copy" constructor that applied a scale factor
    to the coordinates of an existing event.

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::handleEvent):

    Pass the WebMouseEvent through to the plugin unmodified.

(WebKit::PluginView::viewGeometryDidChange):

    Plumb a complex translate+scale transform through to the plugin, so coordinate
    space transformations in will behave correctly with scale factors other than 1.

LayoutTests: 

Add a test verifying that NetscapePlugins receive correctly transformed
mouse events with a page scale factor applied.

* platform/mac-wk2/plugins/mouse-events-scaled-expected.txt: Added.
* platform/mac-wk2/plugins/mouse-events-scaled.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102539 => 102540)


--- trunk/LayoutTests/ChangeLog	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/LayoutTests/ChangeLog	2011-12-11 19:38:49 UTC (rev 102540)
@@ -1,3 +1,16 @@
+2011-12-11  Andreas Kling  <kl...@webkit.org>
+
+        WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.
+        <http://webkit.org/b/74209> and <rdar://problem/10438197>
+
+        Reviewed by Anders Carlsson.
+
+        Add a test verifying that NetscapePlugins receive correctly transformed
+        mouse events with a page scale factor applied.
+
+        * platform/mac-wk2/plugins/mouse-events-scaled-expected.txt: Added.
+        * platform/mac-wk2/plugins/mouse-events-scaled.html: Added.
+
 2011-12-11  Dan Bernstein  <m...@apple.com>
 
         Test and updated results for <rdar://problem/10561285> REGRESSION (r80438): First word on a line or after collapsed space may not be hyphenated even though it should

Added: trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled-expected.txt (0 => 102540)


--- trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled-expected.txt	2011-12-11 19:38:49 UTC (rev 102540)
@@ -0,0 +1,7 @@
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (300, 300)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseUp at (300, 300)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (200, 200)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseUp at (200, 200)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseDown at (133, 133)
+CONSOLE MESSAGE: line 0: PLUGIN: mouseUp at (133, 133)
+

Added: trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled.html (0 => 102540)


--- trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/plugins/mouse-events-scaled.html	2011-12-11 19:38:49 UTC (rev 102540)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body>
+<embed style="position: absolute; left: 0; top: 0;" name="plg" type="application/x-webkit-test-netscape" windowedPlugin="false" width="1000" height="1000"></embed>
+<script>
+function fakeClick(x, y) {
+    eventSender.mouseMoveTo(300, 300);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+if (!window.layoutTestController)
+    document.write("This test does not work in manual mode.");
+else {
+    layoutTestController.dumpAsText();
+    
+    plg.windowedPlugin = false;
+    plg.eventLoggingEnabled = true;
+
+    eventSender.scalePageBy(1, 100, 100);
+    fakeClick(300, 300);
+    eventSender.scalePageBy(2, 100, 100);
+    fakeClick(300, 300);
+    eventSender.scalePageBy(3, 100, 100);
+    fakeClick(300, 300);
+
+    plg.eventLoggingEnabled = false;
+}
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (102539 => 102540)


--- trunk/Source/WebCore/ChangeLog	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebCore/ChangeLog	2011-12-11 19:38:49 UTC (rev 102540)
@@ -1,3 +1,12 @@
+2011-12-11  Andreas Kling  <kl...@webkit.org>
+
+        WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.
+        <http://webkit.org/b/74209> and <rdar://problem/10438197>
+
+        Reviewed by Anders Carlsson.
+
+        * WebCore.exp.in: Export AffineTransform::scale(double).
+
 2011-12-10  Andreas Kling  <kl...@webkit.org>
 
         Remove OS(SYMBIAN) block from Settings constructor.

Modified: trunk/Source/WebCore/WebCore.exp.in (102539 => 102540)


--- trunk/Source/WebCore/WebCore.exp.in	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-12-11 19:38:49 UTC (rev 102540)
@@ -407,6 +407,7 @@
 __ZN7WebCore14StorageTracker32syncFileSystemAndTrackerDatabaseEv
 __ZN7WebCore14endOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
 __ZN7WebCore15AffineTransform5flipYEv
+__ZN7WebCore15AffineTransform5scaleEd
 __ZN7WebCore15AffineTransform8multiplyERKS0_
 __ZN7WebCore15AffineTransform9translateEdd
 __ZN7WebCore15AffineTransformC1Edddddd

Modified: trunk/Source/WebKit2/ChangeLog (102539 => 102540)


--- trunk/Source/WebKit2/ChangeLog	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-11 19:38:49 UTC (rev 102540)
@@ -1,3 +1,26 @@
+2011-12-11  Andreas Kling  <kl...@webkit.org>
+
+        WK2/NetscapePlugin: Incorrect mouse event coordinates when frameScaleFactor != 1.
+        <http://webkit.org/b/74209> and <rdar://problem/10438197>
+
+        Reviewed by Anders Carlsson.
+
+        * Shared/WebEvent.h:
+        * Shared/WebMouseEvent.cpp:
+
+            Remove the WebMouseEvent "copy" constructor that applied a scale factor
+            to the coordinates of an existing event.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::handleEvent):
+
+            Pass the WebMouseEvent through to the plugin unmodified.
+
+        (WebKit::PluginView::viewGeometryDidChange):
+
+            Plumb a complex translate+scale transform through to the plugin, so coordinate
+            space transformations in will behave correctly with scale factors other than 1.
+
 2011-12-10  Sam Weinig  <s...@webkit.org>
 
         Try to fix the windows build.

Modified: trunk/Source/WebKit2/Shared/WebEvent.h (102539 => 102540)


--- trunk/Source/WebKit2/Shared/WebEvent.h	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebKit2/Shared/WebEvent.h	2011-12-11 19:38:49 UTC (rev 102540)
@@ -125,8 +125,6 @@
 #if PLATFORM(WIN)
     WebMouseEvent(Type, Button, const WebCore::IntPoint& position, const WebCore::IntPoint& globalPosition, float deltaX, float deltaY, float deltaZ, int clickCount, Modifiers, double timestamp, bool didActivateWebView);
 #endif
-    
-    WebMouseEvent(const WebMouseEvent&, float pageScaleFactor);
 
     Button button() const { return static_cast<Button>(m_button); }
     const WebCore::IntPoint& position() const { return m_position; }

Modified: trunk/Source/WebKit2/Shared/WebMouseEvent.cpp (102539 => 102540)


--- trunk/Source/WebKit2/Shared/WebMouseEvent.cpp	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebKit2/Shared/WebMouseEvent.cpp	2011-12-11 19:38:49 UTC (rev 102540)
@@ -78,21 +78,6 @@
 }
 #endif
 
-WebMouseEvent::WebMouseEvent(const WebMouseEvent& event, float pageScaleFactor)
-    : WebEvent(event.type(), event.modifiers(), event.timestamp())
-    , m_button(event.button())
-    , m_position(WebCore::IntPoint(event.position().x() / pageScaleFactor, event.position().y() / pageScaleFactor))
-    , m_globalPosition(m_position + (event.globalPosition() - event.position()))
-    , m_deltaX(event.deltaX())
-    , m_deltaY(event.deltaY())
-    , m_deltaZ(event.deltaZ())
-    , m_clickCount(event.clickCount())
-#if PLATFORM(WIN)
-    , m_didActivateWebView(false)
-#endif
-{
-}
-
 void WebMouseEvent::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
     WebEvent::encode(encoder);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (102539 => 102540)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-12-11 19:33:25 UTC (rev 102539)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-12-11 19:38:49 UTC (rev 102540)
@@ -633,10 +633,8 @@
         // FIXME: Clicking in a scroll bar should not change focus.
         if (currentEvent->type() == WebEvent::MouseDown)
             focusPluginElement();
-        
-        // Adjust mouse coordinates to account for frameScaleFactor
-        WebMouseEvent eventWithScaledCoordinates(*static_cast<const WebMouseEvent*>(currentEvent), frame()->frameScaleFactor());
-        didHandleEvent = m_plugin->handleMouseEvent(eventWithScaledCoordinates);
+
+        didHandleEvent = m_plugin->handleMouseEvent(static_cast<const WebMouseEvent&>(*currentEvent));
     } else if (event->type() == eventNames().mousewheelEvent && currentEvent->type() == WebEvent::Wheel) {
         // We have a wheel event.
         didHandleEvent = m_plugin->handleWheelEvent(static_cast<const WebWheelEvent&>(*currentEvent));
@@ -706,10 +704,17 @@
     if (!m_isInitialized || !m_plugin || !parent())
         return;
 
-    // FIXME: Just passing a translation matrix isn't good enough.
-    IntPoint locationInWindowCoordinates = parent()->contentsToRootView(frameRect().location());
-    AffineTransform transform = AffineTransform::translation(locationInWindowCoordinates.x(), locationInWindowCoordinates.y());
+    ASSERT(frame());
+    float frameScaleFactor = frame()->frameScaleFactor();
 
+    IntPoint scaledFrameRectLocation(frameRect().location().x() * frameScaleFactor, frameRect().location().y() * frameScaleFactor);
+    IntPoint scaledLocationInRootViewCoordinates(parent()->contentsToRootView(scaledFrameRectLocation));
+
+    // FIXME: We still don't get the right coordinates for transformed plugins.
+    AffineTransform transform;
+    transform.translate(scaledLocationInRootViewCoordinates.x(), scaledLocationInRootViewCoordinates.y());
+    transform.scale(frameScaleFactor);
+
     // FIXME: The clip rect isn't correct.
     IntRect clipRect = boundsRect();
     m_plugin->geometryDidChange(size(), clipRect, transform);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to