Changeset 106783 in webkit
- Timestamp:
- Feb 6, 2012 12:56:02 AM (12 years ago)
- Location:
- trunk/Source
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r106782 r106783 1 2012-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 1 43 2012-02-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 44 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r106676 r106783 136 136 ?defaultAttributes@PropertyDescriptor@JSC@@0IA 137 137 ?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 140 139 ?defineOwnProperty@JSObject@JSC@@SA_NPAV12@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z 141 ?defineSetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z142 ?defineSetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z143 140 ?deleteOwnedPtr@WTF@@YAXPAUHBITMAP__@@@Z 144 141 ?deleteOwnedPtr@WTF@@YAXPAUHBRUSH__@@@Z … … 179 176 ?fastStrDup@WTF@@YAPADPBD@Z 180 177 ?fastZeroedMalloc@WTF@@YAPAXI@Z 181 ?fillGetterPropertySlot@JSObject@JSC@@ QAEXAAVPropertySlot@2@PAV?$WriteBarrierBase@W4Unknown@JSC@@@2@@Z178 ?fillGetterPropertySlot@JSObject@JSC@@AAEXAAVPropertySlot@2@PAV?$WriteBarrierBase@W4Unknown@JSC@@@2@@Z 182 179 ?finalize@WeakHandleOwner@JSC@@UAEXV?$Handle@W4Unknown@JSC@@@2@PAX@Z 183 180 ?finishCreation@DateInstance@JSC@@IAEXAAVJSGlobalData@2@N@Z -
trunk/Source/JavaScriptCore/debugger/DebuggerActivation.cpp
r104899 r106783 102 102 } 103 103 104 void DebuggerActivation::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunction, unsigned attributes)104 bool DebuggerActivation::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow) 105 105 { 106 106 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); 114 108 } 115 109 -
trunk/Source/JavaScriptCore/debugger/DebuggerActivation.h
r104900 r106783 50 50 static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); 51 51 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); 54 53 55 54 JS_EXPORTDATA static const ClassInfo s_info; -
trunk/Source/JavaScriptCore/runtime/ClassInfo.h
r104899 r106783 67 67 ToThisObjectFunctionPtr toThisObject; 68 68 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 75 69 typedef JSValue (*DefaultValueFunctionPtr)(const JSObject*, ExecState*, PreferredPrimitiveType); 76 70 DefaultValueFunctionPtr defaultValue; … … 129 123 &ClassName::getOwnPropertySlotByIndex, \ 130 124 &ClassName::toThisObject, \ 131 &ClassName::defineGetter, \132 &ClassName::defineSetter, \133 125 &ClassName::defaultValue, \ 134 126 &ClassName::getOwnPropertyNames, \ -
trunk/Source/JavaScriptCore/runtime/JSBoundFunction.cpp
r104784 r106783 27 27 #include "JSBoundFunction.h" 28 28 29 #include "GetterSetter.h" 29 30 #include "JSGlobalObject.h" 30 31 … … 112 113 ASSERT(inherits(&s_info)); 113 114 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); 116 117 } 117 118 -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r105698 r106783 159 159 } 160 160 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 171 161 JSValue JSCell::defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType) 172 162 { -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r105698 r106783 153 153 154 154 // 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);157 155 static JSValue defaultValue(const JSObject*, ExecState*, PreferredPrimitiveType); 158 156 static NO_RETURN_DUE_TO_ASSERT void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r106504 r106783 31 31 #include "ExceptionHelpers.h" 32 32 #include "FunctionPrototype.h" 33 #include "GetterSetter.h" 33 34 #include "JSArray.h" 34 35 #include "JSGlobalObject.h" … … 220 221 bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 221 222 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); 223 224 result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 224 225 ASSERT(result); … … 239 240 bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 240 241 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); 242 243 result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 243 244 ASSERT(result); … … 268 269 bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 269 270 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); 271 272 result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 272 273 ASSERT(result); … … 287 288 bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 288 289 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); 290 291 result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 291 292 ASSERT(result); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r104899 r106783 172 172 } 173 173 174 void JSGlobalObject::defineGetter(JSObject* object, ExecState* exec, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes)174 bool JSGlobalObject::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool shouldThrow) 175 175 { 176 176 JSGlobalObject* thisObject = jsCast<JSGlobalObject*>(object); 177 177 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 189 184 190 185 static inline JSObject* lastInPrototypeChain(JSObject* object) -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r104900 r106783 207 207 JS_EXPORT_PRIVATE static void defineGetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* getterFunc, unsigned attributes); 208 208 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); 209 210 210 211 // We use this in the code generator as we perform symbol table -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r106255 r106783 360 360 } 361 361 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. For384 // getters and setters, though, we also need to change our Structure385 // 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. For404 // getters and setters, though, we also need to change our Structure405 // 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. For431 // getters and setters, though, we also need to change our Structure432 // 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();462 362 } 463 363 -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r106512 r106783 193 193 void putUndefinedAtDirectOffset(size_t offset) { propertyStorage()[offset].setUndefined(); } 194 194 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);202 195 JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow); 203 196 … … 297 290 298 291 bool inlineGetOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 292 JS_EXPORT_PRIVATE void fillGetterPropertySlot(PropertySlot&, WriteBarrierBase<Unknown>* location); 299 293 300 294 const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const; -
trunk/Source/JavaScriptCore/runtime/ObjectPrototype.cpp
r105698 r106783 147 147 return JSValue::encode(jsUndefined()); 148 148 149 JSValue get = exec->argument(1); 149 150 CallData callData; 150 if (getCallData( exec->argument(1), callData) == CallTypeNone)151 if (getCallData(get, callData) == CallTypeNone) 151 152 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 153 160 return JSValue::encode(jsUndefined()); 154 161 } … … 160 167 return JSValue::encode(jsUndefined()); 161 168 169 JSValue set = exec->argument(1); 162 170 CallData callData; 163 if (getCallData( exec->argument(1), callData) == CallTypeNone)171 if (getCallData(set, callData) == CallTypeNone) 164 172 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 166 180 return JSValue::encode(jsUndefined()); 167 181 } … … 173 187 return JSValue::encode(jsUndefined()); 174 188 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()); 176 195 } 177 196 … … 182 201 return JSValue::encode(jsUndefined()); 183 202 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()); 185 209 } 186 210 -
trunk/Source/WebCore/ChangeLog
r106782 r106783 1 2012-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 1 26 2012-02-06 Carlos Garcia Campos <cgarcia@igalia.com> 2 27 -
trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
r105698 r106783 389 389 } 390 390 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 414 391 bool JSDOMWindow::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow) 415 392 { … … 418 395 if (!thisObject->allowsAccessFrom(exec)) 419 396 return false; 397 398 // Don't allow shadowing location using accessor properties. 399 if (descriptor.isAccessorDescriptor() && propertyName == "location") 400 return false; 401 420 402 return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow); 421 403 } -
trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp
r104899 r106783 140 140 } 141 141 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 154 142 155 143 // ---- -
trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h
r104899 r106783 87 87 static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode); 88 88 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);91 89 static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow); 92 90 -
trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp
r106618 r106783 171 171 } 172 172 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);173 bool 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); 178 178 } 179 179 … … 282 282 } 283 283 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);284 bool 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); 289 289 } 290 290 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r106776 r106783 828 828 } 829 829 830 # Custom defineProperty function exists on DOMWindow831 push(@headerContent, " static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow";832 833 830 # Custom getOwnPropertyNames function 834 831 if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) { … … 837 834 } 838 835 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"}; 844 838 845 839 # Override toBoolean to return false for objects that want to 'MasqueradesAsUndefined'. … … 1061 1055 } 1062 1056 1063 # Custom define Getterfunction1064 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"}; 1065 1059 1066 1060 push(@headerContent, "\nprivate:\n"); -
trunk/Source/WebCore/page/DOMWindow.idl
r106776 r106783 29 29 interface [ 30 30 CheckDomainSecurity, 31 CustomDefineGetter, 32 CustomDefineSetter, 31 CustomDefineOwnProperty, 33 32 CustomDeleteProperty, 34 33 CustomGetOwnPropertySlot, -
trunk/Source/WebCore/page/Location.idl
r106737 r106783 38 38 CustomDeleteProperty, 39 39 CustomGetPropertyNames, 40 CustomDefine Getter,40 CustomDefineOwnProperty, 41 41 JSCustomPrototypePutDelegate, 42 CustomPrototypeDefine Getter,42 CustomPrototypeDefineOwnProperty, 43 43 OmitConstructor 44 44 ] Location { -
trunk/Source/WebKit/qt/Api/qwebframe.cpp
r106659 r106783 70 70 #include "PrintContext.h" 71 71 #if USE(JSC) 72 #include "PropertyDescriptor.h" 72 73 #include "PutPropertySlot.h" 73 74 #endif … … 518 519 519 520 // 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); 522 527 } 523 528 #endif -
trunk/Source/WebKit/qt/ChangeLog
r106695 r106783 1 2012-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 1 14 2012-02-03 Antti Koivisto <antti@apple.com> 2 15
Note: See TracChangeset
for help on using the changeset viewer.