Title: [99448] trunk/Source/WebKit2
Revision
99448
Author
[email protected]
Date
2011-11-07 11:20:34 -0800 (Mon, 07 Nov 2011)

Log Message

NetscapePlugin::wantsWindowRelativeNPWindowCoordinates should return false on Mac
https://bugs.webkit.org/show_bug.cgi?id=71707

Reviewed by Sam Weinig.

This changes the way the fake Carbon plug-in window is positioned, so that it's always the same size
and location as the plug-in (relative to the screen).

* WebProcess/Plugins/Netscape/NetscapePlugin.h:
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::platformGeometryDidChange):
Call updateFakeWindowBounds.

(WebKit::NetscapePlugin::updateFakeWindowBounds):
Convert the plug-in position to screen coordinates and set the window bounds to be the location and
size of the plug-in, where the location is relative to the screen.

(WebKit::NetscapePlugin::wantsWindowRelativeNPWindowCoordinates):
Return false.

(WebKit::NetscapePlugin::windowAndViewFramesChanged):
Call updateFakeWindowBounds.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (99447 => 99448)


--- trunk/Source/WebKit2/ChangeLog	2011-11-07 19:12:08 UTC (rev 99447)
+++ trunk/Source/WebKit2/ChangeLog	2011-11-07 19:20:34 UTC (rev 99448)
@@ -1,3 +1,28 @@
+2011-11-07  Anders Carlsson  <[email protected]>
+
+        NetscapePlugin::wantsWindowRelativeNPWindowCoordinates should return false on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=71707
+
+        Reviewed by Sam Weinig.
+
+        This changes the way the fake Carbon plug-in window is positioned, so that it's always the same size
+        and location as the plug-in (relative to the screen).
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformGeometryDidChange):
+        Call updateFakeWindowBounds.
+
+        (WebKit::NetscapePlugin::updateFakeWindowBounds):
+        Convert the plug-in position to screen coordinates and set the window bounds to be the location and
+        size of the plug-in, where the location is relative to the screen.
+
+        (WebKit::NetscapePlugin::wantsWindowRelativeNPWindowCoordinates):
+        Return false.
+
+        (WebKit::NetscapePlugin::windowAndViewFramesChanged):
+        Call updateFakeWindowBounds.
+
 2011-11-07  Sam Weinig  <[email protected]>
 
         WKPage.h should be in PrivateHeaders.

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-07 19:12:08 UTC (rev 99447)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-11-07 19:20:34 UTC (rev 99448)
@@ -71,6 +71,7 @@
 #ifndef NP_NO_CARBON
     WindowRef windowRef() const;
     bool isWindowActive() const { return m_windowHasFocus; }
+    void updateFakeWindowBounds();
 
     static NetscapePlugin* netscapePluginFromWindow(WindowRef);
     static unsigned buttonState();

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


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-07 19:12:08 UTC (rev 99447)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-11-07 19:20:34 UTC (rev 99448)
@@ -293,6 +293,18 @@
 
 void NetscapePlugin::platformGeometryDidChange()
 {
+    switch (m_eventModel) {
+    case NPEventModelCocoa:
+        // Nothing to do
+        break;
+#ifndef NP_NO_CARBON
+    case NPEventModelCarbon:
+        updateFakeWindowBounds();
+        break;
+#endif
+    default:
+        ASSERT_NOT_REACHED();
+    }
 }
 
 void NetscapePlugin::platformVisibilityDidChange()
@@ -324,6 +336,21 @@
     return reinterpret_cast<WindowRef>(m_npCGContext.window);
 }
 
+void NetscapePlugin::updateFakeWindowBounds()
+{
+    double screenX, screenY;
+    bool didConvert = convertPoint(0, 0, NPCoordinateSpacePlugin, screenX, screenY, NPCoordinateSpaceFlippedScreen);
+    ASSERT_UNUSED(didConvert, didConvert);
+    
+    Rect bounds;
+    bounds.top = screenY;
+    bounds.left = screenX;
+    bounds.bottom = screenY + m_pluginSize.height();
+    bounds.right = screenX + m_pluginSize.width();
+    
+    ::SetWindowBounds(windowRef(), kWindowStructureRgn, &bounds);
+}
+
 unsigned NetscapePlugin::buttonState()
 {
     return buttonStateFromLastMouseEvent;
@@ -834,7 +861,7 @@
 
 bool NetscapePlugin::wantsWindowRelativeNPWindowCoordinates()
 {
-    return true;
+    return false;
 }
 
 void NetscapePlugin::windowFocusChanged(bool hasFocus)
@@ -872,26 +899,6 @@
     }
 }
 
-#ifndef NP_NO_CARBON
-static Rect computeFakeWindowBoundsRect(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates)
-{
-    // Carbon global coordinates has the origin set at the top left corner of the main viewing screen, so we want to flip the y coordinate.
-    CGFloat maxY = NSMaxY([(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame]);
-
-    int flippedWindowFrameYCoordinate = maxY - windowFrameInScreenCoordinates.maxY();
-    int flippedViewFrameYCoordinate = windowFrameInScreenCoordinates.height() - viewFrameInWindowCoordinates.maxY();
-
-    Rect bounds;
-    
-    bounds.top = flippedWindowFrameYCoordinate + flippedViewFrameYCoordinate;
-    bounds.left = windowFrameInScreenCoordinates.x();
-    bounds.right = bounds.left + viewFrameInWindowCoordinates.width();
-    bounds.bottom = bounds.top + viewFrameInWindowCoordinates.height();
-    
-    return bounds;
-}
-#endif
-
 void NetscapePlugin::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
 {
     m_windowFrameInScreenCoordinates = windowFrameInScreenCoordinates;
@@ -903,12 +910,9 @@
             break;
 
 #ifndef NP_NO_CARBON
-        case NPEventModelCarbon: {
-            Rect bounds = computeFakeWindowBoundsRect(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
-
-            ::SetWindowBounds(windowRef(), kWindowStructureRgn, &bounds);
+        case NPEventModelCarbon:
+            updateFakeWindowBounds();
             break;
-        }
 #endif
 
         default:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to