Changeset 106783 in webkit


Ignore:
Timestamp:
Feb 6, 2012 12:56:02 AM (12 years ago)
Author:
barraclough@apple.com
Message:

Remove JSObject defineGetter/defineSetter lookupGetter/lookupSetter
https://bugs.webkit.org/show_bug.cgi?id=77451

Reviewed by Sam Weinig.

These can now all be implemented in terms of defineOwnProperty & getPropertyDescriptor.
Also remove initializeGetterSetterProperty, since this is equivalent to putDirectAccessor.

Source/JavaScriptCore:

(JSC::DebuggerActivation::defineOwnProperty):

  • debugger/DebuggerActivation.h:

(DebuggerActivation):

  • runtime/ClassInfo.h:

(MethodTable):
(JSC):

  • runtime/JSBoundFunction.cpp:

(JSC::JSBoundFunction::finishCreation):

  • runtime/JSCell.cpp:

(JSC):

  • runtime/JSCell.h:

(JSCell):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::getOwnPropertySlot):
(JSC::JSFunction::getOwnPropertyDescriptor):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::defineOwnProperty):
(JSC):

  • runtime/JSGlobalObject.h:

(JSGlobalObject):

  • runtime/JSObject.cpp:

(JSC):

  • runtime/JSObject.h:

(JSObject):

  • runtime/ObjectPrototype.cpp:

(JSC::objectProtoFuncDefineGetter):
(JSC::objectProtoFuncDefineSetter):
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):

Source/WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore):
(WebCore::JSDOMWindow::defineOwnProperty):

  • bindings/js/JSDOMWindowShell.cpp:

(WebCore):

  • bindings/js/JSDOMWindowShell.h:

(JSDOMWindowShell):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::defineOwnProperty):
(WebCore::JSLocationPrototype::defineOwnProperty):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • page/DOMWindow.idl:
  • page/Location.idl:

Source/WebKit/qt:

  • Api/qwebframe.cpp:

(QWebFramePrivate::addQtSenderToGlobalObject):

