Bug 1276438 part 1. Move the implementation of the .body getter from nsHTMLDocument to nsIDocument. r=mystor

MozReview-Commit-ID: BhQuGS1NdmQ
This commit is contained in:
Boris Zbarsky 2018-01-25 06:55:47 -05:00
Родитель fba82e4ebc
Коммит 672340ede6
4 изменённых файлов: 25 добавлений и 21 удалений

Просмотреть файл

@ -6800,6 +6800,26 @@ nsIDocument::GetHtmlChildElement(nsAtom* aTag)
return nullptr;
}
nsGenericHTMLElement*
nsIDocument::GetBody()
{
Element* html = GetHtmlElement();
if (!html) {
return nullptr;
}
for (nsIContent* child = html->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->IsHTMLElement(nsGkAtoms::body) ||
child->IsHTMLElement(nsGkAtoms::frameset)) {
return static_cast<nsGenericHTMLElement*>(child);
}
}
return nullptr;
}
Element*
nsDocument::GetTitleElement()
{

Просмотреть файл

@ -68,6 +68,7 @@ class nsGlobalWindowInner;
class nsHTMLCSSStyleSheet;
class nsHTMLDocument;
class nsHTMLStyleSheet;
class nsGenericHTMLElement;
class nsAtom;
class nsIBFCacheEntry;
class nsIChannel;
@ -1275,6 +1276,9 @@ public:
Element* GetHeadElement() {
return GetHtmlChildElement(nsGkAtoms::head);
}
// Get the "body" in the sense of document.body: The first <body> or
// <frameset> that's a child of a root <html>
nsGenericHTMLElement* GetBody();
/**
* Accessors to the collection of stylesheets owned by this document.

Просмотреть файл

@ -1076,26 +1076,6 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv)
rv = NodePrincipal()->SetDomain(newURI);
}
nsGenericHTMLElement*
nsHTMLDocument::GetBody()
{
Element* html = GetHtmlElement();
if (!html) {
return nullptr;
}
for (nsIContent* child = html->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (child->IsHTMLElement(nsGkAtoms::body) ||
child->IsHTMLElement(nsGkAtoms::frameset)) {
return static_cast<nsGenericHTMLElement*>(child);
}
}
return nullptr;
}
NS_IMETHODIMP
nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody)
{

Просмотреть файл

@ -172,7 +172,7 @@ public:
JS::MutableHandle<JSObject*> aRetval,
mozilla::ErrorResult& rv);
void GetSupportedNames(nsTArray<nsString>& aNames);
nsGenericHTMLElement *GetBody();
using nsIDocument::GetBody;
void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv);
mozilla::dom::HTMLSharedElement *GetHead() {
return static_cast<mozilla::dom::HTMLSharedElement*>(GetHeadElement());