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

Unified Diff: Source/core/editing/MarkupAccumulator.cpp

Issue 426293002: Use tighter typing in editing: MarkupAccumulator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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/editing/MarkupAccumulator.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/MarkupAccumulator.cpp
diff --git a/Source/core/editing/MarkupAccumulator.cpp b/Source/core/editing/MarkupAccumulator.cpp
index ee12e50793c8ae2eeafab5f96e49e20ab5904795..e67e8380a13757a989abfff4a0c470f4abefffd8 100644
--- a/Source/core/editing/MarkupAccumulator.cpp
+++ b/Source/core/editing/MarkupAccumulator.cpp
@@ -145,8 +145,8 @@ void MarkupAccumulator::serializeNodesWithNamespaces(Node& targetNode, EChildren
serializeNodesWithNamespaces(*current, IncludeNode, &namespaceHash, tagNamesToSkip);
}
- if (!childrenOnly)
- appendEndTag(targetNode);
+ if (!childrenOnly && targetNode.isElementNode())
+ appendEndTag(toElement(targetNode));
yosin_UTC9 2014/08/01 02:27:14 Good catch!
}
String MarkupAccumulator::resolveURLIfNeeded(const Element& element, const String& urlString) const
@@ -178,9 +178,9 @@ void MarkupAccumulator::appendStartTag(Node& node, Namespaces* namespaces)
m_nodes->append(&node);
}
-void MarkupAccumulator::appendEndTag(const Node& node)
+void MarkupAccumulator::appendEndTag(const Element& element)
{
- appendEndMarkup(m_markup, node);
+ appendEndMarkup(m_markup, element);
}
size_t MarkupAccumulator::totalLength(const Vector<String>& strings)
@@ -398,15 +398,10 @@ void MarkupAccumulator::appendElement(StringBuilder& result, Element& element, N
appendCloseTag(result, element);
}
-static String nodeNamePreservingCase(const Element& element)
-{
- return element.tagQName().toString();
-}
-
void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& element, Namespaces* namespaces)
{
result.append('<');
- result.append(nodeNamePreservingCase(element));
+ result.append(element.tagQName().toString());
if (!serializeAsHTMLDocument(element) && namespaces && shouldAddNamespaceElement(element, *namespaces))
appendNamespace(result, element.prefix(), element.namespaceURI(), *namespaces);
}
@@ -527,13 +522,13 @@ void MarkupAccumulator::appendStartMarkup(StringBuilder& result, Node& node, Nam
// 2. Elements w/ children never self-close because they use a separate end tag.
// 3. HTML elements which do not have a "forbidden" end tag will close with a separate end tag.
// 4. Other elements self-close.
-bool MarkupAccumulator::shouldSelfClose(const Node& node)
+bool MarkupAccumulator::shouldSelfClose(const Element& element)
{
- if (serializeAsHTMLDocument(node))
+ if (serializeAsHTMLDocument(element))
return false;
- if (node.hasChildren())
+ if (element.hasChildren())
return false;
- if (node.isHTMLElement() && !elementCannotHaveEndTag(node))
+ if (element.isHTMLElement() && !elementCannotHaveEndTag(element))
return false;
return true;
}
@@ -550,13 +545,13 @@ bool MarkupAccumulator::elementCannotHaveEndTag(const Node& node)
return toHTMLElement(node).ieForbidsInsertHTML();
}
-void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Node& node)
+void MarkupAccumulator::appendEndMarkup(StringBuilder& result, const Element& element)
{
- if (!node.isElementNode() || shouldSelfClose(node) || (!node.hasChildren() && elementCannotHaveEndTag(node)))
+ if (shouldSelfClose(element) || (!element.hasChildren() && elementCannotHaveEndTag(element)))
return;
result.appendLiteral("</");
- result.append(nodeNamePreservingCase(toElement(node)));
+ result.append(element.tagQName().toString());
result.append('>');
}
« no previous file with comments | « Source/core/editing/MarkupAccumulator.h ('k') | Source/core/editing/markup.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698