Title: [99437] trunk/Source
Revision
99437
Author
[email protected]
Date
2011-11-07 10:00:24 -0800 (Mon, 07 Nov 2011)

Log Message

Simplify NetscapePlugin::convertPoint and make it work (in theory) with transformed plug-ins
https://bugs.webkit.org/show_bug.cgi?id=71699

Reviewed by Sam Weinig.

Source/WebCore:

Export AffineTransform symbols used by WebKit2.

* WebCore.exp.in:

Source/WebKit2:

Add a getScreenTransform function which given a coordinate space returns a transform that converts a
point from that coordinate space to the screen coordinate space. We then get the source -> screen transform
and the destination -> screen transform. We invert the destination -> screen transform, multiply it with the
source -> screen transform and use mapPoint to get a complete affine transform from the source to the destination space
and use mapPoint to map the source point and return the destination point.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::getScreenTransform):
(WebKit::NetscapePlugin::convertPoint):

* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::initializePlugin):
Call windowAndViewFramesChanged before viewGeometryDidChange so that the window and view frames will be up to date by
the time NPP_SetWindow is called in the plug-in.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99436 => 99437)


--- trunk/Source/WebCore/ChangeLog	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebCore/ChangeLog	2011-11-07 18:00:24 UTC (rev 99437)
@@ -1,3 +1,14 @@
+2011-11-07  Anders Carlsson  <[email protected]>
+
+        Simplify NetscapePlugin::convertPoint and make it work (in theory) with transformed plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=71699
+
+        Reviewed by Sam Weinig.
+
+        Export AffineTransform symbols used by WebKit2.
+
+        * WebCore.exp.in:
+
 2011-11-07  Michael Saboff  <[email protected]>
 
         Towards 8 Bit Strings: Templatize JSC::Lexer class by character type

Modified: trunk/Source/WebCore/WebCore.exp.in (99436 => 99437)


--- trunk/Source/WebCore/WebCore.exp.in	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-11-07 18:00:24 UTC (rev 99437)
@@ -401,6 +401,9 @@
 __ZN7WebCore14StorageTracker18diskUsageForOriginEPNS_14SecurityOriginE
 __ZN7WebCore14StorageTracker32syncFileSystemAndTrackerDatabaseEv
 __ZN7WebCore14endOfParagraphERKNS_15VisiblePositionENS_27EditingBoundaryCrossingRuleE
+__ZN7WebCore15AffineTransform5flipYEv
+__ZN7WebCore15AffineTransform8multiplyERKS0_
+__ZN7WebCore15AffineTransform9translateEdd
 __ZN7WebCore15AffineTransformC1Edddddd
 __ZN7WebCore15AffineTransformC1Ev
 __ZN7WebCore15ArchiveResource6createEN3WTF10PassRefPtrINS_12SharedBufferEEERKNS_4KURLERKNS1_6StringESA_SA_RKNS_16ResourceResponseE
@@ -1223,8 +1226,10 @@
 __ZNK7WebCore14SecurityOrigin10canDisplayERKNS_4KURLE
 __ZNK7WebCore14SecurityOrigin18databaseIdentifierEv
 __ZNK7WebCore14SecurityOrigin5equalEPKS0_
+__ZNK7WebCore15AffineTransform10isIdentityEv
 __ZNK7WebCore15AffineTransform12isInvertibleEv
 __ZNK7WebCore15AffineTransform7inverseEv
+__ZNK7WebCore15AffineTransform8mapPointERKNS_10FloatPointE
 __ZNK7WebCore15AffineTransform8mapPointERKNS_8IntPointE
 __ZNK7WebCore15FocusController18focusedOrMainFrameEv
 __ZNK7WebCore15GraphicsContext15platformContextEv

Modified: trunk/Source/WebKit2/ChangeLog (99436 => 99437)


