Remotely hosted plugins don’t work in window-server-hosted WebKit1 views

https://bugs.webkit.org/show_bug.cgi?id=119709
<rdar://problem/14717572>

Reviewed by Anders Carlsson.

* Plugins/Hosted/NetscapePluginHostManager.h:
Add hostLayersInWindowServer argument to instantiatePlugin.

* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::instantiatePlugin):
Add hostLayersInWindowServer argument to instantiatePlugin, and pass it through to WebKitPluginHost.

* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WKPCLayerHostingModeChanged):
Forward the notification that the plugin host changed its layer hosting mode
to the instance proxy.

* Plugins/Hosted/NetscapePluginInstanceProxy.h:
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::setShouldHostLayersInWindowServer):
Ask the plugin host to re-host its layers when the layer hosting mode changes.

(WebKit::NetscapePluginInstanceProxy::layerHostingModeChanged):
Inform the WebHostedNetscapePluginView of the new layer hosting mode
when it changes. Also, store the new CAContext ID.

* Plugins/Hosted/WebHostedNetscapePluginView.h:
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView windowHostsLayersInWindowServer]):
Determine whether the WebView's current window uses window-server hosting for its layers.

(-[WebHostedNetscapePluginView createPlugin]):
Drive-by spelling fix.
Factor _pluginLayer initialization out into createPluginLayer.
Instantiate the plugin with the appropriate layer hosting mode.

(-[WebHostedNetscapePluginView createPluginLayer]):

(-[WebHostedNetscapePluginView setHostsLayersInWindowServer:]):
Create a new _pluginLayer if the layer hosting mode changes.
Attach the new _pluginLayer to our parent layer.

(-[WebHostedNetscapePluginView updateAndSetWindow]):
Inform the NetscapePluginInstanceProxy if the layer hosting mode changes,
so it can inform the plugin host. We will asynchronously receive a reply
with the new hosting mode and renderContextID and switch to the new CAContext,
in setHostsLayersInWindowServer:.

