Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index bc0bd807493829928565217fc62f1ede6f0538db..00229a3f3b7501ad34aa123a2e588fe756e94ca6 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -3089,11 +3089,29 @@ 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()); |
+ setEncoding(other.encoding()); |
+ setContextFeatures(other.contextFeatures()); |
+ setSecurityOrigin(other.securityOrigin()); |
abarth-chromium
2013/08/30 06:56:42
Shouldn't this be a copy of the security origin?
|
} |
StyleSheetList* Document::styleSheets() |