Commit ff5b28bd authored by weinig@apple.com's avatar weinig@apple.com

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29134 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 226b6314
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.
......
......@@ -11554,7 +11554,6 @@
B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */,
B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */,
B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
93B70D4109EB0C7C009D8468 /* JSXMLHttpRequest.cpp */,
93B70D4209EB0C7C009D8468 /* JSXMLHttpRequest.h */,
93B70D4509EB0C7C009D8468 /* JSXSLTProcessor.cpp */,
......@@ -11629,6 +11628,9 @@
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 */,
......@@ -11639,9 +11641,6 @@
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 */,
......@@ -11675,6 +11674,7 @@
B2C96D8C0B3AF2B7005E80EC /* JSSVGPathSegCustom.cpp */,
B297BC6F0B3C14CF0045A590 /* JSSVGPathSegListCustom.cpp */,
516BB7910CE91E6800512F79 /* JSSVGPointListCustom.cpp */,
B2D3FC890C2212CB00CF3618 /* JSSVGTransformListCustom.cpp */,
516BB7920CE91E6800512F79 /* JSTreeWalkerCustom.cpp */,
);
name = Custom;
......@@ -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;
}
......
......@@ -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;
......
/*
* 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.
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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)
{
}
......
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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
......@@ -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();
}
......
......@@ -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)
......
......@@ -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);
......
......@@ -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);
}
......
......@@ -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)
{
}
......
......@@ -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;
};
......
......@@ -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)
......
......@@ -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&);
......
......@@ -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);
......
......@@ -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());
}
}
......
......@@ -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);
}
}