diff options
Diffstat (limited to 'Source/WebKit2/WebProcess/Plugins')
12 files changed, 74 insertions, 28 deletions
diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp index edf42e4d5..46eff09d6 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp @@ -51,7 +51,7 @@ JSNPMethod::JSNPMethod(JSGlobalObject* globalObject, Structure* structure, NPIde { } -void JSNPMethod::finishCreation(JSGlobalData& globalData, const UString& name) +void JSNPMethod::finishCreation(JSGlobalData& globalData, const String& name) { Base::finishCreation(globalData, name); ASSERT(inherits(&s_info)); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h index 3cb33fc41..93614d52d 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h @@ -41,7 +41,7 @@ class JSNPMethod : public JSC::InternalFunction { public: typedef JSC::InternalFunction Base; - static JSNPMethod* create(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, const JSC::UString& name, NPIdentifier npIdent) + static JSNPMethod* create(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, const String& name, NPIdentifier npIdent) { JSC::Structure* structure = createStructure(exec->globalData(), globalObject, globalObject->functionPrototype()); JSNPMethod* method = new (JSC::allocateCell<JSNPMethod>(*exec->heap())) JSNPMethod(globalObject, structure, npIdent); @@ -54,7 +54,7 @@ public: NPIdentifier npIdentifier() const { return m_npIdentifier; } protected: - void finishCreation(JSC::JSGlobalData&, const JSC::UString& name); + void finishCreation(JSC::JSGlobalData&, const String& name); private: JSNPMethod(JSC::JSGlobalObject*, JSC::Structure*, NPIdentifier); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp index 54fec0c1a..56e1a1097 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp @@ -48,7 +48,7 @@ namespace WebKit { static NPIdentifier npIdentifierFromIdentifier(PropertyName propertyName) { - UString name(propertyName.publicName()); + String name(propertyName.publicName()); if (name.isNull()) return 0; return static_cast<NPIdentifier>(IdentifierRep::get(name.utf8().data())); @@ -77,7 +77,8 @@ void JSNPObject::finishCreation(JSGlobalObject* globalObject) JSNPObject::~JSNPObject() { - ASSERT(!m_npObject); + if (m_npObject) + invalidate(); } void JSNPObject::destroy(JSCell* cell) @@ -268,6 +269,11 @@ bool JSNPObject::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName); + // Calling NPClass::invoke will call into plug-in code, and there's no telling what the plug-in can do. + // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until + // the call has finished. + NPRuntimeObjectMap::PluginProtector protector(thisObject->m_objectMap); + // First, check if the NPObject has a property with this name. if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) { slot.setCustom(thisObject, thisObject->propertyGetter); @@ -294,6 +300,11 @@ bool JSNPObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, Pro NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName); + // Calling NPClass::invoke will call into plug-in code, and there's no telling what the plug-in can do. + // (including destroying the plug-in). Because of this, we make sure to keep the plug-in alive until + // the call has finished. + NPRuntimeObjectMap::PluginProtector protector(thisObject->m_objectMap); + // First, check if the NPObject has a property with this name. if (thisObject->m_npObject->_class->hasProperty && thisObject->m_npObject->_class->hasProperty(thisObject->m_npObject, npIdentifier)) { PropertySlot slot; diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp index 1fadc177f..d21f7e410 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPJSObject.cpp @@ -243,7 +243,7 @@ bool NPJSObject::enumerate(NPIdentifier** identifiers, uint32_t* identifierCount NPIdentifier* nameIdentifiers = npnMemNewArray<NPIdentifier>(propertyNames.size()); for (size_t i = 0; i < propertyNames.size(); ++i) - nameIdentifiers[i] = static_cast<NPIdentifier>(IdentifierRep::get(propertyNames[i].ustring().utf8().data())); + nameIdentifiers[i] = static_cast<NPIdentifier>(IdentifierRep::get(propertyNames[i].string().utf8().data())); *identifiers = nameIdentifiers; *identifierCount = propertyNames.size(); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp index 358533feb..9dcd91669 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp @@ -178,7 +178,7 @@ void NPRuntimeObjectMap::convertJSValueToNPVariant(ExecState* exec, JSValue valu ASSERT_NOT_REACHED(); } -bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString, NPVariant* result) +bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result) { Strong<JSGlobalObject> globalObject(this->globalObject()->globalData(), this->globalObject()); if (!globalObject) @@ -190,7 +190,7 @@ bool NPRuntimeObjectMap::evaluate(NPObject* npObject, const String&scriptString, JSValue thisValue = getOrCreateJSObject(globalObject.get(), npObject); globalObject->globalData().timeoutChecker.start(); - JSValue resultValue = JSC::evaluate(exec, globalObject->globalScopeChain(), makeSource(UString(scriptString.impl())), thisValue); + JSValue resultValue = JSC::evaluate(exec, makeSource(scriptString), thisValue); globalObject->globalData().timeoutChecker.stop(); convertJSValueToNPVariant(exec, resultValue, *result); @@ -267,7 +267,7 @@ void NPRuntimeObjectMap::moveGlobalExceptionToExecState(ExecState* exec) { JSLockHolder lock(exec); - throwError(exec, createError(exec, stringToUString(globalExceptionString()))); + throwError(exec, createError(exec, globalExceptionString())); } globalExceptionString() = String(); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp index d40db796e..75838ec80 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp @@ -37,6 +37,7 @@ #include <WebCore/ProtectionSpace.h> #include <WebCore/SharedBuffer.h> #include <utility> +#include <wtf/text/StringBuilder.h> #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 #include "NetscapeSandboxFunctions.h" @@ -123,7 +124,7 @@ static const char* findEndOfLine(const char* bytes, unsigned length) static String capitalizeRFC822HeaderFieldName(const String& name) { bool capitalizeCharacter = true; - String result; + StringBuilder result; for (unsigned i = 0; i < name.length(); i++) { UChar c; @@ -143,7 +144,7 @@ static String capitalizeRFC822HeaderFieldName(const String& name) result.append(c); } - return result; + return result.toString(); } static HTTPHeaderMap parseRFC822HeaderFields(const char* bytes, unsigned length) @@ -203,12 +204,8 @@ static HTTPHeaderMap parseRFC822HeaderFields(const char* bytes, unsigned length) value = String(colon, endOfLine - colon); String oldValue = headerFields.get(lastHeaderKey); - if (!oldValue.isNull()) { - String tmp = oldValue; - tmp += ", "; - tmp += value; - value = tmp; - } + if (!oldValue.isNull()) + value = oldValue + ", " + value; headerFields.set(lastHeaderKey, value); } diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp index b20743213..15e7648da 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp @@ -38,7 +38,6 @@ #include <WebCore/IntRect.h> #include <WebCore/KURL.h> #include <runtime/JSObject.h> -#include <runtime/ScopeChain.h> #include <utility> #include <wtf/text/CString.h> @@ -162,7 +161,7 @@ const char* NetscapePlugin::userAgent() #if PLUGIN_ARCHITECTURE(MAC) if (quirks().contains(PluginQuirks::AppendVersion3UserAgent)) - userAgent += " Version/3.2.1"; + userAgent.append(" Version/3.2.1"); #endif m_userAgent = userAgent.utf8(); @@ -510,6 +509,20 @@ void NetscapePlugin::callSetWindow() m_hasCalledSetWindow = true; } +void NetscapePlugin::callSetWindowInvisible() +{ + NPWindow invisibleWindow = m_npWindow; + + invisibleWindow.window = 0; + invisibleWindow.clipRect.top = 0; + invisibleWindow.clipRect.left = 0; + invisibleWindow.clipRect.bottom = 0; + invisibleWindow.clipRect.right = 0; + + NPP_SetWindow(&invisibleWindow); + m_hasCalledSetWindow = true; +} + bool NetscapePlugin::shouldLoadSrcURL() { // Check if we should cancel the load diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h index 8591892b8..5f93c5747 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h @@ -147,6 +147,7 @@ private: NetscapePlugin(PassRefPtr<NetscapePluginModule> pluginModule); void callSetWindow(); + void callSetWindowInvisible(); bool shouldLoadSrcURL(); NetscapePluginStream* streamFromID(uint64_t streamID); void stopAllStreams(); diff --git a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm index 8a447df31..4edc32ff4 100644 --- a/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm +++ b/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm @@ -914,9 +914,12 @@ void NetscapePlugin::windowAndViewFramesChanged(const IntRect& windowFrameInScre } } -void NetscapePlugin::windowVisibilityChanged(bool) +void NetscapePlugin::windowVisibilityChanged(bool visible) { - // FIXME: Implement. + if (visible) + callSetWindow(); + else + callSetWindowInvisible(); } uint64_t NetscapePlugin::pluginComplexTextInputIdentifier() const diff --git a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp index cc313d2e4..3fe4d0b6c 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginProcessConnection.cpp @@ -29,7 +29,6 @@ #if ENABLE(PLUGIN_PROCESS) #include <runtime/JSObject.h> -#include <runtime/ScopeChain.h> #include "NPRemoteObjectMap.h" #include "NPRuntimeObjectMap.h" #include "PluginProcessConnectionManager.h" diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp index d07f8b79d..0a0c6b63d 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp @@ -407,10 +407,10 @@ void PluginView::webPageDestroyed() #if PLATFORM(MAC) void PluginView::setWindowIsVisible(bool windowIsVisible) { - if (!m_plugin) + if (!m_isInitialized || !m_plugin) return; - // FIXME: Implement. + m_plugin->windowVisibilityChanged(windowIsVisible); } void PluginView::setWindowIsFocused(bool windowIsFocused) @@ -550,6 +550,10 @@ JSObject* PluginView::scriptObject(JSGlobalObject* globalObject) if (m_isWaitingForSynchronousInitialization) return 0; + // The plug-in can be null here if it failed to initialize previously. + if (!m_plugin) + return 0; + // If the plug-in exists but is not initialized then we're still initializing asynchronously. // We need to wait here until initialization has either succeeded or failed. if (m_plugin->isBeingAsynchronouslyInitialized()) { @@ -558,7 +562,7 @@ JSObject* PluginView::scriptObject(JSGlobalObject* globalObject) m_isWaitingForSynchronousInitialization = false; } - // The plug-in can be null here if it failed to initialize. + // The plug-in can be null here if it still failed to initialize. if (!m_isInitialized || !m_plugin) return 0; @@ -583,6 +587,9 @@ void PluginView::privateBrowsingStateChanged(bool privateBrowsingEnabled) if (!m_isInitialized || !m_plugin) return; + if (!privateBrowsingEnabled && !frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->tree()->top()->document()->securityOrigin())) + return; + m_plugin->privateBrowsingStateChanged(privateBrowsingEnabled); } @@ -785,8 +792,19 @@ void PluginView::viewGeometryDidChange() transform.translate(scaledLocationInRootViewCoordinates.x(), scaledLocationInRootViewCoordinates.y()); transform.scale(pageScaleFactor); - // FIXME: The clip rect isn't correct. + // FIXME: The way we calculate this clip rect isn't correct. + // But it is still important to distinguish between empty and non-empty rects so we can notify the plug-in when it becomes invisible. + // Making the rect actually correct is covered by https://bugs.webkit.org/show_bug.cgi?id=95362 IntRect clipRect = boundsRect(); + + // FIXME: We can only get a semi-reliable answer from clipRectInWindowCoordinates() when the page is not scaled. + // Fixing that is tracked in <rdar://problem/9026611> - Make the Widget hierarchy play nicely with transforms, for zoomed plug-ins and iframes + if (pageScaleFactor == 1) { + clipRect = clipRectInWindowCoordinates(); + if (!clipRect.isEmpty()) + clipRect = boundsRect(); + } + m_plugin->geometryDidChange(size(), clipRect, transform); } @@ -1262,6 +1280,9 @@ bool PluginView::isPrivateBrowsingEnabled() if (!frame()) return true; + if (!frame()->document()->securityOrigin()->canAccessPluginStorage(frame()->tree()->top()->document()->securityOrigin())) + return true; + Settings* settings = frame()->settings(); if (!settings) return true; diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.h b/Source/WebKit2/WebProcess/Plugins/PluginView.h index a6a056ccd..d1d985363 100644 --- a/Source/WebKit2/WebProcess/Plugins/PluginView.h +++ b/Source/WebKit2/WebProcess/Plugins/PluginView.h @@ -40,8 +40,9 @@ // FIXME: Eventually this should move to WebCore. namespace WebCore { - class Frame; - class HTMLPlugInElement; +class Frame; +class HTMLPlugInElement; +class RenderBoxModelObject; } namespace WebKit { |