mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 00:27:29 +09:00
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:
parent
0ef352d74b
commit
c939244e89
4 changed files with 28 additions and 26 deletions
|
|
@ -6556,6 +6556,31 @@ nsIDocument::GetBody()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsIDocument::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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Element*
|
Element*
|
||||||
nsDocument::GetTitleElement()
|
nsDocument::GetTitleElement()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1040,6 +1040,8 @@ public:
|
||||||
// Get the "body" in the sense of document.body: The first <body> or
|
// Get the "body" in the sense of document.body: The first <body> or
|
||||||
// <frameset> that's a child of a root <html>
|
// <frameset> that's a child of a root <html>
|
||||||
nsGenericHTMLElement* GetBody();
|
nsGenericHTMLElement* GetBody();
|
||||||
|
// Set the "body" in the sense of document.body.
|
||||||
|
void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accessors to the collection of stylesheets owned by this document.
|
* Accessors to the collection of stylesheets owned by this document.
|
||||||
|
|
|
||||||
|
|
@ -1034,31 +1034,6 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
|
||||||
return rv.StealNSResult();
|
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
|
NS_IMETHODIMP
|
||||||
nsHTMLDocument::GetHead(nsIDOMHTMLHeadElement** aHead)
|
nsHTMLDocument::GetHead(nsIDOMHTMLHeadElement** aHead)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ public:
|
||||||
mozilla::ErrorResult& rv);
|
mozilla::ErrorResult& rv);
|
||||||
void GetSupportedNames(nsTArray<nsString>& aNames);
|
void GetSupportedNames(nsTArray<nsString>& aNames);
|
||||||
using nsIDocument::GetBody;
|
using nsIDocument::GetBody;
|
||||||
void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv);
|
using nsIDocument::SetBody;
|
||||||
mozilla::dom::HTMLSharedElement *GetHead() {
|
mozilla::dom::HTMLSharedElement *GetHead() {
|
||||||
return static_cast<mozilla::dom::HTMLSharedElement*>(GetHeadElement());
|
return static_cast<mozilla::dom::HTMLSharedElement*>(GetHeadElement());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue