Changeset 13150 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Mar 5, 2006, 7:58:15 PM (19 years ago)
Author:
ggaren
Message:

JavaScriptCore:

Reviewed by Maciej.

  • JSC support for the fix for <rdar://problem/4467143> JavaScript enumeration of HTML element properties skips DOM node properties
  • kjs/lookup.h: (1) Added the KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE macro. The class definiton macro needs to know about the prototype's prototype so that the class constructor properly sets it. (2) Removed the KJS_IMPLEMENT_PROTOTYPE_WITH_PARENT macro. The class implementation macro does not need to know about the prototype's prototype, since getOwnPropertySlot should only look in the current object's property map, and not its prototype's.

LayoutTests:

Reviewed by Maciej.

  • Layout test for <rdar://problem/4467143> JavaScript enumeration of HTML element properties skips DOM node properties
  • fast/dom/prototype-chain-expected.txt: Added.
  • fast/dom/prototype-chain.html: Added.

WebCore:

Reviewed by Maciej.

  • Second cut at fixing <rdar://problem/4467143> JavaScript enumeration of HTML element properties skips DOM node properties


The approach here is for prototypes, in their constructor methods,
to set their own prototypes, preserving the prototype
chain in cases of multiple levels of inheritance. (Previously, our
code assumed that a prototype never had a prototype of its own,
and always used an empty object as a prototype's prototype).

  • bindings/scripts/CodeGeneratorJS.pm: Use the new DEFINE_PROTOTYPE_WITH_PROTOTYPE macro in place of the KJS_IMPLEMENT_PROTOTYPE_WITH_PARENT macro.
  • khtml/ecma/kjs_dom.cpp: Ditto.
  • khtml/ecma/kjs_dom.h: Ditto.
  • khtml/ecma/kjs_events.cpp: Ditto.

Touched these files to force a rebuild:

  • bindings/js/JSDOMCore.cpp:
  • bindings/js/JSDOMEvents.cpp:
  • dom/Attr.idl:
  • dom/CharacterData.idl:
  • dom/DOMImplementation.idl:
  • dom/DocumentType.idl:
  • dom/Element.idl:
  • dom/Entity.idl:
  • dom/MutationEvent.idl:
  • dom/Notation.idl:
  • dom/ProcessingInstruction.idl:
  • dom/Text.idl:
  • dom/WheelEvent.idl:
File:
1 edited

Legend:

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

    r13089 r13150  
    296296 * and use DOMNodeProto::self(exec) as prototype in the DOMNode constructor.
    297297 * If the prototype has a "parent prototype", e.g. DOMElementProto falls back on DOMNodeProto,
    298  * then the last line will use IMPLEMENT_PROTOTYPE_WITH_PARENT, with DOMNodeProto as last argument.
     298 * then the first line will use KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE, with DOMNodeProto as the second argument.
    299299 */
    300300
     
    306306#endif
    307307
     308// These macros assume that a prototype's only properties are functions
    308309#define KJS_DEFINE_PROTOTYPE(ClassProto) \
    309310  class ClassProto : public KJS::JSObject { \
     
    316317  protected: \
    317318    ClassProto(KJS::ExecState *exec) \
    318       : JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { } \
     319      : KJS::JSObject(exec->lexicalInterpreter()->builtinObjectPrototype()) { } \
    319320    \
    320321  };
    321322
    322 #define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassProto,ClassFunc) \
     323#define KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(ClassProto, ClassProtoProto) \
     324    class ClassProto : public KJS::JSObject { \
     325        friend KJS::JSObject* KJS_GCC_ROOT_NS_HACK cacheGlobalObject<ClassProto>(KJS::ExecState* exec, const KJS::Identifier& propertyName); \
     326    public: \
     327        static KJS::JSObject* self(KJS::ExecState* exec); \
     328        virtual const KJS::ClassInfo* classInfo() const { return &info; } \
     329        static const KJS::ClassInfo info; \
     330        bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&); \
     331    protected: \
     332        ClassProto(KJS::ExecState* exec) \
     333            : KJS::JSObject(ClassProtoProto::self(exec)) { } \
     334    \
     335    };
     336
     337#define KJS_IMPLEMENT_PROTOTYPE(ClassName, ClassProto, ClassFunc) \
    323338    const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 }; \
    324339    JSObject *ClassProto::self(ExecState *exec) \
     
    328343    bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
    329344    { \
    330       return getStaticFunctionSlot<ClassFunc,JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \
    331     }
    332 
    333 #define KJS_IMPLEMENT_PROTOTYPE_WITH_PARENT(ClassName, ClassProto,ClassFunc,ParentProto)  \
    334     const ClassInfo ClassProto::info = { ClassName, 0, &ClassProto##Table, 0 }; \
    335     JSObject *ClassProto::self(ExecState *exec) \
    336     { \
    337         return ::cacheGlobalObject<ClassProto>(exec, "[[" ClassName ".prototype]]"); \
    338     } \
    339     bool ClassProto::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot) \
    340     { \
    341       if (getStaticFunctionSlot<ClassFunc,JSObject>(exec, &ClassProto##Table, this, propertyName, slot)) \
    342           return true; \
    343       return ParentProto::self(exec)->getOwnPropertySlot(exec, propertyName, slot); \
     345      return getStaticFunctionSlot<ClassFunc, JSObject>(exec, &ClassProto##Table, this, propertyName, slot); \
    344346    }
    345347
Note: See TracChangeset for help on using the changeset viewer.