Changeset 18912 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Jan 17, 2007, 11:34:43 AM (18 years ago)
Author:
ap
Message:

Reviewed by Maciej.

http://bugs.webkit.org/show_bug.cgi?id=12268
Give object prototypes their own names

JavaScriptCore:

  • kjs/lookup.h: Append "Prototype" to ClassName in KJS_IMPLEMENT_PROTOTYPE.

WebCore:

  • bindings/scripts/CodeGeneratorJS.pm: Append "Proto" to interface name for the prototype's ClassInfo.
  • bindings/js/JSHTMLInputElementBase.cpp: (WebCore::JSHTMLInputElementBasePrototypeFunction::callAsFunction): (WebCore::JSHTMLInputElementBase::JSHTMLInputElementBase):
  • bindings/js/JSHTMLInputElementBase.h:
  • bindings/js/JSXMLHttpRequest.cpp: (KJS::JSXMLHttpRequestConstructorImp::JSXMLHttpRequestConstructorImp): (KJS::JSXMLHttpRequest::JSXMLHttpRequest): (KJS::JSXMLHttpRequestPrototypeFunction::callAsFunction):
  • bindings/js/JSXMLHttpRequest.h:
  • bindings/js/JSXSLTProcessor.cpp: (KJS::JSXSLTProcessor::JSXSLTProcessor): (KJS::XSLTProcessorPrototypeFunction::callAsFunction): (KJS::XSLTProcessorConstructorImp::XSLTProcessorConstructorImp):
  • bindings/js/kjs_css.cpp: (KJS::DOMCSSStyleDeclaration::DOMCSSStyleDeclaration): (KJS::DOMCSSStyleDeclarationPrototypeFunction::callAsFunction): (KJS::DOMMediaList::DOMMediaList): (KJS::KJS::DOMMediaListPrototypeFunction::callAsFunction): (KJS::DOMCSSStyleSheet::DOMCSSStyleSheet): (KJS::DOMCSSStyleSheetPrototypeFunction::callAsFunction): (KJS::DOMCSSValue::DOMCSSValue): (KJS::DOMCSSValuePrototypeFunction::callAsFunction):
  • bindings/js/kjs_css.h:
  • bindings/js/kjs_dom.cpp: (KJS::DOMNode::DOMNode): (KJS::DOMNodePrototypeFunction::callAsFunction): (KJS::DOMEventTargetNode::DOMEventTargetNode): (KJS::DOMEventTargetNodePrototypeFunction::callAsFunction): (KJS::DOMNamedNodeMap::DOMNamedNodeMap): (KJS::DOMNamedNodeMapPrototypeFunction::callAsFunction):
  • bindings/js/kjs_dom.h:
  • bindings/js/kjs_domnode.h:
  • bindings/js/kjs_events.cpp: (KJS::DOMEvent::DOMEvent): (KJS::DOMEventPrototypeFunction::callAsFunction): (KJS::Clipboard::Clipboard): (KJS::ClipboardPrototypeFunction::callAsFunction):
  • bindings/js/kjs_events.h:
  • bindings/js/kjs_html.cpp: (KJS::JSHTMLDocumentPrototypeFunction::callAsFunction): (KJS::): (KJS::JSHTMLDocument::JSHTMLDocument): (KJS::JSHTMLElementPrototypeFunction::callAsFunction): (KJS::JSHTMLElement::JSHTMLElement): (KJS::JSHTMLCollection::JSHTMLCollection): (KJS::JSHTMLCollectionPrototypeFunction::callAsFunction):
  • bindings/js/kjs_html.h:
  • bindings/js/kjs_navigator.cpp:
  • bindings/js/kjs_traversal.cpp: (KJS::DOMNodeFilter::DOMNodeFilter): (KJS::DOMNodeFilterPrototypeFunction::callAsFunction):
  • bindings/js/kjs_window.cpp: (KJS::Window::clear): Changed Proto to Prototype, and ProtoFunc to PrototypeFunction.

