Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1025)

Side by Side Diff: Source/core/html/parser/HTMLTreeBuilder.cpp

Issue 25900003: Hoist <template> in <head> if encountered in AfterHead insertion mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/html5lib/resources/template.dat ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 return; 1137 return;
1138 } 1138 }
1139 if (token->name() == baseTag 1139 if (token->name() == baseTag
1140 || token->name() == basefontTag 1140 || token->name() == basefontTag
1141 || token->name() == bgsoundTag 1141 || token->name() == bgsoundTag
1142 || token->name() == linkTag 1142 || token->name() == linkTag
1143 || token->name() == metaTag 1143 || token->name() == metaTag
1144 || token->name() == noframesTag 1144 || token->name() == noframesTag
1145 || token->name() == scriptTag 1145 || token->name() == scriptTag
1146 || token->name() == styleTag 1146 || token->name() == styleTag
1147 || token->name() == templateTag
1147 || token->name() == titleTag) { 1148 || token->name() == titleTag) {
1148 parseError(token); 1149 parseError(token);
1149 ASSERT(m_tree.head()); 1150 ASSERT(m_tree.head());
1150 m_tree.openElements()->pushHTMLHeadElement(m_tree.headStackItem()); 1151 m_tree.openElements()->pushHTMLHeadElement(m_tree.headStackItem());
1151 processStartTagForInHead(token); 1152 processStartTagForInHead(token);
1152 m_tree.openElements()->removeHTMLHeadElement(m_tree.head()); 1153 m_tree.openElements()->removeHTMLHeadElement(m_tree.head());
1153 return; 1154 return;
1154 } 1155 }
1155 if (token->name() == headTag) { 1156 if (token->name() == headTag) {
1156 parseError(token); 1157 parseError(token);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 } 1598 }
1598 1599
1599 void HTMLTreeBuilder::resetInsertionModeAppropriately() 1600 void HTMLTreeBuilder::resetInsertionModeAppropriately()
1600 { 1601 {
1601 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html# reset-the-insertion-mode-appropriately 1602 // http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html# reset-the-insertion-mode-appropriately
1602 bool last = false; 1603 bool last = false;
1603 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topReco rd(); 1604 HTMLElementStack::ElementRecord* nodeRecord = m_tree.openElements()->topReco rd();
1604 while (1) { 1605 while (1) {
1605 RefPtr<HTMLStackItem> item = nodeRecord->stackItem(); 1606 RefPtr<HTMLStackItem> item = nodeRecord->stackItem();
1606 if (item->node() == m_tree.openElements()->rootNode()) { 1607 if (item->node() == m_tree.openElements()->rootNode()) {
1607 ASSERT(isParsingFragment());
adamk 2013/10/03 21:51:37 So this ASSERT was completely wrong before? Doesn'
rafaelw 2013/10/03 21:55:34 No, it wasn't wrong before. It's just the case tha
1608 last = true; 1608 last = true;
1609 item = HTMLStackItem::create(m_fragmentContext.contextElement(), HTM LStackItem::ItemForContextElement); 1609 if (isParsingFragment())
1610 item = HTMLStackItem::create(m_fragmentContext.contextElement(), HTMLStackItem::ItemForContextElement);
1610 } 1611 }
1611 if (item->hasTagName(templateTag)) 1612 if (item->hasTagName(templateTag))
1612 return setInsertionMode(m_templateInsertionModes.last()); 1613 return setInsertionMode(m_templateInsertionModes.last());
1613 if (item->hasTagName(selectTag)) { 1614 if (item->hasTagName(selectTag)) {
1614 if (!last) { 1615 if (!last) {
1615 while (item->node() != m_tree.openElements()->rootNode() && !ite m->hasTagName(templateTag)) { 1616 while (item->node() != m_tree.openElements()->rootNode() && !ite m->hasTagName(templateTag)) {
1616 nodeRecord = nodeRecord->next(); 1617 nodeRecord = nodeRecord->next();
1617 item = nodeRecord->stackItem(); 1618 item = nodeRecord->stackItem();
1618 if (isHTMLTableElement(item->node())) 1619 if (isHTMLTableElement(item->node()))
1619 return setInsertionMode(InSelectInTableMode); 1620 return setInsertionMode(InSelectInTableMode);
(...skipping 18 matching lines...) Expand all
1638 if (!m_fragmentContext.fragment() || m_fragmentContext.contextElemen t() != item->node()) 1639 if (!m_fragmentContext.fragment() || m_fragmentContext.contextElemen t() != item->node())
1639 return setInsertionMode(InHeadMode); 1640 return setInsertionMode(InHeadMode);
1640 return setInsertionMode(InBodyMode); 1641 return setInsertionMode(InBodyMode);
1641 } 1642 }
1642 if (item->hasTagName(bodyTag)) 1643 if (item->hasTagName(bodyTag))
1643 return setInsertionMode(InBodyMode); 1644 return setInsertionMode(InBodyMode);
1644 if (item->hasTagName(framesetTag)) { 1645 if (item->hasTagName(framesetTag)) {
1645 return setInsertionMode(InFramesetMode); 1646 return setInsertionMode(InFramesetMode);
1646 } 1647 }
1647 if (isHTMLHtmlElement(item->node())) { 1648 if (isHTMLHtmlElement(item->node())) {
1649 if (m_tree.headStackItem())
adamk 2013/10/03 21:51:37 Again, this change doesn't look specific to <templ
rafaelw 2013/10/03 21:55:34 This is what will happen in the case of <head></he
1650 return setInsertionMode(AfterHeadMode);
1651
1648 ASSERT(isParsingFragment()); 1652 ASSERT(isParsingFragment());
1649 return setInsertionMode(BeforeHeadMode); 1653 return setInsertionMode(BeforeHeadMode);
1650 } 1654 }
1651 if (last) { 1655 if (last) {
1652 ASSERT(isParsingFragment()); 1656 ASSERT(isParsingFragment());
1653 return setInsertionMode(InBodyMode); 1657 return setInsertionMode(InBodyMode);
1654 } 1658 }
1655 nodeRecord = nodeRecord->next(); 1659 nodeRecord = nodeRecord->next();
1656 } 1660 }
1657 } 1661 }
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
2819 ASSERT(m_isAttached); 2823 ASSERT(m_isAttached);
2820 // Warning, this may detach the parser. Do not do anything else after this. 2824 // Warning, this may detach the parser. Do not do anything else after this.
2821 m_tree.finishedParsing(); 2825 m_tree.finishedParsing();
2822 } 2826 }
2823 2827
2824 void HTMLTreeBuilder::parseError(AtomicHTMLToken*) 2828 void HTMLTreeBuilder::parseError(AtomicHTMLToken*)
2825 { 2829 {
2826 } 2830 }
2827 2831
2828 } 2832 }
OLDNEW
« no previous file with comments | « LayoutTests/html5lib/resources/template.dat ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698