[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:18:46 UTC 2010


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

    More NPRuntime work
    https://bugs.webkit.org/show_bug.cgi?id=42526
    
    Reviewed by Sam Weinig.
    
    * WebProcess/Plugins/NPJSObjectMap.cpp:
    (WebKit::identifierFromIdentifierRep):
    (WebKit::NPJSObject::hasProperty):
    Check if the JSObject has the given property.
    
    (WebKit::NPJSObject::getProperty):
    Add stubbed out function.
    
    (WebKit::NPJSObject::npClass):
    Add NP_HasProperty and NP_GetProperty.
    
    (WebKit::NPJSObject::NP_HasProperty):
    Call NPJSObject::hasProperty.
    
    (WebKit::NPJSObject::NP_GetProperty):
    Call NPJSObject::getProperty.
    
    * WebProcess/Plugins/NPRuntimeUtilities.cpp:
    (WebKit::releaseNPVariantValue):
    Release the given NPVariant.
    
    * WebProcess/Plugins/NPRuntimeUtilities.h:
    * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
    (WebKit::NPN_GetProperty):
    Call the NPClass GetProperty function.
    
    (WebKit::NPN_HasProperty):
    Call the NPClass HasProperty function.
    
    (WebKit::NPN_ReleaseVariantValue):
    Call releaseNPVariantValue.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63636 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index eebe6ea..af5890d 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -2,6 +2,45 @@
 
         Reviewed by Sam Weinig.
 
+        More NPRuntime work
+        https://bugs.webkit.org/show_bug.cgi?id=42526
+
+        * WebProcess/Plugins/NPJSObjectMap.cpp:
+        (WebKit::identifierFromIdentifierRep):
+        (WebKit::NPJSObject::hasProperty):
+        Check if the JSObject has the given property.
+
+        (WebKit::NPJSObject::getProperty):
+        Add stubbed out function.
+
+        (WebKit::NPJSObject::npClass):
+        Add NP_HasProperty and NP_GetProperty.
+
+        (WebKit::NPJSObject::NP_HasProperty):
+        Call NPJSObject::hasProperty.
+
+        (WebKit::NPJSObject::NP_GetProperty):
+        Call NPJSObject::getProperty.
+
+        * WebProcess/Plugins/NPRuntimeUtilities.cpp:
+        (WebKit::releaseNPVariantValue):
+        Release the given NPVariant.
+
+        * WebProcess/Plugins/NPRuntimeUtilities.h:
+        * WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:
+        (WebKit::NPN_GetProperty):
+        Call the NPClass GetProperty function.
+
+        (WebKit::NPN_HasProperty):
+        Call the NPClass HasProperty function.
+        
+        (WebKit::NPN_ReleaseVariantValue):
+        Call releaseNPVariantValue.
+
+2010-07-18  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Sam Weinig.
+
         Add NPJSObjectMap class
         https://bugs.webkit.org/show_bug.cgi?id=42524
 
diff --git a/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp
index f887eb6..ea4d27e 100644
--- a/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp
+++ b/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp
@@ -26,12 +26,16 @@
 #include "NPJSObjectMap.h"
 
 #include "NPRuntimeUtilities.h"
+#include "PluginView.h"
+#include <WebCore/Frame.h>
+#include <WebCore/IdentifierRep.h>
 #include <JavaScriptCore/JSObject.h>
 #include <JavaScriptCore/Protect.h>
 #include <WebKit/npruntime.h>
 #include <wtf/Noncopyable.h>
 
 using namespace JSC;
+using namespace WebCore;
 
 namespace WebKit {
 
@@ -62,10 +66,15 @@ private:
 
     void initialize(NPJSObjectMap*, JSObject* jsObject);
 
+    bool hasProperty(NPIdentifier);
+    bool getProperty(NPIdentifier, NPVariant* result);
+
     static NPClass* npClass();
     static NPObject* NP_Allocate(NPP, NPClass*);
     static void NP_Deallocate(NPObject*);
-
+    static bool NP_HasProperty(NPObject* npobj, NPIdentifier name);
+    static bool NP_GetProperty(NPObject* npobj, NPIdentifier name, NPVariant* result);
+    
     NPJSObjectMap* m_objectMap;
     ProtectedPtr<JSObject> m_jsObject;
 };
@@ -92,6 +101,42 @@ void NPJSObject::initialize(NPJSObjectMap* objectMap, JSObject* jsObject)
     m_jsObject = jsObject;
 }
 
