[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:30:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 6dc6441175f76bf342ccc0d8eb37ea5e29fba40d
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jul 27 19:04:50 2010 +0000

    Rename NPJSObjectMap to NPRuntimeObjectMap
    https://bugs.webkit.org/show_bug.cgi?id=43066
    
    Reviewed by Adam Roben.
    
    * WebKit2.xcodeproj/project.pbxproj:
    * WebProcess/Plugins/NPJSObjectMap.cpp: Removed.
    * WebProcess/Plugins/NPJSObjectMap.h: Removed.
    * WebProcess/Plugins/NPRuntimeObjectMap.cpp: Added.
    (WebKit::NPJSObject::NPJSObject):
    (WebKit::NPJSObject::~NPJSObject):
    (WebKit::NPJSObject::toNPJSObject):
    (WebKit::NPJSObject::create):
    (WebKit::NPJSObject::isNPJSObject):
    (WebKit::NPJSObject::initialize):
    (WebKit::identifierFromIdentifierRep):
    (WebKit::NPJSObject::hasProperty):
    (WebKit::NPJSObject::getProperty):
    (WebKit::NPJSObject::npClass):
    (WebKit::NPJSObject::NP_Allocate):
    (WebKit::NPJSObject::NP_Deallocate):
    (WebKit::NPJSObject::NP_HasProperty):
    (WebKit::NPJSObject::NP_GetProperty):
    (WebKit::NPRuntimeObjectMap::NPRuntimeObjectMap):
    (WebKit::NPRuntimeObjectMap::getOrCreateNPObject):
    (WebKit::NPRuntimeObjectMap::invalidate):
    * WebProcess/Plugins/NPRuntimeObjectMap.h: Added.
    * WebProcess/Plugins/PluginView.cpp:
    (WebKit::PluginView::PluginView):
    (WebKit::PluginView::~PluginView):
    (WebKit::PluginView::windowScriptNPObject):
    (WebKit::PluginView::pluginElementNPObject):
    * WebProcess/Plugins/PluginView.h:
    * win/WebKit2.vcproj:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64145 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index c901c27..7a0ff79 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,40 @@
+2010-07-27  Anders Carlsson  <andersca at apple.com>
+
+        Reviewed by Adam Roben.
+
+        Rename NPJSObjectMap to NPRuntimeObjectMap
+        https://bugs.webkit.org/show_bug.cgi?id=43066
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/Plugins/NPJSObjectMap.cpp: Removed.
+        * WebProcess/Plugins/NPJSObjectMap.h: Removed.
+        * WebProcess/Plugins/NPRuntimeObjectMap.cpp: Added.
+        (WebKit::NPJSObject::NPJSObject):
+        (WebKit::NPJSObject::~NPJSObject):
+        (WebKit::NPJSObject::toNPJSObject):
+        (WebKit::NPJSObject::create):
+        (WebKit::NPJSObject::isNPJSObject):
+        (WebKit::NPJSObject::initialize):
+        (WebKit::identifierFromIdentifierRep):
+        (WebKit::NPJSObject::hasProperty):
+        (WebKit::NPJSObject::getProperty):
+        (WebKit::NPJSObject::npClass):
+        (WebKit::NPJSObject::NP_Allocate):
+        (WebKit::NPJSObject::NP_Deallocate):
+        (WebKit::NPJSObject::NP_HasProperty):
+        (WebKit::NPJSObject::NP_GetProperty):
+        (WebKit::NPRuntimeObjectMap::NPRuntimeObjectMap):
+        (WebKit::NPRuntimeObjectMap::getOrCreateNPObject):
+        (WebKit::NPRuntimeObjectMap::invalidate):
+        * WebProcess/Plugins/NPRuntimeObjectMap.h: Added.
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::PluginView::PluginView):
+        (WebKit::PluginView::~PluginView):
+        (WebKit::PluginView::windowScriptNPObject):
+        (WebKit::PluginView::pluginElementNPObject):
+        * WebProcess/Plugins/PluginView.h:
+        * win/WebKit2.vcproj:
+
 2010-07-27  Adam Roben  <aroben at apple.com>
 
         Make preferences APIs robust against web process crashes
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 683f70b..0ded45a 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -33,8 +33,8 @@
 		1A10475A110A5AD500A43ECD /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C7DE100E846E0078DEBC /* JavaScriptCore.framework */; };
 		1A1C4EC810D06099005E67E7 /* WebCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AA1C79A100E7FC50078DEBC /* WebCore.framework */; };
 		1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C648611F415B700553C19 /* WebContextMac.mm */; };