* Plugins/Hosted/WebKitPluginClient.defs:
* Plugins/Hosted/WebKitPluginHost.defs:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154019 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32c18dfd
2013-08-13 Tim Horton <timothy_horton@apple.com>
Remotely hosted plugins don’t work in window-server-hosted WebKit1 views
https://bugs.webkit.org/show_bug.cgi?id=119709
<rdar://problem/14717572>
Reviewed by Anders Carlsson.
* Plugins/Hosted/NetscapePluginHostManager.h:
Add hostLayersInWindowServer argument to instantiatePlugin.
* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::instantiatePlugin):
Add hostLayersInWindowServer argument to instantiatePlugin, and pass it through to WebKitPluginHost.
* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WKPCLayerHostingModeChanged):
Forward the notification that the plugin host changed its layer hosting mode
to the instance proxy.
* Plugins/Hosted/NetscapePluginInstanceProxy.h:
* Plugins/Hosted/NetscapePluginInstanceProxy.mm:
(WebKit::NetscapePluginInstanceProxy::setShouldHostLayersInWindowServer):
Ask the plugin host to re-host its layers when the layer hosting mode changes.
(WebKit::NetscapePluginInstanceProxy::layerHostingModeChanged):
Inform the WebHostedNetscapePluginView of the new layer hosting mode
when it changes. Also, store the new CAContext ID.
* Plugins/Hosted/WebHostedNetscapePluginView.h:
* Plugins/Hosted/WebHostedNetscapePluginView.mm:
(-[WebHostedNetscapePluginView windowHostsLayersInWindowServer]):
Determine whether the WebView's current window uses window-server hosting for its layers.
(-[WebHostedNetscapePluginView createPlugin]):
Drive-by spelling fix.
Factor _pluginLayer initialization out into createPluginLayer.
Instantiate the plugin with the appropriate layer hosting mode.
(-[WebHostedNetscapePluginView createPluginLayer]):
(-[WebHostedNetscapePluginView setHostsLayersInWindowServer:]):
Create a new _pluginLayer if the layer hosting mode changes.
Attach the new _pluginLayer to our parent layer.
(-[WebHostedNetscapePluginView updateAndSetWindow]):
Inform the NetscapePluginInstanceProxy if the layer hosting mode changes,
so it can inform the plugin host. We will asynchronously receive a reply
with the new hosting mode and renderContextID and switch to the new CAContext,
in setHostsLayersInWindowServer:.
* Plugins/Hosted/WebKitPluginClient.defs:
* Plugins/Hosted/WebKitPluginHost.defs:
2013-08-08 Tim Horton <timothy_horton@apple.com>
navigator.plugins has plugins in it when plugins are disabled
......
......@@ -44,14 +44,14 @@ class NetscapePluginHostManager {
public:
static NetscapePluginHostManager& shared();
PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled);
PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled, bool hostLayersInWindowServer);
void pluginHostDied(NetscapePluginHostProxy*);
void createPropertyListFile(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier);
void didCreateWindow();
private:
NetscapePluginHostProxy* hostForPlugin(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier);
......
......@@ -218,7 +218,7 @@ void NetscapePluginHostManager::pluginHostDied(NetscapePluginHostProxy* pluginHo
}
}
PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled)
PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(const String& pluginPath, cpu_type_t pluginArchitecture, const String& bundleIdentifier, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled, bool hostLayersInWindowServer)
{
NetscapePluginHostProxy* hostProxy = hostForPlugin(pluginPath, pluginArchitecture, bundleIdentifier);
if (!hostProxy)
......@@ -244,6 +244,7 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
[properties.get() setObject:[NSNumber numberWithBool:fullFrame] forKey:@"fullFrame"];
[properties.get() setObject:[NSNumber numberWithBool:isPrivateBrowsingEnabled] forKey:@"privateBrowsingEnabled"];
[properties.get() setObject:[NSNumber numberWithBool:isAcceleratedCompositingEnabled] forKey:@"acceleratedCompositingEnabled"];
[properties.get() setObject:[NSNumber numberWithBool:hostLayersInWindowServer] forKey:@"hostLayersInWindowServer"];
NSData *data = [NSPropertyListSerialization dataFromPropertyList:properties.get() format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
ASSERT(data);
......
......@@ -1097,6 +1097,20 @@ kern_return_t WKPCConvertPoint(mach_port_t clientPort, uint32_t pluginID,
return KERN_SUCCESS;
}
kern_return_t WKPCLayerHostingModeChanged(mach_port_t clientPort, uint32_t pluginID, boolean_t hostsLayersInWindowServer, uint32_t renderContextID)
{
NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
if (!hostProxy)
return KERN_FAILURE;
NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID);
if (!instanceProxy)
return KERN_FAILURE;
instanceProxy->layerHostingModeChanged(hostsLayersInWindowServer, renderContextID);
return KERN_SUCCESS;
}
kern_return_t WKPCCheckIfAllowedToLoadURL(mach_port_t clientPort, uint32_t pluginID, data_t urlData, mach_msg_type_number_t urlLength,
data_t targetData, mach_msg_type_number_t targetLength, uint32_t *checkID)
{
......
......@@ -91,6 +91,9 @@ public:
void focusChanged(bool hasFocus);
void windowFocusChanged(bool hasFocus);
void windowFrameChanged(NSRect frame);
void setShouldHostLayersInWindowServer(bool);
void layerHostingModeChanged(bool hostsLayersInWindowServer, uint32_t renderContextID);
void mouseEvent(NSView *pluginView, NSEvent *, NPCocoaEventType);
void keyEvent(NSView *pluginView, NSEvent *, NPCocoaEventType);
......
......@@ -277,6 +277,19 @@ void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect)
waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
}
void NetscapePluginInstanceProxy::setShouldHostLayersInWindowServer(bool shouldHostLayersInWindowServer)
{
_WKPHPluginShouldHostLayersInWindowServerChanged(m_pluginHostProxy->port(), m_pluginID, shouldHostLayersInWindowServer);
}
void NetscapePluginInstanceProxy::layerHostingModeChanged(bool hostsLayersInWindowServer, uint32_t renderContextID)
{
setRenderContextID(renderContextID);
[m_pluginView setHostsLayersInWindowServer:hostsLayersInWindowServer];
}
void NetscapePluginInstanceProxy::stopAllStreams()
{
Vector<RefPtr<HostedNetscapePluginStream> > streamsCopy;
......
......@@ -41,6 +41,7 @@ namespace WebKit {
RetainPtr<NSArray> _attributeValues;
RetainPtr<CALayer> _pluginLayer;
BOOL _hostsLayersInWindowServer;
WKSoftwareCARendererRef _softwareRenderer;
NSSize _previousSize;
......@@ -61,6 +62,7 @@ namespace WebKit {
- (CALayer *)pluginLayer;
- (BOOL)getFormValue:(NSString **)value;
- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithReason:(NPReason)reason;
- (void)setHostsLayersInWindowServer:(bool)hostsLayersInWindowServer;
@end
......
......@@ -60,6 +60,12 @@ extern "C" {
#include "WebKitPluginHost.h"
}
#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
@interface NSWindow (Details)
- (BOOL)_hostsLayersInWindowServer;
@end
#endif
@implementation WebHostedNetscapePluginView
+ (void)initialize
......@@ -101,48 +107,37 @@ extern "C" {
_attributeKeys = adoptNS([keys copy]);
_attributeValues = adoptNS([values copy]);
}
}
- (BOOL)windowHostsLayersInWindowServer
{
#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER)
return [[[self webView] window] _hostsLayersInWindowServer];
#else
return false;
#endif
}
- (BOOL)createPlugin
{
ASSERT(!_proxy);
NSString *userAgent = [[self webView] userAgentForURL:_baseURL.get()];
BOOL accleratedCompositingEnabled = false;
BOOL acceleratedCompositingEnabled = false;
#if USE(ACCELERATED_COMPOSITING)
accleratedCompositingEnabled = [[[self webView] preferences] acceleratedCompositingEnabled];
acceleratedCompositingEnabled = [[[self webView] preferences] acceleratedCompositingEnabled];
#endif
_proxy = NetscapePluginHostManager::shared().instantiatePlugin([_pluginPackage.get() path], [_pluginPackage.get() pluginHostArchitecture], [_pluginPackage.get() bundleIdentifier], self, _MIMEType.get(), _attributeKeys.get(), _attributeValues.get(), userAgent, _sourceURL.get(),
_mode == NP_FULL, _isPrivateBrowsingEnabled, accleratedCompositingEnabled);
_hostsLayersInWindowServer = [self windowHostsLayersInWindowServer];
_proxy = NetscapePluginHostManager::shared().instantiatePlugin([_pluginPackage.get() path], [_pluginPackage.get() pluginHostArchitecture], [_pluginPackage.get() bundleIdentifier], self, _MIMEType.get(), _attributeKeys.get(), _attributeValues.get(), userAgent, _sourceURL.get(),
_mode == NP_FULL, _isPrivateBrowsingEnabled, acceleratedCompositingEnabled, _hostsLayersInWindowServer);
if (!_proxy)
return NO;
if (_proxy->rendererType() == UseSoftwareRenderer)
_softwareRenderer = WKSoftwareCARendererCreate(_proxy->renderContextID());
else {
_pluginLayer = WKMakeRenderLayer(_proxy->renderContextID());
if (accleratedCompositingEnabled && _proxy->rendererType() == UseAcceleratedCompositing) {
// FIXME: This code can be shared between WebHostedNetscapePluginView and WebNetscapePluginView.
// Since this layer isn't going to be inserted into a view, we need to create another layer and flip its geometry
// in order to get the coordinate system right.
RetainPtr<CALayer> realPluginLayer = adoptNS(_pluginLayer.leakRef());
_pluginLayer = adoptNS([[CALayer alloc] init]);
_pluginLayer.get().bounds = realPluginLayer.get().bounds;
_pluginLayer.get().geometryFlipped = YES;
realPluginLayer.get().autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
[_pluginLayer.get() addSublayer:realPluginLayer.get()];
// Eagerly enter compositing mode, since we know we'll need it. This avoids firing setNeedsStyleRecalc()
// for iframes that contain composited plugins at bad times. https://bugs.webkit.org/show_bug.cgi?id=39033
core([self webFrame])->view()->enterCompositingMode();
[self element]->setNeedsStyleRecalc(SyntheticStyleChange);
} else
self.wantsLayer = YES;
}
else
[self createPluginLayer];
// Update the window frame.
_proxy->windowFrameChanged([[self window] frame]);
......@@ -150,6 +145,51 @@ extern "C" {
return YES;
}
- (void)createPluginLayer
{
BOOL acceleratedCompositingEnabled = false;
#if USE(ACCELERATED_COMPOSITING)
acceleratedCompositingEnabled = [[[self webView] preferences] acceleratedCompositingEnabled];
#endif
_pluginLayer = WKMakeRenderLayer(_proxy->renderContextID());
if (acceleratedCompositingEnabled && _proxy->rendererType() == UseAcceleratedCompositing) {
// FIXME: This code can be shared between WebHostedNetscapePluginView and WebNetscapePluginView.
// Since this layer isn't going to be inserted into a view, we need to create another layer and flip its geometry
// in order to get the coordinate system right.
RetainPtr<CALayer> realPluginLayer = adoptNS(_pluginLayer.leakRef());
_pluginLayer = adoptNS([[CALayer alloc] init]);
_pluginLayer.get().bounds = realPluginLayer.get().bounds;
_pluginLayer.get().geometryFlipped = YES;
_pluginLayer.get().backgroundColor = CGColorCreateGenericRGB(1, 0, 1, 1);
realPluginLayer.get().autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
[_pluginLayer.get() addSublayer:realPluginLayer.get()];
// Eagerly enter compositing mode, since we know we'll need it. This avoids firing setNeedsStyleRecalc()
// for iframes that contain composited plugins at bad times. https://bugs.webkit.org/show_bug.cgi?id=39033
core([self webFrame])->view()->enterCompositingMode();
[self element]->setNeedsStyleRecalc(SyntheticStyleChange);
} else
self.wantsLayer = YES;
}
- (void)setHostsLayersInWindowServer:(bool)hostsLayersInWindowServer
{
if (_proxy->rendererType() == UseSoftwareRenderer)
return;
RetainPtr<CALayer> currentSuperlayer = [_pluginLayer superlayer];
_hostsLayersInWindowServer = hostsLayersInWindowServer;
[self createPluginLayer];
[self setLayer:currentSuperlayer.get()];
}
// FIXME: This method is an ideal candidate to move up to the base class
- (CALayer *)pluginLayer
{
......@@ -215,6 +255,10 @@ extern "C" {
_previousSize = boundsInWindow.size;
_proxy->resize(boundsInWindow, visibleRectInWindow);
bool shouldHostLayersInWindowServer = [self windowHostsLayersInWindowServer];
if (_hostsLayersInWindowServer != shouldHostLayersInWindowServer)
_proxy->setShouldHostLayersInWindowServer(shouldHostLayersInWindowServer);
}
- (void)windowFocusChanged:(BOOL)hasFocus
......
......@@ -207,6 +207,11 @@ routine PCResolveURL(clientPort :mach_port_t;
target :data_t;
out resolvedURL :data_t, dealloc);
simpleroutine PCLayerHostingModeChanged(clientPort :mach_port_t;
pluginID :uint32_t;
hostsLayersInWindowServer :boolean_t;
renderContextID :uint32_t);
// Replies
simpleroutine PCInstantiatePluginReply(clientPort :mach_port_t;
pluginID :uint32_t;
......
......@@ -71,6 +71,8 @@ simpleroutine PHPluginInstanceWindowFrameChanged(pluginHostPort :mach_port_t;
height :double;
maxScreenY :double);
simpleroutine PHPluginShouldHostLayersInWindowServerChanged(pluginHostPort :mach_port_t; pluginID :uint32_t; shouldHostLayersInWindowServer :boolean_t);
simpleroutine PHPluginInstanceMouseEvent(pluginHostPort :mach_port_t;
pluginID :uint32_t;
timestamp :double;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment