Title: [93720] trunk/Source/WebKit2
Revision
93720
Author
oli...@apple.com
Date
2011-08-24 12:34:03 -0700 (Wed, 24 Aug 2011)

Log Message

JSNPObject and JSNPMethod create their structure in their constructors
https://bugs.webkit.org/show_bug.cgi?id=66879

Reviewed by Anders Carlsson.

It's not safe to create the Structure for an object inside its constructor
so we hoist construction out into their ::create methods and move the methods
into the cpp file.

* WebProcess/Plugins/Netscape/JSNPMethod.cpp:
(WebKit::JSNPMethod::JSNPMethod):
(WebKit::JSNPMethod::create):
* WebProcess/Plugins/Netscape/JSNPMethod.h:
(WebKit::JSNPMethod::create):
* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::JSNPObject::JSNPObject):
(WebKit::JSNPObject::create):
* WebProcess/Plugins/Netscape/JSNPObject.h:
(WebKit::JSNPObject::create):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (93719 => 93720)


--- trunk/Source/WebKit2/ChangeLog	2011-08-24 19:32:01 UTC (rev 93719)
+++ trunk/Source/WebKit2/ChangeLog	2011-08-24 19:34:03 UTC (rev 93720)
@@ -1,3 +1,25 @@
+2011-08-24  Oliver Hunt  <oli...@apple.com>
+
+        JSNPObject and JSNPMethod create their structure in their constructors
+        https://bugs.webkit.org/show_bug.cgi?id=66879
+
+        Reviewed by Anders Carlsson.
+
+        It's not safe to create the Structure for an object inside its constructor
+        so we hoist construction out into their ::create methods and move the methods
+        into the cpp file.
+
+        * WebProcess/Plugins/Netscape/JSNPMethod.cpp:
+        (WebKit::JSNPMethod::JSNPMethod):
+        (WebKit::JSNPMethod::create):
+        * WebProcess/Plugins/Netscape/JSNPMethod.h:
+        (WebKit::JSNPMethod::create):
+        * WebProcess/Plugins/Netscape/JSNPObject.cpp:
+        (WebKit::JSNPObject::JSNPObject):
+        (WebKit::JSNPObject::create):
+        * WebProcess/Plugins/Netscape/JSNPObject.h:
+        (WebKit::JSNPObject::create):
+
 2011-08-24  Anders Carlsson  <ander...@apple.com>
 
         More plug-in complex text input scaffolding

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp (93719 => 93720)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp	2011-08-24 19:32:01 UTC (rev 93719)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.cpp	2011-08-24 19:34:03 UTC (rev 93720)
@@ -41,13 +41,19 @@
 
 const ClassInfo JSNPMethod::s_info = { "NPMethod", &InternalFunction::s_info, 0, 0 };
 
-JSNPMethod::JSNPMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, NPIdentifier npIdentifier)
-    : InternalFunction(&exec->globalData(), globalObject, createStructure(exec->globalData(), globalObject->functionPrototype()), name)
+JSNPMethod::JSNPMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, NPIdentifier npIdentifier, Structure* structure)
+    : InternalFunction(&exec->globalData(), globalObject, structure, name)
     , m_npIdentifier(npIdentifier)
 {
     ASSERT(inherits(&s_info));
 }
 
+JSNPMethod* JSNPMethod::create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& ident, NPIdentifier npIdent)
+{
+    JSC::Structure* structure = createStructure(exec->globalData(), globalObject->functionPrototype());
+    return new (JSC::allocateCell<JSNPMethod>(*exec->heap())) JSNPMethod(exec, globalObject, ident, npIdent, structure);
+}
+
 static EncodedJSValue JSC_HOST_CALL callMethod(ExecState* exec)
 {
     JSNPMethod* jsNPMethod = static_cast<JSNPMethod*>(exec->callee());

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h (93719 => 93720)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h	2011-08-24 19:32:01 UTC (rev 93719)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h	2011-08-24 19:34:03 UTC (rev 93720)
@@ -37,17 +37,14 @@
 public:
     typedef JSC::InternalFunction Base;
 
-    static JSNPMethod* create(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, const JSC::Identifier& ident, NPIdentifier npIdent)
-    {
-        return new (JSC::allocateCell<JSNPMethod>(*exec->heap())) JSNPMethod(exec, globalObject, ident, npIdent);
-    }
+    static JSNPMethod* create(JSC::ExecState*, JSC::JSGlobalObject*, const JSC::Identifier&, NPIdentifier);
 
     static const JSC::ClassInfo s_info;
 
     NPIdentifier npIdentifier() const { return m_npIdentifier; }
 
 private:    
-    JSNPMethod(JSC::ExecState*, JSC::JSGlobalObject*, const JSC::Identifier&, NPIdentifier);
+    JSNPMethod(JSC::ExecState*, JSC::JSGlobalObject*, const JSC::Identifier&, NPIdentifier, JSC::Structure*);
 
     static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
     {

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp (93719 => 93720)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp	2011-08-24 19:32:01 UTC (rev 93719)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp	2011-08-24 19:34:03 UTC (rev 93720)
@@ -50,8 +50,8 @@
 
 const ClassInfo JSNPObject::s_info = { "NPObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
 
-JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
-    : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->globalData(), globalObject->objectPrototype()))
+JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject, Structure* structure)
+    : JSObjectWithGlobalObject(globalObject, structure)
     , m_objectMap(objectMap)
     , m_npObject(npObject)
 {
@@ -63,6 +63,12 @@
     retainNPObject(m_npObject);
 }
 
+JSNPObject* JSNPObject::create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
+{
+    Structure* structure = createStructure(globalObject->globalData(), globalObject->objectPrototype());
+    return new (JSC::allocateCell<JSNPObject>(globalObject->globalData().heap)) JSNPObject(globalObject, objectMap, npObject, structure);
+}
+
 JSNPObject::~JSNPObject()
 {
     ASSERT(!m_npObject);

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h (93719 => 93720)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h	2011-08-24 19:32:01 UTC (rev 93719)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h	2011-08-24 19:34:03 UTC (rev 93720)
@@ -41,11 +41,7 @@
 public:
     typedef JSC::JSObjectWithGlobalObject Base;
 
-    static JSNPObject* create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
-    {
-        return new (JSC::allocateCell<JSNPObject>(globalObject->globalData().heap)) JSNPObject(globalObject, objectMap, npObject);
-    }
-
+    static JSNPObject* create(JSC::JSGlobalObject*, NPRuntimeObjectMap*, NPObject*);
     ~JSNPObject();
 
     void invalidate();
@@ -62,7 +58,7 @@
     NPObject* npObject() const { return m_npObject; }
 
 private:
-    JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap*, NPObject*);
+    JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap*, NPObject*, JSC::Structure*);
 
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags;
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to