-		1A2161B011F37664008AD0F5 /* NPJSObjectMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */; };
-		1A2161B111F37664008AD0F5 /* NPJSObjectMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */; };
+		1A2161B011F37664008AD0F5 /* NPRuntimeObjectMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */; };
+		1A2161B111F37664008AD0F5 /* NPRuntimeObjectMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2161AF11F37664008AD0F5 /* NPRuntimeObjectMap.cpp */; };
 		1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */; };
 		1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */; };
 		1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A24B5F011F531E800C38269 /* MachUtilities.cpp */; };
@@ -312,8 +312,8 @@
 		0F52667311DD4A490006D33C /* WebProcessProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebProcessProxyMac.mm; sourceTree = "<group>"; };
 		1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
 		1A1C648611F415B700553C19 /* WebContextMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMac.mm; sourceTree = "<group>"; };
-		1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPJSObjectMap.h; sourceTree = "<group>"; };
-		1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPJSObjectMap.cpp; sourceTree = "<group>"; };
+		1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeObjectMap.h; sourceTree = "<group>"; };
+		1A2161AF11F37664008AD0F5 /* NPRuntimeObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeObjectMap.cpp; sourceTree = "<group>"; };
 		1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeUtilities.cpp; sourceTree = "<group>"; };
 		1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRuntimeUtilities.h; sourceTree = "<group>"; };
 		1A24B5F011F531E800C38269 /* MachUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MachUtilities.cpp; sourceTree = "<group>"; };
@@ -673,8 +673,8 @@
 			isa = PBXGroup;
 			children = (
 				1A6FB90811E66FB100DB1371 /* Netscape */,
-				1A2161AF11F37664008AD0F5 /* NPJSObjectMap.cpp */,
-				1A2161AE11F37664008AD0F5 /* NPJSObjectMap.h */,
+				1A2161AF11F37664008AD0F5 /* NPRuntimeObjectMap.cpp */,
+				1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */,
 				1A2162AE11F38971008AD0F5 /* NPRuntimeUtilities.cpp */,
 				1A2162AF11F38971008AD0F5 /* NPRuntimeUtilities.h */,
 				1A6FB7D011E651E200DB1371 /* Plugin.cpp */,
@@ -1273,7 +1273,7 @@
 				BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */,
 				BC2E6E8C1141971500A63B1E /* WorkItem.h in Headers */,
 				BC2E6E8E1141971500A63B1E /* WorkQueue.h in Headers */,
-				1A2161B011F37664008AD0F5 /* NPJSObjectMap.h in Headers */,
+				1A2161B011F37664008AD0F5 /* NPRuntimeObjectMap.h in Headers */,
 				1A2162B111F38971008AD0F5 /* NPRuntimeUtilities.h in Headers */,
 				1A24B5F311F531E800C38269 /* MachUtilities.h in Headers */,
 				E1EE53E311F8CFC000CCBEE4 /* InjectedBundlePageEditorClient.h in Headers */,
@@ -1471,7 +1471,7 @@
 				BC8699B6116AADAA002A925B /* WKView.mm in Sources */,
 				BC2E6E8D1141971500A63B1E /* WorkQueue.cpp in Sources */,
 				BC0092F8115837A300E0AE2A /* WorkQueueMac.cpp in Sources */,
-				1A2161B111F37664008AD0F5 /* NPJSObjectMap.cpp in Sources */,
+				1A2161B111F37664008AD0F5 /* NPRuntimeObjectMap.cpp in Sources */,
 				1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
 				1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */,
 				1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */,
