Title: [87986] branches/safari-534-branch/Source/WebKit2

Diff

Modified: branches/safari-534-branch/Source/WebKit2/ChangeLog (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/ChangeLog	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/ChangeLog	2011-06-03 01:50:43 UTC (rev 87986)
@@ -1,5 +1,43 @@
 2011-06-02  Lucas Forschler  <lforsch...@apple.com>
 
+    Merged 87945.
+
+    2011-06-02  Anders Carlsson  <ander...@apple.com>
+
+        Reviewed by Simon Fraser.
+
+        Add quirk for plug-ins that return a retained CALayer
+        https://bugs.webkit.org/show_bug.cgi?id=61948
+        <rdar://problem/9530390>
+
+        * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+        (WebKit::NetscapePluginModule::determineQuirks):
+        Set the ReturnsRetainedCoreAnimationLayer quirk for Flash.
+
+        * Shared/Plugins/PluginQuirks.h:
+        Add ReturnsRetainedCoreAnimationLayer quirk.
+
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_GetValue):
+        Handle WKNVExpectsNonretainedLayer by always returning true, and also
+        call NetscapePlugin::setPluginReturnsNonretainedLayer(true) to add a way
+        for plug-ins to opt into returning non-retained layers even if they have
+        the quirk specified.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::NetscapePlugin):
+        Initialize m_pluginReturnsNonretainedLayer to true.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.h:
+        (WebKit::NetscapePlugin::setPluginReturnsNonretainedLayer):
+        Add setter.
+
+        * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+        (WebKit::NetscapePlugin::platformPostInitialize):
+        If m_pluginReturnsNonretainedLayer is false, adopt the layer.
+
+2011-06-02  Lucas Forschler  <lforsch...@apple.com>
+
     Merged 87857.
 
     2011-06-01  Sam Weinig  <s...@webkit.org>

Modified: branches/safari-534-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2011-06-03 01:50:43 UTC (rev 87986)
@@ -418,6 +418,9 @@
 
         // We can short circuit some NPRuntime calls during initialization.
         m_pluginQuirks.add(PluginQuirks::CanShortCircuitSomeNPRuntimeCallsDuringInitialization);
+
+        // Flash returns a retained Core Animation layer.
+        m_pluginQuirks.add(PluginQuirks::ReturnsRetainedCoreAnimationLayer);
     }
 
     if (plugin.bundleIdentifier == "com.microsoft.SilverlightPlugin") {

Modified: branches/safari-534-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2011-06-03 01:50:43 UTC (rev 87986)
@@ -54,6 +54,11 @@
         // we can return the right values without having to do sync IPC back into the web process.
         CanShortCircuitSomeNPRuntimeCallsDuringInitialization,
 
+        // Whether calling NPP_GetValue with NPPVpluginCoreAnimationLayer returns a retained Core Animation
+        // layer or not. According to the NPAPI specifications, plug-in shouldn't return a retained layer but
+        // WebKit1 expects a retained plug-in layer. We use this for Flash to avoid leaking OpenGL layers.
+        ReturnsRetainedCoreAnimationLayer,
+
 #ifndef NP_NO_QUICKDRAW
         // Allow the plug-in to use the QuickDraw drawing model, since we know that the plug-in
         // will never paint or receive events. Used by the AppleConnect plug-in.

Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp	2011-06-03 01:50:43 UTC (rev 87986)
@@ -408,9 +408,12 @@
 }
 
 #if PLATFORM(MAC)
-// true if the browser supports hardware compositing of Core Animation plug-ins.
+// Whether the browser supports compositing of Core Animation plug-ins.
 static const unsigned WKNVSupportsCompositingCoreAnimationPluginsBool = 74656;
 
+// Whether the browser expects a non-retained Core Animation layer.
+static const unsigned WKNVExpectsNonretainedLayer = 74657;
+
 // The Core Animation render server port.
 static const unsigned WKNVCALayerRenderServerPort = 71879;
 
@@ -468,7 +471,16 @@
             *(mach_port_t*)value = plugin->compositingRenderServerPort();
             break;
         }
-        
+
+        case WKNVExpectsNonretainedLayer: {
+            RefPtr<NetscapePlugin> plugin = NetscapePlugin::fromNPP(npp);
+
+            // Asking for this will make us expect a non-retained layer from the plug-in.
+            plugin->setPluginReturnsNonretainedLayer(true);
+            *(NPBool*)value = true;
+            break;
+        }
+
 #ifndef NP_NO_QUICKDRAW
         case NPNVsupportsQuickDrawBool:
             // We don't support the QuickDraw drawing model.

Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-06-03 01:50:43 UTC (rev 87986)
@@ -70,6 +70,7 @@
 #if PLATFORM(MAC)
     , m_drawingModel(static_cast<NPDrawingModel>(-1))
     , m_eventModel(static_cast<NPEventModel>(-1))
+    , m_pluginReturnsNonretainedLayer(!m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsRetainedCoreAnimationLayer))
     , m_currentMouseEvent(0)
     , m_pluginHasFocus(false)
     , m_windowHasFocus(false)

Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h	2011-06-03 01:50:43 UTC (rev 87986)
@@ -57,6 +57,8 @@
     NPBool convertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double& destX, double& destY, NPCoordinateSpace destSpace);
     NPError popUpContextMenu(NPMenu*);
 
+    void setPluginReturnsNonretainedLayer(bool pluginReturnsNonretainedLayer) { m_pluginReturnsNonretainedLayer = pluginReturnsNonretainedLayer; }
+
     mach_port_t compositingRenderServerPort();
 
 #ifndef NP_NO_CARBON
@@ -225,7 +227,9 @@
 #if PLUGIN_ARCHITECTURE(MAC)
     NPDrawingModel m_drawingModel;
     NPEventModel m_eventModel;
+
     RetainPtr<PlatformLayer> m_pluginLayer;
+    bool m_pluginReturnsNonretainedLayer;
 
     NPCocoaEvent* m_currentMouseEvent;
 

Modified: branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (87985 => 87986)


--- branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-06-03 01:48:35 UTC (rev 87985)
+++ branches/safari-534-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2011-06-03 01:50:43 UTC (rev 87986)
@@ -233,7 +233,20 @@
         // Get the Core Animation layer.
         if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) {
             ASSERT(!m_pluginLayer);
-            m_pluginLayer = reinterpret_cast<CALayer *>(value);
+
+            // The original Core Animation drawing model required that plug-ins pass a retained layer
+            // to the browser, which the browser would then adopt. However, the final spec changed this
+            // (See https://wiki.mozilla.org/NPAPI:CoreAnimationDrawingModel for more information)
+            // after a version of WebKit1 with the original implementation had shipped, but that now means
+            // that any plug-ins that expect the WebKit1 behavior would leak the CALayer.
+            // For plug-ins that we know return retained layers, we have the ReturnsRetainedCoreAnimationLayer 
+            // plug-in quirk. Plug-ins can also check for whether the browser expects a non-retained layer to
+            // be returned by using NPN_GetValue and pass the WKNVExpectsNonretainedLayer parameter.
+            // https://bugs.webkit.org/show_bug.cgi?id=58282 describes the bug where WebKit expects retained layers.
+            if (m_pluginReturnsNonretainedLayer)
+                m_pluginLayer = reinterpret_cast<CALayer *>(value);
+            else
+                m_pluginLayer.adoptNS(reinterpret_cast<CALayer *>(value));
         }
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to