Changeset 64167 in webkit
- Timestamp:
- Jul 27, 2010 3:20:31 PM (14 years ago)
- Location:
- trunk/WebKit2
- Files:
-
- 7 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit2/ChangeLog
r64155 r64167 20 20 Removed Mac-specific code that put the PageClient in an OwnPtr. We now 21 21 store it in a bare pointer just like on Windows. 22 23 2010-07-27 Anders Carlsson <andersca@apple.com> 24 25 Reviewed by Sam Weinig. 26 27 Add JSNPObject, a JSObject that wraps an NPObject 28 https://bugs.webkit.org/show_bug.cgi?id=43079 29 30 * WebKit2.xcodeproj/project.pbxproj: 31 Add JSNPObject.cpp and JSNPObject.h 32 33 * WebProcess/Plugins/JSNPObject.cpp: Added. 34 (WebKit::npIdentifierFromIdentifier): 35 (WebKit::JSNPObject::JSNPObject): 36 (WebKit::JSNPObject::~JSNPObject): 37 (WebKit::JSNPObject::getOwnPropertySlot): 38 Check if the NPObject has the given property. 39 40 (WebKit::JSNPObject::propertyGetter): 41 (WebKit::JSNPObject::throwInvalidAccessError): 42 * WebProcess/Plugins/JSNPObject.h: Added. 43 (WebKit::JSNPObject::createStructure): 44 * WebProcess/Plugins/NPJSObject.h: 45 46 * win/WebKit2.vcproj: 47 Add JSNPObject.cpp and JSNPObject.h 22 48 23 49 2010-07-27 Anders Carlsson <andersca@apple.com> -
trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj
r64147 r64167 74 74 1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4976611FF658E0048B464 /* NPJSObject.h */; }; 75 75 1AE4976911FF658E0048B464 /* NPJSObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE4976711FF658E0048B464 /* NPJSObject.cpp */; }; 76 1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AE4987611FF7FAA0048B464 /* JSNPObject.h */; }; 77 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */; }; 76 78 1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */; }; 77 79 1AEFCC1211D01F96008219D3 /* PluginInfoStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */; }; … … 361 363 1AE4976611FF658E0048B464 /* NPJSObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPJSObject.h; sourceTree = "<group>"; }; 362 364 1AE4976711FF658E0048B464 /* NPJSObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPJSObject.cpp; sourceTree = "<group>"; }; 365 1AE4987611FF7FAA0048B464 /* JSNPObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNPObject.h; sourceTree = "<group>"; }; 366 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNPObject.cpp; sourceTree = "<group>"; }; 363 367 1AE5B7F911E7AED200BA6767 /* NetscapePluginMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetscapePluginMac.mm; sourceTree = "<group>"; }; 364 368 1AEFCC1011D01F96008219D3 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; }; … … 678 682 children = ( 679 683 1A6FB90811E66FB100DB1371 /* Netscape */, 684 1AE4987711FF7FAA0048B464 /* JSNPObject.cpp */, 685 1AE4987611FF7FAA0048B464 /* JSNPObject.h */, 680 686 1AE4976711FF658E0048B464 /* NPJSObject.cpp */, 681 687 1AE4976611FF658E0048B464 /* NPJSObject.h */, … … 1289 1295 BCF049E711FE20F600F86A58 /* WKBundlePrivate.h in Headers */, 1290 1296 1AE4976811FF658E0048B464 /* NPJSObject.h in Headers */, 1297 1AE4987811FF7FAA0048B464 /* JSNPObject.h in Headers */, 1291 1298 ); 1292 1299 runOnlyForDeploymentPostprocessing = 0; … … 1487 1494 E1EE565611F8F71700CCBEE4 /* WKBundleNode.cpp in Sources */, 1488 1495 1AE4976911FF658E0048B464 /* NPJSObject.cpp in Sources */, 1496 1AE4987911FF7FAA0048B464 /* JSNPObject.cpp in Sources */, 1489 1497 ); 1490 1498 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebKit2/WebProcess/Plugins/JSNPObject.cpp
r64166 r64167 24 24 */ 25 25 26 #include " NPRuntimeObjectMap.h"26 #include "JSNPObject.h" 27 27 28 #include "NPJSObject.h"29 28 #include "NPRuntimeUtilities.h" 30 #include "PluginView.h" 31 #include <WebCore/Frame.h> 29 #include <JavaScriptCore/Error.h> 30 #include <JavaScriptCore/JSGlobalObject.h> 31 #include <JavaScriptCore/ObjectPrototype.h> 32 #include <WebCore/IdentifierRep.h> 32 33 34 using namespace WebCore; 33 35 using namespace JSC; 34 using namespace WebCore;35 36 36 37 namespace WebKit { 37 38 38 39 NPRuntimeObjectMap::NPRuntimeObjectMap(PluginView* pluginView) 40 : m_pluginView(pluginView) 39 static NPIdentifier npIdentifierFromIdentifier(const Identifier& identifier) 41 40 { 41 return static_cast<NPIdentifier>(IdentifierRep::get(identifier.ascii())); 42 } 43 44 JSNPObject::JSNPObject(ExecState*, JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject) 45 : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype())) 46 , m_objectMap(objectMap) 47 , m_npObject(npObject) 48 { 49 retainNPObject(m_npObject); 42 50 } 43 51 44 NPObject* NPRuntimeObjectMap::getOrCreateNPObject(JSObject* jsObject)52 JSNPObject::~JSNPObject() 45 53 { 46 // First, check if we already know about this object. 47 if (NPJSObject* npJSObject = m_objects.get(jsObject)) { 48 retainNPObject(npJSObject); 49 return npJSObject; 54 // FIXME: Implement. 55 } 56 57 bool JSNPObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 58 { 59 if (!m_npObject) { 60 throwInvalidAccessError(exec); 61 return false; 62 } 63 64 NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName); 65 if (m_npObject->_class->hasProperty && m_npObject->_class->hasProperty(m_npObject, npIdentifier)) { 66 slot.setCustom(this, propertyGetter); 67 return true; 50 68 } 51 69 52 NPJSObject* npJSObject = NPJSObject::create(this, jsObject); 53 m_objects.set(jsObject, npJSObject); 54 55 return npJSObject; 70 // FIXME: Check methods. 71 return false; 56 72 } 57 73 58 void NPRuntimeObjectMap::npJSObjectDestroyed(NPJSObject* npJSObject)74 JSValue JSNPObject::propertyGetter(ExecState*, JSValue, const Identifier&) 59 75 { 60 // Remove the object from the map. 61 ASSERT(m_objects.contains(npJSObject->jsObject())); 62 m_objects.remove(npJSObject->jsObject()); 76 // FIXME: Implement. 77 return jsUndefined(); 63 78 } 64 79 65 JSObject* NPRuntimeObjectMap::getOrCreateJSObject(NPObject*, ExecState*, JSGlobalObject*)80 JSObject* JSNPObject::throwInvalidAccessError(ExecState* exec) 66 81 { 67 // FIXME: Implement. 68 return 0; 82 return throwError(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in.")); 69 83 } 70 84 71 void NPRuntimeObjectMap::invalidate()72 {73 Vector<NPJSObject*> npJSObjects;74 copyValuesToVector(m_objects, npJSObjects);75 76 // Deallocate all the object wrappers so we won't leak any JavaScript objects.77 for (size_t i = 0; i < npJSObjects.size(); ++i)78 deallocateNPObject(npJSObjects[i]);79 80 // We shouldn't have any objects left now.81 ASSERT(m_objects.isEmpty());82 }83 84 ExecState* NPRuntimeObjectMap::globalExec() const85 {86 Frame* frame = m_pluginView->frame();87 if (!frame)88 return 0;89 90 return frame->script()->globalObject(pluginWorld())->globalExec();91 }92 93 94 85 } // namespace WebKit -
trunk/WebKit2/WebProcess/Plugins/JSNPObject.h
r64166 r64167 24 24 */ 25 25 26 #ifndef NPJSObjectWrapperMap_h27 #define NPJSObjectWrapperMap_h26 #ifndef JSNPObject_h 27 #define JSNPObject_h 28 28 29 #include < wtf/HashMap.h>29 #include <JavaScriptCore/JSObjectWithGlobalObject.h> 30 30 31 31 struct NPObject; 32 32 33 namespace JSC {34 class ExecState;35 class JSGlobalObject;36 class JSObject;37 }38 39 33 namespace WebKit { 40 34 41 class NPJSObject; 42 class PluginView; 35 class NPRuntimeObjectMap; 36 37 // JSNPObject is a JSObject that wraps an NPObject. 43 38 44 // A per plug-in map of NPObjects that wrap JavaScript objects. 45 class NPRuntimeObjectMap { 39 class JSNPObject : public JSC::JSObjectWithGlobalObject { 46 40 public: 47 explicit NPRuntimeObjectMap(PluginView*); 48 49 // Returns an NPObject that wraps the given JSObject object. If there is already an NPObject that wraps this JSObject, it will 50 // retain it and return it. 51 NPObject* getOrCreateNPObject(JSC::JSObject*); 52 53 void npJSObjectDestroyed(NPJSObject*); 54 55 // Returns a JSObject object that wraps the given NPObject. 56 JSC::JSObject* getOrCreateJSObject(NPObject*, JSC::ExecState*, JSC::JSGlobalObject*); 57 58 59 // Called when the plug-in is destroyed. Will invalidate all the NPObjects. 60 void invalidate(); 61 62 JSC::ExecState* globalExec() const; 41 JSNPObject(JSC::ExecState*, JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject); 42 ~JSNPObject(); 63 43 64 44 private: 65 PluginView* m_pluginView; 45 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSObject::StructureFlags; 46 47 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) 48 { 49 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); 50 } 66 51 67 HashMap<JSC::JSObject*, NPJSObject*> m_objects; 52 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); 53 54 static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); 55 static JSC::JSObject* throwInvalidAccessError(JSC::ExecState*); 56 57 NPRuntimeObjectMap* m_objectMap; 58 NPObject* m_npObject; 68 59 }; 69 60 70 61 } // namespace WebKit 71 62 72 #endif // NPJSObjectWrapperMap_h63 #endif // JSNPObject_h -
trunk/WebKit2/WebProcess/Plugins/NPJSObject.h
r64147 r64167 39 39 class NPRuntimeObjectMap; 40 40 41 // NPJSObject is an NPObject that wrap pes a JavaScript object.41 // NPJSObject is an NPObject that wraps a JSObject. 42 42 class NPJSObject : public NPObject, Noncopyable { 43 43 public: -
trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.cpp
r64154 r64167 26 26 #include "NPRuntimeObjectMap.h" 27 27 28 #include "JSNPObject.h" 28 29 #include "NPJSObject.h" 29 30 #include "NPRuntimeUtilities.h" … … 63 64 } 64 65 65 JSObject* NPRuntimeObjectMap::getOrCreateJSObject( NPObject*, ExecState*, JSGlobalObject*)66 JSObject* NPRuntimeObjectMap::getOrCreateJSObject(ExecState* exec, JSGlobalObject* globalObject, NPObject* npObject) 66 67 { 67 // FIXME: Implement.68 return 0;68 // FIXME: Check if we already have a wrapper for this NPObject! 69 return new (exec) JSNPObject(exec, globalObject, this, npObject); 69 70 } 70 71 … … 91 92 } 92 93 93 94 94 } // namespace WebKit -
trunk/WebKit2/WebProcess/Plugins/NPRuntimeObjectMap.h
r64154 r64167 54 54 55 55 // Returns a JSObject object that wraps the given NPObject. 56 JSC::JSObject* getOrCreateJSObject( NPObject*, JSC::ExecState*, JSC::JSGlobalObject*);56 JSC::JSObject* getOrCreateJSObject(JSC::ExecState*, JSC::JSGlobalObject*, NPObject*); 57 57 58 58 -
trunk/WebKit2/WebProcess/Plugins/PluginView.cpp
r64154 r64167 288 288 return 0; 289 289 290 JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject( scriptableNPObject, exec, globalObject);290 JSObject* jsObject = m_npRuntimeObjectMap.getOrCreateJSObject(exec, globalObject, scriptableNPObject); 291 291 releaseNPObject(scriptableNPObject); 292 292 -
trunk/WebKit2/win/WebKit2.vcproj
r64147 r64167 753 753 > 754 754 <File 755 RelativePath="..\WebProcess\Plugins\JSNPObject.cpp" 756 > 757 </File> 758 <File 759 RelativePath="..\WebProcess\Plugins\JSNPObject.h" 760 > 761 </File> 762 <File 755 763 RelativePath="..\WebProcess\Plugins\NPJSObject.cpp" 756 764 >
Note: See TracChangeset
for help on using the changeset viewer.