+static Identifier identifierFromIdentifierRep(ExecState* exec, IdentifierRep* identifierRep)
+{
+    ASSERT(identifierRep->isString());
+
+    const char* string = identifierRep->string();
+    int length = strlen(string);
+
+    return Identifier(exec, String::fromUTF8WithLatin1Fallback(string, length).impl());
+}
+
+bool NPJSObject::hasProperty(NPIdentifier identifier)
+{
+    IdentifierRep* identifierRep = static_cast<IdentifierRep*>(identifier);
+    
+    Frame* frame = m_objectMap->m_pluginView->frame();
+    if (!frame)
+        return false;
+
+    bool result;
+    ExecState* exec = frame->script()->globalObject(pluginWorld())->globalExec();
+    if (identifierRep->isString())
+        result = m_jsObject->hasProperty(exec, identifierFromIdentifierRep(exec, identifierRep));
+    else
+        result = m_jsObject->hasProperty(exec, identifierRep->number());
+
+    exec->clearException();
+
+    return result;
+}
+
+bool NPJSObject::getProperty(NPIdentifier identifier, NPVariant* result)
+{
+    // FIXME: Implement.
+    return false;
+}
+
 NPClass* NPJSObject::npClass()
 {
     static NPClass npClass = {
@@ -102,8 +147,8 @@ NPClass* NPJSObject::npClass()
         0,
         0,
         0,
-        0,
-        0,
+        NP_HasProperty,
+        NP_GetProperty,
         0,
         0,
         0,
@@ -126,6 +171,16 @@ void NPJSObject::NP_Deallocate(NPObject* npObject)
     delete npJSObject;
 }
 
+bool NPJSObject::NP_HasProperty(NPObject* npObject, NPIdentifier propertyName)
+{
+    return toNPJSObject(npObject)->hasProperty(propertyName);
+}
+    
+bool NPJSObject::NP_GetProperty(NPObject* npObject, NPIdentifier propertyName, NPVariant* result)
+{
+    return toNPJSObject(npObject)->getProperty(propertyName, result);
+}
+
 NPJSObjectMap::NPJSObjectMap(PluginView* pluginView)
     : m_pluginView(pluginView)
 {
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.cpp b/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.cpp
index 4bad830..3b3ecec 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.cpp
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.cpp
@@ -81,5 +81,32 @@ void releaseNPObject(NPObject* npObject)
     if (!npObject->referenceCount)
         deallocateNPObject(npObject);
 }
+
+void releaseNPVariantValue(NPVariant* variant)
+{
+    ASSERT(variant);
     
+    switch (variant->type) {
+    case NPVariantType_Void:
+    case NPVariantType_Null:
+    case NPVariantType_Bool:
+    case NPVariantType_Int32:
+    case NPVariantType_Double:
+        // Nothing to do.
+        break;
+        
+    case NPVariantType_String:
+        free(const_cast<NPUTF8*>(variant->value.stringValue.UTF8Characters));
+        variant->value.stringValue.UTF8Characters = 0;
+        variant->value.stringValue.UTF8Length = 0;
+        break;
+    case NPVariantType_Object:
+        releaseNPObject(variant->value.objectValue);
+        variant->value.objectValue = 0;
+        break;
+    }
+
+    variant->type = NPVariantType_Void;
+}
+
 } // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.h b/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.h
index dea45f5..b2930b3 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.h
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeUtilities.h
@@ -39,6 +39,8 @@ void deallocateNPObject(NPObject*);
 void retainNPObject(NPObject*);
 void releaseNPObject(NPObject*);
 
+void releaseNPVariantValue(NPVariant*);
+
 }
 
 #endif // NPRuntimeUtilities_h
diff --git a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
index 1d7b055..0af9b57 100644
--- a/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
+++ b/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp
@@ -310,9 +310,14 @@ static bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script, NPVariant *
     return false;
 }
 
-static bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName, NPVariant *result)
+static bool NPN_GetProperty(NPP npp, NPObject *npObject, NPIdentifier propertyName, NPVariant *result)
 {
-    notImplemented();
+    if (npObject->_class->hasProperty && npObject->_class->getProperty) {
+        if (npObject->_class->hasProperty(npObject, propertyName))
+            return npObject->_class->getProperty(npObject, propertyName, result);
+    }
+    
+    VOID_TO_NPVARIANT(*result);
     return false;
 }
 
@@ -328,9 +333,11 @@ static bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyNa
     return false;
 }
 
-static bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName)
+static bool NPN_HasProperty(NPP npp, NPObject *npObject, NPIdentifier propertyName)
 {
-    notImplemented();
+    if (npObject->_class->hasProperty)
+        return npObject->_class->hasProperty(npObject, propertyName);
+
     return false;
 }
 
@@ -342,7 +349,7 @@ static bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName)
 
 static void NPN_ReleaseVariantValue(NPVariant *variant)
 {
-    notImplemented();
+    releaseNPVariantValue(variant);
 }
 
 static void NPN_SetException(NPObject *npobj, const NPUTF8 *message)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list