--- trunk/Source/WebKit2/ChangeLog	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-07 18:00:24 UTC (rev 99437)
@@ -1,3 +1,26 @@
+2011-11-07  Anders Carlsson  <[email protected]>
+
+        Simplify NetscapePlugin::convertPoint and make it work (in theory) with transformed plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=71699
+
+        Reviewed by Sam Weinig.
+
+        Add a getScreenTransform function which given a coordinate space returns a transform that converts a
+        point from that coordinate space to the screen coordinate space. We then get the source -> screen transform
+        and the destination -> screen transform. We invert the destination -> screen transform, multiply it with the
+        source -> screen transform and use mapPoint to get a complete affine transform from the source to the destination space
+        and use mapPoint to map the source point and return the destination point.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::getScreenTransform):
+        (WebKit::NetscapePlugin::convertPoint):
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::initializePlugin):
+        Call windowAndViewFramesChanged before viewGeometryDidChange so that the window and view frames will be up to date by
+        the time NPP_SetWindow is called in the plug-in.
+
 2011-11-07  Kenneth Rohde Christiansen  <[email protected]>
 
         [Qt] Put handling of gestures and their interaction in one place

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (99436 => 99437)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-07 18:00:24 UTC (rev 99437)
@@ -65,6 +65,9 @@
 
     mach_port_t compositingRenderServerPort();
 
+    // Computes an affine transform from the given coordinate space to the screen coordinate space.
+    bool getScreenTransform(NPCoordinateSpace sourceSpace, WebCore::AffineTransform&);
+
 #ifndef NP_NO_CARBON
     WindowRef windowRef() const;
     bool isWindowActive() const { return m_windowHasFocus; }

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (99436 => 99437)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-07 18:00:24 UTC (rev 99437)
@@ -88,75 +88,66 @@
     return NPERR_NO_ERROR;
 }
 
