Changeset 154300 in webkit
- Timestamp:
- Aug 19, 2013 2:44:17 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 63 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r154295 r154300 1 2013-08-19 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=119995 4 Start removing custom implementations of getOwnPropertyDescriptor 5 6 Reviewed by Sam Weinig. 7 8 This can now typically implemented in terms of getOwnPropertySlot. 9 Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS. 10 Switch over most classes in JSC & the WebCore bindings generator to use this. 11 12 * http/tests/security/xss-DENIED-defineProperty-expected.txt: 13 - Remove erroneous error messages - cross frame access to reload is allowed - it's just read-only, non-configurable. 14 1 15 2013-08-19 Jer Noble <jer.noble@apple.com> 2 16 -
trunk/LayoutTests/http/tests/security/xss-DENIED-defineProperty-expected.txt
r145692 r154300 1 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.2 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.3 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.4 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.5 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.6 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.7 1 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match. 8 2 CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match. -
trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
r154253 r154300 214 214 215 215 template <class Parent> 216 bool JSCallbackObject<Parent>::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 217 { 218 JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(object); 219 PropertySlot slot(thisObject); 220 if (thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot)) { 221 // Ideally we should return an access descriptor, but returning a value descriptor is better than nothing. 222 JSValue value = slot.getValue(exec, propertyName); 223 if (!exec->hadException()) 224 descriptor.setValue(value); 225 // We don't know whether the property is configurable, but assume it is. 226 descriptor.setConfigurable(true); 227 // We don't know whether the property is enumerable (we could call getOwnPropertyNames() to find out), but assume it isn't. 228 descriptor.setEnumerable(false); 229 return true; 230 } 231 232 return Parent::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 233 } 216 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSCallbackObject<Parent>) 234 217 235 218 template <class Parent> -
trunk/Source/JavaScriptCore/ChangeLog
r154298 r154300 1 2013-08-18 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=119995 4 Start removing custom implementations of getOwnPropertyDescriptor 5 6 Reviewed by Sam Weinig. 7 8 This can now typically implemented in terms of getOwnPropertySlot. 9 Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS. 10 Switch over most classes in JSC & the WebCore bindings generator to use this. 11 12 * API/JSCallbackObjectFunctions.h: 13 * debugger/DebuggerActivation.cpp: 14 * runtime/Arguments.cpp: 15 * runtime/ArrayConstructor.cpp: 16 * runtime/ArrayPrototype.cpp: 17 * runtime/BooleanPrototype.cpp: 18 * runtime/DateConstructor.cpp: 19 * runtime/DatePrototype.cpp: 20 * runtime/ErrorPrototype.cpp: 21 * runtime/JSActivation.cpp: 22 * runtime/JSArray.cpp: 23 * runtime/JSArrayBuffer.cpp: 24 * runtime/JSArrayBufferView.cpp: 25 * runtime/JSCell.cpp: 26 * runtime/JSDataView.cpp: 27 * runtime/JSDataViewPrototype.cpp: 28 * runtime/JSFunction.cpp: 29 * runtime/JSGenericTypedArrayViewInlines.h: 30 * runtime/JSNotAnObject.cpp: 31 * runtime/JSONObject.cpp: 32 * runtime/JSObject.cpp: 33 * runtime/NamePrototype.cpp: 34 * runtime/NumberConstructor.cpp: 35 * runtime/NumberPrototype.cpp: 36 * runtime/ObjectConstructor.cpp: 37 - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL. 38 * runtime/PropertyDescriptor.h: 39 - Added GET_OWN_PROPERTY_DESCRIPTOR_IMPL macro. 40 * runtime/PropertySlot.h: 41 (JSC::PropertySlot::isValue): 42 (JSC::PropertySlot::isGetter): 43 (JSC::PropertySlot::isCustom): 44 (JSC::PropertySlot::isCacheableValue): 45 (JSC::PropertySlot::isCacheableGetter): 46 (JSC::PropertySlot::isCacheableCustom): 47 (JSC::PropertySlot::attributes): 48 (JSC::PropertySlot::getterSetter): 49 - Add accessors necessary to convert PropertySlot to descriptor. 50 * runtime/RegExpConstructor.cpp: 51 * runtime/RegExpMatchesArray.cpp: 52 * runtime/RegExpMatchesArray.h: 53 * runtime/RegExpObject.cpp: 54 * runtime/RegExpPrototype.cpp: 55 * runtime/StringConstructor.cpp: 56 * runtime/StringObject.cpp: 57 - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL. 58 1 59 2013-08-19 Michael Saboff <msaboff@apple.com> 2 60 -
trunk/Source/JavaScriptCore/debugger/DebuggerActivation.cpp
r154038 r154300 96 96 } 97 97 98 bool DebuggerActivation::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 99 { 100 DebuggerActivation* thisObject = jsCast<DebuggerActivation*>(object); 101 return thisObject->m_activation->methodTable()->getOwnPropertyDescriptor(thisObject->m_activation.get(), exec, propertyName, descriptor); 102 } 98 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DebuggerActivation) 103 99 104 100 bool DebuggerActivation::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor, bool shouldThrow) -
trunk/Source/JavaScriptCore/runtime/Arguments.cpp
r154253 r154300 153 153 } 154 154 155 bool Arguments::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 156 { 157 Arguments* thisObject = jsCast<Arguments*>(object); 158 unsigned i = propertyName.asIndex(); 159 if (JSValue value = thisObject->tryGetArgument(i)) { 160 RELEASE_ASSERT(i < PropertyName::NotAnIndex); 161 descriptor.setDescriptor(value, None); 162 return true; 163 } 164 165 if (propertyName == exec->propertyNames().length && LIKELY(!thisObject->m_overrodeLength)) { 166 descriptor.setDescriptor(jsNumber(thisObject->m_numArguments), DontEnum); 167 return true; 168 } 169 170 if (propertyName == exec->propertyNames().callee && LIKELY(!thisObject->m_overrodeCallee)) { 171 if (!thisObject->m_isStrictMode) { 172 descriptor.setDescriptor(thisObject->m_callee.get(), DontEnum); 173 return true; 174 } 175 thisObject->createStrictModeCalleeIfNecessary(exec); 176 } 177 178 if (propertyName == exec->propertyNames().caller && thisObject->m_isStrictMode) 179 thisObject->createStrictModeCallerIfNecessary(exec); 180 181 return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 182 } 155 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(Arguments) 183 156 184 157 void Arguments::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) -
trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp
r154038 r154300 72 72 } 73 73 74 bool ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 75 { 76 return getStaticFunctionDescriptor<InternalFunction>(exec, ExecState::arrayConstructorTable(exec), jsCast<ArrayConstructor*>(object), propertyName, descriptor); 77 } 74 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ArrayConstructor) 78 75 79 76 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r154038 r154300 142 142 } 143 143 144 bool ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 145 { 146 return getStaticFunctionDescriptor<JSArray>(exec, ExecState::arrayPrototypeTable(exec), jsCast<ArrayPrototype*>(object), propertyName, descriptor); 147 } 144 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ArrayPrototype) 148 145 149 146 // ------------------------------ Array Functions ---------------------------- -
trunk/Source/JavaScriptCore/runtime/BooleanPrototype.cpp
r154038 r154300 69 69 } 70 70 71 bool BooleanPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 72 { 73 return getStaticFunctionDescriptor<BooleanObject>(exec, ExecState::booleanPrototypeTable(exec), jsCast<BooleanPrototype*>(object), propertyName, descriptor); 74 } 71 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(BooleanPrototype) 75 72 76 73 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp
r154038 r154300 92 92 } 93 93 94 bool DateConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 95 { 96 return getStaticFunctionDescriptor<InternalFunction>(exec, ExecState::dateConstructorTable(exec), jsCast<DateConstructor*>(object), propertyName, descriptor); 97 } 94 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DateConstructor) 98 95 99 96 // ECMA 15.9.3 -
trunk/Source/JavaScriptCore/runtime/DatePrototype.cpp
r154038 r154300 520 520 } 521 521 522 bool DatePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 523 { 524 return getStaticFunctionDescriptor<JSObject>(exec, ExecState::dateTable(exec), jsCast<DatePrototype*>(object), propertyName, descriptor); 525 } 522 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DatePrototype) 526 523 527 524 // Functions -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
r154038 r154300 67 67 } 68 68 69 bool ErrorPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 70 { 71 return getStaticFunctionDescriptor<ErrorInstance>(exec, ExecState::errorPrototypeTable(exec), jsCast<ErrorPrototype*>(object), propertyName, descriptor); 72 } 69 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ErrorPrototype) 73 70 74 71 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/JSActivation.cpp
r154253 r154300 179 179 } 180 180 181 bool JSActivation::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 182 { 183 JSActivation* thisObject = jsCast<JSActivation*>(object); 184 185 if (propertyName == exec->propertyNames().arguments) { 186 // Defend against the inspector asking for the arguments object after it has been optimized out. 187 if (!thisObject->isTornOff()) { 188 PropertySlot slot(thisObject); 189 JSActivation::getOwnPropertySlot(thisObject, exec, propertyName, slot); 190 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontEnum); 191 return true; 192 } 193 } 194 195 if (thisObject->symbolTableGet(propertyName, descriptor)) 196 return true; 197 198 return Base::getOwnPropertyDescriptor(object, exec, propertyName, descriptor); 199 } 181 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSActivation) 200 182 201 183 void JSActivation::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) -
trunk/Source/JavaScriptCore/runtime/JSArray.cpp
r154253 r154300 190 190 } 191 191 192 bool JSArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 193 { 194 JSArray* thisObject = jsCast<JSArray*>(object); 195 if (propertyName == exec->propertyNames().length) { 196 descriptor.setDescriptor(jsNumber(thisObject->length()), thisObject->isLengthWritable() ? DontDelete | DontEnum : DontDelete | DontEnum | ReadOnly); 197 return true; 198 } 199 200 return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 201 } 192 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArray) 202 193 203 194 // ECMA 15.4.5.1 -
trunk/Source/JavaScriptCore/runtime/JSArrayBuffer.cpp
r154253 r154300 79 79 } 80 80 81 bool JSArrayBuffer::getOwnPropertyDescriptor( 82 JSObject* object, ExecState* exec, PropertyName propertyName, 83 PropertyDescriptor& descriptor) 84 { 85 JSArrayBuffer* thisObject = jsCast<JSArrayBuffer*>(object); 86 87 if (propertyName == exec->propertyNames().byteLength) { 88 descriptor.setDescriptor( 89 jsNumber(thisObject->impl()->byteLength()), DontDelete | ReadOnly); 90 return true; 91 } 92 93 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 94 } 81 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArrayBuffer) 95 82 96 83 void JSArrayBuffer::put( -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferView.cpp
r154253 r154300 140 140 } 141 141 142 bool JSArrayBufferView::getOwnPropertyDescriptor( 143 JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 144 { 145 JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(object); 146 if (propertyName == exec->propertyNames().byteOffset) { 147 descriptor.setDescriptor(jsNumber(thisObject->byteOffset()), DontDelete | ReadOnly); 148 return true; 149 } 150 151 if (propertyName == exec->propertyNames().buffer) { 152 descriptor.setDescriptor( 153 exec->vm().m_typedArrayController->toJS( 154 exec, thisObject->globalObject(), thisObject->buffer()), 155 DontDelete | ReadOnly); 156 return true; 157 } 158 159 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 160 } 142 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArrayBufferView) 161 143 162 144 void JSArrayBufferView::put( -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r154127 r154300 219 219 } 220 220 221 bool JSCell::getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&) 222 { 223 RELEASE_ASSERT_NOT_REACHED(); 224 return false; 225 } 221 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSCell) 226 222 227 223 void JSCell::slowDownAndWasteMemory(JSArrayBufferView*) -
trunk/Source/JavaScriptCore/runtime/JSDataView.cpp
r154253 r154300 96 96 } 97 97 98 bool JSDataView::getOwnPropertyDescriptor( 99 JSObject* object, ExecState* exec, PropertyName propertyName, 100 PropertyDescriptor& descriptor) 101 { 102 JSDataView* thisObject = jsCast<JSDataView*>(object); 103 if (propertyName == exec->propertyNames().byteLength) { 104 descriptor.setDescriptor(jsNumber(thisObject->m_length), DontEnum | ReadOnly); 105 return true; 106 } 107 108 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 109 } 98 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSDataView) 110 99 111 100 void JSDataView::slowDownAndWasteMemory(JSArrayBufferView*) -
trunk/Source/JavaScriptCore/runtime/JSDataViewPrototype.cpp
r154143 r154300 91 91 } 92 92 93 bool JSDataViewPrototype::getOwnPropertyDescriptor( 94 JSObject* object, ExecState* exec, PropertyName propertyName, 95 PropertyDescriptor& descriptor) 96 { 97 return getStaticFunctionDescriptor<JSObject>( 98 exec, ExecState::dataViewTable(exec), jsCast<JSDataViewPrototype*>(object), 99 propertyName, descriptor); 100 } 93 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSDataViewPrototype) 101 94 102 95 template<typename Adaptor> -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r154253 r154300 303 303 } 304 304 305 bool JSFunction::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 306 { 307 JSFunction* thisObject = jsCast<JSFunction*>(object); 308 if (thisObject->isHostFunction()) 309 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 310 311 if (propertyName == exec->propertyNames().prototype) { 312 PropertySlot slot(thisObject); 313 thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot); 314 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 315 } 316 317 if (propertyName == exec->propertyNames().arguments) { 318 if (thisObject->jsExecutable()->isStrictMode()) { 319 bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 320 if (!result) { 321 thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor); 322 result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 323 ASSERT(result); 324 } 325 return result; 326 } 327 descriptor.setDescriptor(retrieveArguments(exec, thisObject), ReadOnly | DontEnum | DontDelete); 328 return true; 329 } 330 331 if (propertyName == exec->propertyNames().length) { 332 descriptor.setDescriptor(jsNumber(thisObject->jsExecutable()->parameterCount()), ReadOnly | DontEnum | DontDelete); 333 return true; 334 } 335 336 if (propertyName == exec->propertyNames().name) { 337 descriptor.setDescriptor(thisObject->jsExecutable()->nameValue(), ReadOnly | DontEnum | DontDelete); 338 return true; 339 } 340 341 if (propertyName == exec->propertyNames().caller) { 342 if (thisObject->jsExecutable()->isStrictMode()) { 343 bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 344 if (!result) { 345 thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor); 346 result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 347 ASSERT(result); 348 } 349 return result; 350 } 351 descriptor.setDescriptor(retrieveCallerFunction(exec, thisObject), ReadOnly | DontEnum | DontDelete); 352 return true; 353 } 354 355 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 356 } 305 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSFunction) 357 306 358 307 void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewInlines.h
r154253 r154300 235 235 236 236 template<typename Adaptor> 237 bool JSGenericTypedArrayView<Adaptor>::getOwnPropertyDescriptor( 238 JSObject* object, ExecState* exec, PropertyName propertyName, 239 PropertyDescriptor& descriptor) 240 { 241 JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object); 242 if (propertyName == exec->propertyNames().length) { 243 descriptor.setDescriptor(jsNumber(thisObject->length()), DontDelete | ReadOnly); 244 return true; 245 } 246 247 if (propertyName == exec->propertyNames().byteLength) { 248 descriptor.setDescriptor(jsNumber(thisObject->byteLength()), DontDelete | ReadOnly); 249 return true; 250 } 251 252 unsigned index = propertyName.asIndex(); 253 if (index != PropertyName::NotAnIndex && thisObject->canGetIndexQuickly(index)) { 254 descriptor.setDescriptor(thisObject->getIndexQuickly(index), DontDelete | ReadOnly); 255 return true; 256 } 257 258 return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 259 } 237 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSGenericTypedArrayView<Adaptor>) 260 238 261 239 template<typename Adaptor> -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp
r153532 r154300 59 59 } 60 60 61 bool JSNotAnObject::getOwnPropertyDescriptor(JSObject*, ExecState* exec, PropertyName, PropertyDescriptor&) 62 { 63 ASSERT_UNUSED(exec, exec->hadException()); 64 return false; 65 } 61 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSNotAnObject) 66 62 67 63 void JSNotAnObject::put(JSCell*, ExecState* exec, PropertyName , JSValue, PutPropertySlot&) -
trunk/Source/JavaScriptCore/runtime/JSONObject.cpp
r154038 r154300 597 597 } 598 598 599 bool JSONObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 600 { 601 return getStaticFunctionDescriptor<JSObject>(exec, ExecState::jsonTable(exec), jsCast<JSONObject*>(object), propertyName, descriptor); 602 } 599 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSONObject) 603 600 604 601 class Walker { -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r154253 r154300 2382 2382 } 2383 2383 2384 bool JSObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 2385 { 2386 unsigned attributes = 0; 2387 JSCell* cell = 0; 2388 PropertyOffset offset = object->structure()->get(exec->vm(), propertyName, attributes, cell); 2389 if (isValidOffset(offset)) { 2390 descriptor.setDescriptor(object->getDirect(offset), attributes); 2391 return true; 2392 } 2393 2394 unsigned i = propertyName.asIndex(); 2395 if (i == PropertyName::NotAnIndex) 2396 return false; 2397 2398 switch (object->structure()->indexingType()) { 2399 case ALL_BLANK_INDEXING_TYPES: 2400 case ALL_UNDECIDED_INDEXING_TYPES: 2401 return false; 2402 2403 case ALL_INT32_INDEXING_TYPES: 2404 case ALL_CONTIGUOUS_INDEXING_TYPES: { 2405 Butterfly* butterfly = object->m_butterfly; 2406 if (i >= butterfly->vectorLength()) 2407 return false; 2408 JSValue value = butterfly->contiguous()[i].get(); 2409 if (!value) 2410 return false; 2411 descriptor.setDescriptor(value, 0); 2412 return true; 2413 } 2414 2415 case ALL_DOUBLE_INDEXING_TYPES: { 2416 Butterfly* butterfly = object->m_butterfly; 2417 if (i >= butterfly->vectorLength()) 2418 return false; 2419 double value = butterfly->contiguousDouble()[i]; 2420 if (value != value) 2421 return false; 2422 descriptor.setDescriptor(JSValue(JSValue::EncodeAsDouble, value), 0); 2423 return true; 2424 } 2425 2426 case ALL_ARRAY_STORAGE_INDEXING_TYPES: { 2427 ArrayStorage* storage = object->m_butterfly->arrayStorage(); 2428 if (i >= storage->length()) 2429 return false; 2430 if (i < storage->vectorLength()) { 2431 WriteBarrier<Unknown>& value = storage->m_vector[i]; 2432 if (!value) 2433 return false; 2434 descriptor.setDescriptor(value.get(), 0); 2435 return true; 2436 } 2437 if (SparseArrayValueMap* map = storage->m_sparseMap.get()) { 2438 SparseArrayValueMap::iterator it = map->find(i); 2439 if (it == map->notFound()) 2440 return false; 2441 it->value.get(descriptor); 2442 return true; 2443 } 2444 return false; 2445 } 2446 2447 default: 2448 RELEASE_ASSERT_NOT_REACHED(); 2449 return false; 2450 } 2451 } 2384 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSObject) 2452 2385 2453 2386 bool JSObject::getPropertyDescriptor(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) -
trunk/Source/JavaScriptCore/runtime/NamePrototype.cpp
r154038 r154300 64 64 } 65 65 66 bool NamePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 67 { 68 return getStaticFunctionDescriptor<Base>(exec, ExecState::privateNamePrototypeTable(exec), jsCast<NamePrototype*>(object), propertyName, descriptor); 69 } 66 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(NamePrototype) 70 67 71 68 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp
r154038 r154300 78 78 } 79 79 80 bool NumberConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 81 { 82 return getStaticValueDescriptor<NumberConstructor, InternalFunction>(exec, ExecState::numberConstructorTable(exec), jsCast<NumberConstructor*>(object), propertyName, descriptor); 83 } 80 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(NumberConstructor) 84 81 85 82 void NumberConstructor::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) -
trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp
r154038 r154300 89 89 } 90 90 91 bool NumberPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 92 { 93 return getStaticFunctionDescriptor<NumberObject>(exec, ExecState::numberPrototypeTable(exec), jsCast<NumberPrototype*>(object), propertyName, descriptor); 94 } 91 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(NumberPrototype) 95 92 96 93 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r153673 r154300 100 100 } 101 101 102 bool ObjectConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 103 { 104 return getStaticFunctionDescriptor<JSObject>(exec, ExecState::objectConstructorTable(exec), jsCast<ObjectConstructor*>(object), propertyName, descriptor); 105 } 102 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ObjectConstructor) 106 103 107 104 static ALWAYS_INLINE JSObject* constructObject(ExecState* exec) -
trunk/Source/JavaScriptCore/runtime/PropertyDescriptor.h
r140718 r154300 56 56 JS_EXPORT_PRIVATE void setUndefined(); 57 57 JS_EXPORT_PRIVATE void setDescriptor(JSValue value, unsigned attributes); 58 void setAccessorDescriptor(GetterSetter* accessor, unsigned attributes);58 JS_EXPORT_PRIVATE void setAccessorDescriptor(GetterSetter* accessor, unsigned attributes); 59 59 JS_EXPORT_PRIVATE void setWritable(bool); 60 60 JS_EXPORT_PRIVATE void setEnumerable(bool); … … 86 86 } 87 87 88 #define GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ClassName) \ 89 bool ClassName::getOwnPropertyDescriptor(JSC::JSObject* object, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor) \ 90 { \ 91 JSC::PropertySlot slot(object); \ 92 if (!getOwnPropertySlot(object, exec, propertyName, slot)) \ 93 return false; \ 94 if (slot.isGetter()) \ 95 descriptor.setAccessorDescriptor(slot.getterSetter(), slot.attributes()); \ 96 else \ 97 descriptor.setDescriptor(slot.getValue(exec, propertyName), slot.attributes()); \ 98 return true; \ 99 } 100 88 101 #endif -
trunk/Source/JavaScriptCore/runtime/PropertySlot.h
r154253 r154300 69 69 70 70 bool isCacheable() const { return m_offset != invalidOffset; } 71 bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; } 72 bool isCacheableGetter() const { return isCacheable() && m_propertyType == TypeGetter; } 73 bool isCacheableCustom() const { return isCacheable() && m_propertyType == TypeCustom; } 71 bool isValue() const { return m_propertyType == TypeValue; } 72 bool isGetter() const { return m_propertyType == TypeGetter; } 73 bool isCustom() const { return m_propertyType == TypeCustom; } 74 bool isCacheableValue() const { return isCacheable() && isValue(); } 75 bool isCacheableGetter() const { return isCacheable() && isGetter(); } 76 bool isCacheableCustom() const { return isCacheable() && isCustom(); } 77 78 unsigned attributes() const { return m_attributes; } 74 79 75 80 PropertyOffset cachedOffset() const … … 77 82 ASSERT(isCacheable()); 78 83 return m_offset; 84 } 85 86 GetterSetter* getterSetter() const 87 { 88 ASSERT(isGetter()); 89 return m_data.getter.getterSetter; 79 90 } 80 91 -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
r154038 r154300 159 159 } 160 160 161 bool RegExpConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 162 { 163 return getStaticValueDescriptor<RegExpConstructor, InternalFunction>(exec, ExecState::regExpConstructorTable(exec), jsCast<RegExpConstructor*>(object), propertyName, descriptor); 164 } 161 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RegExpConstructor) 165 162 166 163 JSValue regExpConstructorDollar1(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/JavaScriptCore/runtime/RegExpMatchesArray.cpp
r154038 r154300 57 57 Base::finishCreation(vm); 58 58 } 59 60 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RegExpMatchesArray) 59 61 60 62 void RegExpMatchesArray::visitChildren(JSCell* cell, SlotVisitor& visitor) -
trunk/Source/JavaScriptCore/runtime/RegExpMatchesArray.h
r154038 r154300 85 85 } 86 86 87 static bool getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 88 { 89 RegExpMatchesArray* thisObject = jsCast<RegExpMatchesArray*>(object); 90 thisObject->reifyAllPropertiesIfNecessary(exec); 91 return JSArray::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 92 } 87 static bool getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&); 93 88 94 89 static void put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue v, PutPropertySlot& slot) -
trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp
r154253 r154300 101 101 } 102 102 103 bool RegExpObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 104 { 105 if (propertyName == exec->propertyNames().lastIndex) { 106 RegExpObject* regExp = asRegExpObject(object); 107 descriptor.setDescriptor(regExp->getLastIndex(), regExp->m_lastIndexIsWritable ? DontDelete | DontEnum : DontDelete | DontEnum | ReadOnly); 108 return true; 109 } 110 return getStaticValueDescriptor<RegExpObject, JSObject>(exec, ExecState::regExpTable(exec), jsCast<RegExpObject*>(object), propertyName, descriptor); 111 } 103 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RegExpObject) 112 104 113 105 bool RegExpObject::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r154038 r154300 71 71 } 72 72 73 bool RegExpPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 74 { 75 return getStaticFunctionDescriptor<RegExpObject>(exec, ExecState::regExpPrototypeTable(exec), jsCast<RegExpPrototype*>(object), propertyName, descriptor); 76 } 73 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RegExpPrototype) 77 74 78 75 // ------------------------------ Functions --------------------------- -
trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp
r153532 r154300 66 66 } 67 67 68 bool StringConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 69 { 70 return getStaticFunctionDescriptor<InternalFunction>(exec, ExecState::stringConstructorTable(exec), jsCast<StringConstructor*>(object), propertyName, descriptor); 71 } 68 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(StringConstructor) 72 69 73 70 // ------------------------------ Functions -------------------------------- -
trunk/Source/JavaScriptCore/runtime/StringObject.cpp
r154038 r154300 61 61 } 62 62 63 bool StringObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 64 { 65 StringObject* thisObject = jsCast<StringObject*>(object); 66 if (thisObject->internalValue()->getStringPropertyDescriptor(exec, propertyName, descriptor)) 67 return true; 68 return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 69 } 63 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(StringObject) 70 64 71 65 void StringObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) -
trunk/Source/WebCore/ChangeLog
r154299 r154300 1 2013-08-19 Gavin Barraclough <barraclough@apple.com> 2 3 https://bugs.webkit.org/show_bug.cgi?id=119995 4 Start removing custom implementations of getOwnPropertyDescriptor 5 6 Reviewed by Sam Weinig. 7 8 This can now typically implemented in terms of getOwnPropertySlot. 9 Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS. 10 Switch over most classes in JSC & the WebCore bindings generator to use this. 11 12 * bindings/js/JSCSSStyleDeclarationCustom.cpp: 13 * bindings/js/JSHTMLAppletElementCustom.cpp: 14 * bindings/js/JSHTMLEmbedElementCustom.cpp: 15 * bindings/js/JSHTMLObjectElementCustom.cpp: 16 * bindings/js/JSHistoryCustom.cpp: 17 (WebCore::JSHistory::getOwnPropertySlotDelegate): 18 * bindings/js/JSLocationCustom.cpp: 19 (WebCore::JSLocation::getOwnPropertySlotDelegate): 20 * bindings/js/JSWorkerGlobalScopeCustom.cpp: 21 - Remove getOwnPropertyDescriptorDelegate methods, 22 Change attributes of cross-frame access properties in JSHistory/JSLocation to prevent properties from being redefined. 23 * bindings/scripts/CodeGeneratorJS.pm: 24 (GenerateHeader): 25 (GenerateImplementation): 26 (GenerateConstructorHelperMethods): 27 - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL. 28 * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: 29 * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: 30 * bindings/scripts/test/JS/JSTestEventConstructor.cpp: 31 * bindings/scripts/test/JS/JSTestEventTarget.cpp: 32 * bindings/scripts/test/JS/JSTestException.cpp: 33 * bindings/scripts/test/JS/JSTestInterface.cpp: 34 * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: 35 * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: 36 * bindings/scripts/test/JS/JSTestNode.cpp: 37 * bindings/scripts/test/JS/JSTestObj.cpp: 38 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: 39 * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: 40 * bindings/scripts/test/JS/JSTestTypedefs.cpp: 41 - Update test expectations. 42 1 43 2013-08-19 Benjamin Poulain <benjamin@webkit.org> 2 44 -
trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp
r154253 r154300 337 337 } 338 338 339 bool JSCSSStyleDeclaration::getOwnPropertyDescriptorDelegate(JSC::ExecState* exec, JSC::PropertyName propertyIdentifier, JSC::PropertyDescriptor& descriptor)340 {341 CSSPropertyInfo propertyInfo = cssPropertyIDForJSCSSPropertyName(propertyIdentifier);342 if (!propertyInfo.propertyID)343 return false;344 345 JSValue value;346 if (propertyInfo.hadPixelOrPosPrefix)347 value = cssPropertyGetterPixelOrPosPrefix(exec, this, propertyInfo.propertyID);348 else349 value = cssPropertyGetter(exec, this, propertyInfo.propertyID);350 descriptor.setDescriptor(value, ReadOnly | DontDelete | DontEnum);351 return true;352 }353 354 339 bool JSCSSStyleDeclaration::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&) 355 340 { -
trunk/Source/WebCore/bindings/js/JSHTMLAppletElementCustom.cpp
r151736 r154300 39 39 } 40 40 41 bool JSHTMLAppletElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)42 {43 return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLAppletElement, Base>(exec, propertyName, descriptor, this);44 }45 46 41 bool JSHTMLAppletElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 47 42 { -
trunk/Source/WebCore/bindings/js/JSHTMLEmbedElementCustom.cpp
r151736 r154300 39 39 } 40 40 41 bool JSHTMLEmbedElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)42 {43 return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLEmbedElement, Base>(exec, propertyName, descriptor, this);44 }45 46 41 bool JSHTMLEmbedElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 47 42 { -
trunk/Source/WebCore/bindings/js/JSHTMLObjectElementCustom.cpp
r151736 r154300 39 39 } 40 40 41 bool JSHTMLObjectElement::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)42 {43 return pluginElementCustomGetOwnPropertyDescriptor<JSHTMLObjectElement, Base>(exec, propertyName, descriptor, this);44 }45 46 41 bool JSHTMLObjectElement::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 47 42 { -
trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp
r154253 r154300 66 66 67 67 // Check for the few functions that we allow, even when called cross-domain. 68 // Make these read-only / non-configurable to prevent writes via defineProperty. 68 69 const HashEntry* entry = JSHistoryPrototype::info()->propHashTable(exec)->entry(exec, propertyName); 69 70 if (entry) { … … 71 72 if (entry->attributes() & JSC::Function) { 72 73 if (entry->function() == jsHistoryPrototypeFunctionBack) { 73 slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter);74 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticBackFunctionGetter); 74 75 return true; 75 76 } else if (entry->function() == jsHistoryPrototypeFunctionForward) { 76 slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter);77 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticForwardFunctionGetter); 77 78 return true; 78 79 } else if (entry->function() == jsHistoryPrototypeFunctionGo) { 79 slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter);80 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticGoFunctionGetter); 80 81 return true; 81 82 } … … 91 92 printErrorMessageForFrame(impl()->frame(), message); 92 93 slot.setUndefined(); 93 return true;94 }95 96 bool JSHistory::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)97 {98 if (!impl()->frame()) {99 descriptor.setUndefined();100 return true;101 }102 103 // Throw out all cross domain access104 if (!shouldAllowAccessToFrame(exec, impl()->frame()))105 return true;106 107 // Check for the few functions that we allow, even when called cross-domain.108 const HashEntry* entry = JSHistoryPrototype::info()->propHashTable(exec)->entry(exec, propertyName);109 if (entry) {110 PropertySlot slot(this);111 // Allow access to back(), forward() and go() from any frame.112 if (entry->attributes() & JSC::Function) {113 if (entry->function() == jsHistoryPrototypeFunctionBack) {114 slot.setCustom(this, entry->attributes(), nonCachingStaticBackFunctionGetter);115 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());116 return true;117 } else if (entry->function() == jsHistoryPrototypeFunctionForward) {118 slot.setCustom(this, entry->attributes(), nonCachingStaticForwardFunctionGetter);119 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());120 return true;121 } else if (entry->function() == jsHistoryPrototypeFunctionGo) {122 slot.setCustom(this, entry->attributes(), nonCachingStaticGoFunctionGetter);123 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());124 return true;125 }126 }127 } else {128 // Allow access to toString() cross-domain, but always Object.toString.129 if (propertyName == exec->propertyNames().toString) {130 PropertySlot slot(this);131 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, objectToStringFunctionGetter);132 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());133 return true;134 }135 }136 137 descriptor.setUndefined();138 94 return true; 139 95 } -
trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp
r154253 r154300 64 64 65 65 // Check for the few functions that we allow, even when called cross-domain. 66 // Make these read-only / non-configurable to prevent writes via defineProperty. 66 67 const HashEntry* entry = JSLocationPrototype::info()->propHashTable(exec)->entry(exec, propertyName); 67 68 if (entry && (entry->attributes() & JSC::Function)) { 68 69 if (entry->function() == jsLocationPrototypeFunctionReplace) { 69 slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter);70 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticReplaceFunctionGetter); 70 71 return true; 71 72 } else if (entry->function() == jsLocationPrototypeFunctionReload) { 72 slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter);73 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticReloadFunctionGetter); 73 74 return true; 74 75 } else if (entry->function() == jsLocationPrototypeFunctionAssign) { 75 slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter);76 slot.setCustom(this, ReadOnly | DontDelete | DontEnum, nonCachingStaticAssignFunctionGetter); 76 77 return true; 77 78 } … … 84 85 printErrorMessageForFrame(frame, message); 85 86 slot.setUndefined(); 86 return true;87 }88 89 bool JSLocation::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)90 {91 Frame* frame = impl()->frame();92 if (!frame) {93 descriptor.setUndefined();94 return true;95 }96 97 // throw out all cross domain access98 if (!shouldAllowAccessToFrame(exec, frame))99 return true;100 101 // Check for the few functions that we allow, even when called cross-domain.102 const HashEntry* entry = JSLocationPrototype::info()->propHashTable(exec)->entry(exec, propertyName);103 PropertySlot slot(this);104 if (entry && (entry->attributes() & JSC::Function)) {105 if (entry->function() == jsLocationPrototypeFunctionReplace) {106 slot.setCustom(this, entry->attributes(), nonCachingStaticReplaceFunctionGetter);107 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());108 return true;109 } else if (entry->function() == jsLocationPrototypeFunctionReload) {110 slot.setCustom(this, entry->attributes(), nonCachingStaticReloadFunctionGetter);111 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());112 return true;113 } else if (entry->function() == jsLocationPrototypeFunctionAssign) {114 slot.setCustom(this, entry->attributes(), nonCachingStaticAssignFunctionGetter);115 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());116 return true;117 }118 }119 120 // FIXME: Other implementers of the Window cross-domain scheme (Window, History) allow toString,121 // but for now we have decided not to, partly because it seems silly to return "[Object Location]" in122 // such cases when normally the string form of Location would be the URL.123 124 descriptor.setUndefined();125 87 return true; 126 88 } -
trunk/Source/WebCore/bindings/js/JSWorkerGlobalScopeCustom.cpp
r154038 r154300 78 78 } 79 79 80 bool JSWorkerGlobalScope::getOwnPropertyDescriptorDelegate(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)81 {82 // Look for overrides before looking at any of our own properties.83 if (JSGlobalObject::getOwnPropertyDescriptor(this, exec, propertyName, descriptor))84 return true;85 return false;86 }87 88 80 JSValue JSWorkerGlobalScope::importScripts(ExecState* exec) 89 81 { -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r154253 r154300 430 430 431 431 return @getOwnPropertySlotImpl; 432 }433 434 sub GenerateGetOwnPropertyDescriptorBody435 {436 my ($interface, $interfaceName, $className, $hasAttributes, $inlined) = @_;437 438 my $namespaceMaybe = ($inlined ? "JSC::" : "");439 my $namedGetterFunction = GetNamedGetterFunction($interface);440 my $indexedGetterFunction = GetIndexedGetterFunction($interface);441 my $hasNumericIndexedGetter = $indexedGetterFunction ? $codeGenerator->IsNumericType($indexedGetterFunction->signature->type) : 0;442 443 444 my @getOwnPropertyDescriptorImpl = ();445 if ($interface->extendedAttributes->{"CheckSecurity"}) {446 if ($interfaceName eq "DOMWindow") {447 $implIncludes{"BindingSecurity.h"} = 1;448 push(@implContent, " if (!BindingSecurity::shouldAllowAccessToDOMWindow(exec, jsCast<$className*>(thisObject)->impl()))\n");449 } else {450 push(@implContent, " if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))\n");451 }452 push(@implContent, " return false;\n");453 }454 455 if ($interfaceName eq "NamedNodeMap" or $interfaceName =~ /^HTML\w*Collection$/) {456 push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}JSValue proto = thisObject->prototype();\n");457 push(@getOwnPropertyDescriptorImpl, " if (proto.isObject() && jsCast<${namespaceMaybe}JSObject*>(asObject(proto))->hasProperty(exec, propertyName))\n");458 push(@getOwnPropertyDescriptorImpl, " return false;\n\n");459 }460 461 my $manualLookupGetterGeneration = sub {462 my $requiresManualLookup = ($indexedGetterFunction && !$hasNumericIndexedGetter) || $namedGetterFunction;463 if ($requiresManualLookup) {464 push(@getOwnPropertyDescriptorImpl, " const ${namespaceMaybe}HashEntry* entry = ${className}Table.entry(exec, propertyName);\n");465 push(@getOwnPropertyDescriptorImpl, " if (entry) {\n");466 push(@getOwnPropertyDescriptorImpl, " PropertySlot slot(thisObject);\n");467 push(@getOwnPropertyDescriptorImpl, " slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter());\n");468 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());\n");469 push(@getOwnPropertyDescriptorImpl, " return true;\n");470 push(@getOwnPropertyDescriptorImpl, " }\n");471 }472 };473 474 if (!$interface->extendedAttributes->{"CustomNamedGetter"}) {475 &$manualLookupGetterGeneration();476 }477 478 if ($indexedGetterFunction) {479 push(@getOwnPropertyDescriptorImpl, " unsigned index = propertyName.asIndex();\n");480 push(@getOwnPropertyDescriptorImpl, " if (index != PropertyName::NotAnIndex && index < static_cast<$interfaceName*>(thisObject->impl())->length()) {\n");481 # Assume that if there's a setter, the index will be writable482 if ($interface->extendedAttributes->{"CustomIndexedSetter"}) {483 push(@getOwnPropertyDescriptorImpl, " unsigned attributes = ${namespaceMaybe}DontDelete;\n");484 } else {485 push(@getOwnPropertyDescriptorImpl, " unsigned attributes = ${namespaceMaybe}DontDelete | ${namespaceMaybe}ReadOnly;\n");486 }487 if ($hasNumericIndexedGetter) {488 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(thisObject->getByIndex(exec, index), attributes);\n");489 } else {490 push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot(thisObject);\n");491 push(@getOwnPropertyDescriptorImpl, " slot.setCustomIndex(thisObject, attributes, index, indexGetter);\n");492 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), attributes);\n");493 }494 push(@getOwnPropertyDescriptorImpl, " return true;\n");495 push(@getOwnPropertyDescriptorImpl, " }\n");496 }497 498 if ($namedGetterFunction || $interface->extendedAttributes->{"CustomNamedGetter"}) {499 push(@getOwnPropertyDescriptorImpl, " if (canGetItemsForName(exec, static_cast<$interfaceName*>(thisObject->impl()), propertyName)) {\n");500 push(@getOwnPropertyDescriptorImpl, " ${namespaceMaybe}PropertySlot slot(thisObject);\n");501 push(@getOwnPropertyDescriptorImpl, " slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter);\n");502 push(@getOwnPropertyDescriptorImpl, " descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);\n");503 push(@getOwnPropertyDescriptorImpl, " return true;\n");504 push(@getOwnPropertyDescriptorImpl, " }\n");505 if ($inlined) {506 $headerIncludes{"wtf/text/AtomicString.h"} = 1;507 } else {508 $implIncludes{"wtf/text/AtomicString.h"} = 1;509 }510 }511 512 if ($interface->extendedAttributes->{"CustomNamedGetter"}) {513 &$manualLookupGetterGeneration();514 }515 516 if ($interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}) {517 push(@getOwnPropertyDescriptorImpl, " if (thisObject->getOwnPropertyDescriptorDelegate(exec, propertyName, descriptor))\n");518 push(@getOwnPropertyDescriptorImpl, " return true;\n");519 }520 521 if ($hasAttributes) {522 if ($inlined) {523 die "Cannot inline if NoStaticTables is set." if ($interface->extendedAttributes->{"JSNoStaticTables"});524 push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, info()->staticPropHashTable, thisObject, propertyName, descriptor);\n");525 } else {526 push(@getOwnPropertyDescriptorImpl, " return ${namespaceMaybe}getStaticValueDescriptor<$className, Base>(exec, " . hashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n");527 }528 } else {529 push(@getOwnPropertyDescriptorImpl, " return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);\n");530 }531 532 return @getOwnPropertyDescriptorImpl;533 432 } 534 433 … … 791 690 push(@headerContent, " static bool getOwnPropertySlotByIndex(JSC::JSObject*, JSC::ExecState*, unsigned propertyName, JSC::PropertySlot&);\n") if ($hasComplexGetter); 792 691 push(@headerContent, " bool getOwnPropertySlotDelegate(JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);\n") if $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"}; 793 push(@headerContent, " bool getOwnPropertyDescriptorDelegate(JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);\n") if $interface->extendedAttributes->{"JSCustomGetOwnPropertySlotAndDescriptor"};794 692 $structureFlags{"JSC::OverridesGetOwnPropertySlot"} = 1; 795 693 $structureFlags{"JSC::InterceptsGetOwnPropertySlotByIndexEvenWhenLengthIsNotZero"} = 1; … … 1008 906 push(@headerContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n"); 1009 907 push(@headerContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numAttributes > 0, 1)); 1010 push(@headerContent, "}\n\n");1011 push(@headerContent, "ALWAYS_INLINE bool ${className}::getOwnPropertyDescriptor(JSC::JSObject* object, JSC::ExecState* exec, JSC::PropertyName propertyName, JSC::PropertyDescriptor& descriptor)\n");1012 push(@headerContent, "{\n");1013 push(@headerContent, " ${className}* thisObject = JSC::jsCast<${className}*>(object);\n");1014 push(@headerContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n");1015 push(@headerContent, GenerateGetOwnPropertyDescriptorBody($interface, $interfaceName, $className, $numAttributes > 0, 1));1016 908 push(@headerContent, "}\n\n"); 1017 909 } … … 1767 1659 push(@implContent, "}\n\n"); 1768 1660 1769 push(@implContent, "bool ${className}Prototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); 1770 push(@implContent, "{\n"); 1771 push(@implContent, " ${className}Prototype* thisObject = jsCast<${className}Prototype*>(object);\n"); 1772 1773 if ($numConstants eq 0 && $numFunctions eq 0) { 1774 push(@implContent, " return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);\n"); 1775 } elsif ($numConstants eq 0) { 1776 push(@implContent, " return getStaticFunctionDescriptor<JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); 1777 } elsif ($numFunctions eq 0) { 1778 push(@implContent, " return getStaticValueDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); 1779 } else { 1780 push(@implContent, " return getStaticPropertyDescriptor<${className}Prototype, JSObject>(exec, " . prototypeHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $className) . ", thisObject, propertyName, descriptor);\n"); 1781 } 1782 push(@implContent, "}\n\n"); 1661 push(@implContent, "GET_OWN_PROPERTY_DESCRIPTOR_IMPL(${className}Prototype)\n\n"); 1783 1662 } 1784 1663 … … 1897 1776 # Attributes 1898 1777 if ($hasGetter) { 1899 if (!$interface->extendedAttributes->{"JSInlineGetOwnPropertySlot"} && !$interface->extendedAttributes->{"CustomGetOwnPropertySlot"}) { 1900 push(@implContent, "bool ${className}::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)\n"); 1901 push(@implContent, "{\n"); 1902 push(@implContent, " ${className}* thisObject = jsCast<${className}*>(object);\n"); 1903 push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n"); 1904 push(@implContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numAttributes > 0, 0)); 1905 push(@implContent, "}\n\n"); 1906 push(@implContent, "bool ${className}::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); 1907 push(@implContent, "{\n"); 1908 push(@implContent, " ${className}* thisObject = jsCast<${className}*>(object);\n"); 1909 push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n"); 1910 push(@implContent, GenerateGetOwnPropertyDescriptorBody($interface, $interfaceName, $className, $numAttributes > 0, 0)); 1911 push(@implContent, "}\n\n"); 1778 if (!$interface->extendedAttributes->{"CustomGetOwnPropertySlot"}) { 1779 if (!$interface->extendedAttributes->{"JSInlineGetOwnPropertySlot"}) { 1780 push(@implContent, "bool ${className}::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)\n"); 1781 push(@implContent, "{\n"); 1782 push(@implContent, " ${className}* thisObject = jsCast<${className}*>(object);\n"); 1783 push(@implContent, " ASSERT_GC_OBJECT_INHERITS(thisObject, info());\n"); 1784 push(@implContent, GenerateGetOwnPropertySlotBody($interface, $interfaceName, $className, $numAttributes > 0, 0)); 1785 push(@implContent, "}\n\n"); 1786 } 1787 push(@implContent, "GET_OWN_PROPERTY_DESCRIPTOR_IMPL(${className})\n\n"); 1912 1788 } 1913 1789 … … 4239 4115 push(@$outputArray, "}\n\n"); 4240 4116 4241 push(@$outputArray, "bool ${constructorClassName}::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)\n"); 4242 push(@$outputArray, "{\n"); 4243 push(@$outputArray, " return getStatic${kind}Descriptor<${constructorClassName}, JSDOMWrapper>(exec, " . constructorHashTableAccessor($interface->extendedAttributes->{"JSNoStaticTables"}, $constructorClassName) . ", jsCast<${constructorClassName}*>(object), propertyName, descriptor);\n"); 4244 push(@$outputArray, "}\n\n"); 4117 push(@$outputArray, "GET_OWN_PROPERTY_DESCRIPTOR_IMPL(${constructorClassName})\n\n"); 4245 4118 } 4246 4119 -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
r154038 r154300 72 72 } 73 73 74 bool JSTestActiveDOMObjectConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 75 { 76 return getStaticValueDescriptor<JSTestActiveDOMObjectConstructor, JSDOMWrapper>(exec, &JSTestActiveDOMObjectConstructorTable, jsCast<JSTestActiveDOMObjectConstructor*>(object), propertyName, descriptor); 77 } 74 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestActiveDOMObjectConstructor) 78 75 79 76 /* Hash table for prototype */ … … 100 97 } 101 98 102 bool JSTestActiveDOMObjectPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 103 { 104 JSTestActiveDOMObjectPrototype* thisObject = jsCast<JSTestActiveDOMObjectPrototype*>(object); 105 return getStaticFunctionDescriptor<JSObject>(exec, &JSTestActiveDOMObjectPrototypeTable, thisObject, propertyName, descriptor); 106 } 99 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestActiveDOMObjectPrototype) 107 100 108 101 const ClassInfo JSTestActiveDOMObject::s_info = { "TestActiveDOMObject", &Base::s_info, &JSTestActiveDOMObjectTable, 0 , CREATE_METHOD_TABLE(JSTestActiveDOMObject) }; … … 143 136 } 144 137 145 bool JSTestActiveDOMObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 146 { 147 JSTestActiveDOMObject* thisObject = jsCast<JSTestActiveDOMObject*>(object); 148 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 149 if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame())) 150 return false; 151 return getStaticValueDescriptor<JSTestActiveDOMObject, Base>(exec, &JSTestActiveDOMObjectTable, thisObject, propertyName, descriptor); 152 } 138 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestActiveDOMObject) 153 139 154 140 JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
r154253 r154300 70 70 } 71 71 72 bool JSTestCustomNamedGetterConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 73 { 74 return getStaticValueDescriptor<JSTestCustomNamedGetterConstructor, JSDOMWrapper>(exec, &JSTestCustomNamedGetterConstructorTable, jsCast<JSTestCustomNamedGetterConstructor*>(object), propertyName, descriptor); 75 } 72 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestCustomNamedGetterConstructor) 76 73 77 74 /* Hash table for prototype */ … … 97 94 } 98 95 99 bool JSTestCustomNamedGetterPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 100 { 101 JSTestCustomNamedGetterPrototype* thisObject = jsCast<JSTestCustomNamedGetterPrototype*>(object); 102 return getStaticFunctionDescriptor<JSObject>(exec, &JSTestCustomNamedGetterPrototypeTable, thisObject, propertyName, descriptor); 103 } 96 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestCustomNamedGetterPrototype) 104 97 105 98 const ClassInfo JSTestCustomNamedGetter::s_info = { "TestCustomNamedGetter", &Base::s_info, &JSTestCustomNamedGetterTable, 0 , CREATE_METHOD_TABLE(JSTestCustomNamedGetter) }; … … 144 137 } 145 138 146 bool JSTestCustomNamedGetter::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 147 { 148 JSTestCustomNamedGetter* thisObject = jsCast<JSTestCustomNamedGetter*>(object); 149 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 150 if (canGetItemsForName(exec, static_cast<TestCustomNamedGetter*>(thisObject->impl()), propertyName)) { 151 PropertySlot slot(thisObject); 152 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter); 153 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 154 return true; 155 } 156 return getStaticValueDescriptor<JSTestCustomNamedGetter, Base>(exec, &JSTestCustomNamedGetterTable, thisObject, propertyName, descriptor); 157 } 139 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestCustomNamedGetter) 158 140 159 141 bool JSTestCustomNamedGetter::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
r154038 r154300 110 110 } 111 111 112 bool JSTestEventConstructorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 113 { 114 return getStaticValueDescriptor<JSTestEventConstructorConstructor, JSDOMWrapper>(exec, &JSTestEventConstructorConstructorTable, jsCast<JSTestEventConstructorConstructor*>(object), propertyName, descriptor); 115 } 112 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestEventConstructorConstructor) 116 113 117 114 ConstructType JSTestEventConstructorConstructor::getConstructData(JSCell*, ConstructData& constructData) … … 173 170 } 174 171 175 bool JSTestEventConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 176 { 177 JSTestEventConstructor* thisObject = jsCast<JSTestEventConstructor*>(object); 178 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 179 return getStaticValueDescriptor<JSTestEventConstructor, Base>(exec, &JSTestEventConstructorTable, thisObject, propertyName, descriptor); 180 } 172 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestEventConstructor) 181 173 182 174 JSValue jsTestEventConstructorAttr1(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
r154253 r154300 76 76 } 77 77 78 bool JSTestEventTargetConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 79 { 80 return getStaticValueDescriptor<JSTestEventTargetConstructor, JSDOMWrapper>(exec, &JSTestEventTargetConstructorTable, jsCast<JSTestEventTargetConstructor*>(object), propertyName, descriptor); 81 } 78 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestEventTargetConstructor) 82 79 83 80 /* Hash table for prototype */ … … 106 103 } 107 104 108 bool JSTestEventTargetPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 109 { 110 JSTestEventTargetPrototype* thisObject = jsCast<JSTestEventTargetPrototype*>(object); 111 return getStaticFunctionDescriptor<JSObject>(exec, &JSTestEventTargetPrototypeTable, thisObject, propertyName, descriptor); 112 } 105 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestEventTargetPrototype) 113 106 114 107 const ClassInfo JSTestEventTarget::s_info = { "TestEventTarget", &Base::s_info, &JSTestEventTargetTable, 0 , CREATE_METHOD_TABLE(JSTestEventTarget) }; … … 164 157 } 165 158 166 bool JSTestEventTarget::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 167 { 168 JSTestEventTarget* thisObject = jsCast<JSTestEventTarget*>(object); 169 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 170 const HashEntry* entry = JSTestEventTargetTable.entry(exec, propertyName); 171 if (entry) { 172 PropertySlot slot(thisObject); 173 slot.setCustom(thisObject, entry->attributes(), entry->propertyGetter()); 174 descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes()); 175 return true; 176 } 177 unsigned index = propertyName.asIndex(); 178 if (index != PropertyName::NotAnIndex && index < static_cast<TestEventTarget*>(thisObject->impl())->length()) { 179 unsigned attributes = DontDelete | ReadOnly; 180 PropertySlot slot(thisObject); 181 slot.setCustomIndex(thisObject, attributes, index, indexGetter); 182 descriptor.setDescriptor(slot.getValue(exec, propertyName), attributes); 183 return true; 184 } 185 if (canGetItemsForName(exec, static_cast<TestEventTarget*>(thisObject->impl()), propertyName)) { 186 PropertySlot slot(thisObject); 187 slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nameGetter); 188 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 189 return true; 190 } 191 return getStaticValueDescriptor<JSTestEventTarget, Base>(exec, &JSTestEventTargetTable, thisObject, propertyName, descriptor); 192 } 159 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestEventTarget) 193 160 194 161 bool JSTestEventTarget::getOwnPropertySlotByIndex(JSObject* object, ExecState* exec, unsigned index, PropertySlot& slot) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
r154038 r154300 69 69 } 70 70 71 bool JSTestExceptionConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 72 { 73 return getStaticValueDescriptor<JSTestExceptionConstructor, JSDOMWrapper>(exec, &JSTestExceptionConstructorTable, jsCast<JSTestExceptionConstructor*>(object), propertyName, descriptor); 74 } 71 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestExceptionConstructor) 75 72 76 73 /* Hash table for prototype */ … … 126 123 } 127 124 128 bool JSTestException::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 129 { 130 JSTestException* thisObject = jsCast<JSTestException*>(object); 131 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 132 return getStaticValueDescriptor<JSTestException, Base>(exec, &JSTestExceptionTable, thisObject, propertyName, descriptor); 133 } 125 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestException) 134 126 135 127 JSValue jsTestExceptionName(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r154038 r154300 176 176 } 177 177 178 bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 179 { 180 return getStaticPropertyDescriptor<JSTestInterfaceConstructor, JSDOMWrapper>(exec, &JSTestInterfaceConstructorTable, jsCast<JSTestInterfaceConstructor*>(object), propertyName, descriptor); 181 } 178 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestInterfaceConstructor) 182 179 183 180 #if ENABLE(TEST_INTERFACE) … … 240 237 } 241 238 242 bool JSTestInterfacePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 243 { 244 JSTestInterfacePrototype* thisObject = jsCast<JSTestInterfacePrototype*>(object); 245 return getStaticPropertyDescriptor<JSTestInterfacePrototype, JSObject>(exec, &JSTestInterfacePrototypeTable, thisObject, propertyName, descriptor); 246 } 239 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestInterfacePrototype) 247 240 248 241 const ClassInfo JSTestInterface::s_info = { "TestInterface", &Base::s_info, &JSTestInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestInterface) }; … … 283 276 } 284 277 285 bool JSTestInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 286 { 287 JSTestInterface* thisObject = jsCast<JSTestInterface*>(object); 288 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 289 return getStaticValueDescriptor<JSTestInterface, Base>(exec, &JSTestInterfaceTable, thisObject, propertyName, descriptor); 290 } 278 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestInterface) 291 279 292 280 #if ENABLE(Condition22) || ENABLE(Condition23) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
r154087 r154300 70 70 } 71 71 72 bool JSTestMediaQueryListListenerConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 73 { 74 return getStaticValueDescriptor<JSTestMediaQueryListListenerConstructor, JSDOMWrapper>(exec, &JSTestMediaQueryListListenerConstructorTable, jsCast<JSTestMediaQueryListListenerConstructor*>(object), propertyName, descriptor); 75 } 72 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestMediaQueryListListenerConstructor) 76 73 77 74 /* Hash table for prototype */ … … 97 94 } 98 95 99 bool JSTestMediaQueryListListenerPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 100 { 101 JSTestMediaQueryListListenerPrototype* thisObject = jsCast<JSTestMediaQueryListListenerPrototype*>(object); 102 return getStaticFunctionDescriptor<JSObject>(exec, &JSTestMediaQueryListListenerPrototypeTable, thisObject, propertyName, descriptor); 103 } 96 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestMediaQueryListListenerPrototype) 104 97 105 98 const ClassInfo JSTestMediaQueryListListener::s_info = { "TestMediaQueryListListener", &Base::s_info, &JSTestMediaQueryListListenerTable, 0 , CREATE_METHOD_TABLE(JSTestMediaQueryListListener) }; … … 140 133 } 141 134 142 bool JSTestMediaQueryListListener::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 143 { 144 JSTestMediaQueryListListener* thisObject = jsCast<JSTestMediaQueryListListener*>(object); 145 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 146 return getStaticValueDescriptor<JSTestMediaQueryListListener, Base>(exec, &JSTestMediaQueryListListenerTable, thisObject, propertyName, descriptor); 147 } 135 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestMediaQueryListListener) 148 136 149 137 JSValue jsTestMediaQueryListListenerConstructor(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
r154038 r154300 69 69 } 70 70 71 bool JSTestNamedConstructorConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 72 { 73 return getStaticValueDescriptor<JSTestNamedConstructorConstructor, JSDOMWrapper>(exec, &JSTestNamedConstructorConstructorTable, jsCast<JSTestNamedConstructorConstructor*>(object), propertyName, descriptor); 74 } 71 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestNamedConstructorConstructor) 75 72 76 73 EncodedJSValue JSC_HOST_CALL JSTestNamedConstructorNamedConstructor::constructJSTestNamedConstructor(ExecState* exec) … … 170 167 } 171 168 172 bool JSTestNamedConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 173 { 174 JSTestNamedConstructor* thisObject = jsCast<JSTestNamedConstructor*>(object); 175 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 176 return getStaticValueDescriptor<JSTestNamedConstructor, Base>(exec, &JSTestNamedConstructorTable, thisObject, propertyName, descriptor); 177 } 169 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestNamedConstructor) 178 170 179 171 JSValue jsTestNamedConstructorConstructor(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r154038 r154300 76 76 } 77 77 78 bool JSTestNodeConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 79 { 80 return getStaticValueDescriptor<JSTestNodeConstructor, JSDOMWrapper>(exec, &JSTestNodeConstructorTable, jsCast<JSTestNodeConstructor*>(object), propertyName, descriptor); 81 } 78 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestNodeConstructor) 82 79 83 80 ConstructType JSTestNodeConstructor::getConstructData(JSCell*, ConstructData& constructData) … … 127 124 } 128 125 129 bool JSTestNode::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 130 { 131 JSTestNode* thisObject = jsCast<JSTestNode*>(object); 132 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 133 return getStaticValueDescriptor<JSTestNode, Base>(exec, &JSTestNodeTable, thisObject, propertyName, descriptor); 134 } 126 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestNode) 135 127 136 128 JSValue jsTestNodeConstructor(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r154219 r154300 241 241 } 242 242 243 bool JSTestObjConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 244 { 245 return getStaticPropertyDescriptor<JSTestObjConstructor, JSDOMWrapper>(exec, &JSTestObjConstructorTable, jsCast<JSTestObjConstructor*>(object), propertyName, descriptor); 246 } 243 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestObjConstructor) 247 244 248 245 ConstructType JSTestObjConstructor::getConstructData(JSCell*, ConstructData& constructData) … … 353 350 } 354 351 355 bool JSTestObjPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 356 { 357 JSTestObjPrototype* thisObject = jsCast<JSTestObjPrototype*>(object); 358 return getStaticPropertyDescriptor<JSTestObjPrototype, JSObject>(exec, &JSTestObjPrototypeTable, thisObject, propertyName, descriptor); 359 } 352 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestObjPrototype) 360 353 361 354 const ClassInfo JSTestObj::s_info = { "TestObject", &Base::s_info, &JSTestObjTable, 0 , CREATE_METHOD_TABLE(JSTestObj) }; … … 396 389 } 397 390 398 bool JSTestObj::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 399 { 400 JSTestObj* thisObject = jsCast<JSTestObj*>(object); 401 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 402 return getStaticValueDescriptor<JSTestObj, Base>(exec, &JSTestObjTable, thisObject, propertyName, descriptor); 403 } 391 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestObj) 404 392 405 393 JSValue jsTestObjReadOnlyLongAttr(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r154131 r154300 135 135 } 136 136 137 bool JSTestOverloadedConstructorsConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 138 { 139 return getStaticValueDescriptor<JSTestOverloadedConstructorsConstructor, JSDOMWrapper>(exec, &JSTestOverloadedConstructorsConstructorTable, jsCast<JSTestOverloadedConstructorsConstructor*>(object), propertyName, descriptor); 140 } 137 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestOverloadedConstructorsConstructor) 141 138 142 139 ConstructType JSTestOverloadedConstructorsConstructor::getConstructData(JSCell*, ConstructData& constructData) … … 198 195 } 199 196 200 bool JSTestOverloadedConstructors::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 201 { 202 JSTestOverloadedConstructors* thisObject = jsCast<JSTestOverloadedConstructors*>(object); 203 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 204 return getStaticValueDescriptor<JSTestOverloadedConstructors, Base>(exec, &JSTestOverloadedConstructorsTable, thisObject, propertyName, descriptor); 205 } 197 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestOverloadedConstructors) 206 198 207 199 JSValue jsTestOverloadedConstructorsConstructor(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
r154038 r154300 78 78 } 79 79 80 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 81 { 82 return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor); 83 } 80 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestSerializedScriptValueInterfaceConstructor) 84 81 85 82 /* Hash table for prototype */ … … 135 132 } 136 133 137 bool JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 138 { 139 JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(object); 140 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 141 return getStaticValueDescriptor<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, descriptor); 142 } 134 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestSerializedScriptValueInterface) 143 135 144 136 JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r154131 r154300 102 102 } 103 103 104 bool JSTestTypedefsConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 105 { 106 return getStaticValueDescriptor<JSTestTypedefsConstructor, JSDOMWrapper>(exec, &JSTestTypedefsConstructorTable, jsCast<JSTestTypedefsConstructor*>(object), propertyName, descriptor); 107 } 104 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestTypedefsConstructor) 108 105 109 106 ConstructType JSTestTypedefsConstructor::getConstructData(JSCell*, ConstructData& constructData) … … 143 140 } 144 141 145 bool JSTestTypedefsPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 146 { 147 JSTestTypedefsPrototype* thisObject = jsCast<JSTestTypedefsPrototype*>(object); 148 return getStaticFunctionDescriptor<JSObject>(exec, &JSTestTypedefsPrototypeTable, thisObject, propertyName, descriptor); 149 } 142 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestTypedefsPrototype) 150 143 151 144 const ClassInfo JSTestTypedefs::s_info = { "TestTypedefs", &Base::s_info, &JSTestTypedefsTable, 0 , CREATE_METHOD_TABLE(JSTestTypedefs) }; … … 186 179 } 187 180 188 bool JSTestTypedefs::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 189 { 190 JSTestTypedefs* thisObject = jsCast<JSTestTypedefs*>(object); 191 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 192 return getStaticValueDescriptor<JSTestTypedefs, Base>(exec, &JSTestTypedefsTable, thisObject, propertyName, descriptor); 193 } 181 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSTestTypedefs) 194 182 195 183 JSValue jsTestTypedefsUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, PropertyName) -
trunk/Source/WebCore/bridge/objc/objc_runtime.mm
r154038 r154300 216 216 } 217 217 218 bool ObjcFallbackObjectImp::getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor& descriptor) 219 { 220 // keep the prototype from getting called instead of just returning false 221 descriptor.setUndefined(); 222 return true; 223 } 218 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ObjcFallbackObjectImp) 224 219 225 220 void ObjcFallbackObjectImp::put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&) -
trunk/Source/WebCore/bridge/runtime_array.cpp
r154253 r154300 104 104 } 105 105 106 bool RuntimeArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) 107 { 108 RuntimeArray* thisObject = jsCast<RuntimeArray*>(object); 109 if (propertyName == exec->propertyNames().length) { 110 PropertySlot slot(thisObject); 111 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter); 112 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 113 return true; 114 } 115 116 unsigned index = propertyName.asIndex(); 117 if (index < thisObject->getLength()) { 118 ASSERT(index != PropertyName::NotAnIndex); 119 PropertySlot slot(thisObject); 120 slot.setCustomIndex(thisObject, DontDelete | DontEnum, index, indexGetter); 121 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | DontEnum); 122 return true; 123 } 124 125 return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 126 } 106 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RuntimeArray) 127 107 128 108 bool RuntimeArray::getOwnPropertySlotByIndex(JSObject* object, ExecState *exec, unsigned index, PropertySlot& slot) -
trunk/Source/WebCore/bridge/runtime_method.cpp
r154253 r154300 73 73 } 74 74 75 bool RuntimeMethod::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor &descriptor) 76 { 77 RuntimeMethod* thisObject = jsCast<RuntimeMethod*>(object); 78 if (propertyName == exec->propertyNames().length) { 79 PropertySlot slot(thisObject); 80 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, lengthGetter); 81 descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum); 82 return true; 83 } 84 85 return InternalFunction::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 86 } 75 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RuntimeMethod) 87 76 88 77 static EncodedJSValue JSC_HOST_CALL callRuntimeMethod(ExecState* exec) -
trunk/Source/WebCore/bridge/runtime_object.cpp
r154253 r154300 162 162 } 163 163 164 bool RuntimeObject::getOwnPropertyDescriptor(JSObject* object, ExecState *exec, PropertyName propertyName, PropertyDescriptor& descriptor) 165 { 166 RuntimeObject* thisObject = jsCast<RuntimeObject*>(object); 167 if (!thisObject->m_instance) { 168 throwInvalidAccessError(exec); 169 return false; 170 } 171 172 RefPtr<Instance> instance = thisObject->m_instance; 173 instance->begin(); 174 175 Class *aClass = instance->getClass(); 176 177 if (aClass) { 178 // See if the instance has a field with the specified name. 179 Field *aField = aClass->fieldNamed(propertyName, instance.get()); 180 if (aField) { 181 PropertySlot slot(thisObject); 182 slot.setCustom(thisObject, DontDelete, fieldGetter); 183 instance->end(); 184 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete); 185 return true; 186 } else { 187 // Now check if a method with specified name exists, if so return a function object for 188 // that method. 189 if (aClass->methodNamed(propertyName, instance.get())) { 190 PropertySlot slot(thisObject); 191 slot.setCustom(thisObject, DontDelete | ReadOnly, methodGetter); 192 instance->end(); 193 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly); 194 return true; 195 } 196 } 197 198 // Try a fallback object. 199 if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) { 200 PropertySlot slot(thisObject); 201 slot.setCustom(thisObject, DontDelete | ReadOnly | DontEnum, fallbackObjectGetter); 202 instance->end(); 203 descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly | DontEnum); 204 return true; 205 } 206 } 207 208 instance->end(); 209 210 return instance->getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor); 211 } 164 GET_OWN_PROPERTY_DESCRIPTOR_IMPL(RuntimeObject) 212 165 213 166 void RuntimeObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
Note: See TracChangeset
for help on using the changeset viewer.