[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

andersca at apple.com andersca at apple.com
Wed Dec 22 11:36:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 5c64a175ea9a6989b2986cceba6cba5a630fcfe0
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jul 30 18:47:27 2010 +0000

    Implement NPN_InvokeDefault
    https://bugs.webkit.org/show_bug.cgi?id=43266
    
    Reviewed by Sam Weinig.
    
    WebCore:
    
    * bindings/js/JSPluginElementFunctions.cpp:
    (WebCore::isPluginElement):
    Add convenience function.
    
    (WebCore::pluginInstance):
    Call isPluginElement.
    
    (WebCore::pluginScriptObjectFromPluginViewBase):
    Given an JSHTMLElement, ask the PluginViewBase for the scriptable object.
    
    (WebCore::pluginScriptObject):
    Call isPluginElement. Call pluginScriptObjectFromPluginViewBase.
    
    (WebCore::callPlugin):
    Get the script object, assemble the arguments and call "call" directly.
    
    (WebCore::runtimeObjectGetCallData):
    Try to get the script object from the PluginViewBase first.
    
    * plugins/PluginViewBase.h:
    (WebCore::PluginViewBase::scriptObject):
    Remove ExecState parameter.
    
    WebKit2:
    
    * WebProcess/Plugins/JSNPObject.cpp:
    (WebKit::JSNPObject::JSNPObject):
    Remove ExecState parameter.
    
    (WebKit::JSNPObject::callObject):
    Call the NPClass::invokeDefault function.
    
    (WebKit::callNPJSObject):
    Call JSNPObject::callObject.
    
    (WebKit::JSNPObject::getCallData):
    Check if the NPClass has an invokeDefault function.
    
    * WebProcess/Plugins/JSNPObject.h:
    * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
    (WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
    Remove ExecState parameter.
    
    (WebKit::NPRuntimeObjectMap::convertNPVariantToJSValue):
    Remove ExecState parameter.
    
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::scriptObject):
    Remove ExecState parameter.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64365 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index d9b4187..71df55a 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-07-30  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Implement NPN_InvokeDefault
+        https://bugs.webkit.org/show_bug.cgi?id=43266
+
+        * bindings/js/JSPluginElementFunctions.cpp:
+        (WebCore::isPluginElement):
+        Add convenience function.
+
+        (WebCore::pluginInstance):
+        Call isPluginElement.
+
+        (WebCore::pluginScriptObjectFromPluginViewBase):
+        Given an JSHTMLElement, ask the PluginViewBase for the scriptable object.
+
+        (WebCore::pluginScriptObject):
+        Call isPluginElement. Call pluginScriptObjectFromPluginViewBase.
+
+        (WebCore::callPlugin):
+        Get the script object, assemble the arguments and call "call" directly.
+
+        (WebCore::runtimeObjectGetCallData):
+        Try to get the script object from the PluginViewBase first.
+
+        * plugins/PluginViewBase.h:
+        (WebCore::PluginViewBase::scriptObject):
+        Remove ExecState parameter.
+
 2010-07-30  Adam Roben  <aroben at apple.com>
 
         Roll our r64361 and r64363
diff --git a/WebCore/bindings/js/JSPluginElementFunctions.cpp b/WebCore/bindings/js/JSPluginElementFunctions.cpp
index cf43e91..893b967 100644
--- a/WebCore/bindings/js/JSPluginElementFunctions.cpp
+++ b/WebCore/bindings/js/JSPluginElementFunctions.cpp
@@ -35,12 +35,18 @@ using namespace HTMLNames;
 
 // Runtime object support code for JSHTMLAppletElement, JSHTMLEmbedElement and JSHTMLObjectElement.
 
+static inline bool isPluginElement(Node* node)
+{
+    return node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag);
+}
+
 Instance* pluginInstance(Node* node)
 {
     if (!node)
         return 0;
-    if (!(node->hasTagName(objectTag) || node->hasTagName(embedTag) || node->hasTagName(appletTag)))
+    if (!isPluginElement(node))
         return 0;
+
     HTMLPlugInElement* plugInElement = static_cast<HTMLPlugInElement*>(node);
     // The plugin element holds an owning reference, so we don't have to.
     Instance* instance = plugInElement->getInstance().get();
@@ -49,22 +55,40 @@ Instance* pluginInstance(Node* node)
     return instance;
 }
 