-static double flipScreenYCoordinate(double y)
+bool NetscapePlugin::getScreenTransform(NPCoordinateSpace sourceSpace, AffineTransform& transform)
 {
-    return [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height - y;
+    ASSERT(transform.isIdentity());
+
+    switch (sourceSpace) {
+        case NPCoordinateSpacePlugin: {
+            transform.translate(m_windowFrameInScreenCoordinates.x(), m_windowFrameInScreenCoordinates.y());
+            transform.translate(m_viewFrameInWindowCoordinates.x(), m_viewFrameInWindowCoordinates.height() + m_viewFrameInWindowCoordinates.y());
+            transform.flipY();
+            transform *= m_pluginToRootViewTransform;
+            return true;
+        }
+
+        case NPCoordinateSpaceWindow: {
+            transform.translate(m_windowFrameInScreenCoordinates.x(), m_windowFrameInScreenCoordinates.y());
+            return true;
+        }
+
+        case NPCoordinateSpaceFlippedWindow: {
+            transform.translate(m_windowFrameInScreenCoordinates.x(), m_windowFrameInScreenCoordinates.height() + m_windowFrameInScreenCoordinates.y());
+            transform.flipY();
+            return true;
+        }
+
+        case NPCoordinateSpaceScreen: {
+            // Nothing to do.
+            return true;
+        }
+
+        case NPCoordinateSpaceFlippedScreen: {
+            double screenHeight = [(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame].size.height;
+            transform.translate(0, screenHeight);
+            transform.flipY();
+            return true;
+        }
+
+        default:
+            return false;
+    }
 }
 
 NPBool NetscapePlugin::convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double& destX, double& destY, NPCoordinateSpace destSpace)
 {
-    if (sourceSpace == destSpace) {
-        destX = sourceX;
-        destY = sourceY;
-        return true;
-    }
+    AffineTransform sourceTransform;
+    if (!getScreenTransform(sourceSpace, sourceTransform))
+        return false;
 
-    double sourceXInScreenSpace;
-    double sourceYInScreenSpace;
-
-    FloatPoint sourceInScreenSpace;
-    switch (sourceSpace) {
-    case NPCoordinateSpacePlugin:
-        sourceXInScreenSpace = sourceX + m_windowFrameInScreenCoordinates.x() + m_viewFrameInWindowCoordinates.x() + m_npWindow.x;
-        sourceYInScreenSpace = m_windowFrameInScreenCoordinates.y() + m_viewFrameInWindowCoordinates.y() + m_viewFrameInWindowCoordinates.height() - (sourceY + m_npWindow.y);
-        break;
-    case NPCoordinateSpaceWindow:
-        sourceXInScreenSpace = sourceX + m_windowFrameInScreenCoordinates.x();
-        sourceYInScreenSpace = sourceY + m_windowFrameInScreenCoordinates.y();
-        break;
-    case NPCoordinateSpaceFlippedWindow:
-        sourceXInScreenSpace = sourceX + m_windowFrameInScreenCoordinates.x();
-        sourceYInScreenSpace = m_windowFrameInScreenCoordinates.y() + m_windowFrameInScreenCoordinates.height() - sourceY;
-        break;
-    case NPCoordinateSpaceScreen:
-        sourceXInScreenSpace = sourceX;
-        sourceYInScreenSpace = sourceY;
-        break;
-    case NPCoordinateSpaceFlippedScreen:
-        sourceXInScreenSpace = sourceX;
-        sourceYInScreenSpace = flipScreenYCoordinate(sourceY);
-        break;
-    default:
+    AffineTransform destTransform;
+    if (!getScreenTransform(destSpace, destTransform))
         return false;
-    }
 
-    // Now convert back.
-    switch (destSpace) {
-    case NPCoordinateSpacePlugin:
-        destX = sourceXInScreenSpace - (m_windowFrameInScreenCoordinates.x() + m_viewFrameInWindowCoordinates.x() + m_npWindow.x);
-        destY = m_windowFrameInScreenCoordinates.y() + m_viewFrameInWindowCoordinates.y() + m_viewFrameInWindowCoordinates.height() - (sourceYInScreenSpace + m_npWindow.y);
-        break;
-    case NPCoordinateSpaceWindow:
-        destX = sourceXInScreenSpace - m_windowFrameInScreenCoordinates.x();
-        destY = sourceYInScreenSpace - m_windowFrameInScreenCoordinates.y();
-        break;
-    case NPCoordinateSpaceFlippedWindow:
-        destX = sourceXInScreenSpace - m_windowFrameInScreenCoordinates.x();
-        destY = sourceYInScreenSpace - m_windowFrameInScreenCoordinates.y();
-        destY = m_windowFrameInScreenCoordinates.height() - destY;
-        break;
-    case NPCoordinateSpaceScreen:
-        destX = sourceXInScreenSpace;
-        destY = sourceYInScreenSpace;
-        break;
-    case NPCoordinateSpaceFlippedScreen:
-        destX = sourceXInScreenSpace;
-        destY = flipScreenYCoordinate(sourceYInScreenSpace);
-        break;
-    default:
+    if (!destTransform.isInvertible())
         return false;
-    }
 
+    AffineTransform transform = destTransform.inverse() * sourceTransform;
+
+    FloatPoint destinationPoint = transform.mapPoint(FloatPoint(sourceX, sourceY));
+
+    destX = destinationPoint.x();
+    destY = destinationPoint.y();
     return true;
 }
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (99436 => 99437)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-11-07 17:54:15 UTC (rev 99436)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-11-07 18:00:24 UTC (rev 99437)
@@ -469,6 +469,10 @@
     
     m_isInitialized = true;
 
+#if PLATFORM(MAC)
+    windowAndViewFramesChanged(m_webPage->windowFrameInScreenCoordinates(), m_webPage->viewFrameInWindowCoordinates());
+#endif
+
     viewGeometryDidChange();
 
     redeliverManualStream();
@@ -481,7 +485,6 @@
         }
     }
 
-    windowAndViewFramesChanged(m_webPage->windowFrameInScreenCoordinates(), m_webPage->viewFrameInWindowCoordinates());
     setWindowIsVisible(m_webPage->windowIsVisible());
     setWindowIsFocused(m_webPage->windowIsFocused());
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to