diff --git a/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp
deleted file mode 100644
index ea4d27e..0000000
--- a/WebKit2/WebProcess/Plugins/NPJSObjectMap.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#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 {
-
-class NPJSObject : public NPObject, Noncopyable {
-public:
-    static NPJSObject* create(NPJSObjectMap* objectMap, JSObject* jsObject);
-
-private:
-    NPJSObject()
-        : m_objectMap(0)
-    {
-    }
-
-    ~NPJSObject()
-    {
-        // Remove ourselves from the map.
-        ASSERT(m_objectMap->m_objects.contains(m_jsObject.get()));
-        m_objectMap->m_objects.remove(m_jsObject.get());
-    }
-
-    static bool isNPJSObject(NPObject*);
-
-    static NPJSObject* toNPJSObject(NPObject* npObject)
-    {
-        ASSERT(isNPJSObject(npObject));
-        return static_cast<NPJSObject*>(npObject);
-    }
-
-    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;
-};
-
-NPJSObject* NPJSObject::create(NPJSObjectMap* objectMap, JSObject* jsObject)
-{
-    NPJSObject* npJSObject = toNPJSObject(createNPObject(0, npClass()));
-    npJSObject->initialize(objectMap, jsObject);
-
-    return npJSObject;
-}
-
-bool NPJSObject::isNPJSObject(NPObject* npObject)
-{
-    return npObject->_class == npClass();
-}
-
-void NPJSObject::initialize(NPJSObjectMap* objectMap, JSObject* jsObject)
-{
-    ASSERT(!m_objectMap);
-    ASSERT(!m_jsObject);
-
-    m_objectMap = objectMap;
-    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 = {
-        NP_CLASS_STRUCT_VERSION,
-        NP_Allocate,
-        NP_Deallocate,
-        0, 
-        0,
-        0,
-        0,
-        NP_HasProperty,
-        NP_GetProperty,
-        0,
-        0,
-        0,
-        0
-    };
-
-    return &npClass;
-}
-    
-NPObject* NPJSObject::NP_Allocate(NPP npp, NPClass* npClass)
-{
-    ASSERT_UNUSED(npp, !npp);
-
-    return new NPJSObject;
-}
-
-void NPJSObject::NP_Deallocate(NPObject* npObject)
-{
-    NPJSObject* npJSObject = toNPJSObject(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)
-{
-}
-
-NPObject* NPJSObjectMap::getOrCreateObject(JSObject* jsObject)
-{
-    // First, check if we already know about this object.
-    if (NPJSObject* npJSObject = m_objects.get(jsObject)) {
-        retainNPObject(npJSObject);
-        return npJSObject;
-    }
-
-    NPJSObject* npJSObject = NPJSObject::create(this, jsObject);
-    m_objects.set(jsObject, npJSObject);
-
-    return npJSObject;
-}
-
-void NPJSObjectMap::invalidate()
-{
-    Vector<NPJSObject*> npJSObjects;
-    copyValuesToVector(m_objects, npJSObjects);
-
-    // Deallocate all the object wrappers so we won't leak any JavaScript objects.
-    for (size_t i = 0; i < npJSObjects.size(); ++i)
-        deallocateNPObject(npJSObjects[i]);
-    
-    // We shouldn't have any objects left now.
-    ASSERT(m_objects.isEmpty());
-}
-
-} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/NPJSObjectMap.h b/WebKit2/WebProcess/Plugins/NPJSObjectMap.h
deleted file mode 100644
index d7b133d..0000000
--- a/WebKit2/WebProcess/Plugins/NPJSObjectMap.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 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
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef NPJSObjectWrapperMap_h
-#define NPJSObjectWrapperMap_h
-
-#include <wtf/HashMap.h>
-
-struct NPObject;
-
-namespace JSC {
-    class JSObject;
-}
-
-namespace WebKit {
-
-class NPJSObject;
-class PluginView;
-
-// A per plug-in map of NPObjects that wrap JavaScript objects.
-
-class NPJSObjectMap {
-public:
-    explicit NPJSObjectMap(PluginView*);
-
-    // Returns an NPObject that wraps the given JavaScript object. If there is already an NPObject that wraps this JSObject, it will
-    // retain it and return it.
-    NPObject* getOrCreateObject(JSC::JSObject*);
-
-    void invalidate();
-
-private:
-    friend class NPJSObject;
-    PluginView* m_pluginView;
-
-    HashMap<JSC::JSObject*, NPJSObject*> m_objects;
-};
-
-} // namespace WebKit
-
-#endif // NPJSObjectWrapperMap_h
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
new file mode 100644
index 0000000..90da8b1
--- /dev/null
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "NPRuntimeObjectMap.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 {
+
+class NPJSObject : public NPObject, Noncopyable {
+public:
+    static NPJSObject* create(NPRuntimeObjectMap* objectMap, JSObject* jsObject);
+
+private:
+    NPJSObject()
+        : m_objectMap(0)
+    {
+    }
+
+    ~NPJSObject()
+    {
+        // Remove ourselves from the map.
+        ASSERT(m_objectMap->m_objects.contains(m_jsObject.get()));
+        m_objectMap->m_objects.remove(m_jsObject.get());
+    }
+
+    static bool isNPJSObject(NPObject*);
+
+    static NPJSObject* toNPJSObject(NPObject* npObject)
+    {
+        ASSERT(isNPJSObject(npObject));
+        return static_cast<NPJSObject*>(npObject);
+    }
+
+    void initialize(NPRuntimeObjectMap*, 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);
+    
+    NPRuntimeObjectMap* m_objectMap;
+    ProtectedPtr<JSObject> m_jsObject;
+};
+
+NPJSObject* NPJSObject::create(NPRuntimeObjectMap* objectMap, JSObject* jsObject)
+{
+    NPJSObject* npJSObject = toNPJSObject(createNPObject(0, npClass()));
+    npJSObject->initialize(objectMap, jsObject);
+
+    return npJSObject;
+}
+
+bool NPJSObject::isNPJSObject(NPObject* npObject)
+{
+    return npObject->_class == npClass();
+}
+
+void NPJSObject::initialize(NPRuntimeObjectMap* objectMap, JSObject* jsObject)
+{
+    ASSERT(!m_objectMap);
+    ASSERT(!m_jsObject);
+
+    m_objectMap = objectMap;
+    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 = {
+        NP_CLASS_STRUCT_VERSION,
+        NP_Allocate,
+        NP_Deallocate,
+        0, 
+        0,
+        0,
+        0,
+        NP_HasProperty,
+        NP_GetProperty,
+        0,
+        0,
+        0,
+        0
+    };
+
+    return &npClass;
+}
+    
+NPObject* NPJSObject::NP_Allocate(NPP npp, NPClass* npClass)
+{
+    ASSERT_UNUSED(npp, !npp);
+
+    return new NPJSObject;
+}
+
+void NPJSObject::NP_Deallocate(NPObject* npObject)
+{
+    NPJSObject* npJSObject = toNPJSObject(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);
+}
+
+NPRuntimeObjectMap::NPRuntimeObjectMap(PluginView* pluginView)
+    : m_pluginView(pluginView)
+{
+}
+
+NPObject* NPRuntimeObjectMap::getOrCreateNPObject(JSObject* jsObject)
+{
+    // First, check if we already know about this object.
+    if (NPJSObject* npJSObject = m_objects.get(jsObject)) {
+        retainNPObject(npJSObject);
+        return npJSObject;
+    }
+
+    NPJSObject* npJSObject = NPJSObject::create(this, jsObject);
+    m_objects.set(jsObject, npJSObject);
+
+    return npJSObject;
+}
+
+void NPRuntimeObjectMap::invalidate()
+{
+    Vector<NPJSObject*> npJSObjects;
+    copyValuesToVector(m_objects, npJSObjects);
+
+    // Deallocate all the object wrappers so we won't leak any JavaScript objects.
+    for (size_t i = 0; i < npJSObjects.size(); ++i)
+        deallocateNPObject(npJSObjects[i]);
+    
+    // We shouldn't have any objects left now.
+    ASSERT(m_objects.isEmpty());
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
new file mode 100644
index 0000000..43d5b78
--- /dev/null
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NPJSObjectWrapperMap_h
+#define NPJSObjectWrapperMap_h
+
+#include <wtf/HashMap.h>
+
+struct NPObject;
+
+namespace JSC {
+    class JSObject;
+}
+
+namespace WebKit {
+
+class NPJSObject;
+class PluginView;
+
+// A per plug-in map of NPObjects that wrap JavaScript objects.
+
+class NPRuntimeObjectMap {
+public:
+    explicit NPRuntimeObjectMap(PluginView*);
+
+    // Returns an NPObject that wraps the given JavaScript object. If there is already an NPObject that wraps this JSObject, it will
+    // retain it and return it.
+    NPObject* getOrCreateNPObject(JSC::JSObject*);
+
+    void invalidate();
+
+private:
+    friend class NPJSObject;
+    PluginView* m_pluginView;
+
+    HashMap<JSC::JSObject*, NPJSObject*> m_objects;
+};
+
+} // namespace WebKit
+
+#endif // NPJSObjectWrapperMap_h
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 1447632..8651bb3 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -215,7 +215,7 @@ PluginView::PluginView(WebCore::HTMLPlugInElement* pluginElement, PassRefPtr<Plu
     , m_isInitialized(false)
     , m_isWaitingUntilMediaCanStart(false)
     , m_pendingURLRequestsTimer(RunLoop::main(), this, &PluginView::pendingURLRequestsTimerFired)
-    , m_npJSObjectMap(this)
+    , m_npRuntimeObjectMap(this)
 {
 }
 
@@ -232,8 +232,8 @@ PluginView::~PluginView()
     if (m_plugin && m_isInitialized)
         m_plugin->destroy();
 
-    // Invalidate the NPObject map.
-    m_npJSObjectMap.invalidate();
+    // Invalidate the object map.
+    m_npRuntimeObjectMap.invalidate();
 
     // Cancel all streams.
     cancelAllStreams();
@@ -606,7 +606,7 @@ NPObject* PluginView::windowScriptNPObject()
     // FIXME: Handle JavaScript being disabled.
     ASSERT(frame()->script()->canExecuteScripts(NotAboutToExecuteScript));
 
-    return m_npJSObjectMap.getOrCreateObject(frame()->script()->windowShell(pluginWorld())->window());
+    return m_npRuntimeObjectMap.getOrCreateNPObject(frame()->script()->windowShell(pluginWorld())->window());
 }
 
 NPObject* PluginView::pluginElementNPObject()
@@ -618,7 +618,7 @@ NPObject* PluginView::pluginElementNPObject()
     JSObject* object = frame()->script()->jsObjectForPluginElement(m_pluginElement);
     ASSERT(object);
 
-    return m_npJSObjectMap.getOrCreateObject(object);
+    return m_npRuntimeObjectMap.getOrCreateNPObject(object);
 }
 
 void PluginView::didFinishLoad(WebFrame* webFrame)
