Bug 562688 part 4. Change GetRootContent and the like to return Elements. r=jst, sr=sicking

This commit is contained in:
Boris Zbarsky 2010-04-30 09:12:05 -04:00
Родитель bfdfa8fe7a
Коммит 9c2ad4b2aa
53 изменённых файлов: 323 добавлений и 270 удалений

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

@ -76,6 +76,8 @@
#include "nsIDOMNSEventTarget.h"
#include "nsIDOMDocumentEvent.h"
#include "nsFocusManager.h"
#include "Element.h"
#ifdef MOZ_XUL
#include "nsXULTreeAccessible.h"
@ -83,6 +85,8 @@
#include "nsIXULWindow.h"
#endif
using namespace mozilla::dom;
////////////////////////////////////////////////////////////////////////////////
// nsISupports
@ -143,9 +147,9 @@ nsRootAccessible::GetRoleInternal(PRUint32 *aRole)
}
// If it's a <dialog> or <wizard>, use nsIAccessibleRole::ROLE_DIALOG instead
nsIContent *rootContent = mDocument->GetRootContent();
if (rootContent) {
nsCOMPtr<nsIDOMElement> rootElement(do_QueryInterface(rootContent));
Element *root = mDocument->GetRootElement();
if (root) {
nsCOMPtr<nsIDOMElement> rootElement(do_QueryInterface(root));
if (rootElement) {
nsAutoString name;
rootElement->GetLocalName(name);

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

@ -111,6 +111,7 @@ class Loader;
namespace dom {
class Link;
class Element;
} // namespace dom
} // namespace mozilla
@ -470,32 +471,34 @@ public:
virtual nsIContent *FindContentForSubDocument(nsIDocument *aDocument) const = 0;
/**
* Return the root content object for this document.
* Return the root element for this document.
*/
nsIContent *GetRootContent() const
mozilla::dom::Element *GetRootElement() const
{
return (mCachedRootContent &&
mCachedRootContent->GetNodeParent() == this) ?
reinterpret_cast<nsIContent*>(mCachedRootContent.get()) :
GetRootContentInternal();
return (mCachedRootElement &&
mCachedRootElement->GetNodeParent() == this) ?
reinterpret_cast<mozilla::dom::Element*>(mCachedRootElement.get()) :
GetRootElementInternal();
}
virtual nsIContent *GetRootContentInternal() const = 0;
protected:
virtual mozilla::dom::Element *GetRootElementInternal() const = 0;
public:
// Get the root <html> element, or return null if there isn't one (e.g.
// if the root isn't <html>)
nsIContent* GetHtmlContent();
mozilla::dom::Element* GetHtmlElement();
// Returns the first child of GetHtmlContent which has the given tag,
// or nsnull if that doesn't exist.
nsIContent* GetHtmlChildContent(nsIAtom* aTag);
mozilla::dom::Element* GetHtmlChildElement(nsIAtom* aTag);
// Get the canonical <body> element, or return null if there isn't one (e.g.
// if the root isn't <html> or if the <body> isn't there)
nsIContent* GetBodyContent() {
return GetHtmlChildContent(nsGkAtoms::body);
mozilla::dom::Element* GetBodyElement() {
return GetHtmlChildElement(nsGkAtoms::body);
}
// Get the canonical <head> element, or return null if there isn't one (e.g.
// if the root isn't <html> or if the <head> isn't there)
nsIContent* GetHeadContent() {
return GetHtmlChildContent(nsGkAtoms::head);
mozilla::dom::Element* GetHeadElement() {
return GetHtmlChildElement(nsGkAtoms::head);
}
/**
@ -1379,10 +1382,10 @@ protected:
// This is just a weak pointer; the parent document owns its children.
nsIDocument* mParentDocument;
// A reference to the content last returned from GetRootContent().
// This should be an nsIContent, but that would force us to pull in
// nsIContent.h
nsCOMPtr<nsINode> mCachedRootContent;
// A reference to the element last returned from GetRootElement().
// This should be an Element, but that would force us to pull in
// Element.h and therefore nsIContent.h.
nsCOMPtr<nsINode> mCachedRootElement;
// We'd like these to be nsRefPtrs, but that'd require us to include
// additional headers that we don't want to expose.

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

@ -469,7 +469,7 @@ public:
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
* than one element node as a child of a document. Doing this will also
* assert -- you shouldn't be doing it! Check with
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
* one constraint, this doesn't do any checking on whether aKid is a valid
* child of |this|.
*
@ -490,7 +490,7 @@ public:
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
* than one element node as a child of a document. Doing this will also
* assert -- you shouldn't be doing it! Check with
* nsIDocument::GetRootContent() first if you're not sure. Apart from this
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
* one constraint, this doesn't do any checking on whether aKid is a valid
* child of |this|.
*

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

@ -1018,7 +1018,7 @@ nsContentList::AssertInSync()
// elements that are outside of the document element.
nsIContent *root;
if (mRootNode->IsNodeOfType(nsINode::eDOCUMENT)) {
root = static_cast<nsIDocument*>(mRootNode)->GetRootContent();
root = static_cast<nsIDocument*>(mRootNode)->GetRootElement();
}
else {
root = static_cast<nsIContent*>(mRootNode);

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

@ -1096,7 +1096,7 @@ void
nsContentSink::ProcessOfflineManifest(nsIContent *aElement)
{
// Only check the manifest for root document nodes.
if (aElement != mDocument->GetRootContent()) {
if (aElement != mDocument->GetRootElement()) {
return;
}

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

@ -61,6 +61,7 @@
#include "nsIContentUtils.h"
#include "nsIXPConnect.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDocument.h"
#include "nsINodeInfo.h"
#include "nsReadableUtils.h"
@ -193,6 +194,8 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_XTFSERVICE_CID);
#include "jsregexp.h"
#include "jstypedarray.h"
using namespace mozilla::dom;
const char kLoadAsData[] = "loadAsData";
static const char kJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1";
@ -887,7 +890,7 @@ nsContentUtils::IsHTMLWhitespace(PRUnichar aChar)
void
nsContentUtils::GetOfflineAppManifest(nsIDocument *aDocument, nsIURI **aURI)
{
nsCOMPtr<nsIContent> docElement = aDocument->GetRootContent();
Element* docElement = aDocument->GetRootElement();
if (!docElement) {
return;
}
@ -1186,7 +1189,7 @@ nsContentUtils::InProlog(nsINode *aNode)
}
nsIDocument* doc = static_cast<nsIDocument*>(parent);
nsIContent* root = doc->GetRootContent();
nsIContent* root = doc->GetRootElement();
return !root || doc->IndexOf(aNode) < doc->IndexOf(root);
}

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

@ -682,7 +682,7 @@ nsCopySupport::FireClipboardEvent(PRInt32 aType, nsIPresShell* aPresShell, nsISe
// if no content node was set, just get the root
if (!content) {
content = doc->GetRootContent();
content = doc->GetRootElement();
if (!content)
return PR_FALSE;
}

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

@ -1458,7 +1458,7 @@ nsDocument::~nsDocument()
mChildren.ChildAt(indx)->UnbindFromTree();
mChildren.RemoveChildAt(indx);
}
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
// Let the stylesheets know we're going away
indx = mStyleSheets.Count();
@ -1648,7 +1648,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_USERDATA
// Traverse all nsIDocument pointer members.
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedRootContent)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mCachedRootElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mNodeInfoManager,
nsNodeInfoManager)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSecurityInfo)
@ -1715,7 +1715,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
tmp->mChildren.RemoveChildAt(indx);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootContent)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mCachedRootElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDisplayDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mFirstBaseNodeWithHref)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDOMImplementation)
@ -1903,7 +1903,7 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
content->UnbindFromTree();
}
}
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
// Reset our stylesheets
ResetStylesheetsToURI(aURI);
@ -2941,7 +2941,7 @@ void
nsDocument::GetBaseTarget(nsAString &aBaseTarget)
{
aBaseTarget.Truncate();
nsIContent* head = GetHeadContent();
Element* head = GetHeadElement();
if (!head) {
return;
}
@ -3060,7 +3060,7 @@ nsDocument::SetHeaderData(nsIAtom* aHeaderField, const nsAString& aData)
// Set the default script-type on the root element.
if (aHeaderField == nsGkAtoms::headerContentScriptType) {
nsIContent *root = GetRootContent();
Element *root = GetRootElement();
if (root) {
// Get the script-type ID for this value.
nsresult rv;
@ -3329,21 +3329,21 @@ nsDocument::IsNodeOfType(PRUint32 aFlags) const
return !(aFlags & ~eDOCUMENT);
}
nsIContent*
nsDocument::GetRootContentInternal() const
Element*
nsDocument::GetRootElementInternal() const
{
// Loop backwards because any non-elements, such as doctypes and PIs
// are likely to appear before the root element.
PRUint32 i;
for (i = mChildren.ChildCount(); i > 0; --i) {
nsIContent* child = mChildren.ChildAt(i - 1);
if (child->IsNodeOfType(nsINode::eELEMENT)) {
const_cast<nsDocument*>(this)->mCachedRootContent = child;
return child;
if (child->IsElement()) {
const_cast<nsDocument*>(this)->mCachedRootElement = child;
return child->AsElement();
}
}
const_cast<nsDocument*>(this)->mCachedRootContent = nsnull;
const_cast<nsDocument*>(this)->mCachedRootElement = nsnull;
return nsnull;
}
@ -3376,8 +3376,7 @@ nsresult
nsDocument::InsertChildAt(nsIContent* aKid, PRUint32 aIndex,
PRBool aNotify)
{
if (aKid->IsNodeOfType(nsINode::eELEMENT) &&
GetRootContent()) {
if (aKid->IsElement() && GetRootElement()) {
NS_ERROR("Inserting element child when we already have one");
return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
}
@ -3414,7 +3413,7 @@ nsDocument::RemoveChildAt(PRUint32 aIndex, PRBool aNotify, PRBool aMutationEvent
nsresult rv = nsGenericElement::doRemoveChildAt(aIndex, aNotify, oldKid,
nsnull, this, mChildren,
aMutationEvent);
mCachedRootContent = nsnull;
mCachedRootElement = nsnull;
return rv;
}
@ -4127,7 +4126,7 @@ nsDocument::DispatchContentLoadedEvents()
// If the document has a manifest attribute, fire a MozApplicationManifest
// event.
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root && root->HasAttr(kNameSpaceID_None, nsGkAtoms::manifest)) {
nsContentUtils::DispatchChromeEvent(this, static_cast<nsIDocument*>(this),
NS_LITERAL_STRING("MozApplicationManifest"),
@ -4254,7 +4253,7 @@ nsDocument::GetDocumentElement(nsIDOMElement** aDocumentElement)
{
NS_ENSURE_ARG_POINTER(aDocumentElement);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root) {
return CallQueryInterface(root, aDocumentElement);
}
@ -5013,20 +5012,20 @@ nsDocument::GetLocation(nsIDOMLocation **_retval)
return w->GetLocation(_retval);
}
nsIContent*
nsIDocument::GetHtmlContent()
Element*
nsIDocument::GetHtmlElement()
{
nsIContent* rootContent = GetRootContent();
if (rootContent && rootContent->Tag() == nsGkAtoms::html &&
rootContent->IsHTML())
return rootContent;
Element* rootElement = GetRootElement();
if (rootElement && rootElement->Tag() == nsGkAtoms::html &&
rootElement->IsHTML())
return rootElement;
return nsnull;
}
nsIContent*
nsIDocument::GetHtmlChildContent(nsIAtom* aTag)
Element*
nsIDocument::GetHtmlChildElement(nsIAtom* aTag)
{
nsIContent* html = GetHtmlContent();
Element* html = GetHtmlElement();
if (!html)
return nsnull;
@ -5035,7 +5034,7 @@ nsIDocument::GetHtmlChildContent(nsIAtom* aTag)
for (PRUint32 i = 0; i < html->GetChildCount(); ++i) {
nsIContent* result = html->GetChildAt(i);
if (result->Tag() == aTag && result->IsHTML())
return result;
return result->AsElement();
}
return nsnull;
}
@ -5073,21 +5072,21 @@ nsDocument::GetTitle(nsAString& aTitle)
{
aTitle.Truncate();
nsIContent *rootContent = GetRootContent();
if (!rootContent)
nsIContent *rootElement = GetRootElement();
if (!rootElement)
return NS_OK;
nsAutoString tmp;
switch (rootContent->GetNameSpaceID()) {
switch (rootElement->GetNameSpaceID()) {
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
rootContent->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
rootElement->GetAttr(kNameSpaceID_None, nsGkAtoms::title, tmp);
break;
#endif
#ifdef MOZ_SVG
case kNameSpaceID_SVG:
if (rootContent->Tag() == nsGkAtoms::svg) {
if (rootElement->Tag() == nsGkAtoms::svg) {
GetTitleFromElement(kNameSpaceID_SVG, tmp);
break;
} // else fall through
@ -5105,18 +5104,18 @@ nsDocument::GetTitle(nsAString& aTitle)
NS_IMETHODIMP
nsDocument::SetTitle(const nsAString& aTitle)
{
nsIContent *rootContent = GetRootContent();
if (!rootContent)
Element *rootElement = GetRootElement();
if (!rootElement)
return NS_OK;
switch (rootContent->GetNameSpaceID()) {
switch (rootElement->GetNameSpaceID()) {
#ifdef MOZ_SVG
case kNameSpaceID_SVG:
return NS_OK; // SVG doesn't support setting a title
#endif
#ifdef MOZ_XUL
case kNameSpaceID_XUL:
return rootContent->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
return rootElement->SetAttr(kNameSpaceID_None, nsGkAtoms::title,
aTitle, PR_TRUE);
#endif
}
@ -5127,7 +5126,7 @@ nsDocument::SetTitle(const nsAString& aTitle)
nsIContent* title = GetTitleContent(kNameSpaceID_XHTML);
if (!title) {
nsIContent *head = GetHeadContent();
Element *head = GetHeadElement();
if (!head)
return NS_OK;
@ -5849,7 +5848,7 @@ NS_IMETHODIMP
nsDocument::LookupPrefix(const nsAString& aNamespaceURI,
nsAString& aPrefix)
{
nsCOMPtr<nsIDOM3Node> root(do_QueryInterface(GetRootContent()));
nsCOMPtr<nsIDOM3Node> root(do_QueryInterface(GetRootElement()));
if (root) {
return root->LookupPrefix(aNamespaceURI, aPrefix);
}
@ -5862,7 +5861,7 @@ NS_IMETHODIMP
nsDocument::LookupNamespaceURI(const nsAString& aNamespacePrefix,
nsAString& aNamespaceURI)
{
if (NS_FAILED(nsContentUtils::LookupNamespaceURI(GetRootContent(),
if (NS_FAILED(nsContentUtils::LookupNamespaceURI(GetRootElement(),
aNamespacePrefix,
aNamespaceURI))) {
SetDOMStringToNull(aNamespaceURI);
@ -7369,7 +7368,7 @@ nsDocument::OnPageShow(PRBool aPersisted,
EnumerateFreezableElements(NotifyActivityChanged, nsnull);
EnumerateExternalResources(NotifyPageShow, &aPersisted);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (aPersisted && root) {
// Send out notifications that our <link> elements are attached.
nsRefPtr<nsContentList> links = NS_GetContentList(root,
@ -7419,7 +7418,7 @@ nsDocument::OnPageHide(PRBool aPersisted,
{
// Send out notifications that our <link> elements are detached,
// but only if this is not a full unload.
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (aPersisted && root) {
nsRefPtr<nsContentList> links = NS_GetContentList(root,
nsGkAtoms::link,

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

@ -589,7 +589,7 @@ public:
nsIDocument* aSubDoc);
virtual nsIDocument* GetSubDocumentFor(nsIContent *aContent) const;
virtual nsIContent* FindContentForSubDocument(nsIDocument *aDocument) const;
virtual nsIContent* GetRootContentInternal() const;
virtual mozilla::dom::Element* GetRootElementInternal() const;
/**
* Get the style sheets owned by this document.

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

@ -158,19 +158,7 @@
#include "nsSVGFeatures.h"
#endif /* MOZ_SVG */
#ifdef DEBUG_waterson
/**
* List a content tree to stdout. Meant to be called from gdb.
*/
void
DebugListContentTree(nsIContent* aElement)
{
aElement->List(stdout, 0);
printf("\n");
}
#endif
using namespace mozilla::dom;
NS_DEFINE_IID(kThisPtrOffsetsSID, NS_THISPTROFFSETS_SID);
@ -391,7 +379,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
NS_ENSURE_TRUE(aPresShell, nsnull);
if (IsNodeOfType(eDOCUMENT))
return static_cast<nsIDocument*>(this)->GetRootContent();
return static_cast<nsIDocument*>(this)->GetRootElement();
if (!IsNodeOfType(eCONTENT))
return nsnull;
@ -440,7 +428,7 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell)
if (!content) {
nsIDocument* doc = aPresShell->GetDocument();
NS_ENSURE_TRUE(doc, nsnull);
content = doc->GetRootContent();
content = doc->GetRootElement();
if (!content)
return nsnull;
}
@ -1272,8 +1260,8 @@ nsNSElementTearoff::GetScrollFrame(nsIFrame **aStyledFrame)
nsIDocument* doc = mContent->GetOwnerDoc();
PRBool quirksMode = doc->GetCompatibilityMode() == eCompatibility_NavQuirks;
nsIContent* elementWithRootScrollInfo =
quirksMode ? doc->GetBodyContent() : doc->GetRootContent();
Element* elementWithRootScrollInfo =
quirksMode ? doc->GetBodyElement() : doc->GetRootElement();
if (mContent == elementWithRootScrollInfo) {
// In quirks mode, the scroll info for the body element should map to the
// root scrollable frame.
@ -3623,12 +3611,12 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
return PR_TRUE;
}
nsIContent* rootContent =
static_cast<nsIDocument*>(aParent)->GetRootContent();
if (rootContent) {
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
if (rootElement) {
// Already have a documentElement, so this is only OK if we're
// replacing it.
return aIsReplace && rootContent == aRefContent;
return aIsReplace && rootElement == aRefContent;
}
// We don't have a documentElement yet. Our one remaining constraint is
@ -3678,9 +3666,9 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
// We don't have a doctype yet. Our one remaining constraint is
// that the doctype must come before the documentElement.
nsIContent* rootContent =
static_cast<nsIDocument*>(aParent)->GetRootContent();
if (!rootContent) {
Element* rootElement =
static_cast<nsIDocument*>(aParent)->GetRootElement();
if (!rootElement) {
// It's all good
return PR_TRUE;
}
@ -3690,12 +3678,12 @@ PRBool IsAllowedAsChild(nsIContent* aNewChild, PRUint16 aNewNodeType,
return PR_FALSE;
}
PRInt32 rootIndex = aParent->IndexOf(rootContent);
PRInt32 rootIndex = aParent->IndexOf(rootElement);
PRInt32 insertIndex = aParent->IndexOf(aRefContent);
// Now we're OK if and only if insertIndex <= rootIndex. Indeed, either
// we end up replacing aRefContent or we end up before it. Either one is
// ok as long as aRefContent is not after rootContent.
// ok as long as aRefContent is not after rootElement.
return insertIndex <= rootIndex;
}
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :

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

@ -48,6 +48,7 @@
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeDecoder.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsGkAtoms.h"
#include "nsNetUtil.h"
#include "nsIScriptGlobalObject.h"
@ -79,6 +80,7 @@
static PRLogModuleInfo* gCspPRLog;
#endif
using namespace mozilla::dom;
//////////////////////////////////////////////////////////////
// Per-request data structure
@ -384,11 +386,11 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement)
return NS_ERROR_NOT_AVAILABLE;
}
// Default script language is whatever the root content specifies
// Default script language is whatever the root element specifies
// (which may come from a header or http-meta tag), or if there
// is no root content, from the script global object.
nsCOMPtr<nsIContent> rootContent = mDocument->GetRootContent();
PRUint32 typeID = rootContent ? rootContent->GetScriptTypeID() :
// is no root element, from the script global object.
Element* rootElement = mDocument->GetRootElement();
PRUint32 typeID = rootElement ? rootElement->GetScriptTypeID() :
context->GetScriptTypeID();
PRUint32 version = 0;
nsAutoString language, type, src;

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

@ -266,7 +266,7 @@ nsSyncLoader::LoadDocument(nsIChannel* aChannel,
NS_ENSURE_TRUE(mLoadSuccess, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(document->GetRootContent(), NS_ERROR_FAILURE);
NS_ENSURE_TRUE(document->GetRootElement(), NS_ERROR_FAILURE);
return CallQueryInterface(document, aResult);
}

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

@ -66,6 +66,7 @@
#include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIFrame.h"
#include "nsIView.h"
#include "nsIViewManager.h"
@ -96,6 +97,8 @@
#include "nsDOMEvent.h"
#include "nsIContentSecurityPolicy.h"
using namespace mozilla::dom;
#define EVENT_TYPE_EQUALS( ls, type, userType ) \
(ls->mEventType && ls->mEventType == type && \
(ls->mEventType != NS_USER_DEFINED_EVENT || ls->mTypeAtom == userType))
@ -778,7 +781,7 @@ nsEventListenerManager::AddScriptEventListener(nsISupports *aObject,
nameSpace = content->GetNameSpaceID();
}
else if (doc) {
nsCOMPtr<nsIContent> root = doc->GetRootContent();
Element* root = doc->GetRootElement();
if (root)
nameSpace = root->GetNameSpaceID();
}

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

@ -2760,7 +2760,7 @@ nsEventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// designMode. In designMode, all contents are not focusable.
if (newFocus && !newFocus->IsEditable()) {
nsIDocument *doc = newFocus->GetCurrentDoc();
if (doc && newFocus == doc->GetRootContent()) {
if (doc && newFocus == doc->GetRootElement()) {
nsIContent *bodyContent =
nsLayoutUtils::GetEditableRootContentByContentEditable(doc);
if (bodyContent) {
@ -3616,7 +3616,7 @@ nsEventStateManager::GenerateMouseEnterExit(nsGUIEvent* aEvent)
// We're always over the document root, even if we're only
// over dead space in a page (whose frame is not associated with
// any content) or in print preview dead space
targetElement = mDocument->GetRootContent();
targetElement = mDocument->GetRootElement();
}
if (targetElement) {
NotifyMouseOver(aEvent, targetElement);

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

@ -452,7 +452,7 @@ nsGenericHTMLElement::GetOffsetRect(nsRect& aRect, nsIContent** aOffsetParent)
parent = parent->GetParent();
}
nsIContent* docElement = GetCurrentDoc()->GetRootContent();
Element* docElement = GetCurrentDoc()->GetRootElement();
nsIContent* content = frame->GetContent();
if (content && (IsBody(content) || content == docElement)) {

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

@ -432,7 +432,7 @@ void
SetBaseURIUsingFirstBaseWithHref(nsIContent* aHead, nsIContent* aMustMatch)
{
NS_PRECONDITION(aHead && aHead->GetOwnerDoc() &&
aHead->GetOwnerDoc()->GetHeadContent() == aHead,
aHead->GetOwnerDoc()->GetHeadElement() == aHead,
"Bad head");
nsIDocument* doc = aHead->GetOwnerDoc();
@ -483,7 +483,7 @@ nsHTMLSharedElement::SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
aNameSpaceID == kNameSpaceID_None &&
IsInDoc() &&
(head = GetParent()) &&
head == GetOwnerDoc()->GetHeadContent()) {
head == GetOwnerDoc()->GetHeadElement()) {
SetBaseURIUsingFirstBaseWithHref(head, this);
}
@ -506,7 +506,7 @@ nsHTMLSharedElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
aNameSpaceID == kNameSpaceID_None &&
IsInDoc() &&
(head = GetParent()) &&
head == GetOwnerDoc()->GetHeadContent()) {
head == GetOwnerDoc()->GetHeadElement()) {
SetBaseURIUsingFirstBaseWithHref(head, nsnull);
}
@ -528,7 +528,7 @@ nsHTMLSharedElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (mNodeInfo->Equals(nsGkAtoms::base, kNameSpaceID_XHTML) &&
HasAttr(kNameSpaceID_None, nsGkAtoms::href) &&
aDocument && aParent &&
aDocument->GetHeadContent() == aParent) {
aDocument->GetHeadElement() == aParent) {
SetBaseURIUsingFirstBaseWithHref(aParent, this);
}
@ -554,7 +554,7 @@ nsHTMLSharedElement::UnbindFromTree(PRBool aDeep, PRBool aNullParent)
if (inHeadBase) {
// We might have gotten here as a result of the <head> being removed
// from the document. In that case we need to call SetBaseURI(nsnull)
nsIContent* head = doc->GetHeadContent();
Element* head = doc->GetHeadElement();
if (head) {
SetBaseURIUsingFirstBaseWithHref(head, nsnull);
}

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

@ -63,6 +63,7 @@
#include "nsInt64.h"
#include "nsNodeUtils.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsGenericHTMLElement.h"
@ -123,6 +124,8 @@
#include "nsContentCreatorFunctions.h"
#include "mozAutoDocUpdate.h"
using namespace mozilla::dom;
#ifdef NS_DEBUG
static PRLogModuleInfo* gSinkLogModuleInfo;
@ -1615,14 +1618,6 @@ HTMLContentSink::Init(nsIDocument* aDoc,
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
// Make root part
nsIContent *doc_root = mDocument->GetRootContent();
if (doc_root) {
// If the document already has a root we'll use it. This will
// happen when we do document.open()/.write()/.close()...
mRoot = static_cast<nsGenericHTMLElement*>(doc_root);
} else {
mRoot = NS_NewHTMLHtmlElement(nodeInfo);
if (!mRoot) {
return NS_ERROR_OUT_OF_MEMORY;
@ -1632,7 +1627,6 @@ HTMLContentSink::Init(nsIDocument* aDoc,
"Document should have no kids here!");
rv = mDocument->AppendChildTo(mRoot, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
}
// Make head part
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::head,
@ -2982,7 +2976,7 @@ HTMLContentSink::DumpContentModel()
FILE* out = ::fopen("rtest_html.txt", "a");
if (out) {
if (mDocument) {
nsIContent* root = mDocument->GetRootContent();
Element* root = mDocument->GetRootElement();
if (root) {
if (mDocumentURI) {
nsCAutoString buf;

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

@ -143,6 +143,9 @@
#include "nsCCUncollectableMarker.h"
#include "nsHtml5Module.h"
#include "prprf.h"
#include "Element.h"
using namespace mozilla::dom;
#define NS_MAX_DOCUMENT_WRITE_DEPTH 20
@ -1602,7 +1605,7 @@ nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody)
{
*aBody = nsnull;
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (body) {
// There is a body element, return that as the body.
@ -1634,7 +1637,7 @@ NS_IMETHODIMP
nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
{
nsCOMPtr<nsIContent> newBody = do_QueryInterface(aBody);
nsIContent* root = GetRootContent();
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
@ -1650,7 +1653,7 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody)
nsCOMPtr<nsIDOMNode> tmp;
// Use DOM methods so that we pass through the appropriate security checks.
nsCOMPtr<nsIDOMNode> currentBody = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMNode> currentBody = do_QueryInterface(GetBodyElement());
if (currentBody) {
return rootElem->ReplaceChild(aBody, currentBody, getter_AddRefs(tmp));
}
@ -2361,7 +2364,7 @@ nsHTMLDocument::GetBodySize(PRInt32* aWidth,
// Find the <body> element: this is what we'll want to use for the
// document's width and height values.
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
return NS_OK;
}
@ -2402,7 +2405,7 @@ nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
{
aAlinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetALink(aAlinkColor);
}
@ -2413,7 +2416,7 @@ nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetAlinkColor(const nsAString& aAlinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetALink(aAlinkColor);
}
@ -2426,7 +2429,7 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor)
{
aLinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetLink(aLinkColor);
}
@ -2437,7 +2440,7 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetLinkColor(const nsAString& aLinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetLink(aLinkColor);
}
@ -2450,7 +2453,7 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor)
{
aVlinkColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetVLink(aVlinkColor);
}
@ -2461,7 +2464,7 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor)
NS_IMETHODIMP
nsHTMLDocument::SetVlinkColor(const nsAString& aVlinkColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetVLink(aVlinkColor);
}
@ -2474,7 +2477,7 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor)
{
aBgColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetBgColor(aBgColor);
}
@ -2485,7 +2488,7 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor)
NS_IMETHODIMP
nsHTMLDocument::SetBgColor(const nsAString& aBgColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetBgColor(aBgColor);
}
@ -2498,7 +2501,7 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor)
{
aFgColor.Truncate();
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->GetText(aFgColor);
}
@ -2509,7 +2512,7 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor)
NS_IMETHODIMP
nsHTMLDocument::SetFgColor(const nsAString& aFgColor)
{
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyContent());
nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
if (body) {
body->SetText(aFgColor);
}
@ -2714,7 +2717,7 @@ nsHTMLDocument::ResolveName(const nsAString& aName,
if (NS_FAILED(rv))
return rv;
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (root && !aName.IsEmpty()) {
FindNamedItems(name, root, entry);
}
@ -2835,7 +2838,7 @@ nsHTMLDocument::PrePopulateIdentifierMap()
/* virtual */ nsIContent*
nsHTMLDocument::GetBodyContentExternal()
{
return GetBodyContent();
return GetBodyElement();
}
// forms related stuff
@ -3123,7 +3126,7 @@ nsHTMLDocument::GetDocumentAllResult(const nsAString& aID, nsISupports** aResult
nsIdentifierMapEntry *entry = mIdentifierMap.PutEntry(id);
NS_ENSURE_TRUE(entry, NS_ERROR_OUT_OF_MEMORY);
nsIContent* root = GetRootContent();
Element* root = GetRootElement();
if (!root) {
return NS_OK;
}

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

@ -73,6 +73,9 @@
#include "nsIDocShellTreeItem.h"
#include "nsThreadUtils.h"
#include "nsIScrollableFrame.h"
#include "Element.h"
using namespace mozilla::dom;
#define AUTOMATIC_IMAGE_RESIZING_PREF "browser.enable_automatic_image_resizing"
#define CLICK_IMAGE_RESIZING_PREF "browser.enable_click_image_resizing"
@ -400,7 +403,7 @@ nsImageDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObjec
nsHTMLDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject) {
if (!GetRootContent()) {
if (!GetRootElement()) {
// Create synthetic document
#ifdef DEBUG
nsresult rv =
@ -643,7 +646,7 @@ nsImageDocument::CreateSyntheticDocument()
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
return NS_ERROR_FAILURE;
@ -692,14 +695,14 @@ nsImageDocument::CheckOverflowing(PRBool changeState)
nsPresContext *context = shell->GetPresContext();
nsRect visibleArea = context->GetVisibleArea();
nsIContent* content = GetBodyContent();
if (!content) {
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on image document!");
return NS_ERROR_FAILURE;
}
nsRefPtr<nsStyleContext> styleContext =
context->StyleSet()->ResolveStyleFor(content, nsnull);
context->StyleSet()->ResolveStyleFor(body, nsnull);
nsMargin m;
if (styleContext->GetStyleMargin()->GetMargin(m))

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

@ -46,6 +46,9 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentPolicyUtils.h"
#include "nsIPropertyBag2.h"
#include "Element.h"
using namespace mozilla::dom;
class nsPluginDocument : public nsMediaDocument,
public nsIPluginDocument
@ -274,7 +277,7 @@ nsPluginDocument::CreateSyntheticPluginDocument()
NS_ENSURE_SUCCESS(rv, rv);
// then attach our plugin
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on plugin document!");
return NS_ERROR_FAILURE;

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

@ -41,6 +41,9 @@
#include "nsContentCreatorFunctions.h"
#include "nsHTMLMediaElement.h"
#include "nsIDocShellTreeItem.h"
#include "Element.h"
using namespace mozilla::dom;
class nsVideoDocument : public nsMediaDocument
{
@ -100,7 +103,7 @@ nsVideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
nsresult rv = nsMediaDocument::CreateSyntheticDocument();
NS_ENSURE_SUCCESS(rv, rv);
nsIContent* body = GetBodyContent();
Element* body = GetBodyElement();
if (!body) {
NS_WARNING("no body on video document!");
return NS_ERROR_FAILURE;

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

@ -44,6 +44,9 @@
#include "nsIContent.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "Element.h"
using namespace mozilla::dom;
//----------------------------------------------------------------------
// Implementation
@ -72,16 +75,16 @@ nsDOMSVGZoomEvent::nsDOMSVGZoomEvent(nsPresContext* aPresContext,
if (mPresContext && (presShell = mPresContext->GetPresShell())) {
nsIDocument *doc = presShell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
Element *rootElement = doc->GetRootElement();
if (rootElement) {
// If the root element isn't an SVG 'svg' element this QI will fail
// (e.g. if this event was created by calling createEvent on a
// non-SVGDocument). In these circumstances the "New" and "Previous"
// properties will be left null which is probably what we want.
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(rootContent);
nsCOMPtr<nsIDOMSVGSVGElement> svgElement = do_QueryInterface(rootElement);
if (svgElement) {
nsSVGSVGElement *SVGSVGElement =
static_cast<nsSVGSVGElement*>(rootContent);
static_cast<nsSVGSVGElement*>(rootElement);
mNewScale = SVGSVGElement->GetCurrentScale();
mPreviousScale = SVGSVGElement->GetPreviousScale();

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

@ -233,7 +233,7 @@ protected:
PRBool IsRoot() {
NS_ASSERTION((IsInDoc() && !GetParent()) ==
(GetOwnerDoc() && (GetOwnerDoc()->GetRootContent() == this)),
(GetOwnerDoc() && (GetOwnerDoc()->GetRootElement() == this)),
"Can't determine if we're root");
return IsInDoc() && !GetParent();
}

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

@ -42,6 +42,9 @@
#include "nsString.h"
#include "nsLiteralString.h"
#include "nsIDOMSVGSVGElement.h"
#include "Element.h"
using namespace mozilla::dom;
//----------------------------------------------------------------------
// Implementation
@ -126,7 +129,7 @@ NS_IMETHODIMP
nsSVGDocument::GetRootElement(nsIDOMSVGSVGElement** aRootElement)
{
*aRootElement = nsnull;
nsIContent* root = GetRootContent();
Element* root = nsDocument::GetRootElement();
return root ? CallQueryInterface(root, aRootElement) : NS_OK;
}

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

@ -437,7 +437,7 @@ nsXBLStreamListener::Load(nsIDOMEvent* aEvent)
nsIURI* documentURI = bindingDocument->GetDocumentURI();
bindingManager->RemoveLoadingDocListener(documentURI);
if (!bindingDocument->GetRootContent()) {
if (!bindingDocument->GetRootElement()) {
NS_WARNING("*** XBL doc with no root element! Something went horribly wrong! ***");
return NS_ERROR_FAILURE;
}

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

@ -441,13 +441,13 @@ nsXMLContentSink::OnTransformDone(nsresult aResult,
// into the document.
// XXX do we need to notify for things like PIs? Or just the
// documentElement?
nsIContent *rootContent = mDocument->GetRootContent();
if (rootContent) {
NS_ASSERTION(mDocument->IndexOf(rootContent) != -1,
"rootContent not in doc?");
nsIContent *rootElement = mDocument->GetRootElement();
if (rootElement) {
NS_ASSERTION(mDocument->IndexOf(rootElement) != -1,
"rootElement not in doc?");
mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
nsNodeUtils::ContentInserted(mDocument, rootContent,
mDocument->IndexOf(rootContent));
nsNodeUtils::ContentInserted(mDocument, rootElement,
mDocument->IndexOf(rootElement));
mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
}

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

@ -463,7 +463,7 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn)
}
// We set return to true unless there was a parsing error
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(GetRootContent());
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(GetRootElement());
if (node) {
nsAutoString name, ns;
if (NS_SUCCEEDED(node->GetLocalName(name)) &&

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

@ -499,7 +499,7 @@ nsXULElement::GetEventListenerManagerForAttr(nsIEventListenerManager** aManager,
return NS_ERROR_UNEXPECTED; // XXX
nsPIDOMWindow *window;
nsIContent *root = doc->GetRootContent();
Element *root = doc->GetRootElement();
if ((!root || root == this) && !mNodeInfo->Equals(nsGkAtoms::overlay) &&
(window = doc->GetInnerWindow()) && window->IsInnerWindow()) {
@ -1115,7 +1115,7 @@ nsXULElement::AfterSetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
// title, (in)activetitlebarcolor and drawintitlebar are settable on
// any root node (windows, dialogs, etc)
nsIDocument *document = GetCurrentDoc();
if (document && document->GetRootContent() == this) {
if (document && document->GetRootElement() == this) {
if (aName == nsGkAtoms::title) {
document->NotifyPossibleTitleChange(PR_FALSE);
}
@ -1365,7 +1365,7 @@ nsXULElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify)
HideWindowChrome(PR_FALSE);
}
if (doc && doc->GetRootContent() == this) {
if (doc && doc->GetRootElement() == this) {
if ((aName == nsGkAtoms::activetitlebarcolor ||
aName == nsGkAtoms::inactivetitlebarcolor)) {
// Use 0, 0, 0, 0 as the "none" color.
@ -1957,8 +1957,8 @@ nsXULElement::LoadSrc()
return NS_OK;
}
if (!IsInDoc() ||
!GetOwnerDoc()->GetRootContent() ||
GetOwnerDoc()->GetRootContent()->
!GetOwnerDoc()->GetRootElement() ||
GetOwnerDoc()->GetRootElement()->
NodeInfo()->Equals(nsGkAtoms::overlay, kNameSpaceID_XUL)) {
return NS_OK;
}
@ -2327,7 +2327,7 @@ nsresult
nsXULElement::HideWindowChrome(PRBool aShouldHide)
{
nsIDocument* doc = GetCurrentDoc();
if (!doc || doc->GetRootContent() != this)
if (!doc || doc->GetRootElement() != this)
return NS_ERROR_UNEXPECTED;
// only top level chrome documents can hide the window chrome

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

@ -164,7 +164,7 @@ nsXULPopupListener::PreLaunchPopup(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (doc)
targetNode = do_QueryInterface(doc->GetRootContent());
targetNode = do_QueryInterface(doc->GetRootElement());
if (!targetNode) {
return NS_ERROR_FAILURE;
}

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

@ -126,6 +126,9 @@
#include "nsXULPopupManager.h"
#include "nsCCUncollectableMarker.h"
#include "nsURILoader.h"
#include "Element.h"
using namespace mozilla::dom;
//----------------------------------------------------------------------
//
@ -2427,7 +2430,7 @@ nsXULDocument::PrepareToWalk()
PRUint32 piInsertionPoint = 0;
if (mState != eState_Master) {
piInsertionPoint = IndexOf(GetRootContent());
piInsertionPoint = IndexOf(GetRootElement());
NS_ASSERTION(piInsertionPoint >= 0,
"No root content when preparing to walk overlay!");
}
@ -3058,7 +3061,7 @@ nsXULDocument::ResumeWalk()
}
nsIContent* parent = processingOverlayHookupNodes ?
GetRootContent() : element.get();
GetRootElement() : element.get();
if (parent) {
// an inline script could have removed the root element
@ -3918,7 +3921,7 @@ nsXULDocument::OverlayForwardReference::Resolve()
if (id.IsEmpty()) {
// mOverlay is a direct child of <overlay> and has no id.
// Insert it under the root element in the base document.
nsIContent* root = mDocument->GetRootContent();
Element* root = mDocument->GetRootElement();
if (!root) {
return eResolve_Error;
}
@ -4607,11 +4610,11 @@ nsXULDocument::IsDocumentRightToLeft()
{
// setting the localedir attribute on the root element forces a
// specific direction for the document.
nsIContent* content = GetRootContent();
if (content) {
Element* element = GetRootElement();
if (element) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::ltr, &nsGkAtoms::rtl, nsnull};
switch (content->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::localedir,
switch (element->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::localedir,
strings, eCaseMatters)) {
case 0: return PR_FALSE;
case 1: return PR_TRUE;
@ -4678,15 +4681,15 @@ nsXULDocument::GetDocumentLWTheme()
if (mDocLWTheme == Doc_Theme_Uninitialized) {
mDocLWTheme = Doc_Theme_None; // No lightweight theme by default
nsIContent* content = GetRootContent();
Element* element = GetRootElement();
nsAutoString hasLWTheme;
if (content &&
content->GetAttr(kNameSpaceID_None, nsGkAtoms::lwtheme, hasLWTheme) &&
if (element &&
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwtheme, hasLWTheme) &&
!(hasLWTheme.IsEmpty()) &&
hasLWTheme.EqualsLiteral("true")) {
mDocLWTheme = Doc_Theme_Neutral;
nsAutoString lwTheme;
content->GetAttr(kNameSpaceID_None, nsGkAtoms::lwthemetextcolor, lwTheme);
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwthemetextcolor, lwTheme);
if (!(lwTheme.IsEmpty())) {
if (lwTheme.EqualsLiteral("dark"))
mDocLWTheme = Doc_Theme_Dark;

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

@ -49,6 +49,7 @@
#include "nsIBrowserDOMWindow.h"
#include "nsIComponentManager.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDocument.h"
#include "nsIDOMDocument.h"
#include "nsIDOM3Document.h"
@ -223,6 +224,8 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#include "nsIChannelPolicy.h"
#include "nsIContentSecurityPolicy.h"
using namespace mozilla::dom;
// Number of documents currently loading
static PRInt32 gNumberOfDocumentsLoading = 0;
@ -2833,13 +2836,13 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel)
if (vm) {
vm->GetWidget(getter_AddRefs(widget));
}
nsIContent* rootContent = doc->GetRootContent();
Element* rootElement = doc->GetRootElement();
printf("DS %p Ty %s Doc %p DW %p EM %p CN %p\n",
(void*)parentAsDocShell.get(),
type==nsIDocShellTreeItem::typeChrome?"Chr":"Con",
(void*)doc, (void*)domwin.get(),
(void*)presContext->EventStateManager(), (void*)rootContent);
(void*)presContext->EventStateManager(), (void*)rootElement);
if (childWebshellCount > 0) {
for (PRInt32 i=0;i<childWebshellCount;i++) {

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

@ -84,12 +84,15 @@
#include "nsIDOMNodeFilter.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIPrincipal.h"
#include "Element.h"
#ifdef MOZ_XUL
#include "nsIDOMXULTextboxElement.h"
#include "nsIDOMXULMenuListElement.h"
#endif
using namespace mozilla::dom;
//#define DEBUG_FOCUS 1
//#define DEBUG_FOCUS_NAVIGATION 1
#define PRINTTAGF(format, content) \
@ -1307,7 +1310,7 @@ nsFocusManager::IsNonFocusableRoot(nsIContent* aContent)
// focusable.
nsIDocument* doc = aContent->GetCurrentDoc();
NS_ASSERTION(doc, "aContent must have current document");
return aContent == doc->GetRootContent() &&
return aContent == doc->GetRootElement() &&
(doc->HasFlag(NODE_IS_EDITABLE) || !aContent->IsEditable());
}
@ -1337,7 +1340,7 @@ nsFocusManager::CheckIfFocusable(nsIContent* aContent, PRUint32 aFlags)
return nsnull;
// the root content can always be focused
if (aContent == doc->GetRootContent())
if (aContent == doc->GetRootElement())
return aContent;
// cannot focus content in print preview mode. Only the root can be focused.
@ -1584,7 +1587,7 @@ nsFocusManager::Focus(nsPIDOMWindow* aWindow,
PRINTTAGF("**Element %s has been focused", aContent);
nsCOMPtr<nsIDocument> docm = do_QueryInterface(aWindow->GetExtantDocument());
if (docm)
PRINTTAGF(" from %s", docm->GetRootContent());
PRINTTAGF(" from %s", docm->GetRootElement());
printf(" [Newdoc: %d FocusChanged: %d Raised: %d Flags: %x]\n",
aIsNewDocument, aFocusChanged, aWindowRaised, aFlags);
#endif
@ -2071,7 +2074,7 @@ nsFocusManager::GetSelectionLocation(nsIDocument* aDocument,
startContent->IsNodeOfType(nsINode::eHTML_FORM_CONTROL);
if (nodeValue.Length() == (PRUint32)startOffset && !isFormControl &&
startContent != aDocument->GetRootContent()) {
startContent != aDocument->GetRootElement()) {
// Yes, indeed we were at the end of the last node
nsCOMPtr<nsIFrameEnumerator> frameTraversal;
nsresult rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
@ -2173,7 +2176,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
return NS_OK;
}
nsIContent* rootContent = doc->GetRootContent();
nsIContent* rootContent = doc->GetRootElement();
NS_ENSURE_TRUE(rootContent, NS_OK);
nsIPresShell *presShell = doc->GetPrimaryShell();
@ -2398,7 +2401,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
presShell = doc->GetPrimaryShell();
rootContent = doc->GetRootContent();
rootContent = doc->GetRootElement();
startContent = do_QueryInterface(piWindow->GetFrameElementInternal());
if (startContent) {
nsIFrame* frame = startContent->GetPrimaryFrame();
@ -2609,11 +2612,11 @@ nsFocusManager::GetNextTabbableContent(nsIPresShell* aPresShell,
}
}
}
nsIContent* rootContent = subdoc->GetRootContent();
Element* rootElement = subdoc->GetRootElement();
nsIPresShell* subShell = subdoc->GetPrimaryShell();
if (rootContent && subShell) {
rv = GetNextTabbableContent(subShell, rootContent,
aOriginalStartContent, rootContent,
if (rootElement && subShell) {
rv = GetNextTabbableContent(subShell, rootElement,
aOriginalStartContent, rootElement,
aForward, (aForward ? 1 : 0),
PR_FALSE, aResultContent);
NS_ENSURE_SUCCESS(rv, rv);
@ -2807,18 +2810,18 @@ nsFocusManager::GetRootForFocus(nsPIDOMWindow* aWindow,
if (aCheckVisibility && !IsWindowVisible(aWindow))
return nsnull;
nsIContent *rootContent = aDocument->GetRootContent();
if (rootContent) {
if (aCheckVisibility && !rootContent->GetPrimaryFrame()) {
Element *rootElement = aDocument->GetRootElement();
if (rootElement) {
if (aCheckVisibility && !rootElement->GetPrimaryFrame()) {
return nsnull;
}
// Finally, check if this is a frameset
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(aDocument);
if (htmlDoc) {
PRUint32 childCount = rootContent->GetChildCount();
PRUint32 childCount = rootElement->GetChildCount();
for (PRUint32 i = 0; i < childCount; ++i) {
nsIContent *childContent = rootContent->GetChildAt(i);
nsIContent *childContent = rootElement->GetChildAt(i);
nsINodeInfo *ni = childContent->NodeInfo();
if (childContent->IsHTML() &&
ni->Equals(nsGkAtoms::frameset))
@ -2827,7 +2830,7 @@ nsFocusManager::GetRootForFocus(nsPIDOMWindow* aWindow,
}
}
return rootContent;
return rootElement;
}
void
@ -2973,11 +2976,11 @@ nsFocusManager::GetNextTabbableDocument(PRBool aForward)
// forward one tabbable item so that the first item is focused. Note
// that we always go forward and not back here.
nsCOMPtr<nsIContent> nextFocus;
nsIContent* rootContent = doc->GetRootContent();
Element* rootElement = doc->GetRootElement();
nsIPresShell* presShell = doc->GetPrimaryShell();
if (presShell) {
nsresult rv = GetNextTabbableContent(presShell, rootContent,
nsnull, rootContent,
nsresult rv = GetNextTabbableContent(presShell, rootElement,
nsnull, rootElement,
PR_TRUE, 1, PR_FALSE,
getter_AddRefs(nextFocus));
return NS_SUCCEEDED(rv) ? nextFocus.get() : nsnull;

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

@ -202,6 +202,7 @@
#include "nsIPopupWindowManager.h"
#include "nsIDragService.h"
#include "Element.h"
#ifdef MOZ_LOGGING
// so we can get logging even in release builds
@ -213,6 +214,8 @@
static PRLogModuleInfo* gDOMLeakPRLog;
#endif
using namespace mozilla::dom;
nsIDOMStorageList *nsGlobalWindow::sGlobalStorageList = nsnull;
static nsIEntropyCollector *gEntropyCollector = nsnull;
@ -4474,7 +4477,7 @@ nsGlobalWindow::Blur()
nsCOMPtr<nsIDOMElement> element;
fm->GetFocusedElementForWindow(this, PR_FALSE, nsnull, getter_AddRefs(element));
nsCOMPtr<nsIContent> content = do_QueryInterface(element);
if (content == doc->GetRootContent())
if (content == doc->GetRootElement())
fm->ClearFocus(this);
}
}
@ -7042,7 +7045,7 @@ nsGlobalWindow::TakeFocus(PRBool aFocus, PRUint32 aFocusMethod)
// true to tell the calling focus manager that a focus event is expected. If
// there is no root content node, the document hasn't loaded enough yet, or
// there isn't one and there is no point in firing a focus event.
if (aFocus && mNeedsFocus && mDoc && mDoc->GetRootContent() != nsnull) {
if (aFocus && mNeedsFocus && mDoc && mDoc->GetRootElement() != nsnull) {
mNeedsFocus = PR_FALSE;
return PR_TRUE;
}
@ -7264,16 +7267,16 @@ nsGlobalWindow::UpdateCanvasFocus(PRBool aFocusChanged, nsIContent* aNewContent)
return;
nsCOMPtr<nsIDocument> doc(do_QueryInterface(mDocument));
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
Element *rootElement = doc->GetRootElement();
if (rootElement) {
if ((mHasFocus || aFocusChanged) &&
(mFocusedNode == rootContent || aNewContent == rootContent)) {
nsIFrame* frame = rootContent->GetPrimaryFrame();
(mFocusedNode == rootElement || aNewContent == rootElement)) {
nsIFrame* frame = rootElement->GetPrimaryFrame();
if (frame) {
frame = frame->GetParent();
nsCanvasFrame* canvasFrame = do_QueryFrame(frame);
if (canvasFrame) {
canvasFrame->SetHasFocus(mHasFocus && rootContent == aNewContent);
canvasFrame->SetHasFocus(mHasFocus && rootElement == aNewContent);
}
}
}

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

@ -912,7 +912,7 @@ FindSelectionRoot(nsEditor *aEditor, nsIContent *aContent)
nsIContent *root;
if (document->HasFlag(NODE_IS_EDITABLE)) {
NS_IF_ADDREF(root = document->GetRootContent());
NS_IF_ADDREF(root = document->GetRootElement());
return root;
}

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

@ -3309,7 +3309,7 @@ nsHTMLEditor::GetLinkedObjects(nsISupportsArray** aNodeList)
if (!doc)
return NS_ERROR_UNEXPECTED;
iter->Init(doc->GetRootContent());
iter->Init(doc->GetRootElement());
// loop through the content iterator for each content node
while (!iter->IsDone())
@ -3642,7 +3642,7 @@ nsHTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
if (!doc)
return NS_ERROR_UNEXPECTED;
iter->Init(doc->GetRootContent());
iter->Init(doc->GetRootElement());
// loop through the content iterator for each content node
while (!iter->IsDone())
@ -4269,8 +4269,7 @@ nsCOMPtr<nsIDOMElement> nsHTMLEditor::FindPreElement()
if (!doc)
return 0;
nsCOMPtr<nsIContent> rootContent;
doc->GetRootContent(getter_AddRefs(rootContent));
nsCOMPtr<nsIContent> rootContent = doc->GetRootElement();
if (!rootContent)
return 0;

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

@ -64,6 +64,9 @@
static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
#include "nsISelectionController.h"
#include "Element.h"
using namespace mozilla::dom;
static already_AddRefed<nsIContentViewer>
doc_viewer(nsIDocShell *aDocShell)
@ -393,7 +396,7 @@ DumpContentRecur(nsIDocShell* aDocShell, FILE* out)
fprintf(out, "docshell=%p \n", static_cast<void*>(aDocShell));
nsCOMPtr<nsIDocument> doc(document(aDocShell));
if (doc) {
nsIContent *root = doc->GetRootContent();
Element *root = doc->GetRootElement();
if (root) {
root->List(out);
}

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

@ -119,6 +119,7 @@
#include "nsBox.h"
#include "nsTArray.h"
#include "nsGenericDOMDataNode.h"
#include "Element.h"
#ifdef MOZ_XUL
#include "nsIRootBox.h"
@ -151,6 +152,7 @@
#endif
using namespace mozilla;
using namespace mozilla::dom;
nsIFrame*
NS_NewHTMLCanvasFrame (nsIPresShell* aPresShell, nsStyleContext* aContext);
@ -2237,7 +2239,7 @@ nsCSSFrameConstructor::PropagateScrollToViewport()
return nsnull;
}
nsIContent* docElement = mDocument->GetRootContent();
Element* docElement = mDocument->GetRootElement();
// Check the style on the document root element
nsStyleSet *styleSet = mPresShell->StyleSet();
@ -2574,7 +2576,7 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement)
NS_PRECONDITION(aDocElement, "No element?");
NS_PRECONDITION(!aDocElement->GetParent(), "Not root content?");
NS_PRECONDITION(aDocElement->GetCurrentDoc(), "Not in a document?");
NS_PRECONDITION(aDocElement->GetCurrentDoc()->GetRootContent() ==
NS_PRECONDITION(aDocElement->GetCurrentDoc()->GetRootElement() ==
aDocElement, "Not the root of the document?");
/*
@ -5456,7 +5458,8 @@ IsRootBoxFrame(nsIFrame *aFrame)
nsresult
nsCSSFrameConstructor::ReconstructDocElementHierarchy()
{
return RecreateFramesForContent(mPresShell->GetDocument()->GetRootContent(), PR_FALSE);
return RecreateFramesForContent(mPresShell->GetDocument()->GetRootElement(),
PR_FALSE);
}
nsIFrame*
@ -6306,12 +6309,12 @@ void nsCSSFrameConstructor::CreateNeededFrames()
mInLazyFCRefresh = PR_FALSE;
nsIContent* rootContent = mDocument->GetRootContent();
NS_ASSERTION(!rootContent || !rootContent->HasFlag(NODE_NEEDS_FRAME),
"root content should not have frame created lazily");
if (rootContent && rootContent->HasFlag(NODE_DESCENDANTS_NEED_FRAMES)) {
Element* rootElement = mDocument->GetRootElement();
NS_ASSERTION(!rootElement || !rootElement->HasFlag(NODE_NEEDS_FRAME),
"root element should not have frame created lazily");
if (rootElement && rootElement->HasFlag(NODE_DESCENDANTS_NEED_FRAMES)) {
BeginUpdate();
CreateNeededFrames(rootContent);
CreateNeededFrames(rootElement);
EndUpdate();
}
}
@ -6840,7 +6843,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
if (! aContainer) {
NS_ASSERTION(isSingleInsert,
"root node insertion should be a single insertion");
nsIContent *docElement = mDocument->GetRootContent();
Element *docElement = mDocument->GetRootElement();
if (aChild != docElement) {
// Not the root element; just bail out
@ -11224,7 +11227,8 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIFrame* aFrame)
}
// If we get here, we're screwed!
return RecreateFramesForContent(mPresShell->GetDocument()->GetRootContent(), PR_TRUE);
return RecreateFramesForContent(mPresShell->GetDocument()->GetRootElement(),
PR_TRUE);
}
void

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

@ -741,7 +741,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow)
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLFrameSetElement> frameset =
do_QueryInterface(mDocument->GetRootContent());
do_QueryInterface(mDocument->GetRootElement());
htmlDoc->SetIsFrameset(frameset != nsnull);
}
@ -2467,7 +2467,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll()
}
else if (mDocument)
{
bodyNode = do_QueryInterface(mDocument->GetRootContent());
bodyNode = do_QueryInterface(mDocument->GetRootElement());
}
if (!bodyNode) return NS_ERROR_FAILURE;

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

@ -378,8 +378,9 @@ nsFrameManager::SetUndisplayedContent(nsIContent* aContent,
if (mUndisplayedMap) {
nsIContent* parent = aContent->GetParent();
NS_ASSERTION(parent || (mPresShell && mPresShell->GetDocument() &&
mPresShell->GetDocument()->GetRootContent() == aContent),
"undisplayed content must have a parent, unless it's the root content");
mPresShell->GetDocument()->GetRootElement() == aContent),
"undisplayed content must have a parent, unless it's the root "
"element");
mUndisplayedMap->AddNodeFor(parent, aContent, aStyleContext);
}
}
@ -1228,7 +1229,7 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext,
undisplayed; undisplayed = undisplayed->mNext) {
NS_ASSERTION(undisplayedParent ||
undisplayed->mContent ==
mPresShell->GetDocument()->GetRootContent(),
mPresShell->GetDocument()->GetRootElement(),
"undisplayed node child of null must be root");
NS_ASSERTION(!undisplayed->mStyle->GetPseudo(),
"Shouldn't have random pseudo style contexts in the "

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

@ -93,6 +93,7 @@
#include "nsCOMPtr.h"
#include "nsListControlFrame.h"
#include "ImageLayers.h"
#include "Element.h"
#ifdef MOZ_SVG
#include "nsSVGUtils.h"
@ -106,6 +107,7 @@
#endif
using namespace mozilla::layers;
using namespace mozilla::dom;
/**
* A namespace class for static layout utilities.
@ -3571,9 +3573,9 @@ nsLayoutUtils::GetEditableRootContentByContentEditable(nsIDocument* aDocument)
return nsnull;
}
nsIContent* rootContent = aDocument->GetRootContent();
if (rootContent && rootContent->IsEditable()) {
return rootContent;
Element* rootElement = aDocument->GetRootElement();
if (rootElement && rootElement->IsEditable()) {
return rootElement;
}
// If there are no editable root element, check its <body> element.

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

@ -95,6 +95,7 @@
#include "nsIDOMEventTarget.h"
#include "nsObjectFrame.h"
#include "nsTransitionManager.h"
#include "Element.h"
#ifdef MOZ_SMIL
#include "nsSMILAnimationController.h"
@ -115,6 +116,7 @@
using mozilla::TimeDuration;
using mozilla::TimeStamp;
using namespace mozilla::dom;
static nscolor
MakeColorPref(const char *colstr)
@ -1173,9 +1175,9 @@ nsPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
if (mShell != nsnull) {
nsIDocument *doc = mShell->GetDocument();
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
SetImgAnimations(rootContent, aMode);
Element *rootElement = doc->GetRootElement();
if (rootElement) {
SetImgAnimations(rootElement, aMode);
}
#ifdef MOZ_SMIL

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

@ -58,6 +58,7 @@
#include "nsIPresShell.h"
#include "nsPresContext.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDocument.h"
#include "nsIDOMXULDocument.h"
#include "nsStubDocumentObserver.h"
@ -210,6 +211,7 @@
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
using namespace mozilla::layers;
using namespace mozilla::dom;
PRBool nsIPresShell::gIsAccessibilityActive = PR_FALSE;
CapturingContentInfo nsIPresShell::gCaptureInfo;
@ -2485,7 +2487,7 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
return NS_ERROR_OUT_OF_MEMORY;
}
nsIContent *root = mDocument->GetRootContent();
Element *root = mDocument->GetRootElement();
if (root) {
{
@ -3235,9 +3237,9 @@ PresShell::FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
printf("\nPresShell@%p: frame %p needs reflow\n", (void*)this, (void*)aFrame);
if (VERIFY_REFLOW_REALLY_NOISY_RC & gVerifyReflowFlags) {
printf("Current content model:\n");
nsIContent *rootContent = mDocument->GetRootContent();
if (rootContent) {
rootContent->List(stdout, 0);
Element *rootElement = mDocument->GetRootElement();
if (rootElement) {
rootElement->List(stdout, 0);
}
}
}
@ -4728,9 +4730,9 @@ PresShell::DocumentStatesChanged(nsIDocument* aDocument,
if (mDidInitialReflow &&
mStyleSet->HasDocumentStateDependentStyle(mPresContext,
mDocument->GetRootContent(),
mDocument->GetRootElement(),
aStateMask)) {
mFrameConstructor->PostRestyleEvent(mDocument->GetRootContent(),
mFrameConstructor->PostRestyleEvent(mDocument->GetRootElement(),
eRestyle_Self, NS_STYLE_HINT_NONE);
VERIFY_STYLE_TREE;
}
@ -4894,7 +4896,7 @@ nsIPresShell::ReconstructStyleDataInternal()
mPresContext->RebuildUserFontSet();
}
nsIContent* root = mDocument->GetRootContent();
Element* root = mDocument->GetRootElement();
if (!mDidInitialReflow) {
// Nothing to do here, since we have no frames yet
return;
@ -6166,7 +6168,7 @@ PresShell::HandleEvent(nsIView *aView,
// still get sent to the window properly if nothing is focused or if a
// frame goes away while it is focused.
if (!mCurrentEventContent || !GetCurrentEventFrame())
mCurrentEventContent = mDocument->GetRootContent();
mCurrentEventContent = mDocument->GetRootElement();
mCurrentEventFrame = nsnull;
if (!mCurrentEventContent || !GetCurrentEventFrame() ||

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

@ -73,6 +73,7 @@
#include "nsThemeConstants.h"
#include "nsCSSFrameConstructor.h"
#include "nsThemeConstants.h"
#include "Element.h"
#ifdef NS_DEBUG
#undef NOISY
@ -81,6 +82,7 @@
#endif
using namespace mozilla;
using namespace mozilla::dom;
NS_IMPL_FRAMEARENA_HELPERS(nsContainerFrame)
@ -478,8 +480,8 @@ nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext,
if (aView != rootView)
return;
nsIContent* rootContent = aPresContext->Document()->GetRootContent();
if (!rootContent || !rootContent->IsXUL()) {
Element* rootElement = aPresContext->Document()->GetRootElement();
if (!rootElement || !rootElement->IsXUL()) {
// Scrollframes use native widgets which don't work well with
// translucent windows, at least in Windows XP. So if the document
// has a root scrollrame it's useless to try to make it transparent,

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

@ -80,6 +80,9 @@
#include "nsBidiUtils.h"
#include "nsFrameManager.h"
#include "nsIPrefService.h"
#include "Element.h"
using namespace mozilla::dom;
//----------------------------------------------------------------------
@ -2687,14 +2690,14 @@ nsGfxScrollFrameInner::IsLTR() const
// If we're the root scrollframe, we need the root element's style data.
nsPresContext *presContext = mOuter->PresContext();
nsIDocument *document = presContext->Document();
nsIContent *root = document->GetRootContent();
Element *root = document->GetRootElement();
// But for HTML we want the body element.
// But for HTML and XHTML we want the body element.
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(document);
if (htmlDoc) {
nsIContent *bodyContent = htmlDoc->GetBodyContentExternal();
if (bodyContent)
root = bodyContent; // we can trust the document to hold on to it
Element *bodyElement = document->GetBodyElement();
if (bodyElement)
root = bodyElement; // we can trust the document to hold on to it
}
if (root) {

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

@ -2211,7 +2211,7 @@ nsFrameSelection::SelectAll()
nsIDocument *doc = mShell->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
rootContent = doc->GetRootContent();
rootContent = doc->GetRootElement();
if (!rootContent)
return NS_ERROR_FAILURE;
}

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

@ -162,6 +162,9 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsRange.h"
#include "nsCDefaultURIFixup.h"
#include "nsIURIFixup.h"
#include "Element.h"
using namespace mozilla::dom;
//-----------------------------------------------------
// PR LOGGING
@ -558,7 +561,7 @@ nsPrintEngine::DoCommonPrint(PRBool aIsPrintPreview,
// XXX This isn't really correct...
if (!mPrt->mPrintObject->mDocument ||
!mPrt->mPrintObject->mDocument->GetRootContent())
!mPrt->mPrintObject->mDocument->GetRootElement())
return NS_ERROR_GFX_PRINTER_STARTDOC;
// Create the linkage from the sub-docs back to the content element
@ -1127,9 +1130,9 @@ nsPrintEngine::IsParentAFrameSet(nsIDocShell * aParent)
nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(aParent);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (doc) {
nsIContent *rootContent = doc->GetRootContent();
if (rootContent) {
isFrameSet = HasFramesetChild(rootContent);
nsIContent *rootElement = doc->GetRootElement();
if (rootElement) {
isFrameSet = HasFramesetChild(rootElement);
}
}
return isFrameSet;
@ -1250,9 +1253,9 @@ nsPrintEngine::MapContentToWebShells(nsPrintObject* aRootPO,
nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
if (!doc) return;
nsIContent* rootContent = doc->GetRootContent();
if (rootContent) {
MapContentForPO(aPO, rootContent);
Element* rootElement = doc->GetRootElement();
if (rootElement) {
MapContentForPO(aPO, rootElement);
} else {
NS_WARNING("Null root content on (sub)document.");
}

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

@ -1733,7 +1733,7 @@ static PRBool SelectorMatches(RuleProcessorData &data,
case nsCSSPseudoClasses::ePseudoClass_root:
if (data.mParentContent != nsnull ||
data.mContent != data.mContent->GetOwnerDoc()->GetRootContent()) {
data.mContent != data.mContent->GetOwnerDoc()->GetRootElement()) {
return PR_FALSE;
}
break;
@ -2441,7 +2441,7 @@ nsCSSRuleProcessor::HasAttributeDependentStyle(AttributeRuleProcessorData* aData
if ((aData->mAttribute == nsGkAtoms::lwtheme ||
aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
aData->mNameSpaceID == kNameSpaceID_XUL &&
aData->mContent == aData->mContent->GetOwnerDoc()->GetRootContent())
aData->mContent == aData->mContent->GetOwnerDoc()->GetRootElement())
{
data.change = nsRestyleHint(data.change | eRestyle_Self);
}

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

@ -78,6 +78,9 @@
#include "nsCSSProps.h"
#include "nsTArray.h"
#include "nsContentUtils.h"
#include "Element.h"
using namespace mozilla::dom;
#define NS_SET_IMAGE_REQUEST(method_, context_, request_) \
if ((context_)->PresContext()->IsDynamic()) { \
@ -227,7 +230,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
// than font size, so rem is relative to the root element's font size.
nsRefPtr<nsStyleContext> rootStyle;
const nsStyleFont *rootStyleFont = aStyleFont;
nsIContent* docElement = aPresContext->Document()->GetRootContent();
Element* docElement = aPresContext->Document()->GetRootElement();
rootStyle = aPresContext->StyleSet()->ResolveStyleFor(docElement,
nsnull);

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

@ -164,7 +164,7 @@ nsSVGOuterSVGFrame::Init(nsIContent* aContent,
nsIDocument* doc = mContent->GetCurrentDoc();
if (doc) {
// we only care about our content's zoom and pan values if it's the root element
if (doc->GetRootContent() == mContent) {
if (doc->GetRootElement() == mContent) {
mIsRootContent = PR_TRUE;
}
// AddMutationObserver checks that the observer is not already added.

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

@ -58,6 +58,9 @@
#include "nsISupportsPrimitives.h"
#include "prtypes.h"
#include "nsSupportsPrimitives.h"
#include "Element.h"
using namespace mozilla::dom;
// Implementation /////////////////////////////////////////////////////////////////
@ -197,7 +200,7 @@ nsBoxObject::GetOffsetRect(nsIntRect& aRect)
nsPoint origin = frame->GetPositionIgnoringScrolling();
// Find the frame parent whose content is the document element.
nsIContent *docElement = mContent->GetCurrentDoc()->GetRootContent();
Element *docElement = mContent->GetCurrentDoc()->GetRootElement();
nsIFrame* parent = frame->GetParent();
for (;;) {
// If we've hit the document element, break here

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

@ -381,7 +381,7 @@ nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent)
nsCOMPtr<nsIBoxObject> bx;
nsIDocument* doc = sourceNode->GetDocument();
if (doc) {
nsCOMPtr<nsIDOMElement> docElement = do_QueryInterface(doc->GetRootContent());
nsCOMPtr<nsIDOMElement> docElement = do_QueryInterface(doc->GetRootElement());
if (docElement) {
doc->GetBoxObjectFor(docElement, getter_AddRefs(bx));
}

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

@ -711,7 +711,7 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer,
}
if (!rootContent)
rootContent = doc->GetRootContent();
rootContent = doc->GetRootElement();
nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));
@ -1007,7 +1007,7 @@ nsTypeAheadFind::Find(const nsAString& aSearchString, PRBool aLinksOnly,
// If the root element is focused, then it's actually the document
// that has the focus, so ignore this.
if (focusedElement &&
!SameCOMIdentity(focusedElement, document->GetRootContent())) {
!SameCOMIdentity(focusedElement, document->GetRootElement())) {
fm->MoveCaretToFocus(window);
isFirstVisiblePreferred = PR_FALSE;
}

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

@ -48,6 +48,7 @@
#include "nsICacheSession.h"
#include "nsICachingChannel.h"
#include "nsIContent.h"
#include "Element.h"
#include "nsIDocumentLoader.h"
#include "nsIDOMElement.h"
#include "nsIDOMWindow.h"
@ -1850,8 +1851,7 @@ nsOfflineCacheUpdate::ScheduleImplicit()
if (!uri)
continue;
nsIContent* content = doc->GetRootContent();
nsCOMPtr<nsIDOMElement> root = do_QueryInterface(content);
nsCOMPtr<nsIDOMElement> root = do_QueryInterface(doc->GetRootElement());
if (!root)
continue;