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

Unified Diff: Source/core/html/parser/HTMLTreeBuilder.cpp

Issue 52443003: Reland 160869 "Move innerHTML and outerHTML to Element" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/parser/HTMLTreeBuilder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLTreeBuilder.cpp
diff --git a/Source/core/html/parser/HTMLTreeBuilder.cpp b/Source/core/html/parser/HTMLTreeBuilder.cpp
index 4caa70c1562c17a8bbe5f2ed4290b75bdc9ad1ba..f419b65ae001cf190ff2e9431402cd2c25a8af32 100644
--- a/Source/core/html/parser/HTMLTreeBuilder.cpp
+++ b/Source/core/html/parser/HTMLTreeBuilder.cpp
@@ -375,10 +375,13 @@ void HTMLTreeBuilder::constructTree(AtomicHTMLToken* token)
processToken(token);
if (m_parser->tokenizer()) {
- bool inForeignContent = !m_tree.isEmpty()
- && !m_tree.currentStackItem()->isInHTMLNamespace()
- && !HTMLElementStack::isHTMLIntegrationPoint(m_tree.currentStackItem())
- && !HTMLElementStack::isMathMLTextIntegrationPoint(m_tree.currentStackItem());
+ bool inForeignContent = false;
+ if (!m_tree.isEmpty()) {
+ RefPtr<HTMLStackItem> adjustedCurrentNode = adjustedCurrentStackItem();
+ inForeignContent = !adjustedCurrentNode->isInHTMLNamespace()
+ && !HTMLElementStack::isHTMLIntegrationPoint(adjustedCurrentNode.get())
+ && !HTMLElementStack::isMathMLTextIntegrationPoint(adjustedCurrentNode.get());
+ }
m_parser->tokenizer()->setForceNullCharacterReplacement(m_insertionMode == TextMode || inForeignContent);
m_parser->tokenizer()->setShouldAllowCDATA(inForeignContent);
@@ -995,6 +998,16 @@ bool HTMLTreeBuilder::processColgroupEndTagForInColumnGroup()
return true;
}
+// http://www.whatwg.org/specs/web-apps/current-work/#adjusted-current-node
+PassRefPtr<HTMLStackItem> HTMLTreeBuilder::adjustedCurrentStackItem() const
+{
+ ASSERT(!m_tree.isEmpty());
+ if (isParsingFragment() && m_tree.openElements()->hasOnlyOneElement())
+ return HTMLStackItem::create(m_fragmentContext.contextElement(), HTMLStackItem::ItemForContextElement);
+
+ return m_tree.currentStackItem();
+}
+
// http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#close-the-cell
void HTMLTreeBuilder::closeTheCell()
{
@@ -2675,10 +2688,11 @@ bool HTMLTreeBuilder::shouldProcessTokenInForeignContent(AtomicHTMLToken* token)
{
if (m_tree.isEmpty())
return false;
- HTMLStackItem* item = m_tree.currentStackItem();
- if (item->isInHTMLNamespace())
+ RefPtr<HTMLStackItem> adjustedCurrentNode = adjustedCurrentStackItem();
+
+ if (adjustedCurrentNode->isInHTMLNamespace())
return false;
- if (HTMLElementStack::isMathMLTextIntegrationPoint(item)) {
+ if (HTMLElementStack::isMathMLTextIntegrationPoint(adjustedCurrentNode.get())) {
if (token->type() == HTMLToken::StartTag
&& token->name() != MathMLNames::mglyphTag
&& token->name() != MathMLNames::malignmarkTag)
@@ -2686,11 +2700,11 @@ bool HTMLTreeBuilder::shouldProcessTokenInForeignContent(AtomicHTMLToken* token)
if (token->type() == HTMLToken::Character)
return false;
}
- if (item->hasTagName(MathMLNames::annotation_xmlTag)
+ if (adjustedCurrentNode->hasTagName(MathMLNames::annotation_xmlTag)
&& token->type() == HTMLToken::StartTag
&& token->name() == SVGNames::svgTag)
return false;
- if (HTMLElementStack::isHTMLIntegrationPoint(item)) {
+ if (HTMLElementStack::isHTMLIntegrationPoint(adjustedCurrentNode.get())) {
if (token->type() == HTMLToken::StartTag)
return false;
if (token->type() == HTMLToken::Character)
@@ -2703,6 +2717,8 @@ bool HTMLTreeBuilder::shouldProcessTokenInForeignContent(AtomicHTMLToken* token)
void HTMLTreeBuilder::processTokenInForeignContent(AtomicHTMLToken* token)
{
+ RefPtr<HTMLStackItem> adjustedCurrentNode = adjustedCurrentStackItem();
+
switch (token->type()) {
case HTMLToken::Uninitialized:
ASSERT_NOT_REACHED();
@@ -2756,7 +2772,7 @@ void HTMLTreeBuilder::processTokenInForeignContent(AtomicHTMLToken* token)
processStartTag(token);
return;
}
- const AtomicString& currentNamespace = m_tree.currentStackItem()->namespaceURI();
+ const AtomicString& currentNamespace = adjustedCurrentNode->namespaceURI();
if (currentNamespace == MathMLNames::mathmlNamespaceURI)
adjustMathMLAttributes(token);
if (currentNamespace == SVGNames::svgNamespaceURI) {
@@ -2768,7 +2784,7 @@ void HTMLTreeBuilder::processTokenInForeignContent(AtomicHTMLToken* token)
break;
}
case HTMLToken::EndTag: {
- if (m_tree.currentStackItem()->namespaceURI() == SVGNames::svgNamespaceURI)
+ if (adjustedCurrentNode->namespaceURI() == SVGNames::svgNamespaceURI)
adjustSVGTagNameCase(token);
if (token->name() == SVGNames::scriptTag && m_tree.currentStackItem()->hasTagName(SVGNames::scriptTag)) {
« no previous file with comments | « Source/core/html/parser/HTMLTreeBuilder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698