diff --git a/WebKit2/WebProcess/Plugins/PluginView.h b/WebKit2/WebProcess/Plugins/PluginView.h
index dc6b713..056c381 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.h
+++ b/WebKit2/WebProcess/Plugins/PluginView.h
@@ -26,7 +26,7 @@
 #ifndef PluginView_h
 #define PluginView_h
 
-#include "NPJSObjectMap.h"
+#include "NPRuntimeObjectMap.h"
 #include "Plugin.h"
 #include "PluginController.h"
 #include "RunLoop.h"
@@ -123,8 +123,8 @@ private:
     // Streams that the plug-in has requested to load. 
     HashMap<uint64_t, RefPtr<Stream> > m_streams;
 
-    // NPObjects wrapping JavaScript objects.
-    NPJSObjectMap m_npJSObjectMap;
+    // A map of all related NPObjects for this plug-in view.
+    NPRuntimeObjectMap m_npRuntimeObjectMap;
 };
 
 } // namespace WebKit
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index a74cc26..7a547d8 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -752,11 +752,11 @@
 				Name="Plugins"
 				>
 				<File
-					RelativePath="..\WebProcess\Plugins\NPJSObjectMap.cpp"
+					RelativePath="..\WebProcess\Plugins\NPRuntimeObjectMap.cpp"
 					>
 				</File>
 				<File
-					RelativePath="..\WebProcess\Plugins\NPJSObjectMap.h"
+					RelativePath="..\WebProcess\Plugins\NPRuntimeObjectMap.h"
 					>
 				</File>
 				<File

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list