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

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

Issue 184633007: Don't emit a default namespace declaration if it's already the default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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') | no next file » | 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 8be6e8a1722c1264be70af5c7f672e29f3ff3306..aa51c289575fe82984bc3d0192d43899c1159781 100644
--- a/Source/core/editing/MarkupAccumulator.cpp
+++ b/Source/core/editing/MarkupAccumulator.cpp
@@ -222,12 +222,17 @@ void MarkupAccumulator::appendQuotedURLAttributeValue(StringBuilder& result, con
result.append(quoteChar);
}
-bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element)
+bool MarkupAccumulator::shouldAddNamespaceElement(const Element& element, Namespaces& namespaces)
{
// Don't add namespace attribute if it is already defined for this elem.
const AtomicString& prefix = element.prefix();
- if (prefix.isEmpty())
- return !element.hasAttribute(xmlnsAtom);
+ if (prefix.isEmpty()) {
+ if (element.hasAttribute(xmlnsAtom)) {
+ namespaces.set(emptyAtom.impl(), element.namespaceURI().impl());
+ return false;
+ }
+ return true;
+ }
DEFINE_STATIC_LOCAL(String, xmlnsWithColon, ("xmlns:"));
return !element.hasAttribute(xmlnsWithColon + prefix);
@@ -399,7 +404,7 @@ void MarkupAccumulator::appendOpenTag(StringBuilder& result, const Element& elem
{
result.append('<');
result.append(nodeNamePreservingCase(element));
- if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespaceElement(element))
+ if (!element.document().isHTMLDocument() && namespaces && shouldAddNamespaceElement(element, *namespaces))
appendNamespace(result, element.prefix(), element.namespaceURI(), *namespaces);
}
« no previous file with comments | « Source/core/editing/MarkupAccumulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698