WebKit Bugzilla
Attachment 346361 Details for
Bug 183397
: Implement customElements.upgrade()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Implements the feature
bug-183397-20180801233734.patch (text/plain), 7.85 KB, created by
Ryosuke Niwa
on 2018-08-01 23:37:34 PDT
(
hide
)
Description:
Implements the feature
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-08-01 23:37:34 PDT
Size:
7.85 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 234492) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,29 @@ >+2018-08-01 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Implement customElements.upgrade() >+ https://bugs.webkit.org/show_bug.cgi?id=183397 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implemented the method as specified at: >+ https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade >+ >+ When invoked, the upgrade(root) method must run these steps: >+ 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. >+ 2. For each candidate of candidates, try to upgrade candidate. >+ >+ Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html >+ >+ * dom/CustomElementReactionQueue.cpp: >+ (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): >+ * dom/CustomElementRegistry.cpp: >+ (WebCore::upgradeElementsInShadowIncludingdescendants): >+ (WebCore::CustomElementRegistry::upgrade): >+ * dom/CustomElementRegistry.h: >+ * dom/CustomElementRegistry.idl: >+ * dom/Element.cpp: >+ (WebCore::Element::insertedIntoAncestor): >+ > 2018-08-01 Yusuke Suzuki <utatane.tea@gmail.com> > > Unreviewed, rename TransformationMatrix::Identity to TransformationMatrix::identity >Index: Source/WebCore/dom/CustomElementReactionQueue.cpp >=================================================================== >--- Source/WebCore/dom/CustomElementReactionQueue.cpp (revision 234492) >+++ Source/WebCore/dom/CustomElementReactionQueue.cpp (working copy) >@@ -122,7 +122,6 @@ void CustomElementReactionQueue::enqueue > > void CustomElementReactionQueue::enqueueElementUpgradeIfDefined(Element& element) > { >- ASSERT(element.isConnected()); > ASSERT(element.isCustomElementUpgradeCandidate()); > auto* window = element.document().domWindow(); > if (!window) >Index: Source/WebCore/dom/CustomElementRegistry.cpp >=================================================================== >--- Source/WebCore/dom/CustomElementRegistry.cpp (revision 234492) >+++ Source/WebCore/dom/CustomElementRegistry.cpp (working copy) >@@ -35,6 +35,7 @@ > #include "MathMLNames.h" > #include "QualifiedName.h" > #include "ShadowRoot.h" >+#include "TypedElementDescendantIterator.h" > #include <JavaScriptCore/JSCJSValueInlines.h> > #include <wtf/text/AtomicString.h> > >@@ -113,4 +114,25 @@ JSC::JSValue CustomElementRegistry::get( > return JSC::jsUndefined(); > } > >+static void upgradeElementsInShadowIncludingdescendants(ContainerNode& root) >+{ >+ for (auto& element : descendantsOfType<Element>(root)) { >+ if (element.isCustomElementUpgradeCandidate()) >+ CustomElementReactionQueue::enqueueElementUpgradeIfDefined(element); >+ if (auto* shadowRoot = element.shadowRoot()) >+ upgradeElementsInShadowIncludingdescendants(*shadowRoot); >+ } >+} >+ >+void CustomElementRegistry::upgrade(Node& root) >+{ >+ if (!is<ContainerNode>(root)) >+ return; >+ >+ if (is<Element>(root) && downcast<Element>(root).isCustomElementUpgradeCandidate()) >+ CustomElementReactionQueue::enqueueElementUpgradeIfDefined(downcast<Element>(root)); >+ >+ upgradeElementsInShadowIncludingdescendants(downcast<ContainerNode>(root)); >+} >+ > } >Index: Source/WebCore/dom/CustomElementRegistry.h >=================================================================== >--- Source/WebCore/dom/CustomElementRegistry.h (revision 234492) >+++ Source/WebCore/dom/CustomElementRegistry.h (working copy) >@@ -25,7 +25,6 @@ > > #pragma once > >-#include "JSDOMPromiseDeferred.h" > #include "QualifiedName.h" > #include <wtf/HashMap.h> > #include <wtf/text/AtomicString.h> >@@ -42,8 +41,10 @@ namespace WebCore { > > class CustomElementRegistry; > class DOMWindow; >+class DeferredPromise; > class Element; > class JSCustomElementInterface; >+class Node; > class QualifiedName; > > class CustomElementRegistry : public RefCounted<CustomElementRegistry> { >@@ -62,6 +63,7 @@ public: > bool containsConstructor(const JSC::JSObject*) const; > > JSC::JSValue get(const AtomicString&); >+ void upgrade(Node& root); > > HashMap<AtomicString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; } > >Index: Source/WebCore/dom/CustomElementRegistry.idl >=================================================================== >--- Source/WebCore/dom/CustomElementRegistry.idl (revision 234492) >+++ Source/WebCore/dom/CustomElementRegistry.idl (working copy) >@@ -31,4 +31,5 @@ > [CEReactions, Custom] void define(DOMString name, Function constructor); > any get(DOMString name); > [Custom, MayThrowException, ReturnsOwnPromise] Promise<void> whenDefined(DOMString name); >+ [CEReactions] void upgrade(Node root); > }; >Index: Source/WebCore/dom/Element.cpp >=================================================================== >--- Source/WebCore/dom/Element.cpp (revision 234492) >+++ Source/WebCore/dom/Element.cpp (working copy) >@@ -1747,8 +1747,10 @@ Node::InsertedIntoAncestorResult Element > } > > if (becomeConnected) { >- if (UNLIKELY(isCustomElementUpgradeCandidate())) >+ if (UNLIKELY(isCustomElementUpgradeCandidate())) { >+ ASSERT(isConnected()); > CustomElementReactionQueue::enqueueElementUpgradeIfDefined(*this); >+ } > if (UNLIKELY(isDefinedCustomElement())) > CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded(*this); > } >Index: LayoutTests/imported/w3c/ChangeLog >=================================================================== >--- LayoutTests/imported/w3c/ChangeLog (revision 234496) >+++ LayoutTests/imported/w3c/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2018-08-01 Ryosuke Niwa <rniwa@webkit.org> >+ >+ Implement customElements.upgrade() >+ https://bugs.webkit.org/show_bug.cgi?id=183397 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Rebaseline the test now that we're passing. >+ >+ * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: >+ > 2018-07-23 Manuel Rego Casasnovas <rego@igalia.com> > > [css-grid] Add support for calc() in gutter properties >Index: LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt >=================================================================== >--- LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt (revision 234492) >+++ LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt (working copy) >@@ -1,7 +1,7 @@ > >-FAIL Upgrading an element directly (example from the spec) customElements.upgrade is not a function. (In 'customElements.upgrade(el)', 'customElements.upgrade' is undefined) >-FAIL Two elements as children of the upgraded node customElements.upgrade is not a function. (In 'customElements.upgrade(container)', 'customElements.upgrade' is undefined) >-FAIL Two elements as descendants of the upgraded node customElements.upgrade is not a function. (In 'customElements.upgrade(container)', 'customElements.upgrade' is undefined) >-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) >-FAIL Elements inside a template contents DocumentFragment node customElements.upgrade is not a function. (In 'customElements.upgrade(template)', 'customElements.upgrade' is undefined) >+PASS Upgrading an element directly (example from the spec) >+PASS Two elements as children of the upgraded node >+PASS Two elements as descendants of the upgraded node >+PASS Two elements as shadow-including descendants (and not descendants) of the upgraded node >+PASS Elements inside a template contents DocumentFragment node >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
fred.wang
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 183397
:
346361
|
346362