diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index bc3fb1f89eb7..d536494fb2cc 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -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 or , use nsIAccessibleRole::ROLE_DIALOG instead - nsIContent *rootContent = mDocument->GetRootContent(); - if (rootContent) { - nsCOMPtr rootElement(do_QueryInterface(rootContent)); + Element *root = mDocument->GetRootElement(); + if (root) { + nsCOMPtr rootElement(do_QueryInterface(root)); if (rootElement) { nsAutoString name; rootElement->GetLocalName(name); diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 8c1d24536107..575653406bf8 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -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(mCachedRootContent.get()) : - GetRootContentInternal(); + return (mCachedRootElement && + mCachedRootElement->GetNodeParent() == this) ? + reinterpret_cast(mCachedRootElement.get()) : + GetRootElementInternal(); } - virtual nsIContent *GetRootContentInternal() const = 0; +protected: + virtual mozilla::dom::Element *GetRootElementInternal() const = 0; +public: // Get the root element, or return null if there isn't one (e.g. // if the root isn't ) - 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 element, or return null if there isn't one (e.g. // if the root isn't or if the isn't there) - nsIContent* GetBodyContent() { - return GetHtmlChildContent(nsGkAtoms::body); + mozilla::dom::Element* GetBodyElement() { + return GetHtmlChildElement(nsGkAtoms::body); } // Get the canonical element, or return null if there isn't one (e.g. // if the root isn't or if the 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 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 mCachedRootElement; // We'd like these to be nsRefPtrs, but that'd require us to include // additional headers that we don't want to expose. diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 0399e7bb3783..ce56d5a6fc75 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -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|. * diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index 02fe9cbfb0f7..2ce73108d0c3 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -1018,7 +1018,7 @@ nsContentList::AssertInSync() // elements that are outside of the document element. nsIContent *root; if (mRootNode->IsNodeOfType(nsINode::eDOCUMENT)) { - root = static_cast(mRootNode)->GetRootContent(); + root = static_cast(mRootNode)->GetRootElement(); } else { root = static_cast(mRootNode); diff --git a/content/base/src/nsContentSink.cpp b/content/base/src/nsContentSink.cpp index 6723d7e1b26d..c94f93523820 100644 --- a/content/base/src/nsContentSink.cpp +++ b/content/base/src/nsContentSink.cpp @@ -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; } diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 0cde7e336714..2cbb532df5ef 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -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 docElement = aDocument->GetRootContent(); + Element* docElement = aDocument->GetRootElement(); if (!docElement) { return; } @@ -1186,7 +1189,7 @@ nsContentUtils::InProlog(nsINode *aNode) } nsIDocument* doc = static_cast(parent); - nsIContent* root = doc->GetRootContent(); + nsIContent* root = doc->GetRootElement(); return !root || doc->IndexOf(aNode) < doc->IndexOf(root); } diff --git a/content/base/src/nsCopySupport.cpp b/content/base/src/nsCopySupport.cpp index a8c1a0dcb740..185c5f3a1f00 100644 --- a/content/base/src/nsCopySupport.cpp +++ b/content/base/src/nsCopySupport.cpp @@ -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; } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 707832b74e60..7493dd967605 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -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(this)->mCachedRootContent = child; - return child; + if (child->IsElement()) { + const_cast(this)->mCachedRootElement = child; + return child->AsElement(); } } - const_cast(this)->mCachedRootContent = nsnull; + const_cast(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(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 root(do_QueryInterface(GetRootContent())); + nsCOMPtr 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 elements are attached. nsRefPtr links = NS_GetContentList(root, @@ -7419,7 +7418,7 @@ nsDocument::OnPageHide(PRBool aPersisted, { // Send out notifications that our elements are detached, // but only if this is not a full unload. - nsIContent* root = GetRootContent(); + Element* root = GetRootElement(); if (aPersisted && root) { nsRefPtr links = NS_GetContentList(root, nsGkAtoms::link, diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 2c61e03cd17b..5c5ec9f5d0df 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -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. diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index aed931b26b50..218ae7f5aa3b 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -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(this)->GetRootContent(); + return static_cast(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(aParent)->GetRootContent(); - if (rootContent) { + Element* rootElement = + static_cast(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(aParent)->GetRootContent(); - if (!rootContent) { + Element* rootElement = + static_cast(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 : diff --git a/content/base/src/nsScriptLoader.cpp b/content/base/src/nsScriptLoader.cpp index 4faf46bdcc2a..eaa0eb673518 100644 --- a/content/base/src/nsScriptLoader.cpp +++ b/content/base/src/nsScriptLoader.cpp @@ -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 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; diff --git a/content/base/src/nsSyncLoadService.cpp b/content/base/src/nsSyncLoadService.cpp index 7f00fbdda4f9..29a76fe9478e 100644 --- a/content/base/src/nsSyncLoadService.cpp +++ b/content/base/src/nsSyncLoadService.cpp @@ -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); } diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 632e61dfce54..c673960c9ffb 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -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 root = doc->GetRootContent(); + Element* root = doc->GetRootElement(); if (root) nameSpace = root->GetNameSpaceID(); } diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index f3f3e3c95b72..e333dfd1a960 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -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); diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 08b8d8bd1122..0666c1ccef7b 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -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)) { diff --git a/content/html/content/src/nsHTMLSharedElement.cpp b/content/html/content/src/nsHTMLSharedElement.cpp index c3ce2a1ddfed..1671a38a7a85 100644 --- a/content/html/content/src/nsHTMLSharedElement.cpp +++ b/content/html/content/src/nsHTMLSharedElement.cpp @@ -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 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); } diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index eba4accb5c9b..ca509c0066fa 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -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,25 +1618,16 @@ 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(doc_root); - } else { - mRoot = NS_NewHTMLHtmlElement(nodeInfo); - if (!mRoot) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ASSERTION(mDocument->GetChildCount() == 0, - "Document should have no kids here!"); - rv = mDocument->AppendChildTo(mRoot, PR_FALSE); - NS_ENSURE_SUCCESS(rv, rv); + mRoot = NS_NewHTMLHtmlElement(nodeInfo); + if (!mRoot) { + return NS_ERROR_OUT_OF_MEMORY; } + NS_ASSERTION(mDocument->GetChildCount() == 0, + "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, nsnull, kNameSpaceID_XHTML); @@ -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; diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 27fa481abca8..f2e4fec172f2 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -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 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 tmp; // Use DOM methods so that we pass through the appropriate security checks. - nsCOMPtr currentBody = do_QueryInterface(GetBodyContent()); + nsCOMPtr currentBody = do_QueryInterface(GetBodyElement()); if (currentBody) { return rootElem->ReplaceChild(aBody, currentBody, getter_AddRefs(tmp)); } @@ -2361,7 +2364,7 @@ nsHTMLDocument::GetBodySize(PRInt32* aWidth, // Find the 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr body = do_QueryInterface(GetBodyElement()); if (body) { body->SetALink(aAlinkColor); } @@ -2426,7 +2429,7 @@ nsHTMLDocument::GetLinkColor(nsAString& aLinkColor) { aLinkColor.Truncate(); - nsCOMPtr body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr body = do_QueryInterface(GetBodyElement()); if (body) { body->SetLink(aLinkColor); } @@ -2450,7 +2453,7 @@ nsHTMLDocument::GetVlinkColor(nsAString& aVlinkColor) { aVlinkColor.Truncate(); - nsCOMPtr body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr body = do_QueryInterface(GetBodyElement()); if (body) { body->SetVLink(aVlinkColor); } @@ -2474,7 +2477,7 @@ nsHTMLDocument::GetBgColor(nsAString& aBgColor) { aBgColor.Truncate(); - nsCOMPtr body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr body = do_QueryInterface(GetBodyElement()); if (body) { body->SetBgColor(aBgColor); } @@ -2498,7 +2501,7 @@ nsHTMLDocument::GetFgColor(nsAString& aFgColor) { aFgColor.Truncate(); - nsCOMPtr body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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 body = do_QueryInterface(GetBodyContent()); + nsCOMPtr 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; } diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index b5814147a67c..0429373ee62b 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -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 styleContext = - context->StyleSet()->ResolveStyleFor(content, nsnull); + context->StyleSet()->ResolveStyleFor(body, nsnull); nsMargin m; if (styleContext->GetStyleMargin()->GetMargin(m)) diff --git a/content/html/document/src/nsPluginDocument.cpp b/content/html/document/src/nsPluginDocument.cpp index cecb168d95d0..e5f7152b17a5 100644 --- a/content/html/document/src/nsPluginDocument.cpp +++ b/content/html/document/src/nsPluginDocument.cpp @@ -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; diff --git a/content/html/document/src/nsVideoDocument.cpp b/content/html/document/src/nsVideoDocument.cpp index b80be8348163..2bddd510ab62 100644 --- a/content/html/document/src/nsVideoDocument.cpp +++ b/content/html/document/src/nsVideoDocument.cpp @@ -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; diff --git a/content/svg/content/src/nsDOMSVGZoomEvent.cpp b/content/svg/content/src/nsDOMSVGZoomEvent.cpp index d7c37ab7b85d..67bcd173695d 100644 --- a/content/svg/content/src/nsDOMSVGZoomEvent.cpp +++ b/content/svg/content/src/nsDOMSVGZoomEvent.cpp @@ -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 svgElement = do_QueryInterface(rootContent); + nsCOMPtr svgElement = do_QueryInterface(rootElement); if (svgElement) { nsSVGSVGElement *SVGSVGElement = - static_cast(rootContent); + static_cast(rootElement); mNewScale = SVGSVGElement->GetCurrentScale(); mPreviousScale = SVGSVGElement->GetPreviousScale(); diff --git a/content/svg/content/src/nsSVGSVGElement.h b/content/svg/content/src/nsSVGSVGElement.h index 37968945394d..033079daa4b2 100644 --- a/content/svg/content/src/nsSVGSVGElement.h +++ b/content/svg/content/src/nsSVGSVGElement.h @@ -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(); } diff --git a/content/svg/document/src/nsSVGDocument.cpp b/content/svg/document/src/nsSVGDocument.cpp index d6707dce1c20..521e9f28c5e1 100644 --- a/content/svg/document/src/nsSVGDocument.cpp +++ b/content/svg/document/src/nsSVGDocument.cpp @@ -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; } diff --git a/content/xbl/src/nsXBLService.cpp b/content/xbl/src/nsXBLService.cpp index e4d46bd0180b..0e40da2b165a 100644 --- a/content/xbl/src/nsXBLService.cpp +++ b/content/xbl/src/nsXBLService.cpp @@ -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; } diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 2d7b0e486c97..b36aca9c3da4 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -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); } diff --git a/content/xml/document/src/nsXMLDocument.cpp b/content/xml/document/src/nsXMLDocument.cpp index 108d776077c1..543a210b776c 100644 --- a/content/xml/document/src/nsXMLDocument.cpp +++ b/content/xml/document/src/nsXMLDocument.cpp @@ -463,7 +463,7 @@ nsXMLDocument::Load(const nsAString& aUrl, PRBool *aReturn) } // We set return to true unless there was a parsing error - nsCOMPtr node = do_QueryInterface(GetRootContent()); + nsCOMPtr node = do_QueryInterface(GetRootElement()); if (node) { nsAutoString name, ns; if (NS_SUCCEEDED(node->GetLocalName(name)) && diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 8a92e77fb321..193e4a4db3fb 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -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 diff --git a/content/xul/content/src/nsXULPopupListener.cpp b/content/xul/content/src/nsXULPopupListener.cpp index 6556876822dd..c2d171d6b544 100644 --- a/content/xul/content/src/nsXULPopupListener.cpp +++ b/content/xul/content/src/nsXULPopupListener.cpp @@ -164,7 +164,7 @@ nsXULPopupListener::PreLaunchPopup(nsIDOMEvent* aMouseEvent) nsCOMPtr doc = do_QueryInterface(domDoc); if (doc) - targetNode = do_QueryInterface(doc->GetRootContent()); + targetNode = do_QueryInterface(doc->GetRootElement()); if (!targetNode) { return NS_ERROR_FAILURE; } diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 4e7d5e44c7da..09bf7a5f677f 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -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 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; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 134bfe988246..b6f839e950e2 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -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;iGetCurrentDoc(); 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 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 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 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 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; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f65cd279ec61..f48c9a90cf84 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -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 element; fm->GetFocusedElementForWindow(this, PR_FALSE, nsnull, getter_AddRefs(element)); nsCOMPtr 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 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); } } } diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index a049533d59b4..02ab24651e0b 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -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; } diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index f8a8503ecce2..785db48c0776 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -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 nsHTMLEditor::FindPreElement() if (!doc) return 0; - nsCOMPtr rootContent; - doc->GetRootContent(getter_AddRefs(rootContent)); + nsCOMPtr rootContent = doc->GetRootElement(); if (!rootContent) return 0; diff --git a/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp b/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp index 8f7bd31c4672..bc20ae58dc28 100644 --- a/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp +++ b/extensions/layout-debug/src/nsLayoutDebuggingTools.cpp @@ -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 doc_viewer(nsIDocShell *aDocShell) @@ -393,7 +396,7 @@ DumpContentRecur(nsIDocShell* aDocShell, FILE* out) fprintf(out, "docshell=%p \n", static_cast(aDocShell)); nsCOMPtr doc(document(aDocShell)); if (doc) { - nsIContent *root = doc->GetRootContent(); + Element *root = doc->GetRootElement(); if (root) { root->List(out); } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9fb1aaa83dc1..65cfa0876a46 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -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 diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 2e9e5a71e550..b7ed48ea1e28 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -741,7 +741,7 @@ DocumentViewerImpl::InitPresentationStuff(PRBool aDoInitialReflow) nsCOMPtr htmlDoc = do_QueryInterface(mDocument); if (htmlDoc) { nsCOMPtr 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; diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index ae46fdb62c5e..562a0a2ceaed 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -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 " diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 77e4a199c0b1..a1d9b0ff5557 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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 element. diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 2a863f7a221c..6d3e69e7eab5 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -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 diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 3b7d7de3a863..4d813284fa67 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -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() || diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index b1175cbf7663..e65f3243f1c5 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -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, diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index ed23e6602804..424434cd9d9d 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -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 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) { diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 61c4e3deae95..16ad528aa4b9 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -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; } diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index b767d92c1e37..6d48ad968e36 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -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 domDoc = do_GetInterface(aParent); nsCOMPtr 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 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."); } diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 6ec4b6be68b3..7107b627c224 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -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); } diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 2a69f7f03e90..f7baf440b93c 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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 rootStyle; const nsStyleFont *rootStyleFont = aStyleFont; - nsIContent* docElement = aPresContext->Document()->GetRootContent(); + Element* docElement = aPresContext->Document()->GetRootElement(); rootStyle = aPresContext->StyleSet()->ResolveStyleFor(docElement, nsnull); diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index d7cd32b5a628..78b8a037c0ea 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -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. diff --git a/layout/xul/base/src/nsBoxObject.cpp b/layout/xul/base/src/nsBoxObject.cpp index 2bd3b48e0b12..a05fb44eab0d 100644 --- a/layout/xul/base/src/nsBoxObject.cpp +++ b/layout/xul/base/src/nsBoxObject.cpp @@ -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 diff --git a/layout/xul/base/src/nsXULTooltipListener.cpp b/layout/xul/base/src/nsXULTooltipListener.cpp index a5b45cd90a6d..261bd42803ae 100644 --- a/layout/xul/base/src/nsXULTooltipListener.cpp +++ b/layout/xul/base/src/nsXULTooltipListener.cpp @@ -381,7 +381,7 @@ nsXULTooltipListener::CheckTreeBodyMove(nsIDOMMouseEvent* aMouseEvent) nsCOMPtr bx; nsIDocument* doc = sourceNode->GetDocument(); if (doc) { - nsCOMPtr docElement = do_QueryInterface(doc->GetRootContent()); + nsCOMPtr docElement = do_QueryInterface(doc->GetRootElement()); if (docElement) { doc->GetBoxObjectFor(docElement, getter_AddRefs(bx)); } diff --git a/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp index d11566bd0f1d..7449edfa5189 100644 --- a/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp +++ b/toolkit/components/typeaheadfind/src/nsTypeAheadFind.cpp @@ -711,7 +711,7 @@ nsTypeAheadFind::GetSearchContainers(nsISupports *aContainer, } if (!rootContent) - rootContent = doc->GetRootContent(); + rootContent = doc->GetRootElement(); nsCOMPtr 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; } diff --git a/uriloader/prefetch/nsOfflineCacheUpdate.cpp b/uriloader/prefetch/nsOfflineCacheUpdate.cpp index 697391d772da..1eaeda7b7d4f 100644 --- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp +++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp @@ -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 root = do_QueryInterface(content); + nsCOMPtr root = do_QueryInterface(doc->GetRootElement()); if (!root) continue;