Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index 3a9216003d3c4c679c0e648ce5703314be7db56b..3a37618ee68bc1ad58126b20aa223970df8009e4 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -3090,11 +3090,30 @@ bool Document::canReplaceChild(Node* newChild, Node* oldChild) |
return true; |
} |
-PassRefPtr<Node> Document::cloneNode(bool /*deep*/) |
+PassRefPtr<Node> Document::cloneNode(bool deep) |
{ |
- // Spec says cloning Document nodes is "implementation dependent" |
- // so we do not support it... |
- return 0; |
+ RefPtr<Document> clone = cloneDocumentWithoutChildren(); |
+ clone->cloneDataFromDocument(*this); |
+ if (deep) |
+ cloneChildNodes(clone.get()); |
+ return clone.release(); |
+} |
+ |
+PassRefPtr<Document> Document::cloneDocumentWithoutChildren() |
+{ |
+ DocumentInit init(url()); |
+ if (isXHTMLDocument()) |
+ return createXHTML(init.withRegistrationContext(registrationContext())); |
+ return create(init); |
+} |
+ |
+void Document::cloneDataFromDocument(const Document& other) |
+{ |
+ setCompatibilityMode(other.compatibilityMode()); |
+ setSecurityOrigin(other.securityOrigin()); |
abarth-chromium
2013/08/26 21:04:55
You should make a copy of the security origin. Th
|
+ setContextFeatures(other.contextFeatures()); |
+ |
+ setDecoder(TextResourceDecoder::create(other.suggestedMIMEType(), other.encoding())); |
abarth-chromium
2013/08/26 21:04:55
This doesn't make a lot of sense... There is no t
jamesr
2013/08/26 21:07:51
Have you tested that the exposed encoding on the n
|
} |
StyleSheetList* Document::styleSheets() |