+static JSObject* pluginScriptObjectFromPluginViewBase(HTMLPlugInElement* pluginElement, JSGlobalObject* globalObject)
+{
+    Widget* pluginWidget = pluginElement->pluginWidget();
+    if (!pluginWidget)
+        return 0;
+    
+    if (!pluginWidget->isPluginViewBase())
+        return 0;
+
+    PluginViewBase* pluginViewBase = static_cast<PluginViewBase*>(pluginWidget);
+    return pluginViewBase->scriptObject(globalObject);
+}
+
+static JSObject* pluginScriptObjectFromPluginViewBase(JSHTMLElement* jsHTMLElement)
+{
+    HTMLElement* element = jsHTMLElement->impl();
+    if (!isPluginElement(element))
+        return 0;
+
+    HTMLPlugInElement* pluginElement = static_cast<HTMLPlugInElement*>(element);
+    return pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject());
+}
+
 JSObject* pluginScriptObject(ExecState* exec, JSHTMLElement* jsHTMLElement)
 {
     HTMLElement* element = jsHTMLElement->impl();
-    if (!(element->hasTagName(objectTag) || element->hasTagName(embedTag) || element->hasTagName(appletTag)))
+    if (!isPluginElement(element))
         return 0;
 
     HTMLPlugInElement* pluginElement = static_cast<HTMLPlugInElement*>(element);
 
     // First, see if we can ask the plug-in view for its script object.
-    if (Widget* pluginWidget = pluginElement->pluginWidget()) {
-        if (pluginWidget->isPluginViewBase()) {
-            PluginViewBase* pluginViewBase = static_cast<PluginViewBase*>(pluginWidget);
-            if (JSObject* scriptObject = pluginViewBase->scriptObject(exec, jsHTMLElement->globalObject()))
-                return scriptObject;
-        }
-    }
+    if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(pluginElement, jsHTMLElement->globalObject()))
+        return scriptObject;
 
     // Otherwise, fall back to getting the object from the instance.
 
@@ -127,15 +151,39 @@ bool runtimeObjectCustomPut(ExecState* exec, const Identifier& propertyName, JSV
 
 static EncodedJSValue JSC_HOST_CALL callPlugin(ExecState* exec)
 {
-    Instance* instance = pluginInstance(static_cast<JSHTMLElement*>(exec->callee())->impl());
-    instance->begin();
-    JSValue result = instance->invokeDefaultMethod(exec);
-    instance->end();
+    JSHTMLElement* element = static_cast<JSHTMLElement*>(exec->callee());
+
+    // Get the plug-in script object.
+    JSObject* scriptObject = pluginScriptObject(exec, element);
+    ASSERT(scriptObject);
+
+    size_t argumentCount = exec->argumentCount();
+    MarkedArgumentBuffer argumentList;
+    for (size_t i = 0; i < argumentCount; i++)
+        argumentList.append(exec->argument(i));
+
+    CallData callData;
+    CallType callType = getCallData(scriptObject, callData);
+    ASSERT(callType == CallTypeHost);
+
+    // Call the object.
+    JSValue result = call(exec, scriptObject, callType, callData, exec->hostThisValue(), argumentList);
     return JSValue::encode(result);
 }
 
 CallType runtimeObjectGetCallData(JSHTMLElement* element, CallData& callData)
 {
+    // First, ask the plug-in view base for its runtime object.
+    if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(element)) {
+        CallData scriptObjectCallData;
+        
+        if (scriptObject->getCallData(scriptObjectCallData) == CallTypeNone)
+            return CallTypeNone;
+
+        callData.native.function = callPlugin;
+        return CallTypeHost;
+    }
+    
     Instance* instance = pluginInstance(element->impl());
     if (!instance || !instance->supportsInvokeDefaultMethod())
         return CallTypeNone;
diff --git a/WebCore/plugins/PluginViewBase.h b/WebCore/plugins/PluginViewBase.h
index 3c43c00..4e5fe1a 100644
--- a/WebCore/plugins/PluginViewBase.h
+++ b/WebCore/plugins/PluginViewBase.h
@@ -44,7 +44,7 @@ public:
     virtual PlatformLayer* platformLayer() const { return 0; }
 #endif
 
-    virtual JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*) { return 0; }
+    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*) { return 0; }
 
 protected:
     PluginViewBase(PlatformWidget widget) : Widget(widget) { }
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 409ecb4..03cc956 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2010-07-30  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
+        Implement NPN_InvokeDefault
+        https://bugs.webkit.org/show_bug.cgi?id=43266
+
+        * WebProcess/Plugins/JSNPObject.cpp:
+        (WebKit::JSNPObject::JSNPObject):
+        Remove ExecState parameter.
+
+        (WebKit::JSNPObject::callObject):
+        Call the NPClass::invokeDefault function.
+
+        (WebKit::callNPJSObject):
+        Call JSNPObject::callObject.
+
+        (WebKit::JSNPObject::getCallData):
+        Check if the NPClass has an invokeDefault function.
+
+        * WebProcess/Plugins/JSNPObject.h:
+        * WebProcess/Plugins/NPRuntimeObjectMap.cpp:
+        (WebKit::NPRuntimeObjectMap::getOrCreateJSObject):
+        Remove ExecState parameter.
+
+        (WebKit::NPRuntimeObjectMap::convertNPVariantToJSValue):
+        Remove ExecState parameter.
+
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::scriptObject):
+        Remove ExecState parameter.
+
 2010-07-30  Adam Roben  <aroben at apple.com>
 
         Roll our r64361 and r64363
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.cpp b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
index 28c0821..18d0f27 100644
--- a/WebKit2/WebProcess/Plugins/JSNPObject.cpp
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
@@ -47,7 +47,7 @@ static NPIdentifier npIdentifierFromIdentifier(const Identifier& identifier)
 
 const ClassInfo JSNPObject::s_info = { "NPObject", 0, 0, 0 };
 
