Title: [99289] trunk/Source
Revision
99289
Author
[email protected]
Date
2011-11-04 10:04:15 -0700 (Fri, 04 Nov 2011)

Log Message

Add NetscapePlugin::convertFromRootView
https://bugs.webkit.org/show_bug.cgi?id=71526

Reviewed by Sam Weinig.

Source/WebCore:

Export some symbols that WebKit2 needs.

* WebCore.exp.in:

Source/WebKit2:

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::convertFromRootView):
New function that converts a point from root view coordinates to plug-in coordinates.
Returns false if the conversion can't be done.

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::fillInCocoaEventFromMouseEvent):
(WebKit::initializeMouseEvent):
(WebKit::NetscapePlugin::platformHandleMouseEvent):
(WebKit::NetscapePlugin::platformHandleWheelEvent):
(WebKit::NetscapePlugin::platformHandleMouseEnterEvent):
(WebKit::NetscapePlugin::platformHandleMouseLeaveEvent):
Use convertFromRootView instead of subtracting m_frameRectInWindowCoordinates.location() from the
event position (which is in root view coordinates).

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (99288 => 99289)


--- trunk/Source/WebCore/ChangeLog	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebCore/ChangeLog	2011-11-04 17:04:15 UTC (rev 99289)
@@ -1,3 +1,14 @@
+2011-11-03  Anders Carlsson  <[email protected]>
+
+        Add NetscapePlugin::convertFromRootView
+        https://bugs.webkit.org/show_bug.cgi?id=71526
+
+        Reviewed by Sam Weinig.
+
+        Export some symbols that WebKit2 needs.
+
+        * WebCore.exp.in:
+
 2011-11-03  Adrienne Walker  <[email protected]>
 
         [chromium] Fix incorrect visibility/scissor rect for threaded compositing

Modified: trunk/Source/WebCore/WebCore.exp.in (99288 => 99289)


--- trunk/Source/WebCore/WebCore.exp.in	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebCore/WebCore.exp.in	2011-11-04 17:04:15 UTC (rev 99289)
@@ -1223,6 +1223,8 @@
 __ZNK7WebCore14SecurityOrigin10canDisplayERKNS_4KURLE
 __ZNK7WebCore14SecurityOrigin18databaseIdentifierEv
 __ZNK7WebCore14SecurityOrigin5equalEPKS0_
+__ZNK7WebCore15AffineTransform12isInvertibleEv
+__ZNK7WebCore15AffineTransform7inverseEv
 __ZNK7WebCore15AffineTransform8mapPointERKNS_8IntPointE
 __ZNK7WebCore15FocusController18focusedOrMainFrameEv
 __ZNK7WebCore15GraphicsContext15platformContextEv

Modified: trunk/Source/WebKit2/ChangeLog (99288 => 99289)


--- trunk/Source/WebKit2/ChangeLog	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-04 17:04:15 UTC (rev 99289)
@@ -1,3 +1,26 @@
+2011-11-03  Anders Carlsson  <[email protected]>
+
+        Add NetscapePlugin::convertFromRootView
+        https://bugs.webkit.org/show_bug.cgi?id=71526
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::convertFromRootView):
+        New function that converts a point from root view coordinates to plug-in coordinates.
+        Returns false if the conversion can't be done.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::fillInCocoaEventFromMouseEvent):
+        (WebKit::initializeMouseEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseEvent):
+        (WebKit::NetscapePlugin::platformHandleWheelEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseEnterEvent):
+        (WebKit::NetscapePlugin::platformHandleMouseLeaveEvent):
+        Use convertFromRootView instead of subtracting m_frameRectInWindowCoordinates.location() from the
+        event position (which is in root view coordinates).
+
 2011-11-04  Tor Arne Vestbø  <[email protected]>
 
         [Qt] Refactor and clean up the qmake build system

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (99288 => 99289)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-11-04 17:04:15 UTC (rev 99289)
@@ -952,4 +952,13 @@
     return m_pluginToRootViewTransform.mapPoint(pointInPluginCoordinates);
 }
 
+bool NetscapePlugin::convertFromRootView(const IntPoint& pointInRootViewCoordinates, IntPoint& pointInPluginCoordinates)
+{
+    if (!m_pluginToRootViewTransform.isInvertible())
+        return false;
+
+    pointInPluginCoordinates = m_pluginToRootViewTransform.inverse().mapPoint(pointInRootViewCoordinates);
+    return true;
+}
+
 } // namespace WebKit

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-04 17:04:15 UTC (rev 99289)
@@ -220,6 +220,10 @@
     // Convert the given point from plug-in coordinates to root view coordinates.
     WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const;
 
