Changeset 141327 in webkit


Ignore:
Timestamp:
Jan 30, 2013 3:11:52 PM (11 years ago)
Author:
rafaelw@chromium.org
Message:

[HTMLTemplateElement] prevent the parser from removing nodes from the content when the foster agency is processing formatting elements
https://bugs.webkit.org/show_bug.cgi?id=108377

Reviewed by Adam Barth.

Source/WebCore:

https://dvcs.w3.org/hg/webcomponents/raw-file/50ce1f368c1a/spec/templates/index.html#in-body-addition

callTheAdoptionAgency now appends to the template's content when it previously would have appended to the template element itself.

New test added to html5lib.

  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::parserAppendChild):

  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::HTMLTreeBuilder::callTheAdoptionAgency):

LayoutTests:

Note that dump-as-markup.js is modified here to put both template content and its direct children. This was an oversight and fixing it will make it
easier to spot parse errors like ones that arise from this bug, where nodes are appended directly to the template element.

  • html5lib/resources/template.dat:
  • resources/dump-as-markup.js:

(Markup._get):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141326 r141327  
     12013-01-30  Rafael Weinstein  <rafaelw@chromium.org>
     2
     3        [HTMLTemplateElement] prevent the parser from removing nodes from the content when the foster agency is processing formatting elements
     4        https://bugs.webkit.org/show_bug.cgi?id=108377
     5
     6        Reviewed by Adam Barth.
     7
     8        Note that dump-as-markup.js is modified here to put both template content and its direct children. This was an oversight and fixing it will make it
     9        easier to spot parse errors like ones that arise from this bug, where nodes are appended directly to the template element.
     10
     11        * html5lib/resources/template.dat:
     12        * resources/dump-as-markup.js:
     13        (Markup._get):
     14
    1152013-01-30  Philip Rogers  <pdr@google.com>
    216
  • trunk/LayoutTests/html5lib/resources/template.dat

    r138546 r141327  
    942942|       #document-fragment
    943943|         <col>
     944
     945#data
     946<body><template><i><menu>Foo</i>
     947#errors
     948#document
     949| <html>
     950|   <head>
     951|   <body>
     952|     <template>
     953|       #document-fragment
     954|         <i>
     955|         <menu>
     956|           <i>
     957|             "Foo"
  • trunk/LayoutTests/resources/dump-as-markup.js

    r139169 r141327  
    225225          str += "#document-fragment";
    226226    }
    227    
    228    
    229     // HTML Template elements serialize their content DocumentFragment, and NOT their children.
    230     if (node.namespaceURI = 'http://www.w3.org/1999/xhtml' && node.tagName == 'TEMPLATE') {
     227
     228    if (node.namespaceURI = 'http://www.w3.org/1999/xhtml' && node.tagName == 'TEMPLATE')
    231229        str += Markup._get(node.content, depth + 1, shadowRootList);
    232     } else {
    233         for (var i = 0, len = node.childNodes.length; i < len; i++) {
    234             var selection = Markup._getSelectionMarker(node, i);
    235             if (selection)
    236                 str += Markup._indent(depth + 1) + selection;
    237    
    238             str += Markup._get(node.childNodes[i], depth + 1, shadowRootList);
    239         }
     230
     231    for (var i = 0, len = node.childNodes.length; i < len; i++) {
     232        var selection = Markup._getSelectionMarker(node, i);
     233        if (selection)
     234            str += Markup._indent(depth + 1) + selection;
     235
     236        str += Markup._get(node.childNodes[i], depth + 1, shadowRootList);
    240237    }
    241238   
  • trunk/Source/WebCore/ChangeLog

    r141320 r141327  
     12013-01-30  Rafael Weinstein  <rafaelw@chromium.org>
     2
     3        [HTMLTemplateElement] prevent the parser from removing nodes from the content when the foster agency is processing formatting elements
     4        https://bugs.webkit.org/show_bug.cgi?id=108377
     5
     6        Reviewed by Adam Barth.
     7
     8        https://dvcs.w3.org/hg/webcomponents/raw-file/50ce1f368c1a/spec/templates/index.html#in-body-addition
     9
     10        callTheAdoptionAgency now appends to the template's content when it previously would have appended to the template element itself.
     11
     12        New test added to html5lib.
     13
     14        * dom/ContainerNode.cpp:
     15        (WebCore::ContainerNode::parserInsertBefore):
     16        (WebCore::ContainerNode::parserAppendChild):
     17        * html/parser/HTMLTreeBuilder.cpp:
     18        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
     19
    1202013-01-30  Mark Lam  <mark.lam@apple.com>
    221
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r141198 r141327  
    3333#include "Frame.h"
    3434#include "FrameView.h"
     35#include "HTMLNames.h"
    3536#include "InlineTextBox.h"
    3637#include "InsertionPoint.h"
     
    330331    ASSERT(nextChild->parentNode() == this);
    331332    ASSERT(!newChild->isDocumentFragment());
     333#if ENABLE(TEMPLATE_ELEMENT)
     334    ASSERT(!hasTagName(HTMLNames::templateTag));
     335#endif
    332336
    333337    if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do
     
    698702    ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events).
    699703    ASSERT(!newChild->isDocumentFragment());
     704#if ENABLE(TEMPLATE_ELEMENT)
     705    ASSERT(!hasTagName(HTMLNames::templateTag));
     706#endif
    700707
    701708    if (document() != newChild->document())
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r140659 r141327  
    3535#include "HTMLParserIdioms.h"
    3636#include "HTMLStackItem.h"
     37#include "HTMLTemplateElement.h"
    3738#include "HTMLToken.h"
    3839#include "HTMLTokenizer.h"
     
    15881589            m_tree.fosterParent(lastNode->element());
    15891590        else {
     1591#if ENABLE(TEMPLATE_ELEMENT)
     1592            if (commonAncestor->hasTagName(templateTag))
     1593                toHTMLTemplateElement(commonAncestor->node())->content()->parserAppendChild(lastNode->element());
     1594            else
     1595                commonAncestor->node()->parserAppendChild(lastNode->element());
     1596#else
    15901597            commonAncestor->node()->parserAppendChild(lastNode->element());
     1598#endif
    15911599            ASSERT(lastNode->stackItem()->isElementNode());
    15921600            ASSERT(lastNode->element()->parentNode());
Note: See TracChangeset for help on using the changeset viewer.