[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:31:03 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit f90e6abf9cb5e83c21d4be810d6a70cbfa3e65ed
Author: andersca at apple.com <andersca at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Jul 27 22:20:31 2010 +0000
Add JSNPObject, a JSObject that wraps an NPObject
https://bugs.webkit.org/show_bug.cgi?id=43079
Reviewed by Sam Weinig.
* WebKit2.xcodeproj/project.pbxproj:
Add JSNPObject.cpp and JSNPObject.h
* WebProcess/Plugins/JSNPObject.cpp: Added.
(WebKit::npIdentifierFromIdentifier):
(WebKit::JSNPObject::JSNPObject):
(WebKit::JSNPObject::~JSNPObject):
(WebKit::JSNPObject::getOwnPropertySlot):
Check if the NPObject has the given property.
(WebKit::JSNPObject::propertyGetter):
(WebKit::JSNPObject::throwInvalidAccessError):
* WebProcess/Plugins/JSNPObject.h: Added.
(WebKit::JSNPObject::createStructure):
* WebProcess/Plugins/NPJSObject.h:
* win/WebKit2.vcproj:
Add JSNPObject.cpp and JSNPObject.h
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64167 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 8762c83..9799355 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -24,6 +24,32 @@
Reviewed by Sam Weinig.
+ Add JSNPObject, a JSObject that wraps an NPObject
+ https://bugs.webkit.org/show_bug.cgi?id=43079
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add JSNPObject.cpp and JSNPObject.h
+
+ * WebProcess/Plugins/JSNPObject.cpp: Added.
+ (WebKit::npIdentifierFromIdentifier):
+ (WebKit::JSNPObject::JSNPObject):
+ (WebKit::JSNPObject::~JSNPObject):
+ (WebKit::JSNPObject::getOwnPropertySlot):
+ Check if the NPObject has the given property.
+
+ (WebKit::JSNPObject::propertyGetter):
+ (WebKit::JSNPObject::throwInvalidAccessError):
+ * WebProcess/Plugins/JSNPObject.h: Added.
+ (WebKit::JSNPObject::createStructure):
+ * WebProcess/Plugins/NPJSObject.h:
+
+ * win/WebKit2.vcproj:
+ Add JSNPObject.cpp and JSNPObject.h
+
+2010-07-27 Anders Carlsson <andersca at apple.com>
+
+ Reviewed by Sam Weinig.
+
Expose interface for returning the plug-in script JSObject
https://bugs.webkit.org/show_bug.cgi?id=43074
diff --git a/WebKit2/WebKit2.xcodeproj/project.pbxproj b/WebKit2/WebKit2.xcodeproj/project.pbxproj
index 7a8cbbf..8dceb0e 100644
--- a/WebKit2/WebKit2.xcodeproj/project.pbxproj
+++ b/WebKit2/WebKit2.xcodeproj/project.pbxproj
@@ -73,6 +73,8 @@
1AE117F611DBB30900981615 /* ProcessLauncher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE117F511DBB30900981615 /* ProcessLauncher.cpp */; };
1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4976611FF658E0048B464 /* NPJSObject.h */; };
1AE4976911FF658E0048B464 /* NPJSObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE4976711FF658E0048B464 /* NPJSObject.cpp */; };
+ 1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4987611FF7FAA0048B464 /* JSNPObject.h */; };
+ 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */; };
1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */; };
1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */; };
1AEFCC1311D01F96008219D3 /* PluginInfoStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */; };
@@ -360,6 +362,8 @@
1AE117F511DBB30900981615 /* ProcessLauncher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ProcessLauncher.cpp; sourceTree = "<group>"; };
1AE4976611FF658E0048B464 /* NPJSObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPJSObject.h; sourceTree = "<group>"; };
1AE4976711FF658E0048B464 /* NPJSObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPJSObject.cpp; sourceTree = "<group>"; };
+ 1AE4987611FF7FAA0048B464 /* JSNPObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNPObject.h; sourceTree = "<group>"; };
+ 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNPObject.cpp; sourceTree = "<group>"; };
1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginMac.mm; sourceTree = "<group>"; };
1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; };
1AEFCC1111D01F96008219D3 /* PluginInfoStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginInfoStore.cpp; sourceTree = "<group>"; };
@@ -677,6 +681,8 @@
isa = PBXGroup;
children = (
1A6FB90811E66FB100DB1371 /* Netscape */,
+ 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */,
+ 1AE4987611FF7FAA0048B464 /* JSNPObject.h */,
1AE4976711FF658E0048B464 /* NPJSObject.cpp */,
1AE4976611FF658E0048B464 /* NPJSObject.h */,
1A2161AF11F37664008AD0F5 /* NPRuntimeObjectMap.cpp */,
@@ -1288,6 +1294,7 @@
BCF049E611FE20F600F86A58 /* WKBundleFramePrivate.h in Headers */,
BCF049E711FE20F600F86A58 /* WKBundlePrivate.h in Headers */,
1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */,
+ 1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1486,6 +1493,7 @@
E1EE55F811F8F1BC00CCBEE4 /* WKBundleRange.cpp in Sources */,
E1EE565611F8F71700CCBEE4 /* WKBundleNode.cpp in Sources */,
1AE4976911FF658E0048B464 /* NPJSObject.cpp in Sources */,
+ 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.cpp b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
new file mode 100644
index 0000000..033fbdd
--- /dev/null
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.cpp
@@ -0,0 +1,85 @@
+/*
+ * 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 "JSNPObject.h"
+
+#include "NPRuntimeUtilities.h"
+#include <JavaScriptCore/Error.h>
+#include <JavaScriptCore/JSGlobalObject.h>
+#include <JavaScriptCore/ObjectPrototype.h>
+#include <WebCore/IdentifierRep.h>
+
+using namespace WebCore;
+using namespace JSC;
+
+namespace WebKit {
+
+static NPIdentifier npIdentifierFromIdentifier(const Identifier& identifier)
+{
+ return static_cast<NPIdentifier>(IdentifierRep::get(identifier.ascii()));
+}
+
+JSNPObject::JSNPObject(ExecState*, JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
+ : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype()))
+ , m_objectMap(objectMap)
+ , m_npObject(npObject)
+{
+ retainNPObject(m_npObject);
+}
+
+JSNPObject::~JSNPObject()
+{
+ // FIXME: Implement.
+}
+
+bool JSNPObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
+{
+ if (!m_npObject) {
+ throwInvalidAccessError(exec);
+ return false;
+ }
+
+ NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName);
+ if (m_npObject->_class->hasProperty && m_npObject->_class->hasProperty(m_npObject, npIdentifier)) {
+ slot.setCustom(this, propertyGetter);
+ return true;
+ }
+
+ // FIXME: Check methods.
+ return false;
+}
+
+JSValue JSNPObject::propertyGetter(ExecState*, JSValue, const Identifier&)
+{
+ // FIXME: Implement.
+ return jsUndefined();
+}
+
+JSObject* JSNPObject::throwInvalidAccessError(ExecState* exec)
+{
+ return throwError(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/JSNPObject.h b/WebKit2/WebProcess/Plugins/JSNPObject.h
new file mode 100644
index 0000000..6dc3617
--- /dev/null
+++ b/WebKit2/WebProcess/Plugins/JSNPObject.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 JSNPObject_h
+#define JSNPObject_h
+
+#include <JavaScriptCore/JSObjectWithGlobalObject.h>
+
+struct NPObject;
+
+namespace WebKit {
+
+class NPRuntimeObjectMap;
+
+// JSNPObject is a JSObject that wraps an NPObject.
+
+class JSNPObject : public JSC::JSObjectWithGlobalObject {
+public:
+ JSNPObject(JSC::ExecState*, JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject);
+ ~JSNPObject();
+
+private:
+ static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSObject::StructureFlags;
+
+ static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
+ }
+
+ virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&);
+
+ static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&);
+ static JSC::JSObject* throwInvalidAccessError(JSC::ExecState*);
+
+ NPRuntimeObjectMap* m_objectMap;
+ NPObject* m_npObject;
+};
+
+} // namespace WebKit
+
+#endif // JSNPObject_h
diff --git a/WebKit2/WebProcess/Plugins/NPJSObject.h b/WebKit2/WebProcess/Plugins/NPJSObject.h
index dfc6f08..ccbd0bf 100644
--- a/WebKit2/WebProcess/Plugins/NPJSObject.h
+++ b/WebKit2/WebProcess/Plugins/NPJSObject.h
@@ -38,7 +38,7 @@ namespace WebKit {
class NPRuntimeObjectMap;
-// NPJSObject is an NPObject that wrappes a JavaScript object.
+// NPJSObject is an NPObject that wraps a JSObject.
class NPJSObject : public NPObject, Noncopyable {
public:
static NPJSObject* create(NPRuntimeObjectMap* objectMap, JSC::JSObject* jsObject);
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
index d61559b..6a3cf33 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
@@ -25,6 +25,7 @@
#include "NPRuntimeObjectMap.h"
+#include "JSNPObject.h"
#include "NPJSObject.h"
#include "NPRuntimeUtilities.h"
#include "PluginView.h"
@@ -62,10 +63,10 @@ void NPRuntimeObjectMap::npJSObjectDestroyed(NPJSObject* npJSObject)
m_objects.remove(npJSObject->jsObject());
}
-JSObject* NPRuntimeObjectMap::getOrCreateJSObject(NPObject*, ExecState*, JSGlobalObject*)
+JSObject* NPRuntimeObjectMap::getOrCreateJSObject(ExecState* exec, JSGlobalObject* globalObject, NPObject* npObject)
{
- // FIXME: Implement.
- return 0;
+ // FIXME: Check if we already have a wrapper for this NPObject!
+ return new (exec) JSNPObject(exec, globalObject, this, npObject);
}
void NPRuntimeObjectMap::invalidate()
@@ -90,5 +91,4 @@ ExecState* NPRuntimeObjectMap::globalExec() const
return frame->script()->globalObject(pluginWorld())->globalExec();
}
-
} // namespace WebKit
diff --git a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
index d0d5f26..1ae60e3 100644
--- a/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
+++ b/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
@@ -53,7 +53,7 @@ public:
void npJSObjectDestroyed(NPJSObject*);
// Returns a JSObject object that wraps the given NPObject.
- JSC::JSObject* getOrCreateJSObject(NPObject*, JSC::ExecState*, JSC::JSGlobalObject*);
+ JSC::JSObject* getOrCreateJSObject(JSC::ExecState*, JSC::JSGlobalObject*, NPObject*);
// Called when the plug-in is destroyed. Will invalidate all the NPObjects.
diff --git a/WebKit2/WebProcess/Plugins/PluginView.cpp b/WebKit2/WebProcess/Plugins/PluginView.cpp
index 0344c73..b799d4a 100644
--- a/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -287,7 +287,7 @@ JSObject* PluginView::scriptObject(ExecState* exec, JSGlobalObject* globalObject
if (!scriptableNPObject)
return 0;
- JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(scriptableNPObject, exec, globalObject);
+ JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(exec, globalObject, scriptableNPObject);
releaseNPObject(scriptableNPObject);
return jsObject;
diff --git a/WebKit2/win/WebKit2.vcproj b/WebKit2/win/WebKit2.vcproj
index df7fc5a..db6818e 100755
--- a/WebKit2/win/WebKit2.vcproj
+++ b/WebKit2/win/WebKit2.vcproj
@@ -752,6 +752,14 @@
Name="Plugins"
>
<File
+ RelativePath="..\WebProcess\Plugins\JSNPObject.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\WebProcess\Plugins\JSNPObject.h"
+ >
+ </File>
+ <File
RelativePath="..\WebProcess\Plugins\NPJSObject.cpp"
>
</File>
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list