Reviewed by Darin.
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jan 2008 22:10:34 +0000 (22:10 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Jan 2008 22:10:34 +0000 (22:10 +0000)
        Pass the prototype of WebCore JS objects up the constructor chain
        rather than explicitly setting using setPrototype.  This removes many
        redundant settings of the prototype on construction.  To avoid a CG
        hazard, the prototype must be constructed before before calling the
        constructor of the JS object.

        - JS objects that inherit from DOMObject, which all bindings objects
          (except Window) do, now can't implicitly have a jsNull prototype, but
          must explicitly pass it up the construction chain.

        * bindings/js/JSCSSRuleCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSCSSValueCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSDocumentCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSEventCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSEventTargetNode.cpp:
        (WebCore::JSEventTargetNode::JSEventTargetNode):
        * bindings/js/JSEventTargetNode.h:
        * bindings/js/JSHTMLAllCollection.h:
        (WebCore::JSHTMLAllCollection::JSHTMLAllCollection):
        * bindings/js/JSHTMLAudioElementConstructor.cpp:
        (WebCore::JSHTMLAudioElementConstructor::JSHTMLAudioElementConstructor):
        * bindings/js/JSHTMLCollectionCustom.cpp:
        (WebCore::getNamedItems):
        (WebCore::toJS):
        * bindings/js/JSHTMLElementWrapperFactory.cpp:
        (WebCore::createJSHTMLWrapper):
        * bindings/js/JSHTMLFormElementCustom.cpp:
        (WebCore::JSHTMLFormElement::nameGetter):
        * bindings/js/JSHTMLInputElementBase.cpp:
        (WebCore::JSHTMLInputElementBase::JSHTMLInputElementBase):
        * bindings/js/JSHTMLInputElementBase.h:
        * bindings/js/JSHTMLOptionElementConstructor.cpp:
        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
        * bindings/js/JSLocation.cpp:
        (WebCore::JSLocation::JSLocation):
        * bindings/js/JSLocation.h:
        * bindings/js/JSNamedNodesCollection.cpp:
        (WebCore::JSNamedNodesCollection::JSNamedNodesCollection):
        * bindings/js/JSNamedNodesCollection.h:
        * bindings/js/JSNodeCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSSVGElementWrapperFactory.cpp:
        (WebCore::createJSSVGWrapper):
        * bindings/js/JSSVGPathSegCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSStyleSheetCustom.cpp:
        (WebCore::toJS):
        * bindings/js/JSXMLHttpRequest.cpp:
        (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
        (KJS::JSXMLHttpRequestConstructorImp::construct):
        (KJS::JSXMLHttpRequest::JSXMLHttpRequest):
        * bindings/js/JSXMLHttpRequest.h:
        * bindings/js/JSXSLTProcessor.cpp:
        (KJS::JSXSLTProcessor::JSXSLTProcessor):
        (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
        (KJS::XSLTProcessorConstructorImp::implementsConstruct):
        (KJS::XSLTProcessorConstructorImp::construct):
        * bindings/js/JSXSLTProcessor.h:
        * bindings/js/kjs_binding.h:
        (KJS::DOMObject::DOMObject):
        (KJS::cacheDOMObject):
        (KJS::cacheSVGDOMObject):
        * bindings/js/kjs_css.cpp:
        (WebCore::JSRGBColor::JSRGBColor):
        (WebCore::getJSRGBColor):
        * bindings/js/kjs_css.h:
        * bindings/js/kjs_events.cpp:
        (WebCore::JSClipboard::JSClipboard):
        (WebCore::toJS):
        * bindings/js/kjs_events.h:
        * bindings/js/kjs_html.cpp:
        (WebCore::ImageConstructorImp::ImageConstructorImp):
        * bindings/js/kjs_navigator.cpp:
        (KJS::Navigator::Navigator):
        (KJS::PluginBase::PluginBase):
        * bindings/js/kjs_navigator.h:
        * bindings/js/kjs_window.cpp:
        (KJS::Window::Window):
        (KJS::Window::location):
        (KJS::Window::getValueProperty):
        * bindings/js/kjs_window.h:
        * bindings/scripts/CodeGeneratorJS.pm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29134 268f45cc-cd09-0410-ab3c-d52691b4dbfc

39 files changed:
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSCSSRuleCustom.cpp
WebCore/bindings/js/JSCSSValueCustom.cpp
WebCore/bindings/js/JSDocumentCustom.cpp
WebCore/bindings/js/JSEventCustom.cpp
WebCore/bindings/js/JSEventTargetNode.cpp
WebCore/bindings/js/JSEventTargetNode.h
WebCore/bindings/js/JSHTMLAllCollection.h
WebCore/bindings/js/JSHTMLAudioElementConstructor.cpp
WebCore/bindings/js/JSHTMLCollectionCustom.cpp
WebCore/bindings/js/JSHTMLElementWrapperFactory.cpp
WebCore/bindings/js/JSHTMLFormElementCustom.cpp
WebCore/bindings/js/JSHTMLInputElementBase.cpp
WebCore/bindings/js/JSHTMLInputElementBase.h
WebCore/bindings/js/JSHTMLOptionElementConstructor.cpp
WebCore/bindings/js/JSLocation.cpp
WebCore/bindings/js/JSLocation.h
WebCore/bindings/js/JSNamedNodesCollection.cpp
WebCore/bindings/js/JSNamedNodesCollection.h
WebCore/bindings/js/JSNodeCustom.cpp
WebCore/bindings/js/JSSVGElementWrapperFactory.cpp
WebCore/bindings/js/JSSVGPathSegCustom.cpp
WebCore/bindings/js/JSStyleSheetCustom.cpp
WebCore/bindings/js/JSXMLHttpRequest.cpp
WebCore/bindings/js/JSXMLHttpRequest.h
WebCore/bindings/js/JSXSLTProcessor.cpp
WebCore/bindings/js/JSXSLTProcessor.h
WebCore/bindings/js/kjs_binding.h
WebCore/bindings/js/kjs_css.cpp
WebCore/bindings/js/kjs_css.h
WebCore/bindings/js/kjs_events.cpp
WebCore/bindings/js/kjs_events.h
WebCore/bindings/js/kjs_html.cpp
WebCore/bindings/js/kjs_navigator.cpp
WebCore/bindings/js/kjs_navigator.h
WebCore/bindings/js/kjs_window.cpp
WebCore/bindings/js/kjs_window.h
WebCore/bindings/scripts/CodeGeneratorJS.pm

index c2d73f7..d1eba23 100644 (file)
@@ -1,3 +1,94 @@
+2008-01-02  Sam Weinig  <sam@webkit.org>
+
+        Reviewed by Darin.
+
+        Pass the prototype of WebCore JS objects up the constructor chain
+        rather than explicitly setting using setPrototype.  This removes many
+        redundant settings of the prototype on construction.  To avoid a CG 
+        hazard, the prototype must be constructed before before calling the
+        constructor of the JS object.
+
+        - JS objects that inherit from DOMObject, which all bindings objects
+          (except Window) do, now can't implicitly have a jsNull prototype, but
+          must explicitly pass it up the construction chain.
+
+        * bindings/js/JSCSSRuleCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSCSSValueCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSDocumentCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSEventCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSEventTargetNode.cpp:
+        (WebCore::JSEventTargetNode::JSEventTargetNode):
+        * bindings/js/JSEventTargetNode.h:
+        * bindings/js/JSHTMLAllCollection.h:
+        (WebCore::JSHTMLAllCollection::JSHTMLAllCollection):
+        * bindings/js/JSHTMLAudioElementConstructor.cpp:
+        (WebCore::JSHTMLAudioElementConstructor::JSHTMLAudioElementConstructor):
+        * bindings/js/JSHTMLCollectionCustom.cpp:
+        (WebCore::getNamedItems):
+        (WebCore::toJS):
+        * bindings/js/JSHTMLElementWrapperFactory.cpp:
+        (WebCore::createJSHTMLWrapper):
+        * bindings/js/JSHTMLFormElementCustom.cpp:
+        (WebCore::JSHTMLFormElement::nameGetter):
+        * bindings/js/JSHTMLInputElementBase.cpp:
+        (WebCore::JSHTMLInputElementBase::JSHTMLInputElementBase):
+        * bindings/js/JSHTMLInputElementBase.h:
+        * bindings/js/JSHTMLOptionElementConstructor.cpp:
+        (WebCore::JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor):
+        * bindings/js/JSLocation.cpp:
+        (WebCore::JSLocation::JSLocation):
+        * bindings/js/JSLocation.h:
+        * bindings/js/JSNamedNodesCollection.cpp:
+        (WebCore::JSNamedNodesCollection::JSNamedNodesCollection):
+        * bindings/js/JSNamedNodesCollection.h:
+        * bindings/js/JSNodeCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSSVGElementWrapperFactory.cpp:
+        (WebCore::createJSSVGWrapper):
+        * bindings/js/JSSVGPathSegCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSStyleSheetCustom.cpp:
+        (WebCore::toJS):
+        * bindings/js/JSXMLHttpRequest.cpp:
+        (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp):
+        (KJS::JSXMLHttpRequestConstructorImp::construct):
+        (KJS::JSXMLHttpRequest::JSXMLHttpRequest):
+        * bindings/js/JSXMLHttpRequest.h:
+        * bindings/js/JSXSLTProcessor.cpp:
+        (KJS::JSXSLTProcessor::JSXSLTProcessor):
+        (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
+        (KJS::XSLTProcessorConstructorImp::implementsConstruct):
+        (KJS::XSLTProcessorConstructorImp::construct):
+        * bindings/js/JSXSLTProcessor.h:
+        * bindings/js/kjs_binding.h:
+        (KJS::DOMObject::DOMObject):
+        (KJS::cacheDOMObject):
+        (KJS::cacheSVGDOMObject):
+        * bindings/js/kjs_css.cpp:
+        (WebCore::JSRGBColor::JSRGBColor):
+        (WebCore::getJSRGBColor):
+        * bindings/js/kjs_css.h:
+        * bindings/js/kjs_events.cpp:
+        (WebCore::JSClipboard::JSClipboard):
+        (WebCore::toJS):
+        * bindings/js/kjs_events.h:
+        * bindings/js/kjs_html.cpp:
+        (WebCore::ImageConstructorImp::ImageConstructorImp):
+        * bindings/js/kjs_navigator.cpp:
+        (KJS::Navigator::Navigator):
+        (KJS::PluginBase::PluginBase):
+        * bindings/js/kjs_navigator.h:
+        * bindings/js/kjs_window.cpp:
+        (KJS::Window::Window):
+        (KJS::Window::location):
+        (KJS::Window::getValueProperty):
+        * bindings/js/kjs_window.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+
 2008-01-03  Holger Hans Peter Freyther  <zecke@selfish.org>
 
         Reviewed by Alp.
index 012ce67..8497d0b 100644 (file)
                                B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */,
                                B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */,
                                B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
-                               B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
                                93B70D4109EB0C7C009D8468 /* JSXMLHttpRequest.cpp */,
                                93B70D4209EB0C7C009D8468 /* JSXMLHttpRequest.h */,
                                93B70D4509EB0C7C009D8468 /* JSXSLTProcessor.cpp */,
                        children = (
                                BC2ED6BB0C6BD2F000920BFF /* JSAttrCustom.cpp */,
                                1A9EF4560A1B957D00332B63 /* JSCanvasRenderingContext2DCustom.cpp */,
+                               BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
+                               BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
+                               BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
                                51EC925B0CE90DD400F90308 /* JSCustomSQLStatementCallback.cpp */,
                                51EC925C0CE90DD400F90308 /* JSCustomSQLStatementCallback.h */,
                                51EC925D0CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp */,
                                51EC92620CE90DD400F90308 /* JSCustomSQLTransactionErrorCallback.h */,
                                1A3417C80CECFF250049CBDE /* JSCustomVoidCallback.cpp */,
                                1A3417C70CECFF250049CBDE /* JSCustomVoidCallback.h */,
-                               BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
-                               BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */,
-                               BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
                                1AE830420CAB0ED1002237AE /* JSDatabaseCustom.cpp */,
                                929264760B61FC7200B41D34 /* JSDocumentCustom.cpp */,
                                BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
                                B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
                                B297BC6F0B3C14CF0045A590 /* JSSVGPathSegListCustom.cpp */,
                                516BB7910CE91E6800512F79 /* JSSVGPointListCustom.cpp */,
+                               B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
                                516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */,
                        );
                        name = Custom;
index 7bb4fc8..00f7063 100644 (file)
@@ -55,25 +55,25 @@ KJS::JSValue* toJS(KJS::ExecState* exec, CSSRule* rule)
 
     switch (rule->type()) {
         case CSSRule::STYLE_RULE:
-            ret = new JSCSSStyleRule(exec, static_cast<CSSStyleRule*>(rule));
+            ret = new JSCSSStyleRule(JSCSSRulePrototype::self(exec), static_cast<CSSStyleRule*>(rule));
             break;
         case CSSRule::MEDIA_RULE:
-            ret = new JSCSSMediaRule(exec, static_cast<CSSMediaRule*>(rule));
+            ret = new JSCSSMediaRule(JSCSSMediaRulePrototype::self(exec), static_cast<CSSMediaRule*>(rule));
             break;
         case CSSRule::FONT_FACE_RULE:
-            ret = new JSCSSFontFaceRule(exec, static_cast<CSSFontFaceRule*>(rule));
+            ret = new JSCSSFontFaceRule(JSCSSFontFaceRulePrototype::self(exec), static_cast<CSSFontFaceRule*>(rule));
             break;
         case CSSRule::PAGE_RULE:
-            ret = new JSCSSPageRule(exec, static_cast<CSSPageRule*>(rule));
+            ret = new JSCSSPageRule(JSCSSPageRulePrototype::self(exec), static_cast<CSSPageRule*>(rule));
             break;
         case CSSRule::IMPORT_RULE:
-            ret = new JSCSSImportRule(exec, static_cast<CSSImportRule*>(rule));
+            ret = new JSCSSImportRule(JSCSSImportRulePrototype::self(exec), static_cast<CSSImportRule*>(rule));
             break;
         case CSSRule::CHARSET_RULE:
-            ret = new JSCSSCharsetRule(exec, static_cast<CSSCharsetRule*>(rule));
+            ret = new JSCSSCharsetRule(JSCSSCharsetRulePrototype::self(exec), static_cast<CSSCharsetRule*>(rule));
             break;
         default:
-            ret = new JSCSSRule(exec, rule);
+            ret = new JSCSSRule(JSCSSRulePrototype::self(exec), rule);
             break;
     }
 
index c416034..f544849 100644 (file)
@@ -53,17 +53,17 @@ KJS::JSValue* toJS(KJS::ExecState* exec, CSSValue* value)
         return ret;
 
     if (value->isValueList())
-        ret = new JSCSSValueList(exec, static_cast<CSSValueList*>(value));
+        ret = new JSCSSValueList(JSCSSValueListPrototype::self(exec), static_cast<CSSValueList*>(value));
 #if ENABLE(SVG)
     else if (value->isSVGPaint())
-        ret = new JSSVGPaint(exec, static_cast<SVGPaint*>(value));
+        ret = new JSSVGPaint(JSSVGPaintPrototype::self(exec), static_cast<SVGPaint*>(value));
     else if (value->isSVGColor())
-        ret = new JSSVGColor(exec, static_cast<SVGColor*>(value));
+        ret = new JSSVGColor(JSSVGColorPrototype::self(exec), static_cast<SVGColor*>(value));
 #endif
     else if (value->isPrimitiveValue())
-        ret = new JSCSSPrimitiveValue(exec, static_cast<CSSPrimitiveValue*>(value));
+        ret = new JSCSSPrimitiveValue(JSCSSPrimitiveValuePrototype::self(exec), static_cast<CSSPrimitiveValue*>(value));
     else
-        ret = new JSCSSValue(exec, value);
+        ret = new JSCSSValue(JSCSSValuePrototype::self(exec), value);
 
     KJS::ScriptInterpreter::putDOMObject(value, ret);
     return ret;
index 309c575..133c576 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -85,13 +85,13 @@ JSValue* toJS(ExecState* exec, Document* doc)
         return ret;
 
     if (doc->isHTMLDocument())
-        ret = new JSHTMLDocument(exec, static_cast<HTMLDocument*>(doc));
+        ret = new JSHTMLDocument(JSHTMLDocumentPrototype::self(exec), static_cast<HTMLDocument*>(doc));
 #if ENABLE(SVG)
     else if (doc->isSVGDocument())
-        ret = new JSSVGDocument(exec, static_cast<SVGDocument*>(doc));
+        ret = new JSSVGDocument(JSSVGDocumentPrototype::self(exec), static_cast<SVGDocument*>(doc));
 #endif
     else
-        ret = new JSDocument(exec, doc);
+        ret = new JSDocument(JSDocumentPrototype::self(exec), doc);
 
     // Make sure the document is kept around by the window object, and works right with the
     // back/forward cache.
index 6a55636..55a5f1d 100644 (file)
@@ -73,25 +73,25 @@ JSValue* toJS(ExecState* exec, Event* event)
         return ret;
 
     if (event->isKeyboardEvent())
-        ret = new JSKeyboardEvent(exec, static_cast<KeyboardEvent*>(event));
+        ret = new JSKeyboardEvent(JSKeyboardEventPrototype::self(exec), static_cast<KeyboardEvent*>(event));
     else if (event->isTextEvent())
-        ret = new JSTextEvent(exec, static_cast<TextEvent*>(event));
+        ret = new JSTextEvent(JSTextEventPrototype::self(exec), static_cast<TextEvent*>(event));
     else if (event->isMouseEvent())
-        ret = new JSMouseEvent(exec, static_cast<MouseEvent*>(event));
+        ret = new JSMouseEvent(JSMouseEventPrototype::self(exec), static_cast<MouseEvent*>(event));
     else if (event->isWheelEvent())
-        ret = new JSWheelEvent(exec, static_cast<WheelEvent*>(event));
+        ret = new JSWheelEvent(JSWheelEventPrototype::self(exec), static_cast<WheelEvent*>(event));
     else if (event->isUIEvent())
-        ret = new JSUIEvent(exec, static_cast<UIEvent*>(event));
+        ret = new JSUIEvent(JSUIEventPrototype::self(exec), static_cast<UIEvent*>(event));
     else if (event->isMutationEvent())
-        ret = new JSMutationEvent(exec, static_cast<MutationEvent*>(event));
+        ret = new JSMutationEvent(JSMutationEventPrototype::self(exec), static_cast<MutationEvent*>(event));
     else if (event->isOverflowEvent())
-        ret = new JSOverflowEvent(exec, static_cast<OverflowEvent*>(event));
+        ret = new JSOverflowEvent(JSOverflowEventPrototype::self(exec), static_cast<OverflowEvent*>(event));
     else if (event->isMessageEvent())
-        ret = new JSMessageEvent(exec, static_cast<MessageEvent*>(event));
+        ret = new JSMessageEvent(JSMessageEventPrototype::self(exec), static_cast<MessageEvent*>(event));
     else if (event->isProgressEvent())
-        ret = new JSProgressEvent(exec, static_cast<ProgressEvent*>(event));
+        ret = new JSProgressEvent(JSProgressEventPrototype::self(exec), static_cast<ProgressEvent*>(event));
     else
-        ret = new JSEvent(exec, event);
+        ret = new JSEvent(JSEventPrototype::self(exec), event);
 
     ScriptInterpreter::putDOMObject(event, ret);
     return ret;
index 2a87303..d097aad 100644 (file)
@@ -31,10 +31,9 @@ namespace WebCore {
 
 using namespace KJS;
 
-JSEventTargetNode::JSEventTargetNode(ExecState* exec, Node* n)
-    : JSNode(exec, n)
+JSEventTargetNode::JSEventTargetNode(JSObject* prototype, Node* node)
+    : JSNode(prototype, node)
 {
-    setPrototype(JSEventTargetNodePrototype::self(exec));
 }
 
 bool JSEventTargetNode::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index c92d896..b73482a 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
 
     class JSEventTargetNode : public JSNode {
     public:
-        JSEventTargetNode(KJS::ExecState*, Node*);
+        JSEventTargetNode(KJS::JSObject* prototype, Node*);
 
         void setListener(KJS::ExecState*, const AtomicString& eventType, KJS::JSValue* func) const;
         KJS::JSValue* getListener(const AtomicString& eventType) const;
index ed0a27c..4661e12 100644 (file)
@@ -34,8 +34,8 @@ namespace WebCore {
 
     class JSHTMLAllCollection : public JSHTMLCollection {
     public:
-        JSHTMLAllCollection(KJS::ExecState* exec, HTMLCollection* collection)
-            : JSHTMLCollection(exec, collection)
+        JSHTMLAllCollection(KJS::JSObject* prototype, HTMLCollection* collection)
+            : JSHTMLCollection(prototype, collection)
         {
         }
 
index 84c8104..9f58bde 100644 (file)
@@ -38,9 +38,9 @@ using namespace KJS;
 namespace WebCore {
 
 JSHTMLAudioElementConstructor::JSHTMLAudioElementConstructor(ExecState* exec, Document* d)
-    : m_doc(d)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+    , m_doc(d)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
     put(exec, exec->propertyNames().length, jsNumber(1), ReadOnly|DontDelete|DontEnum);
 }
 
index 578f978..2c44ab0 100644 (file)
@@ -47,7 +47,7 @@ static JSValue* getNamedItems(ExecState* exec, HTMLCollection* impl, const Ident
     if (namedItems.size() == 1)
         return toJS(exec, namedItems[0].get());
 
-    return new JSNamedNodesCollection(exec, namedItems);
+    return new JSNamedNodesCollection(exec->lexicalGlobalObject()->objectPrototype(), namedItems);
 }
 
 // HTMLCollections are strange objects, they support both get and call,
@@ -134,13 +134,13 @@ JSValue* toJS(ExecState* exec, HTMLCollection* collection)
 
     switch (collection->type()) {
         case HTMLCollection::SelectOptions:
-            ret = new JSHTMLOptionsCollection(exec, static_cast<HTMLOptionsCollection*>(collection));
+            ret = new JSHTMLOptionsCollection(JSHTMLOptionsCollectionPrototype::self(exec), static_cast<HTMLOptionsCollection*>(collection));
             break;
         case HTMLCollection::DocAll:
-            ret = new JSHTMLAllCollection(exec, static_cast<HTMLCollection*>(collection));
+            ret = new JSHTMLAllCollection(JSHTMLCollectionPrototype::self(exec), static_cast<HTMLCollection*>(collection));
             break;
         default:
-            ret = new JSHTMLCollection(exec, static_cast<HTMLCollection*>(collection));
+            ret = new JSHTMLCollection(JSHTMLCollectionPrototype::self(exec), static_cast<HTMLCollection*>(collection));
             break;
     }
 
index daa5ba8..cfc9ec1 100644 (file)
@@ -224,7 +224,7 @@ typedef JSNode* (*CreateHTMLElementWrapperFunction)(ExecState*, PassRefPtr<HTMLE
 #define CREATE_WRAPPER_FUNCTION(tag, name) \
 static JSNode* create##name##Wrapper(ExecState* exec, PassRefPtr<HTMLElement> element) \
 { \
-    return new JSHTML##name##Element(exec, static_cast<HTML##name##Element*>(element.get())); \
+    return new JSHTML##name##Element(JSHTML##name##ElementPrototype::self(exec), static_cast<HTML##name##Element*>(element.get())); \
 }
 FOR_EACH_TAG(CREATE_WRAPPER_FUNCTION)
 #if ENABLE(VIDEO)
@@ -260,7 +260,7 @@ FOR_EACH_VIDEO_TAG(ADD_TO_HASH_MAP)
     CreateHTMLElementWrapperFunction createWrapperFunction = map.get(element->localName().impl());
     if (createWrapperFunction)
         return createWrapperFunction(exec, element);
-    return new JSHTMLElement(exec, element.get());
+    return new JSHTMLElement(JSHTMLElementPrototype::self(exec), element.get());
 }
 
 } // namespace WebCore
index fb58cc6..8e24618 100644 (file)
@@ -52,7 +52,7 @@ JSValue* JSHTMLFormElement::nameGetter(ExecState* exec, JSObject*, const Identif
     if (namedItems.size() == 1)
         return toJS(exec, namedItems[0].get());
     if (namedItems.size() > 1) 
-        return new JSNamedNodesCollection(exec, namedItems);
+        return new JSNamedNodesCollection(exec->lexicalGlobalObject()->objectPrototype(), namedItems);
     return jsUndefined();
 }
 
index 7b4a348..f6a1c8d 100644 (file)
@@ -57,11 +57,9 @@ JSValue* JSHTMLInputElementBaseFunctionSetSelectionRange::callAsFunction(ExecSta
 
 const ClassInfo JSHTMLInputElementBase::info = { "JSHTMLInputElementBase", &JSHTMLElement::info, &JSHTMLInputElementBaseTable };
 
-JSHTMLInputElementBase::JSHTMLInputElementBase(ExecState* exec, PassRefPtr<HTMLInputElement> e)
-    : JSHTMLElement(exec, e.get())
+JSHTMLInputElementBase::JSHTMLInputElementBase(KJS::JSObject* prototype, PassRefPtr<HTMLInputElement> e)
+    : JSHTMLElement(prototype, e.get())
 {
-    // We don't really need a prototype, just use our parent class's prototype
-    setPrototype(JSHTMLElementPrototype::self(exec));
 }
 
 bool JSHTMLInputElementBase::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
index 7d2b7bd..4a5ab9a 100644 (file)
@@ -32,7 +32,8 @@ namespace WebCore {
 
     class JSHTMLInputElementBase : public JSHTMLElement {
     public:
-        JSHTMLInputElementBase(KJS::ExecState*, PassRefPtr<HTMLInputElement>);
+        JSHTMLInputElementBase(KJS::JSObject* prototype, PassRefPtr<HTMLInputElement>);
+
         virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
         KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
         virtual void put(KJS::ExecState*, const KJS::Identifier& propertyName, JSValue*, int attr);
index 4949b3e..e0de3f3 100644 (file)
@@ -30,9 +30,9 @@ namespace WebCore {
 using namespace KJS;
 
 JSHTMLOptionElementConstructor::JSHTMLOptionElementConstructor(ExecState* exec, Document* d)
-    : m_doc(d)
+    : KJS::DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+    , m_doc(d)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
     put(exec, exec->propertyNames().length, jsNumber(4), ReadOnly|DontDelete|DontEnum);
 }
 
index edad6fb..f7f6c60 100644 (file)
@@ -56,8 +56,9 @@ const ClassInfo JSLocation::info = { "Location", 0, &JSLocationTable };
 @end
 */
 
-JSLocation::JSLocation(Frame* frame)
-    : m_frame(frame)
+JSLocation::JSLocation(JSObject* /*prototype*/, Frame* frame)
+    : DOMObject(jsNull()) // FIXME: this needs to take a real prototype
+    , m_frame(frame)
 {
 }
 
index e10f2dd..ec42655 100644 (file)
@@ -33,6 +33,8 @@ namespace WebCore {
     class JSLocation : public KJS::DOMObject {
         friend class KJS::Window;
     public:
+        JSLocation(KJS::JSObject* protoype, Frame*);
+    
         virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
         KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
         virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
@@ -49,8 +51,6 @@ namespace WebCore {
         static const KJS::ClassInfo info;
 
     private:
-        JSLocation(Frame*);
-
         Frame* m_frame;
     };
 
index 47715ef..977ce82 100644 (file)
@@ -40,10 +40,10 @@ const ClassInfo JSNamedNodesCollection::info = { "Collection", 0, 0 };
 // Such a collection is usually very short-lived, it only exists
 // for constructs like document.forms.<name>[1],
 // so it shouldn't be a problem that it's storing all the nodes (with the same name). (David)
-JSNamedNodesCollection::JSNamedNodesCollection(ExecState* exec, const Vector<RefPtr<Node> >& nodes)
-    : m_nodes(nodes)
+JSNamedNodesCollection::JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >& nodes)
+    : KJS::DOMObject(prototype)
+    , m_nodes(nodes)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
 }
 
 JSValue* JSNamedNodesCollection::lengthGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
index 1b3b029..336e0cb 100644 (file)
@@ -37,7 +37,7 @@ namespace WebCore {
     // when multiple nodes have the same name.
     class JSNamedNodesCollection : public KJS::DOMObject {
     public:
-        JSNamedNodesCollection(KJS::ExecState*, const Vector<RefPtr<Node> >&);
+        JSNamedNodesCollection(KJS::JSObject* prototype, const Vector<RefPtr<Node> >&);
 
         virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
 
index 720c969..20fdad2 100644 (file)
@@ -175,43 +175,43 @@ JSValue* toJS(ExecState* exec, PassRefPtr<Node> n)
                 ret = createJSSVGWrapper(exec, static_pointer_cast<SVGElement>(n));
 #endif
             else
-                ret = new JSElement(exec, static_cast<Element*>(node));
+                ret = new JSElement(JSElementPrototype::self(exec), static_cast<Element*>(node));
             break;
         case Node::ATTRIBUTE_NODE:
-            ret = new JSAttr(exec, static_cast<Attr*>(node));
+            ret = new JSAttr(JSAttrPrototype::self(exec), static_cast<Attr*>(node));
             break;
         case Node::TEXT_NODE:
-            ret = new JSText(exec, static_cast<Text*>(node));
+            ret = new JSText(JSTextPrototype::self(exec), static_cast<Text*>(node));
             break;
         case Node::CDATA_SECTION_NODE:
-            ret = new JSCDATASection(exec, static_cast<CDATASection*>(node));
+            ret = new JSCDATASection(JSCDATASectionPrototype::self(exec), static_cast<CDATASection*>(node));
             break;
         case Node::ENTITY_NODE:
-            ret = new JSEntity(exec, static_cast<Entity*>(node));
+            ret = new JSEntity(JSEntityPrototype::self(exec), static_cast<Entity*>(node));
             break;
         case Node::PROCESSING_INSTRUCTION_NODE:
-            ret = new JSProcessingInstruction(exec, static_cast<ProcessingInstruction*>(node));
+            ret = new JSProcessingInstruction(JSProcessingInstructionPrototype::self(exec), static_cast<ProcessingInstruction*>(node));
             break;
         case Node::COMMENT_NODE:
-            ret = new JSComment(exec, static_cast<Comment*>(node));
+            ret = new JSComment(JSCommentPrototype::self(exec), static_cast<Comment*>(node));
             break;
         case Node::DOCUMENT_NODE:
             // we don't want to cache the document itself in the per-document dictionary
             return toJS(exec, static_cast<Document*>(node));
         case Node::DOCUMENT_TYPE_NODE:
-            ret = new JSDocumentType(exec, static_cast<DocumentType*>(node));
+            ret = new JSDocumentType(JSDocumentTypePrototype::self(exec), static_cast<DocumentType*>(node));
             break;
         case Node::NOTATION_NODE:
-            ret = new JSNotation(exec, static_cast<Notation*>(node));
+            ret = new JSNotation(JSNotationPrototype::self(exec), static_cast<Notation*>(node));
             break;
         case Node::DOCUMENT_FRAGMENT_NODE:
-            ret = new JSDocumentFragment(exec, static_cast<DocumentFragment*>(node));
+            ret = new JSDocumentFragment(JSDocumentFragmentPrototype::self(exec), static_cast<DocumentFragment*>(node));
             break;
         case Node::ENTITY_REFERENCE_NODE:
-            ret = new JSEntityReference(exec, static_cast<EntityReference*>(node));
+            ret = new JSEntityReference(JSEntityReferencePrototype::self(exec), static_cast<EntityReference*>(node));
             break;
         default:
-            ret = new JSNode(exec, node);
+            ret = new JSNode(JSNodePrototype::self(exec), node);
     }
 
     ScriptInterpreter::putDOMNodeForDocument(doc, node, ret);
index 9f4bd98..c116389 100644 (file)
@@ -276,7 +276,7 @@ typedef JSNode* (*CreateSVGElementWrapperFunction)(ExecState*, PassRefPtr<SVGEle
 #define CREATE_WRAPPER_FUNCTION(tag, name) \
 static JSNode* create##name##Wrapper(ExecState* exec, PassRefPtr<SVGElement> element) \
 { \
-    return new JSSVG##name##Element(exec, static_cast<SVG##name##Element*>(element.get())); \
+    return new JSSVG##name##Element(JSSVG##name##ElementPrototype::self(exec), static_cast<SVG##name##Element*>(element.get())); \
 }
 FOR_EACH_TAG(CREATE_WRAPPER_FUNCTION)
 FOR_EACH_ANIMATION_TAG(CREATE_WRAPPER_FUNCTION)
@@ -299,7 +299,7 @@ FOR_EACH_FILTER_TAG(ADD_TO_HASH_MAP)
     CreateSVGElementWrapperFunction createWrapperFunction = map.get(element->localName().impl());
     if (createWrapperFunction)
         return createWrapperFunction(exec, element);
-    return new JSSVGElement(exec, element.get());
+    return new JSSVGElement(JSSVGElementPrototype::self(exec), element.get());
 }
 
 }
index 6688f9c..55db3a1 100644 (file)
@@ -66,46 +66,46 @@ JSValue* toJS(ExecState* exec, SVGPathSeg* obj, SVGElement* context)
     
     switch (obj->pathSegType()) {
     case SVGPathSeg::PATHSEG_CLOSEPATH:
-        return cacheSVGDOMObject<SVGPathSegClosePath, JSSVGPathSegClosePath>(exec, static_cast<SVGPathSegClosePath*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegClosePath, JSSVGPathSegClosePath, JSSVGPathSegClosePathPrototype>(exec, static_cast<SVGPathSegClosePath*>(obj), context);
     case SVGPathSeg::PATHSEG_MOVETO_ABS:
-        return cacheSVGDOMObject<SVGPathSegMovetoAbs, JSSVGPathSegMovetoAbs>(exec, static_cast<SVGPathSegMovetoAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegMovetoAbs, JSSVGPathSegMovetoAbs, JSSVGPathSegMovetoAbsPrototype>(exec, static_cast<SVGPathSegMovetoAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_MOVETO_REL:
-        return cacheSVGDOMObject<SVGPathSegMovetoRel, JSSVGPathSegMovetoRel>(exec, static_cast<SVGPathSegMovetoRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegMovetoRel, JSSVGPathSegMovetoRel, JSSVGPathSegMovetoRelPrototype>(exec, static_cast<SVGPathSegMovetoRel*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_ABS:
-        return cacheSVGDOMObject<SVGPathSegLinetoAbs, JSSVGPathSegLinetoAbs>(exec, static_cast<SVGPathSegLinetoAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoAbs, JSSVGPathSegLinetoAbs, JSSVGPathSegLinetoAbsPrototype>(exec, static_cast<SVGPathSegLinetoAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_REL:
-        return cacheSVGDOMObject<SVGPathSegLinetoRel, JSSVGPathSegLinetoRel>(exec, static_cast<SVGPathSegLinetoRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoRel, JSSVGPathSegLinetoRel, JSSVGPathSegLinetoRelPrototype>(exec, static_cast<SVGPathSegLinetoRel*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS:
-        return cacheSVGDOMObject<SVGPathSegCurvetoCubicAbs, JSSVGPathSegCurvetoCubicAbs>(exec, static_cast<SVGPathSegCurvetoCubicAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoCubicAbs, JSSVGPathSegCurvetoCubicAbs, JSSVGPathSegCurvetoCubicAbsPrototype>(exec, static_cast<SVGPathSegCurvetoCubicAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL:
-        return cacheSVGDOMObject<SVGPathSegCurvetoCubicRel, JSSVGPathSegCurvetoCubicRel>(exec, static_cast<SVGPathSegCurvetoCubicRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoCubicRel, JSSVGPathSegCurvetoCubicRel, JSSVGPathSegCurvetoCubicRelPrototype>(exec, static_cast<SVGPathSegCurvetoCubicRel*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS:
-        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticAbs, JSSVGPathSegCurvetoQuadraticAbs>(exec, static_cast<SVGPathSegCurvetoQuadraticAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticAbs, JSSVGPathSegCurvetoQuadraticAbs, JSSVGPathSegCurvetoQuadraticAbsPrototype>(exec, static_cast<SVGPathSegCurvetoQuadraticAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL:
-        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticRel, JSSVGPathSegCurvetoQuadraticRel>(exec, static_cast<SVGPathSegCurvetoQuadraticRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticRel, JSSVGPathSegCurvetoQuadraticRel, JSSVGPathSegCurvetoQuadraticRelPrototype>(exec, static_cast<SVGPathSegCurvetoQuadraticRel*>(obj), context);
     case SVGPathSeg::PATHSEG_ARC_ABS:
-        return cacheSVGDOMObject<SVGPathSegArcAbs, JSSVGPathSegArcAbs>(exec, static_cast<SVGPathSegArcAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegArcAbs, JSSVGPathSegArcAbs, JSSVGPathSegArcAbsPrototype>(exec, static_cast<SVGPathSegArcAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_ARC_REL:
-        return cacheSVGDOMObject<SVGPathSegArcRel, JSSVGPathSegArcRel>(exec, static_cast<SVGPathSegArcRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegArcRel, JSSVGPathSegArcRel, JSSVGPathSegArcRelPrototype>(exec, static_cast<SVGPathSegArcRel*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS:
-        return cacheSVGDOMObject<SVGPathSegLinetoHorizontalAbs, JSSVGPathSegLinetoHorizontalAbs>(exec, static_cast<SVGPathSegLinetoHorizontalAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoHorizontalAbs, JSSVGPathSegLinetoHorizontalAbs, JSSVGPathSegLinetoHorizontalAbsPrototype>(exec, static_cast<SVGPathSegLinetoHorizontalAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL:
-        return cacheSVGDOMObject<SVGPathSegLinetoHorizontalRel, JSSVGPathSegLinetoHorizontalRel>(exec, static_cast<SVGPathSegLinetoHorizontalRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoHorizontalRel, JSSVGPathSegLinetoHorizontalRel, JSSVGPathSegLinetoHorizontalRelPrototype>(exec, static_cast<SVGPathSegLinetoHorizontalRel*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
-        return cacheSVGDOMObject<SVGPathSegLinetoVerticalAbs, JSSVGPathSegLinetoVerticalAbs>(exec, static_cast<SVGPathSegLinetoVerticalAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoVerticalAbs, JSSVGPathSegLinetoVerticalAbs, JSSVGPathSegLinetoVerticalAbsPrototype>(exec, static_cast<SVGPathSegLinetoVerticalAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL:
-        return cacheSVGDOMObject<SVGPathSegLinetoVerticalRel, JSSVGPathSegLinetoVerticalRel>(exec, static_cast<SVGPathSegLinetoVerticalRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegLinetoVerticalRel, JSSVGPathSegLinetoVerticalRel, JSSVGPathSegLinetoVerticalRelPrototype>(exec, static_cast<SVGPathSegLinetoVerticalRel*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
-        return cacheSVGDOMObject<SVGPathSegCurvetoCubicSmoothAbs, JSSVGPathSegCurvetoCubicSmoothAbs>(exec, static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoCubicSmoothAbs, JSSVGPathSegCurvetoCubicSmoothAbs, JSSVGPathSegCurvetoCubicSmoothAbsPrototype>(exec, static_cast<SVGPathSegCurvetoCubicSmoothAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
-        return cacheSVGDOMObject<SVGPathSegCurvetoCubicSmoothRel, JSSVGPathSegCurvetoCubicSmoothRel>(exec, static_cast<SVGPathSegCurvetoCubicSmoothRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoCubicSmoothRel, JSSVGPathSegCurvetoCubicSmoothRel, JSSVGPathSegCurvetoCubicSmoothRelPrototype>(exec, static_cast<SVGPathSegCurvetoCubicSmoothRel*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
-        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticSmoothAbs, JSSVGPathSegCurvetoQuadraticSmoothAbs>(exec, static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticSmoothAbs, JSSVGPathSegCurvetoQuadraticSmoothAbs, JSSVGPathSegCurvetoQuadraticSmoothAbsPrototype>(exec, static_cast<SVGPathSegCurvetoQuadraticSmoothAbs*>(obj), context);
     case SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
-        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticSmoothRel, JSSVGPathSegCurvetoQuadraticSmoothRel>(exec, static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(obj), context);
+        return cacheSVGDOMObject<SVGPathSegCurvetoQuadraticSmoothRel, JSSVGPathSegCurvetoQuadraticSmoothRel, JSSVGPathSegCurvetoQuadraticSmoothRelPrototype>(exec, static_cast<SVGPathSegCurvetoQuadraticSmoothRel*>(obj), context);
     case SVGPathSeg::PATHSEG_UNKNOWN:
     default:
-        return cacheSVGDOMObject<SVGPathSeg, JSSVGPathSeg>(exec, obj, context);
+        return cacheSVGDOMObject<SVGPathSeg, JSSVGPathSeg, JSSVGPathSegPrototype>(exec, obj, context);
     }
 }
 
index 68ce4fe..4122831 100644 (file)
@@ -44,9 +44,9 @@ JSValue* toJS(ExecState* exec, StyleSheet* styleSheet)
         return ret;
 
     if (styleSheet->isCSSStyleSheet())
-        ret = new JSCSSStyleSheet(exec, static_cast<CSSStyleSheet*>(styleSheet));
+        ret = new JSCSSStyleSheet(JSCSSStyleSheetPrototype::self(exec), static_cast<CSSStyleSheet*>(styleSheet));
     else
-        ret = new JSStyleSheet(exec, styleSheet);
+        ret = new JSStyleSheet(JSStyleSheetPrototype::self(exec), styleSheet);
 
     ScriptInterpreter::putDOMObject(styleSheet, ret);
     return ret;
index 8b08016..dac365e 100644 (file)
@@ -59,9 +59,9 @@ KJS_DEFINE_PROTOTYPE(JSXMLHttpRequestPrototype)
 KJS_IMPLEMENT_PROTOTYPE("JSXMLHttpRequest", JSXMLHttpRequestPrototype)
 
 JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp(ExecState* exec, Document* d)
-    : doc(d)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+    , doc(d)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
     putDirect(exec->propertyNames().prototype, JSXMLHttpRequestPrototype::self(exec), None);
 }
 
@@ -72,7 +72,7 @@ bool JSXMLHttpRequestConstructorImp::implementsConstruct() const
 
 JSObject* JSXMLHttpRequestConstructorImp::construct(ExecState* exec, const List&)
 {
-    return new JSXMLHttpRequest(exec, doc.get());
+    return new JSXMLHttpRequest(JSXMLHttpRequestPrototype::self(exec), doc.get());
 }
 
 const ClassInfo JSXMLHttpRequest::info = { "JSXMLHttpRequest", 0, &JSXMLHttpRequestTable };
@@ -195,10 +195,10 @@ void JSXMLHttpRequest::mark()
 }
 
 
-JSXMLHttpRequest::JSXMLHttpRequest(ExecState* exec, Document* d)
-  : m_impl(new XMLHttpRequest(d))
+JSXMLHttpRequest::JSXMLHttpRequest(JSObject* prototype, Document* d)
+    : DOMObject(prototype)
+    , m_impl(new XMLHttpRequest(d))
 {
-    setPrototype(JSXMLHttpRequestPrototype::self(exec));
     ScriptInterpreter::putDOMObject(m_impl.get(), this);
 }
 
index 6afb608..fa4cd8f 100644 (file)
@@ -36,16 +36,19 @@ namespace KJS {
 class JSXMLHttpRequestConstructorImp : public DOMObject {
 public:
     JSXMLHttpRequestConstructorImp(ExecState*, WebCore::Document*);
+
     virtual bool implementsConstruct() const;
     virtual JSObject* construct(ExecState*, const List&);
+
 private:
     RefPtr<WebCore::Document> doc;
 };
 
 class JSXMLHttpRequest : public DOMObject {
 public:
-    JSXMLHttpRequest(ExecState*, WebCore::Document*);
+    JSXMLHttpRequest(JSObject* prototype, WebCore::Document*);
     ~JSXMLHttpRequest();
+
     virtual const ClassInfo* classInfo() const { return &info; }
     static const ClassInfo info;
     enum { Onload, Onreadystatechange, ReadyState, ResponseText, ResponseXML, Status,
index 5fb37a2..6e68170 100644 (file)
@@ -58,9 +58,10 @@ const ClassInfo JSXSLTProcessor::info = { "XSLTProcessor", 0, 0 };
 KJS_DEFINE_PROTOTYPE(XSLTProcessorPrototype)
 KJS_IMPLEMENT_PROTOTYPE("XSLTProcessor", XSLTProcessorPrototype)
 
-JSXSLTProcessor::JSXSLTProcessor(ExecState *exec) : m_impl(new XSLTProcessor())
+JSXSLTProcessor::JSXSLTProcessor(JSObject* prototype)
+    : DOMObject(prototype)
+    , m_impl(new XSLTProcessor())
 {
-    setPrototype(XSLTProcessorPrototype::self(exec));
 }
 
 JSXSLTProcessor::~JSXSLTProcessor()
@@ -185,11 +186,21 @@ JSValue* JSXSLTProcessorPrototypeFunctionReset::callAsFunction(ExecState* exec,
 }
 
 XSLTProcessorConstructorImp::XSLTProcessorConstructorImp(ExecState *exec)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
     putDirect(exec->propertyNames().prototype, XSLTProcessorPrototype::self(exec), None);
 }
 
+bool XSLTProcessorConstructorImp::implementsConstruct() const
+{
+    return true;
 }
 
+JSObject* XSLTProcessorConstructorImp::construct(ExecState* exec, const List& args)
+{
+    return new JSXSLTProcessor(XSLTProcessorPrototype::self(exec));
+}
+
+} // namespace KJS
+
 #endif // ENABLE(XSLT)
index d2de406..1f4c0d9 100644 (file)
@@ -42,7 +42,7 @@ namespace KJS {
 
 class JSXSLTProcessor : public DOMObject {
 public:
-    JSXSLTProcessor(ExecState *exec);
+    JSXSLTProcessor(JSObject* prototype);
     ~JSXSLTProcessor();
     
     virtual const ClassInfo *classInfo() const { return &info; }
@@ -55,9 +55,10 @@ private:
 
 class XSLTProcessorConstructorImp : public DOMObject {
 public:
-    XSLTProcessorConstructorImp(ExecState *);
-    virtual bool implementsConstruct() const { return true; }
-    virtual JSObject *construct(ExecState *exec, const List &args) { return new JSXSLTProcessor(exec); }
+    XSLTProcessorConstructorImp(ExecState*);
+
+    virtual bool implementsConstruct() const;
+    virtual JSObject* construct(ExecState*, const List&);
 };
 
 #define FOR_EACH_CLASS(macro) \
index 224f505..9f3c7ba 100644 (file)
@@ -55,15 +55,20 @@ namespace KJS {
      */
     class DOMObject : public JSObject {
     protected:
-        DOMObject()
+        explicit DOMObject(JSValue* prototype) // FIXME: this should take a JSObject once JSLocation has a real prototype
+            : JSObject(prototype)
         {
             // DOMObject destruction is not thread-safe because DOMObjects wrap 
             // unsafe WebCore DOM data structures.
             Collector::collectOnMainThreadOnly(this);
         }
+
 #ifndef NDEBUG
         virtual ~DOMObject();
 #endif
+
+    private:
+        DOMObject();
     };
 
     class ScriptInterpreter : public Interpreter {
@@ -81,30 +86,30 @@ namespace KJS {
     };
 
     /**
-     * Retrieve from cache, or create, a KJS object around a DOM object
+     * Retrieve from cache, or create, a JS object around a DOM object
      */
-    template<class DOMObj, class KJSDOMObj> inline JSValue *cacheDOMObject(ExecState* exec, DOMObj* domObj)
+    template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline JSValue* cacheDOMObject(ExecState* exec, DOMObj* domObj)
     {
         if (!domObj)
             return jsNull();
         if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj))
             return ret;
-        DOMObject* ret = new KJSDOMObj(exec, domObj);
+        DOMObject* ret = new JSDOMObj(JSDOMObjPrototype::self(exec), domObj);
         ScriptInterpreter::putDOMObject(domObj, ret);
         return ret;
     }
 
 #if ENABLE(SVG)
     /**
-     * Retrieve from cache, or create, a KJS object around a SVG DOM object
+     * Retrieve from cache, or create, a JS object around a SVG DOM object
      */
-    template<class DOMObj, class KJSDOMObj> inline JSValue* cacheSVGDOMObject(ExecState* exec, DOMObj* domObj, WebCore::SVGElement* context)
+    template<class DOMObj, class JSDOMObj, class JSDOMObjPrototype> inline JSValue* cacheSVGDOMObject(ExecState* exec, DOMObj* domObj, WebCore::SVGElement* context)
     {
         if (!domObj)
             return jsNull();
         if (DOMObject* ret = ScriptInterpreter::getDOMObject(domObj))
             return ret;
-        DOMObject* ret = new KJSDOMObj(exec, domObj, context);
+        DOMObject* ret = new JSDOMObj(JSDOMObjPrototype::self(exec), domObj, context);
         ScriptInterpreter::putDOMObject(domObj, ret);
         return ret;
     }
index dfe23e1..e2ab70d 100644 (file)
@@ -44,10 +44,10 @@ const ClassInfo JSRGBColor::info = { "RGBColor", 0, &JSRGBColorTable };
 @end
 */
 
-JSRGBColor::JSRGBColor(ExecState* exec, unsigned color) 
-    : m_color(color) 
-{ 
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
+JSRGBColor::JSRGBColor(JSObject* prototype, unsigned color)
+    : DOMObject(prototype)
+    , m_color(color)
+{
 }
 
 JSRGBColor::~JSRGBColor()
@@ -79,7 +79,7 @@ JSValue* JSRGBColor::getValueProperty(ExecState* exec, int token) const
 JSValue* getJSRGBColor(ExecState* exec, unsigned color)
 {
     // FIXME: implement equals for RGBColor since they're not refcounted objects
-    return new JSRGBColor(exec, color);
+    return new JSRGBColor(exec->lexicalGlobalObject()->objectPrototype(), color);
 }
 
 } // namespace WebCore
index 5ae2cc5..d7f14aa 100644 (file)
@@ -30,7 +30,7 @@ namespace WebCore {
 
     class JSRGBColor : public KJS::DOMObject {
     public:
-        JSRGBColor(KJS::ExecState*, unsigned color);
+        JSRGBColor(KJS::JSObject* prototype, unsigned color);
         ~JSRGBColor();
 
         virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
index e29bd87..ae74c23 100644 (file)
@@ -366,10 +366,10 @@ const ClassInfo JSClipboard::info = { "Clipboard", 0, &JSClipboardTable };
 KJS_DEFINE_PROTOTYPE(JSClipboardPrototype)
 KJS_IMPLEMENT_PROTOTYPE("Clipboard", JSClipboardPrototype)
 
-JSClipboard::JSClipboard(ExecState* exec, Clipboard* clipboard)
-    : m_impl(clipboard)
+JSClipboard::JSClipboard(JSObject* prototype, Clipboard* clipboard)
+    : DOMObject(prototype)
+    , m_impl(clipboard)
 {
-    setPrototype(JSClipboardPrototype::self(exec));
 }
 
 JSClipboard::~JSClipboard()
@@ -513,7 +513,7 @@ JSValue* JSClipboardPrototypeFunctionSetDragImage::callAsFunction(ExecState* exe
 
 JSValue* toJS(ExecState* exec, Clipboard* obj)
 {
-    return cacheDOMObject<Clipboard, JSClipboard>(exec, obj);
+    return cacheDOMObject<Clipboard, JSClipboard, JSClipboardPrototype>(exec, obj);
 }
 
 Clipboard* toClipboard(JSValue* val)
index 1ac7b46..9dba2a2 100644 (file)
@@ -99,7 +99,7 @@ namespace WebCore {
 
     class JSClipboard : public KJS::DOMObject {
     public:
-        JSClipboard(KJS::ExecState*, Clipboard*);
+        JSClipboard(KJS::JSObject* prototype, Clipboard*);
         virtual ~JSClipboard();
 
         virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
index 3ac990d..18eb7a8 100644 (file)
@@ -34,9 +34,9 @@ namespace WebCore {
 using namespace KJS;
 
 ImageConstructorImp::ImageConstructorImp(ExecState* exec, Document* doc)
-    : m_doc(doc)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
+    , m_doc(doc)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
 }
 
 JSObject* ImageConstructorImp::construct(ExecState*  exec, const List& list)
index 253fbf6..49dd22f 100644 (file)
@@ -175,10 +175,10 @@ const ClassInfo Navigator::info = { "Navigator", 0, &NavigatorTable };
 @end
 */
 
-Navigator::Navigator(ExecState *exec, Frame *f) 
-    : m_frame(f)
+Navigator::Navigator(JSObject* prototype, Frame* frame)
+    : DOMObject(prototype)
+    , m_frame(frame)
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
 }
 
 bool Navigator::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
@@ -249,10 +249,9 @@ void PluginBase::cachePluginDataIfNecessary()
     }
 }
 
-PluginBase::PluginBase(ExecState *exec)
+PluginBase::PluginBase(ExecState* exec)
+    : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
 {
-    setPrototype(exec->lexicalGlobalObject()->objectPrototype());
-
     cachePluginDataIfNecessary();
     m_plugInCacheRefCount++;
 }
index 15fc12e..82770e3 100644 (file)
@@ -31,7 +31,8 @@ namespace KJS {
 
   class Navigator : public DOMObject {
   public:
-    Navigator(ExecState *exec, WebCore::Frame *p);
+    Navigator(JSObject* prototype, WebCore::Frame*);
+
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     JSValue *getValueProperty(ExecState *exec, int token) const;
     virtual const ClassInfo* classInfo() const { return &info; }
index 496749b..a6e781b 100644 (file)
@@ -200,7 +200,7 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable };
 @end
 */
 
-Window::Window(DOMWindow* window, JSValue* prototype)
+Window::Window(JSObject* prototype, DOMWindow* window)
     : JSGlobalObject(prototype)
     , m_impl(window)
     , d(new WindowPrivate)
@@ -265,7 +265,7 @@ JSValue* Window::retrieve(Frame* frame)
 WebCore::JSLocation* Window::location() const
 {
     if (!d->loc)
-        d->loc = new JSLocation(impl()->frame());
+        d->loc = new JSLocation(0, impl()->frame()); // FIXME: we need to pass a prototype.
     return d->loc;
 }
 
@@ -471,7 +471,7 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
       if (!allowsAccessFrom(exec))
         return jsUndefined();
       // Store the navigator in the object so we get the same one each time.
-      Navigator *n = new Navigator(exec, impl()->frame());
+      Navigator* n = new Navigator(exec->lexicalGlobalObject()->objectPrototype(), impl()->frame());
       // FIXME: this will make the "navigator" object accessible from windows that fail
       // the security check the first time, but not subsequent times, seems weird.
       const_cast<Window *>(this)->putDirect("navigator", n, DontDelete|ReadOnly);
index 499ba81..664fcc3 100644 (file)
@@ -34,7 +34,6 @@ namespace WebCore {
     class JSEventListener;
     class JSLocation;
     class JSUnprotectedEventListener;
-    class Location;
     class PausedTimeouts;
     class ScheduledAction;
 }
@@ -49,11 +48,10 @@ namespace KJS {
   // This is the only WebCore JS binding which does not inherit from DOMObject
   class Window : public JSGlobalObject {
     typedef JSGlobalObject Base;
-    
-    friend class WebCore::JSLocation;
+
     friend class WebCore::ScheduledAction;
   protected:
-    Window(WebCore::DOMWindow*, JSValue* prototype);
+    Window(JSObject* prototype, WebCore::DOMWindow*);
 
   public:
     virtual ~Window();
index 844021e..7907e76 100644 (file)
@@ -323,11 +323,7 @@ sub GenerateHeader
     if ($dataNode->extendedAttributes->{"DoNotCache"}) {
         push(@headerContent, "    $className($passType);\n");
     } else {
-        if (IsSVGTypeNeedingContextParameter($implClassName)) {
-            push(@headerContent, "    $className(KJS::ExecState*, $passType, SVGElement* context);\n");
-        } else {
-            push(@headerContent, "    $className(KJS::ExecState*, $passType);\n");
-        }
+        push(@headerContent, "    $className(KJS::JSObject* prototype, $passType" . (IsSVGTypeNeedingContextParameter($implClassName) ? ", SVGElement* context" : "") .");\n");
     }
 
     # Destructor
@@ -780,40 +776,25 @@ sub GenerateImplementation
     my $podType = $dataNode->extendedAttributes->{"PODType"};
     my $passType = $podType ? "JSSVGPODTypeWrapper<$podType>*" : "$implClassName*";
 
+    my $needsSVGContext = IsSVGTypeNeedingContextParameter($implClassName);
+    my $parentNeedsSVGContext = ($needsSVGContext and $parentClassName =~ /SVG/);
+
     # Constructor
     if ($dataNode->extendedAttributes->{"DoNotCache"}) {
         push(@implContent, "${className}::$className($passType impl)\n");
-        push(@implContent, "    : $parentClassName(impl, ${className}Prototype::self())\n");
+        push(@implContent, "    : $parentClassName(${className}Prototype::self(), impl)\n");
     } else {
-        my $needsSVGContext = IsSVGTypeNeedingContextParameter($implClassName);
-        if ($needsSVGContext) {
-            push(@implContent, "${className}::$className(ExecState* exec, $passType impl, SVGElement* context)\n");
-        } else {
-            push(@implContent, "${className}::$className(ExecState* exec, $passType impl)\n");
-        }
-
+        push(@implContent, "${className}::$className(JSObject* prototype, $passType impl" . ($needsSVGContext ? ", SVGElement* context" : "") . ")\n");
         if ($hasParent) {
-            if ($needsSVGContext and $parentClassName =~ /SVG/) {
-                push(@implContent, "    : $parentClassName(exec, impl, context)\n");
-            } else {
-                push(@implContent, "    : $parentClassName(exec, impl)\n");
-            }
+            push(@implContent, "    : $parentClassName(prototype, impl" . ($parentNeedsSVGContext ? ", context" : "") . ")\n");
         } else {
-            if ($needsSVGContext) {
-                push(@implContent, "    : m_context(context)\n");
-                push(@implContent, "    , m_impl(impl)\n");
-            } else {
-                push(@implContent, "    : m_impl(impl)\n");
-            }            
+            push(@implContent, "    : $parentClassName(prototype)\n");
+            push(@implContent, "    , m_context(context)\n") if $needsSVGContext;
+            push(@implContent, "    , m_impl(impl)\n");  
         }
-    }
 
-    push(@implContent, "{\n");
-
-    if (!$dataNode->extendedAttributes->{"DoNotCache"}) {
-        push(@implContent, "    setPrototype(${className}Prototype::self(exec));\n");
     }
-
+    push(@implContent, "{\n");
     push(@implContent, "}\n\n");
 
     # Destructor
@@ -1205,11 +1186,11 @@ sub GenerateImplementation
 
         push(@implContent, "{\n");
         if ($podType) {
-            push(@implContent, "    return KJS::cacheSVGDOMObject<JSSVGPODTypeWrapper<$podType>, $className>(exec, obj, context);\n");
+            push(@implContent, "    return KJS::cacheSVGDOMObject<JSSVGPODTypeWrapper<$podType>, $className, ${className}Prototype>(exec, obj, context);\n");
         } elsif (IsSVGTypeNeedingContextParameter($implClassName)) {
-            push(@implContent, "    return KJS::cacheSVGDOMObject<$implClassName, $className>(exec, obj, context);\n");
+            push(@implContent, "    return KJS::cacheSVGDOMObject<$implClassName, $className, ${className}Prototype>(exec, obj, context);\n");
         } else {
-            push(@implContent, "    return KJS::cacheDOMObject<$implClassName, $className>(exec, obj);\n");
+            push(@implContent, "    return KJS::cacheDOMObject<$implClassName, $className, ${className}Prototype>(exec, obj);\n");
         }
         push(@implContent, "}\n");
     }
@@ -1750,8 +1731,8 @@ my $implContent = << "EOF";
 class ${className}Constructor : public DOMObject {
 public:
     ${className}Constructor(ExecState* exec)
+        : DOMObject(exec->lexicalGlobalObject()->objectPrototype())
     {
-        setPrototype(exec->lexicalGlobalObject()->objectPrototype());
         putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec), None);
     }
     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);