Bug 1276438 part 2. Move the implementation of the .body setter from nsHTMLDocument to nsIDocument.

Tag UXP Issue #1344
Tag UXP Issue #252
This commit is contained in:
Gaming4JC 2020-01-01 15:04:58 -05:00 committed by Roy Tam
commit c939244e89
4 changed files with 28 additions and 26 deletions

View file

@ -1034,31 +1034,6 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
return rv.StealNSResult();
}
void
nsHTMLDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv)
{
nsCOMPtr<Element> root = GetRootElement();
// The body element must be either a body tag or a frameset tag. And we must
// have a html root tag, otherwise GetBody will not return the newly set
// body.
if (!newBody ||
!newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) ||
!root || !root->IsHTMLElement() ||
!root->IsHTMLElement(nsGkAtoms::html)) {
rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
return;
}
// Use DOM methods so that we pass through the appropriate security checks.
nsCOMPtr<Element> currentBody = GetBodyElement();
if (currentBody) {
root->ReplaceChild(*newBody, *currentBody, rv);
} else {
root->AppendChild(*newBody, rv);
}
}
NS_IMETHODIMP
nsHTMLDocument::GetHead(nsIDOMHTMLHeadElement** aHead)
{