-JSNPObject::JSNPObject(ExecState*, JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
+JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
     : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype()))
     , m_objectMap(objectMap)
     , m_npObject(npObject)
@@ -96,6 +96,42 @@ JSValue JSNPObject::callMethod(ExecState* exec, NPIdentifier methodName)
     return propertyValue;
 }
 
+JSC::JSValue JSNPObject::callObject(JSC::ExecState* exec)
+{
+    if (!m_npObject)
+        return throwInvalidAccessError(exec);
+
+    size_t argumentCount = exec->argumentCount();
+    Vector<NPVariant, 8> arguments(argumentCount);
+    
+    // Convert all arguments to NPVariants.
+    for (size_t i = 0; i < argumentCount; ++i)
+        m_objectMap->convertJSValueToNPVariant(exec, exec->argument(i), arguments[i]);
+    
+    bool returnValue;
+    NPVariant result;
+    VOID_TO_NPVARIANT(result);
+
+    {
+        JSLock::DropAllLocks dropAllLocks(SilenceAssertionsOnly);
+        returnValue = m_npObject->_class->invokeDefault(m_npObject, arguments.data(), argumentCount, &result);
+        
+        // FIXME: Handle invokeDefault setting an exception.
+        // FIXME: Find out what happens if calling invokeDefault causes the plug-in to go away.
+    }
+
+    // Release all arguments;
+    for (size_t i = 0; i < argumentCount; ++i)
+        releaseNPVariantValue(&arguments[i]);
+
+    if (!returnValue)
+        throwError(exec, createError(exec, "Error calling method on NPObject."));
+
+    JSValue propertyValue = m_objectMap->convertNPVariantToJSValue(exec, globalObject(), result);
+    releaseNPVariantValue(&result);
+    return propertyValue;
+}
+
 JSValue JSNPObject::callConstructor(ExecState* exec)
 {
     if (!m_npObject)
@@ -128,6 +164,23 @@ JSValue JSNPObject::callConstructor(ExecState* exec)
     return value;
 }
 
