| Index: Source/WebCore/dom/Document.cpp
|
| ===================================================================
|
| --- Source/WebCore/dom/Document.cpp (revision 88810)
|
| +++ Source/WebCore/dom/Document.cpp (working copy)
|
| @@ -2031,11 +2031,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);
|
|
|