Index: Source/core/xml/XMLSerializer.cpp |
diff --git a/Source/core/xml/XMLSerializer.cpp b/Source/core/xml/XMLSerializer.cpp |
index b39aa329b9da424bc0c871a5dec4f04912158a10..8226055f810cbd7e95d676316739fc764ed19b9a 100644 |
--- a/Source/core/xml/XMLSerializer.cpp |
+++ b/Source/core/xml/XMLSerializer.cpp |
@@ -22,21 +22,34 @@ |
#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 { |
String XMLSerializer::serializeToString(Node* node, ExceptionState& exceptionState) |
{ |
- if (!node) { |
- exceptionState.throwTypeError("Invalid node value."); |
- return String(); |
+ String result; |
+ String xmlDeclaration; |
+ if (node->document().hasXMLDeclaration()) { |
+ StringBuilder builder; |
+ builder.appendLiteral("<?xml version=\""); |
+ 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(); |
} |
- |
- MarkupAccumulator accumulator(0, DoNotResolveURLs, nullptr, ForcedXML); |
- return accumulator.serializeNodes(*node, IncludeNode); |
+ V8XMLSerializer::PrivateScript::serializeToStringInternalMethod(m_document->frame(), this, node, xmlDeclaration, &result); |
+ return result; |
} |
} // namespace blink |