summaryrefslogtreecommitdiffstats
path: root/WebKit/mac/Plugins
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-02 14:57:50 +0000
committerSteve Block <steveblock@google.com>2010-02-04 15:06:55 +0000
commitd0825bca7fe65beaee391d30da42e937db621564 (patch)
tree7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /WebKit/mac/Plugins
parent3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff)
downloadexternal_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip
external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz
external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'WebKit/mac/Plugins')
-rw-r--r--WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h2
-rw-r--r--WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm2
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h6
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm20
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h19
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm107
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h20
-rw-r--r--WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm75
-rw-r--r--WebKit/mac/Plugins/Hosted/ProxyInstance.h22
-rw-r--r--WebKit/mac/Plugins/Hosted/ProxyInstance.mm23
-rw-r--r--WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h3
-rw-r--r--WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm36
-rw-r--r--WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs10
-rw-r--r--WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs3
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginView.h4
-rw-r--r--WebKit/mac/Plugins/WebNetscapePluginView.mm65
16 files changed, 345 insertions, 72 deletions
diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
index 946c8ac..34cea32 100644
--- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
+++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h
@@ -70,6 +70,8 @@ public:
void cancelLoad(NPReason reason);
+ static NPReason reasonForError(NSError* error);
+
private:
NSError *errorForReason(NPReason) const;
void cancelLoad(NSError *);
diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
index 5c25ef7..98b5a7e 100644
--- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
+++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm
@@ -183,7 +183,7 @@ void HostedNetscapePluginStream::didReceiveResponse(NetscapePlugInStreamLoader*,
startStream([r URL], expectedContentLength, WKGetNSURLResponseLastModifiedDate(r), [r MIMEType], theHeaders);
}
-static NPReason reasonForError(NSError *error)
+NPReason HostedNetscapePluginStream::reasonForError(NSError *error)
{
if (!error)
return NPRES_DONE;
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
index 9e29062..e62d87a 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.h
@@ -43,7 +43,7 @@ class NetscapePluginHostManager {
public:
static NetscapePluginHostManager& shared();
- PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(WebNetscapePluginPackage *, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled);
+ PassRefPtr<NetscapePluginInstanceProxy> instantiatePlugin(WebNetscapePluginPackage *, WebHostedNetscapePluginView *, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled);
void pluginHostDied(NetscapePluginHostProxy*);
@@ -52,12 +52,12 @@ public:
void didCreateWindow();
private:
- NetscapePluginHostProxy* hostForPackage(WebNetscapePluginPackage *);
+ NetscapePluginHostProxy* hostForPackage(WebNetscapePluginPackage *, bool useProxiedOpenPanel);
NetscapePluginHostManager();
~NetscapePluginHostManager();
- bool spawnPluginHost(WebNetscapePluginPackage *, mach_port_t clientPort, mach_port_t& pluginHostPort, ProcessSerialNumber& pluginHostPSN);
+ bool spawnPluginHost(WebNetscapePluginPackage *, mach_port_t clientPort, mach_port_t& pluginHostPort, ProcessSerialNumber& pluginHostPSN, bool useProxiedOpenPanel);
bool initializeVendorPort();
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
index 6b36a6d..281d41f 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostManager.mm
@@ -31,7 +31,10 @@
#import "NetscapePluginInstanceProxy.h"
#import "WebLocalizableStrings.h"
#import "WebKitSystemInterface.h"
+#import "WebHostedNetscapePluginView.h"
#import "WebNetscapePluginPackage.h"
+#import "WebPreferencesPrivate.h"
+#import "WebView.h"
#import <mach/mach_port.h>
#import <servers/bootstrap.h>
#import <spawn.h>
@@ -66,7 +69,7 @@ NetscapePluginHostManager::~NetscapePluginHostManager()
{
}
-NetscapePluginHostProxy* NetscapePluginHostManager::hostForPackage(WebNetscapePluginPackage *package)
+NetscapePluginHostProxy* NetscapePluginHostManager::hostForPackage(WebNetscapePluginPackage *package, bool useProxiedOpenPanel)
{
pair<PluginHostMap::iterator, bool> result = m_pluginHosts.add(package, 0);
@@ -82,7 +85,7 @@ NetscapePluginHostProxy* NetscapePluginHostManager::hostForPackage(WebNetscapePl
mach_port_t pluginHostPort;
ProcessSerialNumber pluginHostPSN;
- if (!spawnPluginHost(package, clientPort, pluginHostPort, pluginHostPSN)) {
+ if (!spawnPluginHost(package, clientPort, pluginHostPort, pluginHostPSN, useProxiedOpenPanel)) {
mach_port_destroy(mach_task_self(), clientPort);
m_pluginHosts.remove(result.first);
return 0;
@@ -100,7 +103,7 @@ NetscapePluginHostProxy* NetscapePluginHostManager::hostForPackage(WebNetscapePl
return hostProxy;
}
-bool NetscapePluginHostManager::spawnPluginHost(WebNetscapePluginPackage *package, mach_port_t clientPort, mach_port_t& pluginHostPort, ProcessSerialNumber& pluginHostPSN)
+bool NetscapePluginHostManager::spawnPluginHost(WebNetscapePluginPackage *package, mach_port_t clientPort, mach_port_t& pluginHostPort, ProcessSerialNumber& pluginHostPSN, bool useProxiedOpenPanel)
{
if (m_pluginVendorPort == MACH_PORT_NULL) {
if (!initializeVendorPort())
@@ -120,6 +123,7 @@ bool NetscapePluginHostManager::spawnPluginHost(WebNetscapePluginPackage *packag
pluginHostAppExecutablePath, @"pluginHostPath",
[NSNumber numberWithInt:[package pluginHostArchitecture]], @"cpuType",
localization.get(), @"localization",
+ [NSNumber numberWithBool:useProxiedOpenPanel], @"useProxiedOpenPanel",
nil];
NSData *data = [NSPropertyListSerialization dataFromPropertyList:launchProperties format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
@@ -211,9 +215,10 @@ void NetscapePluginHostManager::pluginHostDied(NetscapePluginHostProxy* pluginHo
}
}
-PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(WebNetscapePluginPackage *pluginPackage, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled)
+PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePlugin(WebNetscapePluginPackage *pluginPackage, WebHostedNetscapePluginView *pluginView, NSString *mimeType, NSArray *attributeKeys, NSArray *attributeValues, NSString *userAgent, NSURL *sourceURL, bool fullFrame, bool isPrivateBrowsingEnabled, bool isAcceleratedCompositingEnabled)
{
- NetscapePluginHostProxy* hostProxy = hostForPackage(pluginPackage);
+ WebPreferences *preferences = [[pluginView webView] preferences];
+ NetscapePluginHostProxy* hostProxy = hostForPackage(pluginPackage, [preferences usesProxiedOpenPanel]);
if (!hostProxy)
return 0;
@@ -236,7 +241,8 @@ 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"];
+
NSData *data = [NSPropertyListSerialization dataFromPropertyList:properties.get() format:NSPropertyListBinaryFormat_v1_0 errorDescription:nil];
ASSERT(data);
@@ -251,7 +257,7 @@ PassRefPtr<NetscapePluginInstanceProxy> NetscapePluginHostManager::instantiatePl
pluginHostDied(hostProxy);
// Try to spawn it again.
- hostProxy = hostForPackage(pluginPackage);
+ hostProxy = hostForPackage(pluginPackage, [preferences usesProxiedOpenPanel]);
// Create a new instance.
instance = NetscapePluginInstanceProxy::create(hostProxy, pluginView, fullFrame);
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
index c3b58de..cd3729f 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h
@@ -50,10 +50,13 @@ public:
void removePluginInstance(NetscapePluginInstanceProxy*);
NetscapePluginInstanceProxy* pluginInstance(uint32_t pluginID);
-
+
bool isMenuBarVisible() const { return m_menuBarIsVisible; }
void setMenuBarVisible(bool);
-
+
+ bool isFullScreenWindowShowing() const { return m_fullScreenWindowIsShowing; }
+ void setFullScreenWindowIsShowing(bool);
+
void setModal(bool);
void applicationDidBecomeActive();
@@ -69,8 +72,11 @@ private:
void beginModal();
void endModal();
-
- static void deadNameNotificationCallback(CFMachPortRef port, void *msg, CFIndex size, void *info);
+
+ void didEnterFullScreen() const;
+ void didExitFullScreen() const;
+
+ static void deadNameNotificationCallback(CFMachPortRef, void *msg, CFIndex size, void *info);
typedef HashMap<uint32_t, RefPtr<NetscapePluginInstanceProxy> > PluginInstanceMap;
PluginInstanceMap m_instances;
@@ -90,10 +96,11 @@ private:
RetainPtr<WebPlaceholderModalWindow *> m_placeholderWindow;
unsigned m_isModal;
bool m_menuBarIsVisible;
+ bool m_fullScreenWindowIsShowing;
const ProcessSerialNumber m_pluginHostPSN;
-
+
unsigned m_processingRequests;
-
+
bool m_shouldCacheMissingPropertiesAndMethods;
};
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
index 970f5f5..0e6c9a3 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
@@ -94,6 +94,7 @@ NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_po
, m_pluginHostPort(pluginHostPort)
, m_isModal(false)
, m_menuBarIsVisible(true)
+ , m_fullScreenWindowIsShowing(false)
, m_pluginHostPSN(pluginHostPSN)
, m_processingRequests(0)
, m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods)
@@ -196,14 +197,42 @@ void NetscapePluginHostProxy::deadNameNotificationCallback(CFMachPortRef port, v
void NetscapePluginHostProxy::setMenuBarVisible(bool visible)
{
m_menuBarIsVisible = visible;
-
+
[NSMenu setMenuBarVisible:visible];
- if (visible) {
- // Make ourselves the front app
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcess(&psn);
- }
+}
+
+void NetscapePluginHostProxy::didEnterFullScreen() const
+{
+ SetFrontProcess(&m_pluginHostPSN);
+}
+
+void NetscapePluginHostProxy::didExitFullScreen() const
+{
+ // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode.
+
+ ProcessSerialNumber frontProcess;
+ GetFrontProcess(&frontProcess);
+ Boolean isSameProcess = 0;
+ SameProcess(&frontProcess, &m_pluginHostPSN, &isSameProcess);
+ if (!isSameProcess)
+ return;
+
+ ProcessSerialNumber currentProcess;
+ GetCurrentProcess(&currentProcess);
+ SetFrontProcess(&currentProcess);
+}
+
+void NetscapePluginHostProxy::setFullScreenWindowIsShowing(bool isShowing)
+{
+ if (m_fullScreenWindowIsShowing == isShowing)
+ return;
+
+ m_fullScreenWindowIsShowing = isShowing;
+ if (m_fullScreenWindowIsShowing)
+ didEnterFullScreen();
+ else
+ didExitFullScreen();
+
}
void NetscapePluginHostProxy::applicationDidBecomeActive()
@@ -875,7 +904,18 @@ kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVis
return KERN_FAILURE;
hostProxy->setMenuBarVisible(menuBarVisible);
-
+
+ return KERN_SUCCESS;
+}
+
+kern_return_t WKPCSetFullScreenWindowIsShowing(mach_port_t clientPort, boolean_t fullScreenWindowIsShowing)
+{
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ hostProxy->setFullScreenWindowIsShowing(fullScreenWindowIsShowing);
+
return KERN_SUCCESS;
}
@@ -1058,4 +1098,55 @@ kern_return_t WKPCResolveURL(mach_port_t clientPort, uint32_t pluginID, data_t u
return KERN_SUCCESS;
}
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mach_msg_type_number_t panelDataLength)
+{
+ DataDeallocator panelDataDeallocator(panelData, panelDataLength);
+
+ NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort);
+ if (!hostProxy)
+ return KERN_FAILURE;
+
+ NSOpenPanel *sheet = [NSOpenPanel openPanel];
+ NSDictionary *panelState = [NSPropertyListSerialization propertyListFromData:[NSData dataWithBytes:panelData length:panelDataLength]
+ mutabilityOption:NSPropertyListImmutable
+ format:NULL
+ errorDescription:nil];
+
+ [sheet setCanChooseFiles:[[panelState objectForKey:@"canChooseFiles"] boolValue]];
+ [sheet setCanChooseDirectories:[[panelState objectForKey:@"canChooseDirectories"] boolValue]];
+ [sheet setResolvesAliases:[[panelState objectForKey:@"resolvesAliases"] boolValue]];
+ [sheet setAllowsMultipleSelection:[[panelState objectForKey:@"allowsMultipleSelection"] boolValue]];
+ [sheet setCanCreateDirectories:[[panelState objectForKey:@"canCreateDirectories"] boolValue]];
+ [sheet setShowsHiddenFiles:[[panelState objectForKey:@"showsHiddenFiles"] boolValue]];
+ [sheet setExtensionHidden:[[panelState objectForKey:@"isExtensionHidden"] boolValue]];
+ [sheet setCanSelectHiddenExtension:[[panelState objectForKey:@"canSelectHiddenExtension"] boolValue]];
+ [sheet setAllowsOtherFileTypes:[[panelState objectForKey:@"allowsOtherFileTypes"] boolValue]];
+ [sheet setTreatsFilePackagesAsDirectories:[[panelState objectForKey:@"treatsFilePackagesAsDirectories"] boolValue]];
+ [sheet setPrompt:[panelState objectForKey:@"prompt"]];
+ [sheet setNameFieldLabel:[panelState objectForKey:@"nameFieldLabel"]];
+ [sheet setMessage:[panelState objectForKey:@"message"]];
+ [sheet setAllowedFileTypes:[panelState objectForKey:@"allowedFileTypes"]];
+ [sheet setRequiredFileType:[panelState objectForKey:@"requiredFileType"]];
+ [sheet setTitle:[panelState objectForKey:@"title"]];
+ [sheet runModal];
+
+ NSDictionary *ret = [NSDictionary dictionaryWithObjectsAndKeys:
+ [sheet filenames], @"filenames",
+ WKNoteOpenPanelFiles([sheet filenames]), @"extensions",
+ nil];
+
+ RetainPtr<NSData*> data = [NSPropertyListSerialization dataFromPropertyList:ret format:NSPropertyListBinaryFormat_v1_0 errorDescription:0];
+ ASSERT(data);
+
+ _WKPHSyncOpenPanelReply(hostProxy->port(), const_cast<char *>(static_cast<const char*>([data.get() bytes])), [data.get() length]);
+ return KERN_SUCCESS;
+}
+#else
+kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mach_msg_type_number_t panelDataLength)
+{
+ return KERN_FAILURE;
+}
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD)
+
#endif // USE(PLUGIN_HOST_PROCESS)
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
index c950ab7..2ef6b02 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -49,11 +49,13 @@ namespace JSC {
}
}
@class WebHostedNetscapePluginView;
+@class WebFrame;
namespace WebKit {
class HostedNetscapePluginStream;
class NetscapePluginHostProxy;
+class PluginRequest;
class ProxyInstance;
class NetscapePluginInstanceProxy : public RefCounted<NetscapePluginInstanceProxy> {
@@ -247,6 +249,8 @@ public:
template <typename T>
std::auto_ptr<T> waitForReply(uint32_t requestID)
{
+ willCallPluginFunction();
+
m_waitingForReply = true;
Reply* reply = processRequestsAndWaitForReply(requestID);
@@ -254,13 +258,18 @@ public:
ASSERT(reply->m_type == T::ReplyType);
m_waitingForReply = false;
+
+ didCallPluginFunction();
+
return std::auto_ptr<T>(static_cast<T*>(reply));
}
+ void webFrameDidFinishLoadWithReason(WebFrame*, NPReason);
+
private:
- NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView *, bool fullFramePlugin);
+ NetscapePluginInstanceProxy(NetscapePluginHostProxy*, WebHostedNetscapePluginView*, bool fullFramePlugin);
- NPError loadRequest(NSURLRequest *, const char* cTarget, bool currentEventIsUserGesture, uint32_t& streamID);
+ NPError loadRequest(NSURLRequest*, const char* cTarget, bool currentEventIsUserGesture, uint32_t& streamID);
class PluginRequest;
void performRequest(PluginRequest*);
@@ -274,7 +283,7 @@ private:
void requestTimerFired(WebCore::Timer<NetscapePluginInstanceProxy>*);
WebCore::Timer<NetscapePluginInstanceProxy> m_requestTimer;
- Deque<PluginRequest*> m_pluginRequests;
+ Deque<RefPtr<PluginRequest> > m_pluginRequests;
HashMap<uint32_t, RefPtr<HostedNetscapePluginStream> > m_streams;
@@ -313,6 +322,9 @@ private:
bool m_pluginIsWaitingForDraw;
RefPtr<HostedNetscapePluginStream> m_manualStream;
+
+ typedef HashMap<WebFrame*, RefPtr<PluginRequest> > FrameLoadMap;
+ FrameLoadMap m_pendingFrameLoads;
};
} // namespace WebKit
diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
index 4ae0220..187b0ea 100644
--- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
+++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -72,9 +72,20 @@ using namespace WebCore;
namespace WebKit {
-class NetscapePluginInstanceProxy::PluginRequest {
+class NetscapePluginInstanceProxy::PluginRequest : public RefCounted<NetscapePluginInstanceProxy::PluginRequest> {
public:
- PluginRequest(uint32_t requestID, NSURLRequest *request, NSString *frameName, bool allowPopups)
+ static PassRefPtr<PluginRequest> create(uint32_t requestID, NSURLRequest* request, NSString* frameName, bool allowPopups)
+ {
+ return adoptRef(new PluginRequest(requestID, request, frameName, allowPopups));
+ }
+
+ uint32_t requestID() const { return m_requestID; }
+ NSURLRequest* request() const { return m_request.get(); }
+ NSString* frameName() const { return m_frameName.get(); }
+ bool allowPopups() const { return m_allowPopups; }
+
+private:
+ PluginRequest(uint32_t requestID, NSURLRequest* request, NSString* frameName, bool allowPopups)
: m_requestID(requestID)
, m_request(request)
, m_frameName(frameName)
@@ -82,15 +93,9 @@ public:
{
}
- uint32_t requestID() const { return m_requestID; }
- NSURLRequest *request() const { return m_request.get(); }
- NSString *frameName() const { return m_frameName.get(); }
- bool allowPopups() const { return m_allowPopups; }
-
-private:
uint32_t m_requestID;
- RetainPtr<NSURLRequest *> m_request;
- RetainPtr<NSString *> m_frameName;
+ RetainPtr<NSURLRequest*> m_request;
+ RetainPtr<NSString*> m_frameName;
bool m_allowPopups;
};
@@ -212,6 +217,10 @@ void NetscapePluginInstanceProxy::destroy()
m_inDestroy = true;
+ FrameLoadMap::iterator end = m_pendingFrameLoads.end();
+ for (FrameLoadMap::iterator it = m_pendingFrameLoads.begin(); it != end; ++it)
+ [(it->first) _setInternalLoadDelegate:nil];
+
_WKPHDestroyPluginInstance(m_pluginHostProxy->port(), m_pluginID, requestID);
// If the plug-in host crashes while we're waiting for a reply, the last reference to the instance proxy
@@ -517,8 +526,33 @@ void NetscapePluginInstanceProxy::performRequest(PluginRequest* pluginRequest)
if (JSString) {
ASSERT(!frame || [m_pluginView webFrame] == frame);
evaluateJavaScript(pluginRequest);
- } else
+ } else {
[frame loadRequest:request];
+
+ // Check if another plug-in view or even this view is waiting for the frame to load.
+ // If it is, tell it that the load was cancelled because it will be anyway.
+ WebHostedNetscapePluginView *view = [frame _internalLoadDelegate];
+ if (view != nil) {
+ ASSERT([view isKindOfClass:[WebHostedNetscapePluginView class]]);
+ [view webFrame:frame didFinishLoadWithReason:NPRES_USER_BREAK];
+ }
+ m_pendingFrameLoads.set(frame, pluginRequest);
+ [frame _setInternalLoadDelegate:m_pluginView];
+ }
+
+}
+
+void NetscapePluginInstanceProxy::webFrameDidFinishLoadWithReason(WebFrame* webFrame, NPReason reason)
+{
+ FrameLoadMap::iterator it = m_pendingFrameLoads.find(webFrame);
+ ASSERT(it != m_pendingFrameLoads.end());
+
+ PluginRequest* pluginRequest = it->second.get();
+ _WKPHLoadURLNotify(m_pluginHostProxy->port(), m_pluginID, pluginRequest->requestID(), reason);
+
+ m_pendingFrameLoads.remove(it);
+
+ [webFrame _setInternalLoadDelegate:nil];
}
void NetscapePluginInstanceProxy::evaluateJavaScript(PluginRequest* pluginRequest)
@@ -557,14 +591,13 @@ void NetscapePluginInstanceProxy::requestTimerFired(Timer<NetscapePluginInstance
ASSERT(!m_pluginRequests.isEmpty());
ASSERT(m_pluginView);
- PluginRequest* request = m_pluginRequests.first();
+ RefPtr<PluginRequest> request = m_pluginRequests.first();
m_pluginRequests.removeFirst();
if (!m_pluginRequests.isEmpty())
m_requestTimer.startOneShot(0);
- performRequest(request);
- delete request;
+ performRequest(request.get());
}
NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const char* cTarget, bool allowPopups, uint32_t& requestID)
@@ -616,8 +649,8 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch
return NPERR_INVALID_PARAM;
}
- PluginRequest* pluginRequest = new PluginRequest(requestID, request, target, allowPopups);
- m_pluginRequests.append(pluginRequest);
+ RefPtr<PluginRequest> pluginRequest = PluginRequest::create(requestID, request, target, allowPopups);
+ m_pluginRequests.append(pluginRequest.release());
m_requestTimer.startOneShot(0);
} else {
RefPtr<HostedNetscapePluginStream> stream = HostedNetscapePluginStream::create(this, requestID, request);
@@ -663,7 +696,7 @@ bool NetscapePluginInstanceProxy::getWindowNPObject(uint32_t& objectID)
if (!frame)
return false;
- if (!frame->script()->isEnabled())
+ if (!frame->script()->canExecuteScripts())
objectID = 0;
else
objectID = idForObject(frame->script()->windowShell(pluginWorld())->window());
@@ -1168,7 +1201,7 @@ bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArr
if (!frame)
return false;
- if (!frame->script()->isEnabled())
+ if (!frame->script()->canExecuteScripts())
return false;
RefPtr<RootObject> rootObject = frame->script()->createRootObject(m_pluginView);
@@ -1220,6 +1253,10 @@ PassRefPtr<Instance> NetscapePluginInstanceProxy::createBindingsInstance(PassRef
if (_WKPHGetScriptableNPObject(m_pluginHostProxy->port(), m_pluginID, requestID) != KERN_SUCCESS)
return 0;
+
+ // If the plug-in host crashes while we're waiting for a reply, the last reference to the instance proxy
+ // will go away. Prevent this by protecting it here.
+ RefPtr<NetscapePluginInstanceProxy> protect(this);
auto_ptr<GetScriptableNPObjectReply> reply = waitForReply<GetScriptableNPObjectReply>(requestID);
if (!reply.get())
diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.h b/WebKit/mac/Plugins/Hosted/ProxyInstance.h
index f84c685..138a316 100644
--- a/WebKit/mac/Plugins/Hosted/ProxyInstance.h
+++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,15 +28,22 @@
#ifndef ProxyInstance_h
#define ProxyInstance_h
+<<<<<<< HEAD
#include <WebCore/Bridge.h>
#include <WebCore/runtime_root.h>
#include <wtf/OwnPtr.h>
#include "WebKitPluginHostTypes.h"
+=======
+#import "NetscapePluginInstanceProxy.h"
+#import "WebKitPluginHostTypes.h"
+#import <WebCore/Bridge.h>
+#import <WebCore/runtime_root.h>
+#import <wtf/OwnPtr.h>
+>>>>>>> webkit.org at r54127
namespace WebKit {
class ProxyClass;
-class NetscapePluginInstanceProxy;
class ProxyInstance : public JSC::Bindings::Instance {
public:
@@ -80,6 +87,17 @@ private:
JSC::JSValue invoke(JSC::ExecState*, InvokeType, uint64_t identifier, const JSC::ArgList& args);
+ template <typename T>
+ std::auto_ptr<T> waitForReply(uint32_t requestID) const {
+ std::auto_ptr<T> reply = m_instanceProxy->waitForReply<T>(requestID);
+
+ // If the instance proxy was invalidated, just return a null reply.
+ if (!m_instanceProxy)
+ return std::auto_ptr<T>();
+
+ return reply;
+ }
+
NetscapePluginInstanceProxy* m_instanceProxy;
uint32_t m_objectID;
JSC::Bindings::FieldMap m_fields;
diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
index 6be3953..1af2ef8 100644
--- a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
+++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,11 +28,10 @@
#import "ProxyInstance.h"
#import "NetscapePluginHostProxy.h"
-#import "NetscapePluginInstanceProxy.h"
-#import <runtime/PropertyNameArray.h>
#import <WebCore/IdentifierRep.h>
#import <WebCore/JSDOMWindow.h>
#import <WebCore/npruntime_impl.h>
+#import <runtime/PropertyNameArray.h>
extern "C" {
#import "WebKitPluginHost.h"
@@ -147,7 +146,7 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id
type, identifier, (char*)[arguments.get() bytes], [arguments.get() length]) != KERN_SUCCESS)
return jsUndefined();
- auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
if (!reply.get() || !reply->m_returnValue)
return jsUndefined();
@@ -175,7 +174,7 @@ bool ProxyInstance::supportsInvokeDefaultMethod() const
m_objectID) != KERN_SUCCESS)
return false;
- auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
if (reply.get() && reply->m_result)
return true;
@@ -199,7 +198,7 @@ bool ProxyInstance::supportsConstruct() const
m_objectID) != KERN_SUCCESS)
return false;
- auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
if (reply.get() && reply->m_result)
return true;
@@ -223,7 +222,7 @@ JSValue ProxyInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint
JSValue ProxyInstance::stringValue(ExecState* exec) const
{
// FIXME: Implement something sensible.
- return jsString(exec, "");
+ return jsEmptyString(exec);
}
JSValue ProxyInstance::numberValue(ExecState* exec) const
@@ -253,7 +252,7 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr
if (_WKPHNPObjectEnumerate(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID) != KERN_SUCCESS)
return;
- auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
if (!reply.get() || !reply->m_returnValue)
return;
@@ -298,7 +297,7 @@ MethodList ProxyInstance::methodsNamed(const Identifier& identifier)
m_objectID, methodName) != KERN_SUCCESS)
return MethodList();
- auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
if (!reply.get())
return MethodList();
@@ -334,7 +333,7 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier)
m_objectID, propertyName) != KERN_SUCCESS)
return 0;
- auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
if (!reply.get())
return 0;
@@ -361,7 +360,7 @@ JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) cons
m_objectID, serverIdentifier) != KERN_SUCCESS)
return jsUndefined();
- auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID);
if (!reply.get() || !reply->m_returnValue)
return jsUndefined();
@@ -387,7 +386,7 @@ void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue v
if (kr != KERN_SUCCESS)
return;
- auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = m_instanceProxy->waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
+ auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID);
}
void ProxyInstance::invalidate()
diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
index 4ff5aba..5313ff2 100644
--- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
+++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h
@@ -59,6 +59,9 @@ namespace WebKit {
element:(PassRefPtr<WebCore::HTMLPlugInElement>)element;
- (void)pluginHostDied;
+- (CALayer *)pluginLayer;
+- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithReason:(NPReason)reason;
+
@end
#endif // USE(PLUGIN_HOST_PROCESS)
diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
index 8de2aa6..9baa328 100644
--- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm
@@ -37,10 +37,10 @@
#import "WebUIDelegate.h"
#import <CoreFoundation/CoreFoundation.h>
+#import <WebCore/Bridge.h>
#import <WebCore/Frame.h>
#import <WebCore/FrameLoaderTypes.h>
#import <WebCore/HTMLPlugInElement.h>
-#import <WebCore/runtime.h>
#import <WebCore/runtime_root.h>
#import <WebCore/WebCoreObjCExtras.h>
#import <runtime/InitializeThreading.h>
@@ -102,9 +102,13 @@ extern "C" {
ASSERT(!_proxy);
NSString *userAgent = [[self webView] userAgentForURL:_baseURL.get()];
-
+ BOOL accleratedCompositingEnabled = false;
+#if USE(ACCELERATED_COMPOSITING)
+ accleratedCompositingEnabled = [[[self webView] preferences] acceleratedCompositingEnabled];
+#endif
+
_proxy = NetscapePluginHostManager::shared().instantiatePlugin(_pluginPackage.get(), self, _MIMEType.get(), _attributeKeys.get(), _attributeValues.get(), userAgent, _sourceURL.get(),
- _mode == NP_FULL, _isPrivateBrowsingEnabled);
+ _mode == NP_FULL, _isPrivateBrowsingEnabled, accleratedCompositingEnabled);
if (!_proxy)
return NO;
@@ -112,7 +116,11 @@ extern "C" {
_softwareRenderer = WKSoftwareCARendererCreate(_proxy->renderContextID());
else {
_pluginLayer = WKMakeRenderLayer(_proxy->renderContextID());
- self.wantsLayer = YES;
+
+ if (accleratedCompositingEnabled)
+ [self element]->setNeedsStyleRecalc(SyntheticStyleChange);
+ else
+ self.wantsLayer = YES;
}
// Update the window frame.
@@ -121,6 +129,12 @@ extern "C" {
return YES;
}
+// FIXME: This method is an ideal candidate to move up to the base class
+- (CALayer *)pluginLayer
+{
+ return _pluginLayer.get();
+}
+
- (void)setLayer:(CALayer *)newLayer
{
// FIXME: This should use the same implementation as WebNetscapePluginView (and move to the base class).
@@ -441,6 +455,20 @@ extern "C" {
_proxy->checkIfAllowedToLoadURLResult(checkID, (policy == PolicyUse));
}
+- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithReason:(NPReason)reason
+{
+ if (_isStarted && _proxy)
+ _proxy->webFrameDidFinishLoadWithReason(webFrame, reason);
+}
+
+- (void)webFrame:(WebFrame *)webFrame didFinishLoadWithError:(NSError *)error
+{
+ NPReason reason = NPRES_DONE;
+ if (error)
+ reason = HostedNetscapePluginStream::reasonForError(error);
+ [self webFrame:webFrame didFinishLoadWithReason:reason];
+}
+
@end
#endif
diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
index 9877d9e..0cf4005 100644
--- a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
+++ b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs
@@ -206,7 +206,7 @@ routine PCResolveURL(clientPort :mach_port_t;
url :data_t;
target :data_t;
out resolvedURL :data_t, dealloc);
-
+
// Replies
simpleroutine PCInstantiatePluginReply(clientPort :mach_port_t;
pluginID :uint32_t;
@@ -224,9 +224,15 @@ simpleroutine PCBooleanReply(clientPort :mach_port_t;
pluginID :uint32_t;
requestID :uint32_t;
result :boolean_t);
-
+
simpleroutine PCBooleanAndDataReply(clientPort :mach_port_t;
pluginID :uint32_t;
requestID :uint32_t;
returnValue :boolean_t;
result :data_t);
+
+simpleroutine PCRunSyncOpenPanel(clientPort :mach_port_t;
+ panelData :data_t);
+
+simpleroutine PCSetFullScreenWindowIsShowing(clientPort :mach_port_t;
+ isShowing :boolean_t);
diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
index 9882bb5..c7cec89 100644
--- a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
+++ b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs
@@ -240,4 +240,5 @@ simpleroutine PHPluginInstancePrivateBrowsingModeDidChange(pluginHostPort :mach_
pluginID :uint32_t;
privateBrowsingEnabled :boolean_t);
-
+simpleroutine PHSyncOpenPanelReply(pluginHostPort :mach_port_t;
+ filenames :data_t);
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.h b/WebKit/mac/Plugins/WebNetscapePluginView.h
index b2583da..2ee566e 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.h
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.h
@@ -151,7 +151,9 @@ typedef union PluginPort {
@interface WebNetscapePluginView (WebInternal)
- (BOOL)sendEvent:(void*)event isDrawRect:(BOOL)eventIsDrawRect;
- (NPEventModel)eventModel;
-
+#ifndef BUILDING_ON_TIGER
+- (CALayer *)pluginLayer;
+#endif
- (NPError)loadRequest:(NSURLRequest *)request inTarget:(NSString *)target withNotifyData:(void *)notifyData sendNotification:(BOOL)sendNotification;
- (NPError)getURLNotify:(const char *)URL target:(const char *)target notifyData:(void *)notifyData;
- (NPError)getURL:(const char *)URL target:(const char *)target;
diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm
index 3ce5e39..4a4a435 100644
--- a/WebKit/mac/Plugins/WebNetscapePluginView.mm
+++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm
@@ -81,6 +81,8 @@
#define LoginWindowDidSwitchFromUserNotification @"WebLoginWindowDidSwitchFromUserNotification"
#define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification"
+#define WKNVSupportsCompositingCoreAnimationPluginsBool 74656 /* TRUE if the browser supports hardware compositing of Core Animation plug-ins */
+static const int WKNVSilverlightFullScreenPerformanceIssueFixed = 7288546; /* TRUE if Siverlight addressed its underlying bug in <rdar://problem/7288546> */
using namespace WebCore;
using namespace WebKit;
@@ -1088,10 +1090,18 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
if (drawingModel == NPDrawingModelCoreAnimation) {
void *value = 0;
if ([_pluginPackage.get() pluginFuncs]->getvalue(plugin, NPPVpluginCoreAnimationLayer, &value) == NPERR_NO_ERROR && value) {
-
+
// The plug-in gives us a retained layer.
_pluginLayer.adoptNS((CALayer *)value);
- [self setWantsLayer:YES];
+
+ BOOL accleratedCompositingEnabled = false;
+#if USE(ACCELERATED_COMPOSITING)
+ accleratedCompositingEnabled = [[[self webView] preferences] acceleratedCompositingEnabled];
+#endif
+ if (accleratedCompositingEnabled)
+ [self element]->setNeedsStyleRecalc(SyntheticStyleChange);
+ else
+ [self setWantsLayer:YES];
LOG(Plugins, "%@ is using Core Animation drawing model with layer %@", _pluginPackage.get(), _pluginLayer.get());
}
@@ -1106,6 +1116,12 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
}
#ifndef BUILDING_ON_TIGER
+// FIXME: This method is an ideal candidate to move up to the base class
+- (CALayer *)pluginLayer
+{
+ return _pluginLayer.get();
+}
+
- (void)setLayer:(CALayer *)newLayer
{
[super setLayer:newLayer];
@@ -2057,6 +2073,13 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
*(WKNBrowserContainerCheckFuncs **)value = browserContainerCheckFuncs();
return NPERR_NO_ERROR;
}
+#if USE(ACCELERATED_COMPOSITING)
+ case WKNVSupportsCompositingCoreAnimationPluginsBool:
+ {
+ *(NPBool *)value = [[[self webView] preferences] acceleratedCompositingEnabled];
+ return NPERR_NO_ERROR;
+ }
+#endif
default:
break;
}
@@ -2297,6 +2320,39 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
return NO;
}
+// Work around Silverlight full screen performance issue by maintaining an accelerated GL pixel format.
+// We can safely remove it at some point in the future when both:
+// 1) Microsoft releases a genuine fix for 7288546.
+// 2) Enough Silverlight users update to the new Silverlight.
+// For now, we'll distinguish older broken versions of Silverlight by asking the plug-in if it resolved its full screen badness.
+- (void)_workaroundSilverlightFullScreenBug:(BOOL)initializedPlugin
+{
+#if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
+ ASSERT(_isSilverlight);
+ NPBool isFullScreenPerformanceIssueFixed = 0;
+ NPPluginFuncs *pluginFuncs = [_pluginPackage.get() pluginFuncs];
+ if (pluginFuncs->getvalue && pluginFuncs->getvalue(plugin, static_cast<NPPVariable>(WKNVSilverlightFullScreenPerformanceIssueFixed), &isFullScreenPerformanceIssueFixed) == NPERR_NO_ERROR && isFullScreenPerformanceIssueFixed)
+ return;
+
+ static CGLPixelFormatObj pixelFormatObject = 0;
+ static unsigned refCount = 0;
+
+ if (initializedPlugin) {
+ refCount++;
+ if (refCount == 1) {
+ const CGLPixelFormatAttribute attributes[] = { kCGLPFAAccelerated, static_cast<CGLPixelFormatAttribute>(0) };
+ GLint npix;
+ CGLChoosePixelFormat(attributes, &pixelFormatObject, &npix);
+ }
+ } else {
+ ASSERT(pixelFormatObject);
+ refCount--;
+ if (!refCount)
+ CGLReleasePixelFormat(pixelFormatObject);
+ }
+#endif
+}
+
- (NPError)_createPlugin
{
plugin = (NPP)calloc(1, sizeof(NPP_t));
@@ -2315,6 +2371,8 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
[[self class] setCurrentPluginView:self];
NPError npErr = [_pluginPackage.get() pluginFuncs]->newp((char *)[_MIMEType.get() cString], plugin, _mode, argsCount, cAttributes, cValues, NULL);
[[self class] setCurrentPluginView:nil];
+ if (_isSilverlight)
+ [self _workaroundSilverlightFullScreenBug:YES];
LOG(Plugins, "NPP_New: %d", npErr);
return npErr;
}
@@ -2323,6 +2381,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr)
{
PluginMainThreadScheduler::scheduler().unregisterPlugin(plugin);
+ if (_isSilverlight)
+ [self _workaroundSilverlightFullScreenBug:NO];
+
NPError npErr;
npErr = ![_pluginPackage.get() pluginFuncs]->destroy(plugin, NULL);
LOG(Plugins, "NPP_Destroy: %d", npErr);