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

Unified Diff: Source/core/xml/XMLSerializer.cpp

Issue 534583002: Implemented XMLSerializer in PrivateScript. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed backdoors added to Document. Created 6 years, 3 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
Index: Source/core/xml/XMLSerializer.cpp
diff --git a/Source/core/xml/XMLSerializer.cpp b/Source/core/xml/XMLSerializer.cpp
index b39aa329b9da424bc0c871a5dec4f04912158a10..b00028fb84ec56b1f93f8506fd30b1dcbc5924ee 100644
--- a/Source/core/xml/XMLSerializer.cpp
+++ b/Source/core/xml/XMLSerializer.cpp
@@ -22,9 +22,10 @@
#include "core/xml/XMLSerializer.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/V8XMLSerializer.h"
+#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
-#include "core/editing/MarkupAccumulator.h"
-#include "wtf/text/WTFString.h"
+#include "wtf/text/StringBuilder.h"
namespace blink {
@@ -35,8 +36,25 @@ String XMLSerializer::serializeToString(Node* node, ExceptionState& exceptionSta
return String();
}
- MarkupAccumulator accumulator(0, DoNotResolveURLs, nullptr, ForcedXML);
- return accumulator.serializeNodes(*node, IncludeNode);
+ String result;
+ String xmlDeclaration;
+ if (node->document().hasXMLDeclaration()) {
+ StringBuilder builder;
+ builder.appendLiteral("<?xml version=\"");
Jens Widell 2014/09/03 10:29:33 IMO it seems a bit odd to serialize an XML declara
tasak 2014/09/03 11:40:46 Firstly I tried to serialize an XML declaration in
+ builder.append(node->document().xmlVersion());
+ builder.append('\"');
+ if (!node->document().xmlEncoding().isEmpty()) {
+ builder.appendLiteral(" encoding=\"");
+ builder.append(node->document().xmlEncoding());
+ builder.append('\"');
+ }
+ if (node->document().xmlStandaloneStatus() != Document::StandaloneUnspecified)
+ builder.append(String::format(" standalone=\"%s\"", node->document().xmlStandalone() ? "yes" : "no"));
+ builder.append("?>");
+ xmlDeclaration = builder.toString();
+ }
+ V8XMLSerializer::PrivateScript::serializeToStringInternalMethod(m_document->frame(), this, node, xmlDeclaration, &result);
+ return result;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698