Title: [234608] trunk
Revision
234608
Author
rn...@webkit.org
Date
2018-08-06 10:45:41 -0700 (Mon, 06 Aug 2018)

Log Message

HTML parser should execute custom element reactions for setting attributes immediately after creating a custom element
https://bugs.webkit.org/show_bug.cgi?id=188336

Reviewed by Frédéric Wang.

LayoutTests/imported/w3c:

Rebaseline the test now that the relevant test case is passing.

* web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt:

Source/WebCore:

Push and pop an element queue from the custom element reactions stack when constructing a custom element:
https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

To do this, we instantiate CustomElementReactionStack in HTMLDocumentParser::runScriptsForPausedTreeBuilder
where we synchronously construct a custom element. We don't have to worry about whether *will execute script*
is set or not since the presence of an element queue should not be observable in the case where we're constructing
a fallback element (since it would not enqueue any new custom element reaction).

Tests: imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children.html

* html/parser/HTMLDocumentParser.cpp:
(WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Instantiate CustomElementReactionStack. Note that we
don't insert the custom element into the parser until we finish processing the custom element reactions.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (234607 => 234608)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2018-08-06 17:43:42 UTC (rev 234607)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2018-08-06 17:45:41 UTC (rev 234608)
@@ -1,3 +1,14 @@
+2018-08-06  Ryosuke Niwa  <rn...@webkit.org>
+
+        HTML parser should execute custom element reactions for setting attributes immediately after creating a custom element
+        https://bugs.webkit.org/show_bug.cgi?id=188336
+
+        Reviewed by Frédéric Wang.
+
+        Rebaseline the test now that the relevant test case is passing.
+
+        * web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt:
+
 2018-08-05  Yusuke Suzuki  <utatane....@gmail.com>
 
         Add support for microtasks in workers

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt (234607 => 234608)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt	2018-08-06 17:43:42 UTC (rev 234607)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt	2018-08-06 17:45:41 UTC (rev 234608)
@@ -3,5 +3,5 @@
 PASS HTML parser must append child nodes 
 PASS HTML parser must set the attributes or append children before calling constructor 
 FAIL HTML parser should call connectedCallback before appending child nodes. assert_equals: expected 0 but got 2
-FAIL HTML parser must enqueue attributeChanged reactions assert_equals: attributeChangedCallback should be called before appending a child expected 0 but got 2
+PASS HTML parser must enqueue attributeChanged reactions 
 hello world

Modified: trunk/Source/WebCore/ChangeLog (234607 => 234608)


--- trunk/Source/WebCore/ChangeLog	2018-08-06 17:43:42 UTC (rev 234607)
+++ trunk/Source/WebCore/ChangeLog	2018-08-06 17:45:41 UTC (rev 234608)
@@ -1,3 +1,24 @@
+2018-08-06  Ryosuke Niwa  <rn...@webkit.org>
+
+        HTML parser should execute custom element reactions for setting attributes immediately after creating a custom element
+        https://bugs.webkit.org/show_bug.cgi?id=188336
+
+        Reviewed by Frédéric Wang.
+
+        Push and pop an element queue from the custom element reactions stack when constructing a custom element:
+        https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
+
+        To do this, we instantiate CustomElementReactionStack in HTMLDocumentParser::runScriptsForPausedTreeBuilder
+        where we synchronously construct a custom element. We don't have to worry about whether *will execute script*
+        is set or not since the presence of an element queue should not be observable in the case where we're constructing
+        a fallback element (since it would not enqueue any new custom element reaction).
+
+        Tests: imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children.html
+
+        * html/parser/HTMLDocumentParser.cpp:
+        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Instantiate CustomElementReactionStack. Note that we
+        don't insert the custom element into the parser until we finish processing the custom element reactions.
+
 2018-08-06  Charlie Turner  <ctur...@igalia.com>
 
         Return extracted key ids as an optional

Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (234607 => 234608)


--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2018-08-06 17:43:42 UTC (rev 234607)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp	2018-08-06 17:45:41 UTC (rev 234608)
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "HTMLDocumentParser.h"
 
+#include "CustomElementReactionQueue.h"
 #include "DocumentFragment.h"
 #include "DocumentLoader.h"
 #include "Frame.h"
@@ -208,9 +209,12 @@
         ASSERT(!m_treeBuilder->hasParserBlockingScriptWork());
 
         // https://html.spec.whatwg.org/#create-an-element-for-the-token
-        auto& elementInterface = constructionData->elementInterface.get();
-        auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name);
-        m_treeBuilder->didCreateCustomOrFallbackElement(WTFMove(newElement), *constructionData);
+        {
+            CustomElementReactionStack reactionStack(document()->execState());
+            auto& elementInterface = constructionData->elementInterface.get();
+            auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name);
+            m_treeBuilder->didCreateCustomOrFallbackElement(WTFMove(newElement), *constructionData);
+        }
         return;
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to