Changeset 204551 in webkit


Ignore:
Timestamp:
Aug 16, 2016 8:17:04 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r204540, r204545, and r204547.
https://bugs.webkit.org/show_bug.cgi?id=160932

Broke Windows builds (Requested by rniwa on #webkit).

Reverted changesets:

"customElements.define should retrieve lifecycle callbacks"
https://bugs.webkit.org/show_bug.cgi?id=160797
http://trac.webkit.org/changeset/204540

"Windows build fix attempt after r204540."
http://trac.webkit.org/changeset/204545

"Another Windows build fix attempt. The error message doesn't
make any sense to me."
http://trac.webkit.org/changeset/204547

Location:
trunk
Files:
2 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r204543 r204551  
     12016-08-16  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r204540, r204545, and r204547.
     4        https://bugs.webkit.org/show_bug.cgi?id=160932
     5
     6        Broke Windows builds (Requested by rniwa on #webkit).
     7
     8        Reverted changesets:
     9
     10        "customElements.define should retrieve lifecycle callbacks"
     11        https://bugs.webkit.org/show_bug.cgi?id=160797
     12        http://trac.webkit.org/changeset/204540
     13
     14        "Windows build fix attempt after r204540."
     15        http://trac.webkit.org/changeset/204545
     16
     17        "Another Windows build fix attempt. The error message doesn't
     18        make any sense to me."
     19        http://trac.webkit.org/changeset/204547
     20
    1212016-08-16  Chris Dumez  <cdumez@apple.com>
    222
  • trunk/LayoutTests/fast/custom-elements/attribute-changed-callback-expected.txt

    r204540 r204551  
    44PASS setAttributeNode and removeAttributeNS must enqueue and invoke attributeChangedCallback
    55PASS setAttributeNode and removeAttributeNS must enqueue and invoke attributeChangedCallback
    6 PASS Mutating attributeChangedCallback after calling customElements.define must not affect the callback being invoked
    7 PASS attributedChangedCallback must not be invoked when the observed attributes does not contain the attribute.
    8 PASS Mutating observedAttributes after calling customElements.define must not affect the set of attributes for which attributedChangedCallback is invoked
    9 PASS attributedChangedCallback must be enqueued for attributes specified in a non-Array iterable observedAttributes
    106
  • trunk/LayoutTests/fast/custom-elements/attribute-changed-callback.html

    r204540 r204551  
    2020    }
    2121}
    22 MyCustomElement.observedAttributes = ['title', 'id', 'r'];
    2322customElements.define('my-custom-element', MyCustomElement);
    2423
     
    9897    assert_equals(argumentList[1].value, null);
    9998    assert_array_equals(argumentList[1].arguments, ['r', '100', null, 'http://www.w3.org/2000/svg']);
     99
    100100}, 'setAttributeNode and removeAttributeNS must enqueue and invoke attributeChangedCallback');
    101 
    102 test(function () {
    103     var callsToOld = [];
    104     var callsToNew = [];
    105     class CustomElement extends HTMLElement { }
    106     CustomElement.prototype.attributeChangedCallback = function () {
    107         callsToOld.push(Array.from(arguments));
    108     }
    109     CustomElement.observedAttributes = ['title'];
    110     customElements.define('element-with-mutated-attribute-changed-callback', CustomElement);
    111     CustomElement.prototype.attributeChangedCallback = function () {
    112         callsToNew.push(Array.from(arguments));
    113     }
    114 
    115     var instance = document.createElement('element-with-mutated-attribute-changed-callback');
    116     instance.setAttribute('title', 'hi');
    117     assert_equals(instance.getAttribute('title'), 'hi');
    118     assert_array_equals(callsToNew, []);
    119     assert_equals(callsToOld.length, 1);
    120     assert_array_equals(callsToOld[0], ['title', null, 'hi', null]);
    121 }, 'Mutating attributeChangedCallback after calling customElements.define must not affect the callback being invoked');
    122 
    123 test(function () {
    124     var calls = [];
    125     class CustomElement extends HTMLElement {
    126         attributeChangedCallback() {
    127             calls.push(Array.from(arguments));
    128         }
    129     }
    130     CustomElement.observedAttributes = ['title'];
    131     customElements.define('element-not-observing-id-attribute', CustomElement);
    132 
    133     var instance = document.createElement('element-not-observing-id-attribute');
    134     instance.setAttribute('title', 'hi');
    135     assert_equals(calls.length, 1);
    136     assert_array_equals(calls[0], ['title', null, 'hi', null]);
    137     instance.setAttribute('id', 'some');
    138     assert_equals(calls.length, 1);
    139 }, 'attributedChangedCallback must not be invoked when the observed attributes does not contain the attribute.');
    140 
    141 test(function () {
    142     var calls = [];
    143     class CustomElement extends HTMLElement { }
    144     CustomElement.prototype.attributeChangedCallback = function () {
    145         calls.push(Array.from(arguments));
    146     }
    147     CustomElement.observedAttributes = ['title', 'lang'];
    148     customElements.define('element-with-mutated-observed-attributes', CustomElement);
    149     CustomElement.observedAttributes = ['title', 'id'];
    150 
    151     var instance = document.createElement('element-with-mutated-observed-attributes');
    152     instance.setAttribute('title', 'hi');
    153     assert_equals(calls.length, 1);
    154     assert_array_equals(calls[0], ['title', null, 'hi', null]);
    155 
    156     instance.setAttribute('id', 'some');
    157     assert_equals(calls.length, 1);
    158 
    159     instance.setAttribute('lang', 'en');
    160     assert_equals(calls.length, 2);
    161     assert_array_equals(calls[0], ['title', null, 'hi', null]);
    162     assert_array_equals(calls[1], ['lang', null, 'en', null]);
    163 }, 'Mutating observedAttributes after calling customElements.define must not affect the set of attributes for which attributedChangedCallback is invoked');
    164 
    165 test(function () {
    166     var calls = [];
    167     class CustomElement extends HTMLElement { }
    168     CustomElement.prototype.attributeChangedCallback = function () {
    169         calls.push(Array.from(arguments));
    170     }
    171     CustomElement.observedAttributes = { [Symbol.iterator]: function *() { yield 'lang'; yield 'style'; } };
    172     customElements.define('element-with-generator-observed-attributes', CustomElement);
    173 
    174     var instance = document.createElement('element-with-generator-observed-attributes');
    175     instance.setAttribute('lang', 'en');
    176     assert_equals(calls.length, 1);
    177     assert_array_equals(calls[0], ['lang', null, 'en', null]);
    178 
    179     instance.setAttribute('lang', 'ja');
    180     assert_equals(calls.length, 2);
    181     assert_array_equals(calls[1], ['lang', 'en', 'ja', null]);
    182 
    183     instance.setAttribute('title', 'hello');
    184     assert_equals(calls.length, 2);
    185 
    186     instance.setAttribute('style', 'font-size: 2rem');
    187     assert_equals(calls.length, 3);
    188     assert_array_equals(calls[2], ['style', null, 'font-size: 2rem', null]);
    189 }, 'attributedChangedCallback must be enqueued for attributes specified in a non-Array iterable observedAttributes');
    190101
    191102</script>
  • trunk/LayoutTests/fast/custom-elements/lifecycle-callback-timing.html

    r204540 r204551  
    2121    handler() { }
    2222}
    23 MyCustomElement.observedAttributes = ['data-title', 'title'];
    2423customElements.define('my-custom-element', MyCustomElement);
    2524
  • trunk/Source/WebCore/ChangeLog

    r204550 r204551  
     12016-08-16  Commit Queue  <commit-queue@webkit.org>
     2
     3        Unreviewed, rolling out r204540, r204545, and r204547.
     4        https://bugs.webkit.org/show_bug.cgi?id=160932
     5
     6        Broke Windows builds (Requested by rniwa on #webkit).
     7
     8        Reverted changesets:
     9
     10        "customElements.define should retrieve lifecycle callbacks"
     11        https://bugs.webkit.org/show_bug.cgi?id=160797
     12        http://trac.webkit.org/changeset/204540
     13
     14        "Windows build fix attempt after r204540."
     15        http://trac.webkit.org/changeset/204545
     16
     17        "Another Windows build fix attempt. The error message doesn't
     18        make any sense to me."
     19        http://trac.webkit.org/changeset/204547
     20
    1212016-08-16  Hunseop Jeong  <hs85.jeong@samsung.com>
    222
  • trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r204545 r204551  
    4747#include "JSCommandLineAPIHostCustom.cpp"
    4848#include "JSCryptoCustom.cpp"
    49 #include "JSCustomElementsRegistryCustom.cpp"
    5049#include "JSCustomEventCustom.cpp"
    5150#include "JSCustomSQLStatementErrorCallback.cpp"
  • trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp

    r204540 r204551  
    152152}
    153153
    154 void JSCustomElementInterface::setAttributeChangedCallback(JSC::JSObject* callback, const Vector<String>& observedAttributes)
    155 {
    156     m_attributeChangedCallback = callback;
    157     m_observedAttributes.clear();
    158     for (auto& name : observedAttributes)
    159         m_observedAttributes.add(name);
    160 }
    161 
    162154void JSCustomElementInterface::attributeChanged(Element& element, const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue)
    163155{
     
    179171    JSObject* jsElement = asObject(toJS(state, globalObject, element));
    180172
     173    PropertyName attributeChanged(Identifier::fromString(state, "attributeChangedCallback"));
     174    JSValue callback = jsElement->get(state, attributeChanged);
    181175    CallData callData;
    182     CallType callType = m_attributeChangedCallback->methodTable()->getCallData(m_attributeChangedCallback.get(), callData);
    183     ASSERT(callType != CallType::None);
     176    CallType callType = getCallData(callback, callData);
     177    if (callType == CallType::None)
     178        return;
    184179
    185180    const AtomicString& namespaceURI = attributeName.namespaceURI();
     
    193188
    194189    NakedPtr<Exception> exception;
    195     JSMainThreadExecState::call(state, m_attributeChangedCallback.get(), callType, callData, jsElement, args, exception);
     190    JSMainThreadExecState::call(state, callback, callType, callData, jsElement, args, exception);
    196191
    197192    InspectorInstrumentation::didCallFunction(cookie, context);
  • trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h

    r204540 r204551  
    3838#include <wtf/RefCounted.h>
    3939#include <wtf/RefPtr.h>
    40 #include <wtf/text/AtomicStringHash.h>
    4140
    4241namespace JSC {
     
    6766    void upgradeElement(Element&);
    6867
    69     void setAttributeChangedCallback(JSC::JSObject* callback, const Vector<String>& observedAttributes);
    70     bool observesAttribute(const AtomicString& name) const { return m_observedAttributes.contains(name); }
    7168    void attributeChanged(Element&, const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue);
    7269
     
    8784    QualifiedName m_name;
    8885    mutable JSC::Weak<JSC::JSObject> m_constructor;
    89     mutable JSC::Weak<JSC::JSObject> m_attributeChangedCallback;
    9086    RefPtr<DOMWrapperWorld> m_isolatedWorld;
    9187    Vector<RefPtr<Element>, 1> m_constructionStack;
    92     HashSet<AtomicString> m_observedAttributes;
    9388};
    9489
  • trunk/Source/WebCore/bindings/js/JSCustomElementsRegistryCustom.cpp

    r204547 r204551  
    3232#include "JSCustomElementInterface.h"
    3333#include "JSDOMBinding.h"
    34 #include "JSDOMConvert.h"
    3534
    3635using namespace JSC;
     
    3837namespace WebCore {
    3938
     39   
    4040#if ENABLE(CUSTOM_ELEMENTS)
    41 
    42 static JSObject* getLifecycleCallback(ExecState& state, JSObject& prototype, const Identifier& id)
    43 {
    44     JSValue callback = prototype.get(&state, id);
    45     if (state.hadException())
    46         return nullptr;
    47     if (callback.isUndefined())
    48         return nullptr;
    49     if (!callback.isFunction()) {
    50         throwTypeError(&state, ASCIILiteral("A lifecycle callback must be a function"));
    51         return nullptr;
    52     }
    53     return callback.getObject();
    54 }
    55 
    56 // https://html.spec.whatwg.org/#dom-customelementsregistry-define
    5741JSValue JSCustomElementsRegistry::define(ExecState& state)
    5842{
     
    7054
    7155    // FIXME: Throw a TypeError if constructor doesn't inherit from HTMLElement.
    72     // https://github.com/w3c/webcomponents/issues/541
    7356
    7457    switch (Document::validateCustomElementName(localName)) {
     
    8366    }
    8467
    85     // FIXME: Check re-entrancy here.
    86     // https://github.com/w3c/webcomponents/issues/545
    87 
    8868    CustomElementsRegistry& registry = wrapped();
    8969    if (registry.findInterface(localName)) {
     
    9777    }
    9878
    99     auto& vm = globalObject()->vm();
    100     JSValue prototypeValue = constructor->get(&state, vm.propertyNames->prototype);
    101     if (state.hadException())
    102         return jsUndefined();
    103     if (!prototypeValue.isObject())
    104         return throwTypeError(&state, ASCIILiteral("Custom element constructor's prototype must be an object"));
    105     JSObject& prototypeObject = *asObject(prototypeValue);
     79    // FIXME: 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.
     80    // FIXME: 11. If Type(prototype) is not Object, throw a TypeError exception.
     81    // FIXME: 12. Let attachedCallback be Get(prototype, "attachedCallback"). Rethrow any exceptions.
     82    // FIXME: 13. Let detachedCallback be Get(prototype, "detachedCallback"). Rethrow any exceptions.
     83    // FIXME: 14. Let attributeChangedCallback be Get(prototype, "attributeChangedCallback"). Rethrow any exceptions.
    10684
    107     // FIXME: Add the support for connectedCallback.
    108     getLifecycleCallback(state, prototypeObject, Identifier::fromString(&vm, "connectedCallback"));
    109     if (state.hadException())
    110         return jsUndefined();
    111 
    112     // FIXME: Add the support for disconnectedCallback.
    113     getLifecycleCallback(state, prototypeObject, Identifier::fromString(&vm, "disconnectedCallback"));
    114     if (state.hadException())
    115         return jsUndefined();
    116 
    117     // FIXME: Add the support for adoptedCallback.
    118     getLifecycleCallback(state, prototypeObject, Identifier::fromString(&vm, "adoptedCallback"));
    119     if (state.hadException())
    120         return jsUndefined();
     85    PrivateName uniquePrivateName;
     86    globalObject()->putDirect(globalObject()->vm(), uniquePrivateName, constructor);
    12187
    12288    QualifiedName name(nullAtom, localName, HTMLNames::xhtmlNamespaceURI);
    123     Ref<JSCustomElementInterface> interface = JSCustomElementInterface::create(name, constructor, globalObject());
    124 
    125     auto* attributeChangedCallback = getLifecycleCallback(state, prototypeObject, Identifier::fromString(&vm, "attributeChangedCallback"));
    126     if (state.hadException())
    127         return jsUndefined();
    128     if (attributeChangedCallback) {
    129         auto value = convertOptional<Vector<String>>(state, constructor->get(&state, Identifier::fromString(&state, "observedAttributes")));
    130         if (state.hadException())
    131             return jsUndefined();
    132         if (value)
    133             interface->setAttributeChangedCallback(attributeChangedCallback, *value);
    134     }
    135 
    136     PrivateName uniquePrivateName;
    137     globalObject()->putDirect(vm, uniquePrivateName, constructor);
    138 
    139     registry.addElementDefinition(WTFMove(interface));
     89    registry.addElementDefinition(JSCustomElementInterface::create(name, constructor, globalObject()));
    14090
    14191    // FIXME: 17. Let map be registry's upgrade candidates map.
    14292    // FIXME: 18. Upgrade a newly-defined element given map and definition.
    143     // FIXME: 19. Resolve whenDefined promise.
    14493
    14594    return jsUndefined();
  • trunk/Source/WebCore/dom/Element.cpp

    r204543 r204551  
    12911291
    12921292#if ENABLE(CUSTOM_ELEMENTS)
    1293     if (UNLIKELY(isCustomElement()))
    1294         LifecycleCallbackQueue::enqueueAttributeChangedCallbackIfNeeded(*this, name, oldValue, newValue);
     1293    if (UNLIKELY(isCustomElement())) {
     1294        if (auto* window = document().domWindow()) {
     1295            if (auto* registry = window->customElementsRegistry()) {
     1296                auto* elementInterface = registry->findInterface(tagQName());
     1297                RELEASE_ASSERT(elementInterface);
     1298                LifecycleCallbackQueue::enqueueAttributeChangedCallback(*this, *elementInterface, name, oldValue, newValue);
     1299            }
     1300        }
     1301    }
    12951302#endif
    12961303
  • trunk/Source/WebCore/dom/LifecycleCallbackQueue.cpp

    r204540 r204551  
    2929#if ENABLE(CUSTOM_ELEMENTS)
    3030
    31 #include "CustomElementsRegistry.h"
    32 #include "DOMWindow.h"
    3331#include "Document.h"
    3432#include "Element.h"
     
    9997}
    10098
    101 void LifecycleCallbackQueue::enqueueAttributeChangedCallbackIfNeeded(Element& element, const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue)
     99void LifecycleCallbackQueue::enqueueAttributeChangedCallback(Element& element, JSCustomElementInterface& elementInterface,
     100    const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue)
    102101{
    103     ASSERT(element.isCustomElement());
    104     auto* window = element.document().domWindow();
    105     if (!window)
    106         return;
    107 
    108     auto* registry = window->customElementsRegistry();
    109     if (!registry)
    110         return;
    111 
    112     auto* elementInterface = registry->findInterface(element.tagQName());
    113     if (!elementInterface->observesAttribute(attributeName.localName()))
    114         return;
    115 
    116102    if (auto* queue = CustomElementLifecycleProcessingStack::ensureCurrentQueue())
    117         queue->m_items.append(LifecycleQueueItem(element, *elementInterface, attributeName, oldValue, newValue));
     103        queue->m_items.append(LifecycleQueueItem(element, elementInterface, attributeName, oldValue, newValue));
    118104}
    119105
  • trunk/Source/WebCore/dom/LifecycleCallbackQueue.h

    r204540 r204551  
    2424 */
    2525
    26 #pragma once
     26#ifndef LifecycleCallbackQueue_h
     27#define LifecycleCallbackQueue_h
    2728
    2829#if ENABLE(CUSTOM_ELEMENTS)
     
    4748
    4849    static void enqueueElementUpgrade(Element&, JSCustomElementInterface&);
    49     static void enqueueAttributeChangedCallbackIfNeeded(Element&, const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue);
     50
     51    static void enqueueAttributeChangedCallback(Element&, JSCustomElementInterface&,
     52        const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue);
    5053
    5154    void invokeAll();
     
    8790
    8891#endif
     92
     93#endif // LifecycleCallbackQueue_h
Note: See TracChangeset for help on using the changeset viewer.