+static EncodedJSValue JSC_HOST_CALL callNPJSObject(ExecState* exec)
+{
+    JSObject* object = exec->callee();
+    ASSERT(object->inherits(&JSNPObject::s_info));
+
+    return JSValue::encode(static_cast<JSNPObject*>(object)->callObject(exec));
+}
+
+JSC::CallType JSNPObject::getCallData(JSC::CallData& callData)
+{
+    if (!m_npObject || !m_npObject->_class->invokeDefault)
+        return CallTypeNone;
+
+    callData.native.function = callNPJSObject;
+    return CallTypeHost;
+}
+
 static EncodedJSValue JSC_HOST_CALL constructWithConstructor(ExecState* exec)
 {
     JSObject* constructor = exec->callee();
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.h b/WebKit2/WebProcess/Plugins/JSNPObject.h
index 9685a59..0fb8e5a 100644
--- a/WebKit2/WebProcess/Plugins/JSNPObject.h
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.h
@@ -39,10 +39,11 @@ class NPRuntimeObjectMap;
 
 class JSNPObject : public JSC::JSObjectWithGlobalObject {
 public:
-    JSNPObject(JSC::ExecState*, JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject);
+    JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject);
     ~JSNPObject();
 
     JSC::JSValue callMethod(JSC::ExecState*, NPIdentifier methodName);
+    JSC::JSValue callObject(JSC::ExecState*);
     JSC::JSValue callConstructor(JSC::ExecState*);
 
     static const JSC::ClassInfo s_info;
@@ -55,6 +56,7 @@ private:
         return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
     }
 
+    virtual JSC::CallType getCallData(JSC::CallData&);
     virtual JSC::ConstructType getConstructData(JSC::ConstructData&);
 
     virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
index d8815af..76f36c8 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
@@ -66,10 +66,10 @@ void NPRuntimeObjectMap::npJSObjectDestroyed(NPJSObject* npJSObject)
     m_objects.remove(npJSObject->jsObject());
 }
 
-JSObject* NPRuntimeObjectMap::getOrCreateJSObject(ExecState* exec, JSGlobalObject* globalObject, NPObject* npObject)
+JSObject* NPRuntimeObjectMap::getOrCreateJSObject(JSGlobalObject* globalObject, NPObject* npObject)
 {
     // FIXME: Check if we already have a wrapper for this NPObject!
-    return new (exec) JSNPObject(exec, globalObject, this, npObject);
+    return new (globalObject->globalData()) JSNPObject(globalObject, this, npObject);
 }
 
 void NPRuntimeObjectMap::jsNPObjectDestroyed(JSNPObject* jsNPObject)
@@ -107,7 +107,7 @@ JSValue NPRuntimeObjectMap::convertNPVariantToJSValue(JSC::ExecState* exec, JSC:
 
         ASSERT(globalObject);
 
-        return getOrCreateJSObject(exec, globalObject, npObject);
+        return getOrCreateJSObject(globalObject, npObject);
     }
     }
 
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
index 6f3263c..67a5860 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
@@ -56,7 +56,7 @@ public:
     void npJSObjectDestroyed(NPJSObject*);
 
     // Returns a JSObject object that wraps the given NPObject.
-    JSC::JSObject* getOrCreateJSObject(JSC::ExecState*, JSC::JSGlobalObject*, NPObject*);
+    JSC::JSObject* getOrCreateJSObject(JSC::JSGlobalObject*, NPObject*);
 
     void jsNPObjectDestroyed(JSNPObject*);
 
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 9f6b9c7..a9f28ec 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -282,13 +282,13 @@ void PluginView::initializePlugin()
     m_isInitialized = true;
 }
 
-JSObject* PluginView::scriptObject(ExecState* exec, JSGlobalObject* globalObject)
+JSObject* PluginView::scriptObject(JSGlobalObject* globalObject)
 {
     NPObject* scriptableNPObject = m_plugin->pluginScriptableNPObject();
     if (!scriptableNPObject)
         return 0;
 
-    JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(exec, globalObject, scriptableNPObject);
+    JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(globalObject, scriptableNPObject);
     releaseNPObject(scriptableNPObject);
 
     return jsObject;
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index a440115..bee8553 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -81,7 +81,7 @@ private:
     void cancelAllStreams();
 
     // WebCore::PluginViewBase
-    virtual JSC::JSObject* scriptObject(JSC::ExecState*, JSC::JSGlobalObject*);
+    virtual JSC::JSObject* scriptObject(JSC::JSGlobalObject*);
     
     // WebCore::Widget
     virtual void setFrameRect(const WebCore::IntRect&);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list