+    // Convert the given point from root view coordinates to plug-in coordinates. Returns false if the point can't be
+    // converted (if the transformation matrix isn't invertible).
+    bool convertFromRootView(const WebCore::IntPoint& pointInRootViewCoordinates, WebCore::IntPoint& pointInPluginCoordinates);
+
 #if PLUGIN_ARCHITECTURE(WIN)
     static BOOL WINAPI hookedTrackPopupMenu(HMENU, UINT uFlags, int x, int y, int nReserved, HWND, const RECT*);
     void scheduleWindowedGeometryUpdate();

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-04 17:00:15 UTC (rev 99288)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-04 17:04:15 UTC (rev 99289)
@@ -473,11 +473,11 @@
     return -1;
 }
 
-static void fillInCocoaEventFromMouseEvent(NPCocoaEvent& event, const WebMouseEvent& mouseEvent, const WebCore::IntPoint& pluginLocation)
+static void fillInCocoaEventFromMouseEvent(NPCocoaEvent& event, const WebMouseEvent& mouseEvent, const WebCore::IntPoint& eventPositionInPluginCoordinates)
 {
     event.data.mouse.modifierFlags = modifierFlags(mouseEvent);
-    event.data.mouse.pluginX = mouseEvent.position().x() - pluginLocation.x();
-    event.data.mouse.pluginY = mouseEvent.position().y() - pluginLocation.y();
+    event.data.mouse.pluginX = eventPositionInPluginCoordinates.x();
+    event.data.mouse.pluginY = eventPositionInPluginCoordinates.y();
     event.data.mouse.buttonNumber = buttonNumber(mouseEvent.button());
     event.data.mouse.clickCount = mouseEvent.clickCount();
     event.data.mouse.deltaX = mouseEvent.deltaX();
@@ -485,7 +485,7 @@
     event.data.mouse.deltaZ = mouseEvent.deltaZ();
 }
     
-static NPCocoaEvent initializeMouseEvent(const WebMouseEvent& mouseEvent, const WebCore::IntPoint& pluginLocation)
+static NPCocoaEvent initializeMouseEvent(const WebMouseEvent& mouseEvent, const WebCore::IntPoint& eventPositionInPluginCoordinates)
 {
     NPCocoaEventType eventType;
 
@@ -508,7 +508,7 @@
     }
 
     NPCocoaEvent event = initializeEvent(eventType);
-    fillInCocoaEventFromMouseEvent(event, mouseEvent, pluginLocation);
+    fillInCocoaEventFromMouseEvent(event, mouseEvent, eventPositionInPluginCoordinates);
     return event;
 }
 
@@ -516,8 +516,12 @@
 {
     switch (m_eventModel) {
         case NPEventModelCocoa: {
-            NPCocoaEvent event = initializeMouseEvent(mouseEvent, m_frameRectInWindowCoordinates.location());
+            IntPoint eventPositionInPluginCoordinates;
+            if (!convertFromRootView(mouseEvent.position(), eventPositionInPluginCoordinates))
+                return true;
 
+            NPCocoaEvent event = initializeMouseEvent(mouseEvent, eventPositionInPluginCoordinates);
+
             NPCocoaEvent* previousMouseEvent = m_currentMouseEvent;
             m_currentMouseEvent = &event;
 
@@ -580,11 +584,15 @@
 {
     switch (m_eventModel) {
         case NPEventModelCocoa: {
+            IntPoint eventPositionInPluginCoordinates;
+            if (!convertFromRootView(wheelEvent.position(), eventPositionInPluginCoordinates))
+                return true;
+
             NPCocoaEvent event = initializeEvent(NPCocoaEventScrollWheel);
             
             event.data.mouse.modifierFlags = modifierFlags(wheelEvent);
-            event.data.mouse.pluginX = wheelEvent.position().x() - m_frameRectInWindowCoordinates.x();
-            event.data.mouse.pluginY = wheelEvent.position().y() - m_frameRectInWindowCoordinates.y();
+            event.data.mouse.pluginX = eventPositionInPluginCoordinates.x();
+            event.data.mouse.pluginY = eventPositionInPluginCoordinates.y();
             event.data.mouse.buttonNumber = 0;
             event.data.mouse.clickCount = 0;
             event.data.mouse.deltaX = wheelEvent.delta().width();
@@ -612,7 +620,7 @@
         case NPEventModelCocoa: {
             NPCocoaEvent event = initializeEvent(NPCocoaEventMouseEntered);
             
-            fillInCocoaEventFromMouseEvent(event, mouseEvent, m_frameRectInWindowCoordinates.location());
+            fillInCocoaEventFromMouseEvent(event, mouseEvent, IntPoint());
             return NPP_HandleEvent(&event);
         }
 
@@ -638,7 +646,7 @@
         case NPEventModelCocoa: {
             NPCocoaEvent event = initializeEvent(NPCocoaEventMouseExited);
             
-            fillInCocoaEventFromMouseEvent(event, mouseEvent, m_frameRectInWindowCoordinates.location());
+            fillInCocoaEventFromMouseEvent(event, mouseEvent, IntPoint());
             return NPP_HandleEvent(&event);
         }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to