Index: Source/WebCore/dom/Document.cpp |
=================================================================== |
--- Source/WebCore/dom/Document.cpp (revision 88809) |
+++ Source/WebCore/dom/Document.cpp (working copy) |
@@ -1966,11 +1966,21 @@ |
void Document::setBody(PassRefPtr<HTMLElement> newBody, ExceptionCode& ec) |
{ |
- if (!newBody || !documentElement()) { |
+ ec = 0; |
+ |
+ if (!newBody || !documentElement() || !newBody->hasTagName(bodyTag)) { |
ec = HIERARCHY_REQUEST_ERR; |
return; |
} |
+ if (newBody->document() && newBody->document() != this) { |
+ RefPtr<Node> node = importNode(newBody.get(), true, ec); |
+ if (ec) |
+ return; |
+ |
+ newBody = toHTMLElement(node.get()); |
+ } |
+ |
HTMLElement* b = body(); |
if (!b) |
documentElement()->appendChild(newBody, ec); |