Ignore:
Timestamp:
Aug 19, 2013, 2:44:17 PM (12 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=119995
Start removing custom implementations of getOwnPropertyDescriptor

Reviewed by Sam Weinig.

This can now typically implemented in terms of getOwnPropertySlot.
Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS.
Switch over most classes in JSC & the WebCore bindings generator to use this.

Source/JavaScriptCore:

  • API/JSCallbackObjectFunctions.h:
  • debugger/DebuggerActivation.cpp:
  • runtime/Arguments.cpp:
  • runtime/ArrayConstructor.cpp:
  • runtime/ArrayPrototype.cpp:
  • runtime/BooleanPrototype.cpp:
  • runtime/DateConstructor.cpp:
  • runtime/DatePrototype.cpp:
  • runtime/ErrorPrototype.cpp:
  • runtime/JSActivation.cpp:
  • runtime/JSArray.cpp:
  • runtime/JSArrayBuffer.cpp:
  • runtime/JSArrayBufferView.cpp:
  • runtime/JSCell.cpp:
  • runtime/JSDataView.cpp:
  • runtime/JSDataViewPrototype.cpp:
  • runtime/JSFunction.cpp:
  • runtime/JSGenericTypedArrayViewInlines.h:
  • runtime/JSNotAnObject.cpp:
  • runtime/JSONObject.cpp:
  • runtime/JSObject.cpp:
  • runtime/NamePrototype.cpp:
  • runtime/NumberConstructor.cpp:
  • runtime/NumberPrototype.cpp:
  • runtime/ObjectConstructor.cpp:
    • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
  • runtime/PropertyDescriptor.h:
    • Added GET_OWN_PROPERTY_DESCRIPTOR_IMPL macro.
  • runtime/PropertySlot.h:

(JSC::PropertySlot::isValue):
(JSC::PropertySlot::isGetter):
(JSC::PropertySlot::isCustom):
(JSC::PropertySlot::isCacheableValue):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::isCacheableCustom):
(JSC::PropertySlot::attributes):
(JSC::PropertySlot::getterSetter):

  • Add accessors necessary to convert PropertySlot to descriptor.
  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpMatchesArray.cpp:
  • runtime/RegExpMatchesArray.h:
  • runtime/RegExpObject.cpp:
  • runtime/RegExpPrototype.cpp:
  • runtime/StringConstructor.cpp:
  • runtime/StringObject.cpp:
    • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.

Source/WebCore:

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:
  • bindings/js/JSHTMLAppletElementCustom.cpp:
  • bindings/js/JSHTMLEmbedElementCustom.cpp:
  • bindings/js/JSHTMLObjectElementCustom.cpp:
  • bindings/js/JSHistoryCustom.cpp:

(WebCore::JSHistory::getOwnPropertySlotDelegate):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::JSLocation::getOwnPropertySlotDelegate):

  • bindings/js/JSWorkerGlobalScopeCustom.cpp:
    • Remove getOwnPropertyDescriptorDelegate methods, Change attributes of cross-frame access properties in JSHistory/JSLocation to prevent properties from being redefined.
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):
(GenerateImplementation):
(GenerateConstructorHelperMethods):

  • Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
  • bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
  • bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:
  • bindings/scripts/test/JS/JSTestEventTarget.cpp:
  • bindings/scripts/test/JS/JSTestException.cpp:
  • bindings/scripts/test/JS/JSTestInterface.cpp:
  • bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
  • bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
  • bindings/scripts/test/JS/JSTestNode.cpp:
  • bindings/scripts/test/JS/JSTestObj.cpp:
  • bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
  • bindings/scripts/test/JS/JSTestTypedefs.cpp:
    • Update test expectations.

LayoutTests:

  • http/tests/security/xss-DENIED-defineProperty-expected.txt:
    • Remove erroneous error messages - cross frame access to reload is allowed - it's just read-only, non-configurable.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r154253 r154300  
    214214
    215215template <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 }
     216GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSCallbackObject<Parent>)
    234217
    235218template <class Parent>
Note: See TracChangeset for help on using the changeset viewer.