diff options
Diffstat (limited to 'WebKit/mac/Plugins/Hosted')
7 files changed, 115 insertions, 32 deletions
diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h index 72e845b..946c8ac 100644 --- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h +++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.h @@ -43,7 +43,7 @@ namespace WebCore { namespace WebKit { class NetscapePluginInstanceProxy; - + class HostedNetscapePluginStream : public RefCounted<HostedNetscapePluginStream> , private WebCore::NetscapePlugInStreamLoaderClient { public: @@ -55,9 +55,11 @@ public: { return adoptRef(new HostedNetscapePluginStream(instance, frameLoader)); } - + + ~HostedNetscapePluginStream(); + uint32_t streamID() const { return m_streamID; } - + void startStreamWithResponse(NSURLResponse *response); void didReceiveData(WebCore::NetscapePlugInStreamLoader*, const char* bytes, int length); void didFinishLoading(WebCore::NetscapePlugInStreamLoader*); diff --git a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm index 63e18a0..5c25ef7 100644 --- a/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm +++ b/WebKit/mac/Plugins/Hosted/HostedNetscapePluginStream.mm @@ -39,12 +39,18 @@ #import <WebCore/DocumentLoader.h> #import <WebCore/Frame.h> #import <WebCore/FrameLoader.h> +#import <WebCore/SecurityOrigin.h> #import <WebCore/WebCoreURLResponse.h> +#import <wtf/RefCountedLeakCounter.h> using namespace WebCore; namespace WebKit { +#ifndef NDEBUG +static WTF::RefCountedLeakCounter hostedNetscapePluginStreamCounter("HostedNetscapePluginStream"); +#endif + HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstanceProxy* instance, uint32_t streamID, NSURLRequest *request) : m_instance(instance) , m_streamID(streamID) @@ -53,8 +59,12 @@ HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstancePro , m_requestURL([request URL]) , m_frameLoader(0) { - if (core([instance->pluginView() webFrame])->loader()->shouldHideReferrer([request URL], core([instance->pluginView() webFrame])->loader()->outgoingReferrer())) + if (SecurityOrigin::shouldHideReferrer([request URL], core([instance->pluginView() webFrame])->loader()->outgoingReferrer())) [m_request.get() _web_setHTTPReferrer:nil]; + +#ifndef NDEBUG + hostedNetscapePluginStreamCounter.increment(); +#endif } HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstanceProxy* instance, WebCore::FrameLoader* frameLoader) @@ -63,6 +73,16 @@ HostedNetscapePluginStream::HostedNetscapePluginStream(NetscapePluginInstancePro , m_isTerminated(false) , m_frameLoader(frameLoader) { +#ifndef NDEBUG + hostedNetscapePluginStreamCounter.increment(); +#endif +} + +HostedNetscapePluginStream::~HostedNetscapePluginStream() +{ +#ifndef NDEBUG + hostedNetscapePluginStreamCounter.decrement(); +#endif } void HostedNetscapePluginStream::startStreamWithResponse(NSURLResponse *response) @@ -178,8 +198,9 @@ void HostedNetscapePluginStream::didFail(WebCore::NetscapePlugInStreamLoader*, c { if (NetscapePluginHostProxy* hostProxy = m_instance->hostProxy()) _WKPHStreamDidFail(hostProxy->port(), m_instance->pluginID(), m_streamID, reasonForError(error)); + m_instance->disconnectStream(this); } - + bool HostedNetscapePluginStream::wantsAllStreams() const { // FIXME: Implement. @@ -218,17 +239,17 @@ void HostedNetscapePluginStream::cancelLoad(NSError *error) ASSERT(!m_loader); DocumentLoader* documentLoader = m_frameLoader->activeDocumentLoader(); - ASSERT(documentLoader); - - if (documentLoader->isLoadingMainResource()) + if (documentLoader && documentLoader->isLoadingMainResource()) documentLoader->cancelMainResourceLoad(error); return; } - - if (!m_loader->isDone()) + + if (!m_loader->isDone()) { + // Cancelling the load will disconnect the stream so there's no need to do it explicitly. m_loader->cancel(error); - m_instance->disconnectStream(this); -} + } else + m_instance->disconnectStream(this); +} NSError *HostedNetscapePluginStream::pluginCancelledConnectionError() const { diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h index 1841afd..280f161 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h @@ -162,6 +162,8 @@ public: void resolveURL(const char* url, const char* target, data_t& resolvedURLData, mach_msg_type_number_t& resolvedURLLength); + void didDraw(); + // Reply structs struct Reply { enum Type { @@ -307,6 +309,7 @@ private: bool m_shouldStopSoon; uint32_t m_currentRequestID; bool m_inDestroy; + bool m_pluginIsWaitingForDraw; RefPtr<HostedNetscapePluginStream> m_manualStream; }; diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm index c01ae92..21f35e2 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm @@ -33,30 +33,32 @@ #import "WebDataSourceInternal.h" #import "WebFrameInternal.h" #import "WebHostedNetscapePluginView.h" +#import "WebKitNSStringExtras.h" #import "WebNSDataExtras.h" #import "WebNSURLExtras.h" -#import "WebKitNSStringExtras.h" #import "WebPluginRequest.h" -#import "WebViewInternal.h" #import "WebUIDelegate.h" #import "WebUIDelegatePrivate.h" - -#import <mach/mach.h> -#import <WebCore/CookieJar.h> +#import "WebViewInternal.h" +#import <JavaScriptCore/JSLock.h> +#import <JavaScriptCore/PropertyNameArray.h> #import <WebCore/CString.h> +#import <WebCore/CookieJar.h> #import <WebCore/DocumentLoader.h> #import <WebCore/Frame.h> #import <WebCore/FrameLoader.h> #import <WebCore/FrameTree.h> #import <WebCore/KURL.h> -#import <WebCore/npruntime_impl.h> -#import <WebCore/runtime_object.h> +#import <WebCore/SecurityOrigin.h> #import <WebCore/ScriptController.h> #import <WebCore/ScriptValue.h> +#import <WebCore/StringSourceProvider.h> +#import <WebCore/npruntime_impl.h> +#import <WebCore/runtime_object.h> #import <WebKitSystemInterface.h> -#import <runtime/JSLock.h> -#import <runtime/PropertyNameArray.h> +#import <mach/mach.h> #import <utility> +#import <wtf/RefCountedLeakCounter.h> extern "C" { #import "WebKitPluginClientServer.h" @@ -94,6 +96,10 @@ private: static uint32_t pluginIDCounter; +#ifndef NDEBUG +static WTF::RefCountedLeakCounter netscapePluginInstanceProxyCounter("NetscapePluginInstanceProxy"); +#endif + NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy* pluginHostProxy, WebHostedNetscapePluginView *pluginView, bool fullFramePlugin) : m_pluginHostProxy(pluginHostProxy) , m_pluginView(pluginView) @@ -108,6 +114,7 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy , m_shouldStopSoon(false) , m_currentRequestID(0) , m_inDestroy(false) + , m_pluginIsWaitingForDraw(false) { ASSERT(m_pluginView); @@ -123,6 +130,10 @@ NetscapePluginInstanceProxy::NetscapePluginInstanceProxy(NetscapePluginHostProxy } while (pluginHostProxy->pluginInstance(m_pluginID) || !m_pluginID); pluginHostProxy->addPluginInstance(this); + +#ifndef NDEBUG + netscapePluginInstanceProxyCounter.increment(); +#endif } NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy() @@ -131,6 +142,10 @@ NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy() m_pluginID = 0; deleteAllValues(m_replies); + +#ifndef NDEBUG + netscapePluginInstanceProxyCounter.decrement(); +#endif } void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect, bool sync) @@ -178,6 +193,7 @@ void NetscapePluginInstanceProxy::cleanup() (*it)->invalidate(); m_pluginView = nil; + m_manualStream = 0; } void NetscapePluginInstanceProxy::invalidate() @@ -583,7 +599,7 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch return NPERR_GENERIC_ERROR; } } else { - if (!FrameLoader::canLoad(URL, String(), core([m_pluginView webFrame])->document())) + if (!SecurityOrigin::canLoad(URL, String(), core([m_pluginView webFrame])->document())) return NPERR_GENERIC_ERROR; } @@ -1032,22 +1048,22 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat PropertyNameArray propertyNames(exec); object->getPropertyNames(exec, propertyNames); - - NSMutableArray *array = [[NSMutableArray alloc] init]; + + RetainPtr<NSMutableArray*> array(AdoptNS, [[NSMutableArray alloc] init]); for (unsigned i = 0; i < propertyNames.size(); i++) { uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().c_str())); - [array addObject:[NSNumber numberWithLongLong:methodName]]; + [array.get() addObject:[NSNumber numberWithLongLong:methodName]]; } - NSData *data = [NSPropertyListSerialization dataFromPropertyList:array format:NSPropertyListBinaryFormat_v1_0 errorDescription:0]; + NSData *data = [NSPropertyListSerialization dataFromPropertyList:array.get() format:NSPropertyListBinaryFormat_v1_0 errorDescription:0]; ASSERT(data); - + resultLength = [data length]; mig_allocate(reinterpret_cast<vm_address_t*>(&resultData), resultLength); - + memcpy(resultData, [data bytes], resultLength); - + exec->clearException(); return true; @@ -1271,9 +1287,19 @@ void NetscapePluginInstanceProxy::invalidateRect(double x, double y, double widt { ASSERT(m_pluginView); + m_pluginIsWaitingForDraw = true; [m_pluginView invalidatePluginContentRect:NSMakeRect(x, y, width, height)]; } +void NetscapePluginInstanceProxy::didDraw() +{ + if (!m_pluginIsWaitingForDraw) + return; + + m_pluginIsWaitingForDraw = false; + _WKPHPluginInstanceDidDraw(m_pluginHostProxy->port(), m_pluginID); +} + bool NetscapePluginInstanceProxy::getCookies(data_t urlData, mach_msg_type_number_t urlLength, data_t& cookiesData, mach_msg_type_number_t& cookiesLength) { ASSERT(m_pluginView); diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm index 75bc639..0b3a32f 100644 --- a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm +++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm @@ -136,6 +136,9 @@ JSC::Bindings::Class *ProxyInstance::getClass() const JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t identifier, const JSC::ArgList& args) { + if (!m_instanceProxy) + return jsUndefined(); + RetainPtr<NSData*> arguments(m_instanceProxy->marshalValues(exec, args)); uint32_t requestID = m_instanceProxy->nextRequestID(); @@ -162,6 +165,9 @@ JSValue ProxyInstance::invokeMethod(ExecState* exec, const MethodList& methodLis bool ProxyInstance::supportsInvokeDefaultMethod() const { + if (!m_instanceProxy) + return false; + uint32_t requestID = m_instanceProxy->nextRequestID(); if (_WKPHNPObjectHasInvokeDefaultMethod(m_instanceProxy->hostProxy()->port(), @@ -183,6 +189,9 @@ JSValue ProxyInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args) bool ProxyInstance::supportsConstruct() const { + if (!m_instanceProxy) + return false; + uint32_t requestID = m_instanceProxy->nextRequestID(); if (_WKPHNPObjectHasConstructMethod(m_instanceProxy->hostProxy()->port(), @@ -236,6 +245,9 @@ JSValue ProxyInstance::valueOf(ExecState* exec) const void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray) { + if (!m_instanceProxy) + return; + uint32_t requestID = m_instanceProxy->nextRequestID(); if (_WKPHNPObjectEnumerate(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID) != KERN_SUCCESS) @@ -266,6 +278,9 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr MethodList ProxyInstance::methodsNamed(const Identifier& identifier) { + if (!m_instanceProxy) + return MethodList(); + // If we already have an entry in the map, use it. MethodMap::iterator existingMapEntry = m_methods.find(identifier.ustring().rep()); if (existingMapEntry != m_methods.end()) { @@ -303,6 +318,9 @@ MethodList ProxyInstance::methodsNamed(const Identifier& identifier) Field* ProxyInstance::fieldNamed(const Identifier& identifier) { + if (!m_instanceProxy) + return 0; + // If we already have an entry in the map, use it. FieldMap::iterator existingMapEntry = m_fields.find(identifier.ustring().rep()); if (existingMapEntry != m_fields.end()) @@ -332,6 +350,9 @@ Field* ProxyInstance::fieldNamed(const Identifier& identifier) JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) const { + if (!m_instanceProxy) + return jsUndefined(); + uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier(); uint32_t requestID = m_instanceProxy->nextRequestID(); @@ -349,6 +370,9 @@ JSC::JSValue ProxyInstance::fieldValue(ExecState* exec, const Field* field) cons void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue value) const { + if (m_instanceProxy) + return; + uint64_t serverIdentifier = static_cast<const ProxyField*>(field)->serverIdentifier(); uint32_t requestID = m_instanceProxy->nextRequestID(); @@ -368,6 +392,8 @@ void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue v void ProxyInstance::invalidate() { + ASSERT(m_instanceProxy); + if (NetscapePluginHostProxy* hostProxy = m_instanceProxy->hostProxy()) _WKPHNPObjectRelease(hostProxy->port(), m_instanceProxy->pluginID(), m_objectID); diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm index 0cce014..34a2211 100644 --- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm +++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm @@ -330,9 +330,10 @@ extern "C" { { if (_proxy) { if (_softwareRenderer) { - if ([NSGraphicsContext currentContextDrawingToScreen]) + if ([NSGraphicsContext currentContextDrawingToScreen]) { WKSoftwareCARendererRender(_softwareRenderer, (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], NSRectToCGRect(rect)); - else + _proxy->didDraw(); + } else _proxy->print(reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), [self bounds].size.width, [self bounds].size.height); } diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs index 41d7498..04edf64 100644 --- a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs +++ b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs @@ -220,7 +220,7 @@ simpleroutine PHNPObjectEnumerate(pluginHostPort :mach_port_t; pluginID :uint32_t; requestID :uint32_t; objectID :uint32_t); - + // Replies simpleroutine PHBooleanReply(clientPort :mach_port_t; @@ -233,3 +233,7 @@ simpleroutine PHBooleanAndDataReply(pluginHostPort :mach_port_t; requestID :uint32_t; returnValue :boolean_t; result :data_t); + +simpleroutine PHPluginInstanceDidDraw(pluginHostPort :mach_port_t; + pluginID :uint32_t); + |