Location:
trunk/Source
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r106782 r106783  
     12012-02-05  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Remove JSObject defineGetter/defineSetter lookupGetter/lookupSetter
     4        https://bugs.webkit.org/show_bug.cgi?id=77451
     5
     6        Reviewed by Sam Weinig.
     7
     8        These can now all be implemented in terms of defineOwnProperty & getPropertyDescriptor.
     9        Also remove initializeGetterSetterProperty, since this is equivalent to putDirectAccessor.
     10
     11        * JavaScriptCore.exp:
     12        * debugger/DebuggerActivation.cpp:
     13        (JSC::DebuggerActivation::defineOwnProperty):
     14        * debugger/DebuggerActivation.h:
     15        (DebuggerActivation):
     16        * runtime/ClassInfo.h:
     17        (MethodTable):
     18        (JSC):
     19        * runtime/JSBoundFunction.cpp:
     20        (JSC::JSBoundFunction::finishCreation):
     21        * runtime/JSCell.cpp:
     22        (JSC):
     23        * runtime/JSCell.h:
     24        (JSCell):
     25        * runtime/JSFunction.cpp:
     26        (JSC::JSFunction::getOwnPropertySlot):
     27        (JSC::JSFunction::getOwnPropertyDescriptor):
     28        * runtime/JSGlobalObject.cpp:
     29        (JSC::JSGlobalObject::defineOwnProperty):
     30        (JSC):
     31        * runtime/JSGlobalObject.h:
     32        (JSGlobalObject):
     33        * runtime/JSObject.cpp:
     34        (JSC):
     35        * runtime/JSObject.h:
     36        (JSObject):
     37        * runtime/ObjectPrototype.cpp:
     38        (JSC::objectProtoFuncDefineGetter):
     39        (JSC::objectProtoFuncDefineSetter):
     40        (JSC::objectProtoFuncLookupGetter):
     41        (JSC::objectProtoFuncLookupSetter):
     42
    1432012-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
    244
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r106676 r106783  
    136136    ?defaultAttributes@PropertyDescriptor@JSC@@0IA
    137137    ?defaultValue@JSObject@JSC@@SA?AVJSValue@2@PBV12@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
    138     ?defineGetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z
    139     ?defineGetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z
     138    ?defineOwnProperty@JSGlobalObject@JSC@@SA_NPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z
    140139    ?defineOwnProperty@JSObject@JSC@@SA_NPAV12@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z
    141     ?defineSetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z
    142     ?defineSetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z
    143140    ?deleteOwnedPtr@WTF@@YAXPAUHBITMAP__@@@Z
    144141    ?deleteOwnedPtr@WTF@@YAXPAUHBRUSH__@@@Z
     
    179176    ?fastStrDup@WTF@@YAPADPBD@Z
    180177    ?fastZeroedMalloc@WTF@@YAPAXI@Z
    181     ?fillGetterPropertySlot@JSObject@JSC@@QAEXAAVPropertySlot@2@PAV?$WriteBarrierBase@W4Unknown@JSC@@@2@@Z
     178    ?fillGetterPropertySlot@JSObject@JSC@@AAEXAAVPropertySlot@2@PAV?$WriteBarrierBase@W4Unknown@JSC@@@2@@Z
    182179    ?finalize@WeakHandleOwner@JSC@@UAEXV?$Handle@W4Unknown@JSC@@@2@PAX@Z
    183180    ?finishCreation@DateInstance@JSC@@IAEXAAVJSGlobalData@2@N@Z
  • trunk/Source/JavaScriptCore/debugger/DebuggerActivation.cpp

    r104899 r106783  
    102102}
    103103
    104 void DebuggerActivation::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
     104bool DebuggerActivation::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow)
    105105{
    106106    DebuggerActivation* thisObject = jsCast<DebuggerActivation*>(object);
    107     thisObject->m_activation->methodTable()->defineGetter(thisObject->m_activation.get(), exec, propertyName, getterFunction, attributes);
    108 }
    109 
    110 void DebuggerActivation::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
    111 {
    112     DebuggerActivation* thisObject = jsCast<DebuggerActivation*>(object);
    113     thisObject->m_activation->methodTable()->defineSetter(thisObject->m_activation.get(), exec, propertyName, setterFunction, attributes);
     107    return thisObject->m_activation->methodTable()->defineOwnProperty(thisObject->m_activation.get(), exec, propertyName, descriptor, shouldThrow);
    114108}
    115109
  • trunk/Source/JavaScriptCore/debugger/DebuggerActivation.h

    r104900 r106783  
    5050        static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
    5151        static bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&);
    52         static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes);
    53         static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes);
     52        static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
    5453
    5554        JS_EXPORTDATA static const ClassInfo s_info;
  • trunk/Source/JavaScriptCore/runtime/ClassInfo.h

    r104899 r106783  
    6767        ToThisObjectFunctionPtr toThisObject;
    6868
    69         typedef void (*DefineGetterFunctionPtr)(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
    70         DefineGetterFunctionPtr defineGetter;
    71 
    72         typedef void (*DefineSetterFunctionPtr)(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
    73         DefineSetterFunctionPtr defineSetter;
    74 
    7569        typedef JSValue (*DefaultValueFunctionPtr)(const JSObject*, ExecState*, PreferredPrimitiveType);
    7670        DefaultValueFunctionPtr defaultValue;
     
    129123        &ClassName::getOwnPropertySlotByIndex, \
    130124        &ClassName::toThisObject, \
    131         &ClassName::defineGetter, \
    132         &ClassName::defineSetter, \
    133125        &ClassName::defaultValue, \
    134126        &ClassName::getOwnPropertyNames, \
  • trunk/Source/JavaScriptCore/runtime/JSBoundFunction.cpp

    r104784 r106783  
    2727#include "JSBoundFunction.h"
    2828
     29#include "GetterSetter.h"
    2930#include "JSGlobalObject.h"
    3031
     
    112113    ASSERT(inherits(&s_info));
    113114
    114     initializeGetterSetterProperty(exec, exec->propertyNames().arguments, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    115     initializeGetterSetterProperty(exec, exec->propertyNames().caller, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     115    putDirectAccessor(exec->globalData(), exec->propertyNames().arguments, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     116    putDirectAccessor(exec->globalData(), exec->propertyNames().caller, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    116117}
    117118
  • trunk/Source/JavaScriptCore/runtime/JSCell.cpp

    r105698 r106783  
    159159}
    160160
    161 void JSCell::defineGetter(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned)
    162 {
    163     ASSERT_NOT_REACHED();
    164 }
    165 
    166 void JSCell::defineSetter(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned)
    167 {
    168     ASSERT_NOT_REACHED();
    169 }
    170 
    171161JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType)
    172162{
  • trunk/Source/JavaScriptCore/runtime/JSCell.h

    r105698 r106783  
    153153
    154154        // Dummy implementations of override-able static functions for classes to put in their MethodTable
    155         static NO_RETURN_DUE_TO_ASSERT void defineGetter(JSObject*, ExecState*, const Identifier&, JSObject*, unsigned);
    156         static NO_RETURN_DUE_TO_ASSERT void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes = 0);
    157155        static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType);
    158156        static NO_RETURN_DUE_TO_ASSERT void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r106504 r106783  
    3131#include "ExceptionHelpers.h"
    3232#include "FunctionPrototype.h"
     33#include "GetterSetter.h"
    3334#include "JSArray.h"
    3435#include "JSGlobalObject.h"
     
    220221            bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    221222            if (!result) {
    222                 thisObject->initializeGetterSetterProperty(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     223                thisObject->putDirectAccessor(exec->globalData(), propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    223224                result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    224225                ASSERT(result);
     
    239240            bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    240241            if (!result) {
    241                 thisObject->initializeGetterSetterProperty(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     242                thisObject->putDirectAccessor(exec->globalData(), propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    242243                result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    243244                ASSERT(result);
     
    268269            bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
    269270            if (!result) {
    270                 thisObject->initializeGetterSetterProperty(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     271                thisObject->putDirectAccessor(exec->globalData(), propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    271272                result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
    272273                ASSERT(result);
     
    287288            bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
    288289            if (!result) {
    289                 thisObject->initializeGetterSetterProperty(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
     290                thisObject->putDirectAccessor(exec->globalData(), propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
    290291                result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
    291292                ASSERT(result);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r104899 r106783  
    172172}
    173173
    174 void JSGlobalObject::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes)
     174bool JSGlobalObject::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow)
    175175{
    176176    JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
    177177    PropertySlot slot;
    178     if (!thisObject->symbolTableGet(propertyName, slot))
    179         JSVariableObject::defineGetter(thisObject, exec, propertyName, getterFunc, attributes);
    180 }
    181 
    182 void JSGlobalObject::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunc, unsigned attributes)
    183 {
    184     JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object);
    185     PropertySlot slot;
    186     if (!thisObject->symbolTableGet(propertyName, slot))
    187         JSVariableObject::defineSetter(thisObject, exec, propertyName, setterFunc, attributes);
    188 }
     178    // silently ignore attempts to add accessors aliasing vars.
     179    if (descriptor.isAccessorDescriptor() && thisObject->symbolTableGet(propertyName, slot))
     180        return false;
     181    return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
     182}
     183
    189184
    190185static inline JSObject* lastInPrototypeChain(JSObject* object)
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r104900 r106783  
    207207        JS_EXPORT_PRIVATE static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes);
    208208        JS_EXPORT_PRIVATE static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunc, unsigned attributes);
     209        JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
    209210
    210211        // We use this in the code generator as we perform symbol table
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r106255 r106783  
    360360    }
    361361    return 0;
    362 }
    363 
    364 void JSObject::defineGetter(JSObject* thisObject, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
    365 {
    366     if (propertyName == exec->propertyNames().underscoreProto) {
    367         // Defining a getter for __proto__ is silently ignored.
    368         return;
    369     }
    370 
    371     JSValue object = thisObject->getDirect(exec->globalData(), propertyName);
    372     if (object && object.isGetterSetter()) {
    373         ASSERT(thisObject->structure()->hasGetterSetterProperties());
    374         asGetterSetter(object)->setGetter(exec->globalData(), getterFunction);
    375         return;
    376     }
    377 
    378     JSGlobalData& globalData = exec->globalData();
    379     PutPropertySlot slot;
    380     GetterSetter* getterSetter = GetterSetter::create(exec);
    381     thisObject->putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, getterSetter, attributes | Accessor, slot, 0);
    382 
    383     // putDirect will change our Structure if we add a new property. For
    384     // getters and setters, though, we also need to change our Structure
    385     // if we override an existing non-getter or non-setter.
    386     if (slot.type() != PutPropertySlot::NewProperty)
    387         thisObject->setStructure(exec->globalData(), Structure::attributeChangeTransition(globalData, thisObject->structure(), propertyName, attributes | Accessor));
    388 
    389     thisObject->structure()->setHasGetterSetterProperties(true);
    390     getterSetter->setGetter(globalData, getterFunction);
    391 }
    392 
    393 void JSObject::initializeGetterSetterProperty(ExecState* exec, const Identifier& propertyName, GetterSetter* getterSetter, unsigned attributes)
    394 {
    395     // Set an inital property on an object; the property must not already exist & the attribute flags must be set correctly.
    396     ASSERT(structure()->get(exec->globalData(), propertyName) == WTF::notFound);
    397     ASSERT(static_cast<bool>(attributes & Accessor));
    398 
    399     JSGlobalData& globalData = exec->globalData();
    400     PutPropertySlot slot;
    401     putDirectInternal<PutModeDefineOwnProperty>(globalData, propertyName, getterSetter, attributes, slot, 0);
    402 
    403     // putDirect will change our Structure if we add a new property. For
    404     // getters and setters, though, we also need to change our Structure
    405     // if we override an existing non-getter or non-setter.
    406     if (slot.type() != PutPropertySlot::NewProperty)
    407         setStructure(exec->globalData(), Structure::attributeChangeTransition(globalData, structure(), propertyName, attributes));
    408 
    409     structure()->setHasGetterSetterProperties(true);
    410 }
    411 
    412 void JSObject::defineSetter(JSObject* thisObject, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
    413 {
    414     if (propertyName == exec->propertyNames().underscoreProto) {
    415         // Defining a setter for __proto__ is silently ignored.
    416         return;
    417     }
    418 
    419     JSValue object = thisObject->getDirect(exec->globalData(), propertyName);
    420     if (object && object.isGetterSetter()) {
    421         ASSERT(thisObject->structure()->hasGetterSetterProperties());
    422         asGetterSetter(object)->setSetter(exec->globalData(), setterFunction);
    423         return;
    424     }
    425 
    426     PutPropertySlot slot;
    427     GetterSetter* getterSetter = GetterSetter::create(exec);
    428     thisObject->putDirectInternal<PutModeDefineOwnProperty>(exec->globalData(), propertyName, getterSetter, attributes | Accessor, slot, 0);
    429 
    430     // putDirect will change our Structure if we add a new property. For
    431     // getters and setters, though, we also need to change our Structure
    432     // if we override an existing non-getter or non-setter.
    433     if (slot.type() != PutPropertySlot::NewProperty)
    434         thisObject->setStructure(exec->globalData(), Structure::attributeChangeTransition(exec->globalData(), thisObject->structure(), propertyName, attributes | Accessor));
    435 
    436     thisObject->structure()->setHasGetterSetterProperties(true);
    437     getterSetter->setSetter(exec->globalData(), setterFunction);
    438 }
    439 
    440 JSValue JSObject::lookupGetter(ExecState* exec, const Identifier& propertyName)
    441 {
    442     PropertyDescriptor descriptor;
    443     if (!getPropertyDescriptor(exec, propertyName, descriptor))
    444         return jsUndefined();
    445 
    446     if (!descriptor.getterPresent())
    447         return jsUndefined();
    448 
    449     return descriptor.getter();
    450 }
    451 
    452 JSValue JSObject::lookupSetter(ExecState* exec, const Identifier& propertyName)
    453 {
    454     PropertyDescriptor descriptor;
    455     if (!getPropertyDescriptor(exec, propertyName, descriptor))
    456         return jsUndefined();
    457 
    458     if (!descriptor.setterPresent())
    459         return jsUndefined();
    460    
    461     return descriptor.setter();
    462362}
    463363
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r106512 r106783  
    193193        void putUndefinedAtDirectOffset(size_t offset) { propertyStorage()[offset].setUndefined(); }
    194194
    195         JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, WriteBarrierBase<Unknown>* location);
    196         void initializeGetterSetterProperty(ExecState*, const Identifier&, GetterSetter*, unsigned attributes);
    197 
    198         JS_EXPORT_PRIVATE static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes = 0);
    199         JS_EXPORT_PRIVATE static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes = 0);
    200         JS_EXPORT_PRIVATE JSValue lookupGetter(ExecState*, const Identifier& propertyName);
    201         JS_EXPORT_PRIVATE JSValue lookupSetter(ExecState*, const Identifier& propertyName);
    202195        JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
    203196
     
    297290
    298291        bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     292        JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, WriteBarrierBase<Unknown>* location);
    299293
    300294        const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
  • trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp

    r105698 r106783  
    147147        return JSValue::encode(jsUndefined());
    148148
     149    JSValue get = exec->argument(1);
    149150    CallData callData;
    150     if (getCallData(exec->argument(1), callData) == CallTypeNone)
     151    if (getCallData(get, callData) == CallTypeNone)
    151152        return throwVMError(exec, createSyntaxError(exec, "invalid getter usage"));
    152     thisObject->methodTable()->defineGetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), asObject(exec->argument(1)), 0);
     153
     154    PropertyDescriptor descriptor;
     155    descriptor.setGetter(get);
     156    descriptor.setEnumerable(true);
     157    descriptor.setConfigurable(true);
     158    thisObject->methodTable()->defineOwnProperty(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor, false);
     159
    153160    return JSValue::encode(jsUndefined());
    154161}
     
    160167        return JSValue::encode(jsUndefined());
    161168
     169    JSValue set = exec->argument(1);
    162170    CallData callData;
    163     if (getCallData(exec->argument(1), callData) == CallTypeNone)
     171    if (getCallData(set, callData) == CallTypeNone)
    164172        return throwVMError(exec, createSyntaxError(exec, "invalid setter usage"));
    165     thisObject->methodTable()->defineSetter(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), asObject(exec->argument(1)), 0);
     173
     174    PropertyDescriptor descriptor;
     175    descriptor.setSetter(set);
     176    descriptor.setEnumerable(true);
     177    descriptor.setConfigurable(true);
     178    thisObject->methodTable()->defineOwnProperty(thisObject, exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor, false);
     179
    166180    return JSValue::encode(jsUndefined());
    167181}
     
    173187        return JSValue::encode(jsUndefined());
    174188
    175     return JSValue::encode(thisObject->lookupGetter(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec))));
     189    PropertyDescriptor descriptor;
     190    if (thisObject->getPropertyDescriptor(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor)
     191        && descriptor.getterPresent())
     192        return JSValue::encode(descriptor.getter());
     193
     194    return JSValue::encode(jsUndefined());
    176195}
    177196
     
    182201        return JSValue::encode(jsUndefined());
    183202
    184     return JSValue::encode(thisObject->lookupSetter(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec))));
     203    PropertyDescriptor descriptor;
     204    if (thisObject->getPropertyDescriptor(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor)
     205        && descriptor.setterPresent())
     206        return JSValue::encode(descriptor.setter());
     207
     208    return JSValue::encode(jsUndefined());
    185209}
    186210
  • trunk/Source/WebCore/ChangeLog

    r106782 r106783  
     12012-02-05  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Remove JSObject defineGetter/defineSetter lookupGetter/lookupSetter
     4        https://bugs.webkit.org/show_bug.cgi?id=77451
     5
     6        Reviewed by Sam Weinig.
     7
     8        These can now all be implemented in terms of defineOwnProperty & getPropertyDescriptor.
     9        Also remove initializeGetterSetterProperty, since this is equivalent to putDirectAccessor.
     10
     11        * bindings/js/JSDOMWindowCustom.cpp:
     12        (WebCore):
     13        (WebCore::JSDOMWindow::defineOwnProperty):
     14        * bindings/js/JSDOMWindowShell.cpp:
     15        (WebCore):
     16        * bindings/js/JSDOMWindowShell.h:
     17        (JSDOMWindowShell):
     18        * bindings/js/JSLocationCustom.cpp:
     19        (WebCore::JSLocation::defineOwnProperty):
     20        (WebCore::JSLocationPrototype::defineOwnProperty):
     21        * bindings/scripts/CodeGeneratorJS.pm:
     22        (GenerateHeader):
     23        * page/DOMWindow.idl:
     24        * page/Location.idl:
     25
    1262012-02-06  Carlos Garcia Campos  <cgarcia@igalia.com>
    227
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r105698 r106783  
    389389}
    390390
    391 void JSDOMWindow::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
    392 {
    393     JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
    394     // Only allow defining getters by frames in the same origin.
    395     if (!thisObject->allowsAccessFrom(exec))
    396         return;
    397 
    398     // Don't allow shadowing location using defineGetter.
    399     if (propertyName == "location")
    400         return;
    401 
    402     Base::defineGetter(thisObject, exec, propertyName, getterFunction, attributes);
    403 }
    404 
    405 void JSDOMWindow::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
    406 {
    407     JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
    408     // Only allow defining setters by frames in the same origin.
    409     if (!thisObject->allowsAccessFrom(exec))
    410         return;
    411     Base::defineSetter(thisObject, exec, propertyName, setterFunction, attributes);
    412 }
    413 
    414391bool JSDOMWindow::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
    415392{
     
    418395    if (!thisObject->allowsAccessFrom(exec))
    419396        return false;
     397
     398    // Don't allow shadowing location using accessor properties.
     399    if (descriptor.isAccessorDescriptor() && propertyName == "location")
     400        return false;
     401
    420402    return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
    421403}
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp

    r104899 r106783  
    140140}
    141141
    142 void JSDOMWindowShell::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
    143 {
    144     JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
    145     thisObject->window()->methodTable()->defineGetter(thisObject->window(), exec, propertyName, getterFunction, attributes);
    146 }
    147 
    148 void JSDOMWindowShell::defineSetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes)
    149 {
    150     JSDOMWindowShell* thisObject = jsCast<JSDOMWindowShell*>(object);
    151     thisObject->window()->methodTable()->defineSetter(thisObject->window(), exec, propertyName, setterFunction, attributes);
    152 }
    153 
    154142
    155143// ----
  • trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h

    r104899 r106783  
    8787        static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
    8888        static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
    89         static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);
    90         static void defineSetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);
    9189        static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);
    9290
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r106618 r106783  
    171171}
    172172
    173 void JSLocation::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
    174 {
    175     if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
    176         return;
    177     Base::defineGetter(object, exec, propertyName, getterFunction, attributes);
     173bool JSLocation::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
     174{
     175    if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
     176        return false;
     177    return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    178178}
    179179
     
    282282}
    283283
    284 void JSLocationPrototype::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)
    285 {
    286     if (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf)
    287         return;
    288     Base::defineGetter(object, exec, propertyName, getterFunction, attributes);
     284bool JSLocationPrototype::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
     285{
     286    if (descriptor.isAccessorDescriptor() && (propertyName == exec->propertyNames().toString || propertyName == exec->propertyNames().valueOf))
     287        return false;
     288    return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    289289}
    290290
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r106776 r106783  
    828828    }
    829829
    830     # Custom defineProperty function exists on DOMWindow
    831     push(@headerContent, "    static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow";
    832 
    833830    # Custom getOwnPropertyNames function
    834831    if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {
     
    837834    }
    838835
    839     # Custom defineGetter function
    840     push(@headerContent, "    static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomDefineGetter"};
    841 
    842     # Custom defineSetter function
    843     push(@headerContent, "    static void defineSetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomDefineSetter"};
     836    # Custom defineOwnProperty function
     837    push(@headerContent, "    static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $dataNode->extendedAttributes->{"CustomDefineOwnProperty"};
    844838
    845839    # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'.
     
    10611055    }
    10621056
    1063     # Custom defineGetter function
    1064     push(@headerContent, "    static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);\n") if $dataNode->extendedAttributes->{"CustomPrototypeDefineGetter"};
     1057    # Custom defineOwnProperty function
     1058    push(@headerContent, "    static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $dataNode->extendedAttributes->{"CustomPrototypeDefineOwnProperty"};
    10651059
    10661060    push(@headerContent, "\nprivate:\n");
  • trunk/Source/WebCore/page/DOMWindow.idl

    r106776 r106783  
    2929    interface [
    3030        CheckDomainSecurity,
    31         CustomDefineGetter,
    32         CustomDefineSetter,
     31        CustomDefineOwnProperty,
    3332        CustomDeleteProperty,
    3433        CustomGetOwnPropertySlot,
  • trunk/Source/WebCore/page/Location.idl

    r106737 r106783  
    3838        CustomDeleteProperty,
    3939        CustomGetPropertyNames,
    40         CustomDefineGetter,
     40        CustomDefineOwnProperty,
    4141        JSCustomPrototypePutDelegate,
    42         CustomPrototypeDefineGetter,
     42        CustomPrototypeDefineOwnProperty,
    4343        OmitConstructor
    4444    ] Location {
  • trunk/Source/WebKit/qt/Api/qwebframe.cpp

    r106659 r106783  
    7070#include "PrintContext.h"
    7171#if USE(JSC)
     72#include "PropertyDescriptor.h"
    7273#include "PutPropertySlot.h"
    7374#endif
     
    518519
    519520    // JSC public API doesn't support setting a Getter for a property of a given object, https://bugs.webkit.org/show_bug.cgi?id=61374.
    520     window->methodTable()->defineGetter(window, exec, propertyName.get()->identifier(&exec->globalData()), ::toJS(function),
    521                          JSC::ReadOnly | JSC::DontEnum | JSC::DontDelete);
     521    JSC::PropertyDescriptor descriptor;
     522    descriptor.setGetter(::toJS(function));
     523    descriptor.setSetter(JSC::jsUndefined());
     524    descriptor.setEnumerable(false);
     525    descriptor.setConfigurable(false);
     526    window->methodTable()->defineOwnProperty(window, exec, propertyName.get()->identifier(&exec->globalData()), descriptor, false);
    522527}
    523528#endif
  • trunk/Source/WebKit/qt/ChangeLog

    r106695 r106783  
     12012-02-05  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Remove JSObject defineGetter/defineSetter lookupGetter/lookupSetter
     4        https://bugs.webkit.org/show_bug.cgi?id=77451
     5
     6        Reviewed by Sam Weinig.
     7
     8        These can now all be implemented in terms of defineOwnProperty & getPropertyDescriptor.
     9        Also remove initializeGetterSetterProperty, since this is equivalent to putDirectAccessor.
     10
     11        * Api/qwebframe.cpp:
     12        (QWebFramePrivate::addQtSenderToGlobalObject):
     13
    1142012-02-03  Antti Koivisto  <antti@apple.com>
    215
Note: See TracChangeset for help on using the changeset viewer.