- Revision
- 112950
- Author
- [email protected]
- Date
- 2012-04-02 15:11:51 -0700 (Mon, 02 Apr 2012)
Log Message
Call NPP_SetValue with WKNVCALayerRenderServerPort when a WKView is moved from a buffered to an unbuffered window, or vice versa
https://bugs.webkit.org/show_bug.cgi?id=82951
<rdar://problem/10589308>
Reviewed by Sam Weinig.
* PluginProcess/mac/PluginControllerProxyMac.mm:
(WebKit::PluginControllerProxy::setLayerHostingMode):
Call Plugin::setLayerHostingMode).
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
* WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h:
Move WKNVCALayerRenderServerPort to the header file.
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::NetscapePlugin):
Initialize m_layerHostingMode.
(WebKit::NetscapePlugin::initialize):
Set m_layerHostingMode from the parameters struct.
* WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
(WebKit::NetscapePlugin::compositingRenderServerPort):
Return MACH_PORT_NULL when hosted in the window server.
(WebKit::NetscapePlugin::platformPostInitialize):
Move the code that gets the layer out into a separate function, updatePluginLayer.
(WebKit::NetscapePlugin::setLayerHostingMode):
Let the plug-in know that the layer hosting mode changed and update the plug-in layer if
setting the new compositing port was successful.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (112949 => 112950)
--- trunk/Source/WebKit2/ChangeLog 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/ChangeLog 2012-04-02 22:11:51 UTC (rev 112950)
@@ -1,3 +1,37 @@
+2012-04-02 Anders Carlsson <[email protected]>
+
+ Call NPP_SetValue with WKNVCALayerRenderServerPort when a WKView is moved from a buffered to an unbuffered window, or vice versa
+ https://bugs.webkit.org/show_bug.cgi?id=82951
+ <rdar://problem/10589308>
+
+ Reviewed by Sam Weinig.
+
+ * PluginProcess/mac/PluginControllerProxyMac.mm:
+ (WebKit::PluginControllerProxy::setLayerHostingMode):
+ Call Plugin::setLayerHostingMode).
+
+ * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+ * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h:
+ Move WKNVCALayerRenderServerPort to the header file.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+ (WebKit::NetscapePlugin::NetscapePlugin):
+ Initialize m_layerHostingMode.
+
+ (WebKit::NetscapePlugin::initialize):
+ Set m_layerHostingMode from the parameters struct.
+
+ * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+ (WebKit::NetscapePlugin::compositingRenderServerPort):
+ Return MACH_PORT_NULL when hosted in the window server.
+
+ (WebKit::NetscapePlugin::platformPostInitialize):
+ Move the code that gets the layer out into a separate function, updatePluginLayer.
+
+ (WebKit::NetscapePlugin::setLayerHostingMode):
+ Let the plug-in know that the layer hosting mode changed and update the plug-in layer if
+ setting the new compositing port was successful.
+
2012-04-02 Jesus Sanchez-Palencia <[email protected]>
[Qt][WK2] ResourceError::isCancellation() is always returning false
Modified: trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm (112949 => 112950)
--- trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm 2012-04-02 22:11:51 UTC (rev 112950)
@@ -111,6 +111,8 @@
void PluginControllerProxy::setLayerHostingMode(uint32_t opaqueLayerHostingMode)
{
LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode);
+
+ m_plugin->setLayerHostingMode(layerHostingMode);
updateLayerHostingContext(layerHostingMode);
m_connection->connection()->send(Messages::PluginProxy::SetLayerHostingContextID(m_layerHostingContext->contextID()), m_pluginInstanceID);
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp (112949 => 112950)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp 2012-04-02 22:11:51 UTC (rev 112950)
@@ -417,9 +417,6 @@
// WKNVSandboxFunctions = 74659 is defined in NetscapeSandboxFunctions.h
-// The Core Animation render server port.
-static const unsigned WKNVCALayerRenderServerPort = 71879;
-
#endif
static NPError NPN_GetValue(NPP npp, NPNVariable variable, void *value)
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h (112949 => 112950)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.h 2012-04-02 22:11:51 UTC (rev 112950)
@@ -30,6 +30,9 @@
namespace WebKit {
+// The Core Animation render server port.
+static const unsigned WKNVCALayerRenderServerPort = 71879;
+
NPNetscapeFuncs* netscapeBrowserFuncs();
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (112949 => 112950)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp 2012-04-02 22:11:51 UTC (rev 112950)
@@ -72,6 +72,7 @@
, m_drawingModel(static_cast<NPDrawingModel>(-1))
, m_eventModel(static_cast<NPEventModel>(-1))
, m_pluginReturnsNonretainedLayer(!m_pluginModule->pluginQuirks().contains(PluginQuirks::ReturnsRetainedCoreAnimationLayer))
+ , m_layerHostingMode(LayerHostingModeDefault)
, m_currentMouseEvent(0)
, m_pluginHasFocus(false)
, m_windowHasFocus(false)
@@ -579,6 +580,8 @@
}
}
}
+
+ m_layerHostingMode = parameters.layerHostingMode;
#endif
NetscapePlugin* previousNPPNewPlugin = currentNPPNewPlugin;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (112949 => 112950)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2012-04-02 22:11:51 UTC (rev 112950)
@@ -209,6 +209,8 @@
void pluginFocusOrWindowFocusChanged();
void setComplexTextInputEnabled(bool);
+
+ void updatePluginLayer();
#endif
virtual void contentsScaleFactorChanged(float);
@@ -302,6 +304,7 @@
RetainPtr<PlatformLayer> m_pluginLayer;
bool m_pluginReturnsNonretainedLayer;
+ LayerHostingMode m_layerHostingMode;
NPCocoaEvent* m_currentMouseEvent;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (112949 => 112950)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2012-04-02 22:08:19 UTC (rev 112949)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm 2012-04-02 22:11:51 UTC (rev 112950)
@@ -26,6 +26,7 @@
#import "config.h"
#import "NetscapePlugin.h"
+#import "NetscapeBrowserFuncs.h"
#import "PluginController.h"
#import "WebEvent.h"
#import <Carbon/Carbon.h>
@@ -167,6 +168,11 @@
mach_port_t NetscapePlugin::compositingRenderServerPort()
{
+#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
+ if (m_layerHostingMode == LayerHostingModeInWindowServer)
+ return MACH_PORT_NULL;
+#endif
+
return controller()->compositingRenderServerPort();
}
@@ -219,28 +225,8 @@
return false;
#endif
- if (m_drawingModel == NPDrawingModelCoreAnimation) {
- void* value = 0;
- // Get the Core Animation layer.
- if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) {
- ASSERT(!m_pluginLayer);
+ updatePluginLayer();
- // 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));
- }
- }
-
#ifndef NP_NO_CARBON
if (m_eventModel == NPEventModelCarbon) {
// Initialize the fake Carbon window.
@@ -1022,8 +1008,17 @@
}
}
-void NetscapePlugin::setLayerHostingMode(LayerHostingMode)
+void NetscapePlugin::setLayerHostingMode(LayerHostingMode layerHostingMode)
{
+ m_layerHostingMode = layerHostingMode;
+
+ // Tell the plug-in about the new compositing render server port. If it returns OK we'll ask it again for a new layer.
+ mach_port_t port = NetscapePlugin::compositingRenderServerPort();
+ if (NPP_SetValue(static_cast<NPNVariable>(WKNVCALayerRenderServerPort), &port) != NPERR_NO_ERROR)
+ return;
+
+ m_pluginLayer = nullptr;
+ updatePluginLayer();
}
void NetscapePlugin::pluginFocusOrWindowFocusChanged()
@@ -1060,6 +1055,37 @@
return static_cast<PlatformLayer*>(m_pluginLayer.get());
}
+void NetscapePlugin::updatePluginLayer()
+{
+ if (m_drawingModel != NPDrawingModelCoreAnimation)
+ return;
+
+ void* value = 0;
+
+ // Get the Core Animation layer.
+ if (NPP_GetValue(NPPVpluginCoreAnimationLayer, &value) != NPERR_NO_ERROR)
+ return;
+
+ if (!value)
+ return;
+
+ ASSERT(!m_pluginLayer);
+
+ // 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));
+}
+
#ifndef NP_NO_CARBON
void NetscapePlugin::nullEventTimerFired()
{