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/runtime/Arguments.cpp

    r154253 r154300  
    153153}
    154154
    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 }
     155GET_OWN_PROPERTY_DESCRIPTOR_IMPL(Arguments)
    183156
    184157void Arguments::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
Note: See TracChangeset for help on using the changeset viewer.