- Revision
- 87945
- Author
- ander...@apple.com
- Date
- 2011-06-02 12:59:17 -0700 (Thu, 02 Jun 2011)
Log Message
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.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (87944 => 87945)
--- trunk/Source/WebKit2/ChangeLog 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-02 19:59:17 UTC (rev 87945)
@@ -1,3 +1,37 @@
+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 Brent Fulgham <bfulg...@webkit.org>
Unreviewed WinCairo build correction.
Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (87944 => 87945)
--- trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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: trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h (87944 => 87945)
--- trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/Shared/Plugins/PluginQuirks.h 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (87944 => 87945)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (87944 => 87945)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (87944 => 87945)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (87944 => 87945)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2011-06-02 19:58:16 UTC (rev 87944)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2011-06-02 19:59:17 UTC (rev 87945)
@@ -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));
}
}