RESOLVED FIXED Bug 27478
All DOMConstructorObjects should hold a pointer to the JSDOMGlobalObject
https://bugs.webkit.org/show_bug.cgi?id=27478
Summary All DOMConstructorObjects should hold a pointer to the JSDOMGlobalObject
Eric Seidel (no email)
Reported 2009-07-20 19:14:52 PDT
All DOMConstructorObjects should hold a pointer to the JSDOMGlobalObject All DOMConstructorObject subclasses are already passed a JSDOMGlobalObject* during construction. Only 4 of them actually hold onto this pointer though. We should make all constructor objects hold onto this pointer, and share the marking and casting code using a subclass instead of the current copy/paste code.
Attachments
patch (19.99 KB, patch)
2009-07-20 19:19 PDT, Eric Seidel (no email)
no flags
Update patch (21.58 KB, patch)
2009-07-20 20:02 PDT, Eric Seidel (no email)
abarth: review+
Eric Seidel (no email)
Comment 1 2009-07-20 19:19:09 PDT
Adam Barth
Comment 2 2009-07-20 19:29:36 PDT
+ explicit DOMObjectWithGlobalPointer(PassRefPtr<JSC::Structure> structure, JSDOMGlobalObject* globalObject) Explicit only makes sense for one-argument constructors. WebCore/bindings/js/JSMessageChannelConstructor.cpp + , m_globalObject(globalObject) Can't we remove this line now? Maciej had some suggestions in the channel. I'll wait for you to address those comments before reviewing this in more detail.
Eric Seidel (no email)
Comment 3 2009-07-20 20:02:51 PDT
Created attachment 33140 [details] Update patch
Adam Barth
Comment 4 2009-07-21 10:19:06 PDT
Comment on attachment 33140 [details] Update patch This patch is awesome. Redundant code: BE GONE! + I've added two new classes: DOMObjectWithGlobalPointer and DOMConstructorObjectInDocument. The ChangeLog uses the old class names. + class DOMConstructorWithDocument : public DOMConstructorObject { + public: + Document* document() const + { + return static_cast<Document*>(scriptExecutionContext()); + } + protected: Missing a blank line here.
Eric Seidel (no email)
Comment 5 2009-07-21 10:36:44 PDT
(In reply to comment #4) > (From update of attachment 33140 [details]) > This patch is awesome. Redundant code: BE GONE! > > + I've added two new classes: DOMObjectWithGlobalPointer and > DOMConstructorObjectInDocument. > > The ChangeLog uses the old class names. My bad. Will fix. > + class DOMConstructorWithDocument : public DOMConstructorObject { > + public: > + Document* document() const > + { > + return static_cast<Document*>(scriptExecutionContext()); > + } > + protected: > > Missing a blank line here. Where? Before protected?
Adam Barth
Comment 6 2009-07-21 10:52:31 PDT
> Where? Before protected? Yes.
Eric Seidel (no email)
Comment 7 2009-07-21 13:35:46 PDT
Committing to http://svn.webkit.org/repository/webkit/trunk ... M WebCore/ChangeLog M WebCore/bindings/js/JSAudioConstructor.cpp M WebCore/bindings/js/JSAudioConstructor.h M WebCore/bindings/js/JSDOMBinding.h M WebCore/bindings/js/JSImageConstructor.cpp M WebCore/bindings/js/JSImageConstructor.h M WebCore/bindings/js/JSMessageChannelConstructor.cpp M WebCore/bindings/js/JSMessageChannelConstructor.h M WebCore/bindings/js/JSOptionConstructor.cpp M WebCore/bindings/js/JSOptionConstructor.h M WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp M WebCore/bindings/js/JSWebKitPointConstructor.cpp M WebCore/bindings/js/JSWorkerConstructor.cpp M WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp M WebCore/bindings/js/JSXMLHttpRequestConstructor.h M WebCore/bindings/js/JSXSLTProcessorConstructor.cpp Committed r46191 M WebCore/ChangeLog M WebCore/bindings/js/JSXMLHttpRequestConstructor.h M WebCore/bindings/js/JSAudioConstructor.h M WebCore/bindings/js/JSWorkerConstructor.cpp M WebCore/bindings/js/JSOptionConstructor.h M WebCore/bindings/js/JSWebKitPointConstructor.cpp M WebCore/bindings/js/JSOptionConstructor.cpp M WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp M WebCore/bindings/js/JSImageConstructor.cpp M WebCore/bindings/js/JSDOMBinding.h M WebCore/bindings/js/JSMessageChannelConstructor.h M WebCore/bindings/js/JSAudioConstructor.cpp M WebCore/bindings/js/JSWebKitCSSMatrixConstructor.cpp M WebCore/bindings/js/JSImageConstructor.h M WebCore/bindings/js/JSXSLTProcessorConstructor.cpp M WebCore/bindings/js/JSMessageChannelConstructor.cpp r46191 = df9f155678da8d894d73bfb7bf58ab24e14fc872 (trunk) No changes between current HEAD and refs/remotes/trunk Resetting to the latest refs/remotes/trunk http://trac.webkit.org/changeset/46191
Note You need to log in before you can comment on or make changes to this bug.