Changeset 234608 in webkit


Ignore:
Timestamp:
Aug 6, 2018 10:45:41 AM (6 years ago)
Author:
rniwa@webkit.org
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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r234586 r234608  
     12018-08-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        HTML parser should execute custom element reactions for setting attributes immediately after creating a custom element
     4        https://bugs.webkit.org/show_bug.cgi?id=188336
     5
     6        Reviewed by Frédéric Wang.
     7
     8        Rebaseline the test now that the relevant test case is passing.
     9
     10        * web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt:
     11
    1122018-08-05  Yusuke Suzuki  <utatane.tea@gmail.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children-expected.txt

    r230330 r234608  
    44PASS HTML parser must set the attributes or append children before calling constructor
    55FAIL HTML parser should call connectedCallback before appending child nodes. assert_equals: expected 0 but got 2
    6 FAIL HTML parser must enqueue attributeChanged reactions assert_equals: attributeChangedCallback should be called before appending a child expected 0 but got 2
     6PASS HTML parser must enqueue attributeChanged reactions
    77hello world
  • trunk/Source/WebCore/ChangeLog

    r234603 r234608  
     12018-08-06  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        HTML parser should execute custom element reactions for setting attributes immediately after creating a custom element
     4        https://bugs.webkit.org/show_bug.cgi?id=188336
     5
     6        Reviewed by Frédéric Wang.
     7
     8        Push and pop an element queue from the custom element reactions stack when constructing a custom element:
     9        https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
     10
     11        To do this, we instantiate CustomElementReactionStack in HTMLDocumentParser::runScriptsForPausedTreeBuilder
     12        where we synchronously construct a custom element. We don't have to worry about whether *will execute script*
     13        is set or not since the presence of an element queue should not be observable in the case where we're constructing
     14        a fallback element (since it would not enqueue any new custom element reaction).
     15
     16        Tests: imported/w3c/web-platform-tests/custom-elements/parser/parser-sets-attributes-and-children.html
     17
     18        * html/parser/HTMLDocumentParser.cpp:
     19        (WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder): Instantiate CustomElementReactionStack. Note that we
     20        don't insert the custom element into the parser until we finish processing the custom element reactions.
     21
    1222018-08-06  Charlie Turner  <cturner@igalia.com>
    223
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r233891 r234608  
    2828#include "HTMLDocumentParser.h"
    2929
     30#include "CustomElementReactionQueue.h"
    3031#include "DocumentFragment.h"
    3132#include "DocumentLoader.h"
     
    209210
    210211        // https://html.spec.whatwg.org/#create-an-element-for-the-token
    211         auto& elementInterface = constructionData->elementInterface.get();
    212         auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name);
    213         m_treeBuilder->didCreateCustomOrFallbackElement(WTFMove(newElement), *constructionData);
     212        {
     213            CustomElementReactionStack reactionStack(document()->execState());
     214            auto& elementInterface = constructionData->elementInterface.get();
     215            auto newElement = elementInterface.constructElementWithFallback(*document(), constructionData->name);
     216            m_treeBuilder->didCreateCustomOrFallbackElement(WTFMove(newElement), *constructionData);
     217        }
    214218        return;
    215219    }
Note: See TracChangeset for help on using the changeset viewer.