LayoutTests:

  • fast/dom/Window/window-properties-expected.txt:
  • fast/dom/prototype-chain-expected.txt:
  • fast/events/event-view-toString-expected.txt:
  • fast/events/mouseclick-target-and-positioning-expected.txt:
  • fast/tokenizer/external-script-document-write-expected.checksum:
  • fast/tokenizer/external-script-document-write-expected.png:
  • fast/tokenizer/external-script-document-write-expected.txt: Updated the results.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/lookup.h

    r16711 r18912  
    297297 * the functions for a type of objects).
    298298 * Sorry for this not being very readable, but it actually saves much copy-n-paste.
    299  * ParentProto is not our base class, it's the object we use as fallback.
     299 * ParentPrototype is not our base class, it's the object we use as fallback.
    300300 * The reason for this is that there should only be ONE DOMNode.hasAttributes (e.g.),
    301301 * not one in each derived class. So we link the (unique) prototypes between them.
    302302 *
    303  * Using those macros is very simple: define the hashtable (e.g. "DOMNodeProtoTable"), then
    304  * KJS_DEFINE_PROTOTYPE(DOMNodeProto)
    305  * KJS_IMPLEMENT_PROTOFUNC(DOMNodeProtoFunc)
    306  * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodeProto,DOMNodeProtoFunc)
    307  * and use DOMNodeProto::self(exec) as prototype in the DOMNode constructor.
    308  * If the prototype has a "parent prototype", e.g. DOMElementProto falls back on DOMNodeProto,
    309  * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodeProto as the second argument.
     303 * Using those macros is very simple: define the hashtable (e.g. "DOMNodePrototypeTable"), then
     304 * KJS_DEFINE_PROTOTYPE(DOMNodePrototype)
     305 * KJS_IMPLEMENT_PROTOFUNC(DOMNodePrototypeFunction)
     306 * KJS_IMPLEMENT_PROTOTYPE("DOMNode", DOMNodePrototype, DOMNodePrototypeFunction)
     307 * and use DOMNodePrototype::self(exec) as prototype in the DOMNode constructor.
     308 * If the prototype has a "parent prototype", e.g. DOMElementPrototype falls back on DOMNodePrototype,
     309 * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodePrototype as the second argument.
    310310 */
    311311
    312312// These macros assume that a prototype's only properties are functions
    313 #define KJS_DEFINE_PROTOTYPE(ClassProto) \
    314   class ClassProto : public KJS::JSObject { \
     313#define KJS_DEFINE_PROTOTYPE(ClassPrototype) \
     314  class ClassPrototype : public KJS::JSObject { \
    315315  public: \
    316316    static KJS::JSObject* self(KJS::ExecState* exec); \
     
    318318    static const KJS::ClassInfo info; \
    319319    bool getOwnPropertySlot(KJS::ExecState* , const KJS::Identifier&, KJS::PropertySlot&); \
    320     ClassProto(KJS::ExecState* exec) \
     320    ClassPrototype(KJS::ExecState* exec) \
    321321      : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { } \
    322322    \
    323323  };
    324324
    325 #define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassProto, ClassProtoProto) \
    326     class ClassProto : public KJS::JSObject { \
     325#define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassPrototype, ClassPrototypePrototype) \
     326    class ClassPrototype : public KJS::JSObject { \
    327327    public: \
    328328        static KJS::JSObject* self(KJS::ExecState* exec); \
     
    330330        static const KJS::ClassInfo info; \
    331331        bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \
    332         ClassProto(KJS::ExecState* exec) \
    333             : KJS::JSObject(ClassProtoProto::self(exec)) { } \
     332        ClassPrototype(KJS::ExecState* exec) \
     333            : KJS::JSObject(ClassPrototypePrototype::self(exec)) { } \
    334334    \
    335335    };
    336336
    337 #define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassProto, ClassFunc) \
    338     const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 }; \
    339     JSObject* ClassProto::self(ExecState* exec) \
     337#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassPrototype, ClassFunction) \
     338    const ClassInfo ClassPrototype::info = { ClassName"Prototype", 0, &ClassPrototype##Table, 0 }; \
     339    JSObject* ClassPrototype::self(ExecState* exec) \
    340340    { \
    341         return KJS::cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
     341        return KJS::cacheGlobalObject<ClassPrototype>(exec, "[[" ClassName ".prototype]]"); \
    342342    } \
    343     bool ClassProto::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
     343    bool ClassPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) \
    344344    { \
    345       return getStaticFunctionSlot<ClassFunc, JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \
     345      return getStaticFunctionSlot<ClassFunction, JSObject>(exec, &ClassPrototype##Table, this, propertyName, slot); \
    346346    }
    347347
    348 #define KJS_IMPLEMENT_PROTOFUNC(ClassFunc) \
    349   class ClassFunc : public InternalFunctionImp { \
     348#define KJS_IMPLEMENT_PROTOTYPE_FUNCTION(ClassFunction) \
     349  class ClassFunction : public InternalFunctionImp { \
    350350  public: \
    351     ClassFunc(ExecState* exec, int i, int len, const Identifier& name) \
     351    ClassFunction(ExecState* exec, int i, int len, const Identifier& name) \
    352352      : InternalFunctionImp(static_cast<FunctionPrototype*>(exec->lexicalInterpreter()->builtinFunctionPrototype()), name) \
    353353      , id(i) \
Note: See TracChangeset for help on using the changeset viewer.