Changeset 234507 in webkit
- Timestamp:
- Aug 2, 2018 12:25:23 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r234131 r234507 1 2018-08-01 Ryosuke Niwa <rniwa@webkit.org> 2 3 Implement customElements.upgrade() 4 https://bugs.webkit.org/show_bug.cgi?id=183397 5 6 Reviewed by Frédéric Wang. 7 8 Rebaseline the test now that we're passing. 9 10 * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: 11 1 12 2018-07-23 Manuel Rego Casasnovas <rego@igalia.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt
r234039 r234507 1 1 2 FAIL Upgrading an element directly (example from the spec) customElements.upgrade is not a function. (In 'customElements.upgrade(el)', 'customElements.upgrade' is undefined) 3 FAIL Two elements as children of the upgraded node customElements.upgrade is not a function. (In 'customElements.upgrade(container)', 'customElements.upgrade' is undefined) 4 FAIL Two elements as descendants of the upgraded node customElements.upgrade is not a function. (In 'customElements.upgrade(container)', 'customElements.upgrade' is undefined) 5 FAIL Two elements as shadow-including descendants (and not descendants) of the upgraded node customElements.upgrade is not a function. (In 'customElements.upgrade(container)', 'customElements.upgrade' is undefined) 6 FAIL Elements inside a template contents DocumentFragment node customElements.upgrade is not a function. (In 'customElements.upgrade(template)', 'customElements.upgrade' is undefined) 2 PASS Upgrading an element directly (example from the spec) 3 PASS Two elements as children of the upgraded node 4 PASS Two elements as descendants of the upgraded node 5 PASS Two elements as shadow-including descendants (and not descendants) of the upgraded node 6 PASS Elements inside a template contents DocumentFragment node 7 7 -
trunk/Source/WebCore/ChangeLog
r234506 r234507 1 2018-08-01 Ryosuke Niwa <rniwa@webkit.org> 2 3 Implement customElements.upgrade() 4 https://bugs.webkit.org/show_bug.cgi?id=183397 5 6 Reviewed by Frédéric Wang. 7 8 Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are 9 inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. 10 Also see https://github.com/w3c/webcomponents/issues/710 11 12 Implemented the method as specified at: 13 https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade 14 15 When invoked, the upgrade(root) method must run these steps: 16 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, 17 in shadow-including tree order. 18 2. For each candidate of candidates, try to upgrade candidate. 19 20 Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html 21 22 * dom/CustomElementReactionQueue.cpp: 23 (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element 24 is connected since the whole point of this API is to upgrade a disconnected element. 25 * dom/CustomElementRegistry.cpp: 26 (WebCore::upgradeElementsInShadowIncludingdescendants): Added. 27 (WebCore::CustomElementRegistry::upgrade): Added. 28 * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. 29 * dom/CustomElementRegistry.idl: 30 * dom/Element.cpp: 31 (WebCore::Element::insertedIntoAncestor): Moved the assertion here. 32 1 33 2018-08-02 Simon Fraser <simon.fraser@apple.com> 2 34 -
trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp
r228218 r234507 123 123 void CustomElementReactionQueue::enqueueElementUpgradeIfDefined(Element& element) 124 124 { 125 ASSERT(element.isConnected());126 125 ASSERT(element.isCustomElementUpgradeCandidate()); 127 126 auto* window = element.document().domWindow(); -
trunk/Source/WebCore/dom/CustomElementRegistry.cpp
r228218 r234507 36 36 #include "QualifiedName.h" 37 37 #include "ShadowRoot.h" 38 #include "TypedElementDescendantIterator.h" 38 39 #include <JavaScriptCore/JSCJSValueInlines.h> 39 40 #include <wtf/text/AtomicString.h> … … 114 115 } 115 116 117 static void upgradeElementsInShadowIncludingDescendants(ContainerNode& root) 118 { 119 for (auto& element : descendantsOfType<Element>(root)) { 120 if (element.isCustomElementUpgradeCandidate()) 121 CustomElementReactionQueue::enqueueElementUpgradeIfDefined(element); 122 if (auto* shadowRoot = element.shadowRoot()) 123 upgradeElementsInShadowIncludingDescendants(*shadowRoot); 124 } 116 125 } 126 127 void CustomElementRegistry::upgrade(Node& root) 128 { 129 if (!is<ContainerNode>(root)) 130 return; 131 132 if (is<Element>(root) && downcast<Element>(root).isCustomElementUpgradeCandidate()) 133 CustomElementReactionQueue::enqueueElementUpgradeIfDefined(downcast<Element>(root)); 134 135 upgradeElementsInShadowIncludingDescendants(downcast<ContainerNode>(root)); 136 } 137 138 } -
trunk/Source/WebCore/dom/CustomElementRegistry.h
r218593 r234507 26 26 #pragma once 27 27 28 #include "JSDOMPromiseDeferred.h"29 28 #include "QualifiedName.h" 30 29 #include <wtf/HashMap.h> … … 43 42 class CustomElementRegistry; 44 43 class DOMWindow; 44 class DeferredPromise; 45 45 class Element; 46 46 class JSCustomElementInterface; 47 class Node; 47 48 class QualifiedName; 48 49 … … 63 64 64 65 JSC::JSValue get(const AtomicString&); 66 void upgrade(Node& root); 65 67 66 68 HashMap<AtomicString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; } -
trunk/Source/WebCore/dom/CustomElementRegistry.idl
r217433 r234507 32 32 any get(DOMString name); 33 33 [Custom, MayThrowException, ReturnsOwnPromise] Promise<void> whenDefined(DOMString name); 34 [CEReactions] void upgrade(Node root); 34 35 }; -
trunk/Source/WebCore/dom/Element.cpp
r234109 r234507 1748 1748 1749 1749 if (becomeConnected) { 1750 if (UNLIKELY(isCustomElementUpgradeCandidate())) 1750 if (UNLIKELY(isCustomElementUpgradeCandidate())) { 1751 ASSERT(isConnected()); 1751 1752 CustomElementReactionQueue::enqueueElementUpgradeIfDefined(*this); 1753 } 1752 1754 if (UNLIKELY(isDefinedCustomElement())) 1753 1755 CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded(*this);
Note: See TracChangeset
for help on using the changeset viewer.