From 76799ff74301c90be579cee6d5440ad3dfa56a88 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 24 Jul 2003 17:30:52 +0000 Subject: [PATCH] Add an nsIDocument* GetOwnerDocument() to nsGenericElement, deCOMify nsINodeInfo a tad. Bug 211634, r=jkeiser, sr=jst --- content/base/public/nsINodeInfo.h | 4 ++-- content/base/src/nsContentUtils.cpp | 4 ++-- content/base/src/nsGenericElement.cpp | 22 +++--------------- content/base/src/nsGenericElement.h | 6 +++++ content/base/src/nsImageLoadingContent.cpp | 10 +++++++- content/base/src/nsNodeInfo.cpp | 6 ++--- content/base/src/nsNodeInfo.h | 3 ++- content/base/src/nsNodeInfoManager.cpp | 8 +++---- content/base/src/nsNodeInfoManager.h | 2 +- content/events/src/nsEventListenerManager.cpp | 3 ++- .../html/content/src/nsGenericHTMLElement.cpp | 23 ++++--------------- .../html/content/src/nsHTMLAnchorElement.cpp | 7 +++--- .../html/content/src/nsHTMLAreaElement.cpp | 7 +++--- .../html/content/src/nsHTMLBodyElement.cpp | 7 ++---- .../html/content/src/nsHTMLFontElement.cpp | 7 ++---- .../html/content/src/nsHTMLFrameElement.cpp | 7 ++---- .../content/src/nsHTMLFrameSetElement.cpp | 17 ++++---------- .../content/src/nsHTMLTableCellElement.cpp | 7 ++---- .../html/content/src/nsHTMLTableElement.cpp | 7 ++---- .../content/src/nsHTMLTableRowElement.cpp | 7 ++---- .../content/src/nsHTMLTableSectionElement.cpp | 7 ++---- .../style/src/nsDOMCSSAttrDeclaration.cpp | 7 ++---- content/xml/document/src/nsXMLContentSink.cpp | 3 +-- content/xul/content/src/nsXULElement.cpp | 3 +-- extensions/cookie/nsImgManager.cpp | 6 +++-- layout/generic/nsImageFrame.cpp | 3 +-- layout/generic/nsImageMap.cpp | 3 +-- layout/html/base/src/nsImageFrame.cpp | 3 +-- layout/html/base/src/nsImageMap.cpp | 3 +-- layout/style/nsDOMCSSAttrDeclaration.cpp | 7 ++---- 30 files changed, 76 insertions(+), 133 deletions(-) diff --git a/content/base/public/nsINodeInfo.h b/content/base/public/nsINodeInfo.h index d432668bbf0..156802512a2 100644 --- a/content/base/public/nsINodeInfo.h +++ b/content/base/public/nsINodeInfo.h @@ -282,7 +282,7 @@ public: /* * Retrieve a pointer to the document that owns this node info. */ - NS_IMETHOD GetDocument(nsIDocument** aDocument) const = 0; + virtual nsIDocument* GetDocument() const = 0; /* * Retrieve a pointer to the principal for the document of this node info. @@ -360,7 +360,7 @@ public: * Retrieve a pointer to the document that owns this node info * manager. */ - NS_IMETHOD GetDocument(nsIDocument** aDocument) = 0; + virtual nsIDocument* GetDocument() const = 0; /** * Gets the principal of the document associated with this. diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 74e405218db..ab02b57ade2 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -787,7 +787,7 @@ nsContentUtils::ReparentContentWrapper(nsIContent *aContent, return NS_OK; } - nsCOMPtr old_doc(aOldDocument); + nsIDocument* old_doc = aOldDocument; if (!old_doc) { nsCOMPtr ni; @@ -795,7 +795,7 @@ nsContentUtils::ReparentContentWrapper(nsIContent *aContent, aContent->GetNodeInfo(getter_AddRefs(ni)); if (ni) { - ni->GetDocument(getter_AddRefs(old_doc)); + old_doc = ni->GetDocument(); } if (!old_doc) { diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index f0e916f9301..08b40999bf2 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1145,13 +1145,7 @@ nsGenericElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) { NS_ENSURE_ARG_POINTER(aOwnerDocument); - nsCOMPtr doc(mDocument); - - if (!doc) { - // If we're not part of the document we can check if our nodeinfo - // can get at the document - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } + nsIDocument* doc = GetOwnerDocument(); if (doc) { return CallQueryInterface(doc, aOwnerDocument); @@ -1776,9 +1770,7 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, if (aDocument) { // check the document on the nodeinfo to see whether we need a // new nodeinfo - nsCOMPtr nodeinfoDoc; - mNodeInfo->GetDocument(getter_AddRefs(nodeinfoDoc)); - if (aDocument != nodeinfoDoc) { + if (aDocument != mNodeInfo->GetDocument()) { // get a new nodeinfo nsCOMPtr name = mNodeInfo->GetNameAtom(); nsCOMPtr prefix = mNodeInfo->GetPrefixAtom(); @@ -2246,11 +2238,7 @@ nsGenericElement::StringToAttribute(nsIAtom* aAttribute, NS_IMETHODIMP nsGenericElement::GetBaseURL(nsIURI** aBaseURL) const { - nsCOMPtr doc = mDocument; - - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } + nsIDocument* doc = GetOwnerDocument(); // Our base URL depends on whether we have an xml:base attribute, as // well as on whether any of our ancestors do. @@ -2893,10 +2881,6 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, return NS_ERROR_DOM_SECURITY_ERR; } - nsCOMPtr document; - - GetDocument(getter_AddRefs(document)); - /* * Make sure the new child is not "this" node or one of this nodes * ancestors. Doing this check here should be safe even if newContent diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h index bbdd218f618..c2bb0509081 100644 --- a/content/base/src/nsGenericElement.h +++ b/content/base/src/nsGenericElement.h @@ -52,6 +52,7 @@ #include "nsIStyleSheetLinkingElement.h" #include "nsICSSStyleSheet.h" #include "nsICSSLoaderObserver.h" +#include "nsIDocument.h" #include "nsVoidArray.h" #include "nsILinkHandler.h" #include "nsGenericDOMNodeList.h" @@ -697,6 +698,11 @@ protected: sEventListenerManagersHash.ops); } + nsIDocument* GetOwnerDocument() const + { + return mDocument ? mDocument : mNodeInfo->GetDocument(); + } + /** * The document for this content */ diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index 7e1db495a51..a8b7d924956 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -237,6 +237,13 @@ nsImageLoadingContent::GetImageBlocked(PRBool* aBlocked) *aBlocked = mImageIsBlocked; return NS_OK; } + +NS_IMETHODIMP +nsImageLoadingContent::GetImageURI(nsIURI** aURI) +{ + NS_NOTREACHED("Subclasses need to implement this"); + return NS_ERROR_NOT_AVAILABLE; +} NS_IMETHODIMP nsImageLoadingContent::AddObserver(imgIDecoderObserver* aObserver) @@ -565,10 +572,11 @@ nsImageLoadingContent::GetOurDocument(nsIDocument** aDocument) rv = thisContent->GetDocument(aDocument); if (!*aDocument) { // nodeinfo time + // XXXbz GetOwnerDocument nsCOMPtr nodeInfo; rv = thisContent->GetNodeInfo(getter_AddRefs(nodeInfo)); if (nodeInfo) { - rv = nodeInfo->GetDocument(aDocument); + NS_IF_ADDREF(*aDocument = nodeInfo->GetDocument()); } } diff --git a/content/base/src/nsNodeInfo.cpp b/content/base/src/nsNodeInfo.cpp index 6dad0883349..810cca96551 100644 --- a/content/base/src/nsNodeInfo.cpp +++ b/content/base/src/nsNodeInfo.cpp @@ -288,10 +288,10 @@ nsNodeInfo::PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult) aResult); } -NS_IMETHODIMP -nsNodeInfo::GetDocument(nsIDocument** aDocument) const +nsIDocument* +nsNodeInfo::GetDocument() const { - return mOwnerManager->GetDocument(aDocument); + return mOwnerManager->GetDocument(); } NS_IMETHODIMP diff --git a/content/base/src/nsNodeInfo.h b/content/base/src/nsNodeInfo.h index 2e7c297edf0..2337bbbc7d6 100644 --- a/content/base/src/nsNodeInfo.h +++ b/content/base/src/nsNodeInfo.h @@ -70,7 +70,8 @@ public: NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo** aResult); NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo** aResult); - NS_IMETHOD GetDocument(nsIDocument** aDocument) const; + + virtual nsIDocument* GetDocument() const; NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal) const; // nsNodeInfo diff --git a/content/base/src/nsNodeInfoManager.cpp b/content/base/src/nsNodeInfoManager.cpp index e7c5b03df80..2be66f2e581 100644 --- a/content/base/src/nsNodeInfoManager.cpp +++ b/content/base/src/nsNodeInfoManager.cpp @@ -315,12 +315,10 @@ nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName, return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo); } -NS_IMETHODIMP -nsNodeInfoManager::GetDocument(nsIDocument** aDocument) +nsIDocument* +nsNodeInfoManager::GetDocument() const { - NS_IF_ADDREF(*aDocument = mDocument); - - return NS_OK; + return mDocument; } NS_IMETHODIMP diff --git a/content/base/src/nsNodeInfoManager.h b/content/base/src/nsNodeInfoManager.h index b7ac2c72ce1..360907e4730 100644 --- a/content/base/src/nsNodeInfoManager.h +++ b/content/base/src/nsNodeInfoManager.h @@ -68,7 +68,7 @@ public: NS_IMETHOD GetNodeInfo(const nsAString& aQualifiedName, const nsAString& aNamespaceURI, nsINodeInfo** aNodeInfo); - NS_IMETHOD GetDocument(nsIDocument** aDocument); + virtual nsIDocument* GetDocument() const; NS_IMETHOD GetDocumentPrincipal(nsIPrincipal** aPrincipal); NS_IMETHOD SetDocumentPrincipal(nsIPrincipal* aPrincipal); NS_IMETHOD GetNodeInfoArray(nsISupportsArray** aArray); diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 1adbb1acc52..0a65faf7425 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -2672,10 +2672,11 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) targetContent->GetDocument(getter_AddRefs(document)); if (!document) { + // XXXbz GetOwnerDocument nsCOMPtr nodeInfo; targetContent->GetNodeInfo(getter_AddRefs(nodeInfo)); if (nodeInfo) { - nodeInfo->GetDocument(getter_AddRefs(document)); + document = nodeInfo->GetDocument(); } } diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index 0c1ae7a5609..3fc2393033d 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -850,8 +850,7 @@ nsGenericHTMLElement::GetInnerHTML(nsAString& aInnerHTML) { aInnerHTML.Truncate(); - nsCOMPtr doc; - mNodeInfo->GetDocument(getter_AddRefs(doc)); + nsCOMPtr doc = GetOwnerDocument(); if (!doc) { return NS_OK; // We rely on the document for doing HTML conversion } @@ -902,8 +901,7 @@ nsGenericHTMLElement::SetInnerHTML(const nsAString& aInnerHTML) nsCOMPtr df; - nsCOMPtr doc; - mNodeInfo->GetDocument(getter_AddRefs(doc)); + nsCOMPtr doc = GetOwnerDocument(); nsCOMPtr scx; PRBool scripts_enabled = PR_FALSE; @@ -2336,11 +2334,7 @@ nsGenericHTMLElement::GetInlineStyleRule(nsIStyleRule** aStyleRule) nsresult nsGenericHTMLElement::GetBaseURL(nsIURI** aBaseURL) const { - nsCOMPtr doc(mDocument); - - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } + nsIDocument* doc = GetOwnerDocument(); if (mAttributes && mAttributes->HasAttribute(nsHTMLAtoms::_baseHref, kNameSpaceID_None)) { @@ -3077,10 +3071,7 @@ nsGenericHTMLElement::AttrToURI(nsIAtom* aAttrName, nsAString& aAbsoluteURI) nsCOMPtr baseURI; GetBaseURL(getter_AddRefs(baseURI)); - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } + nsIDocument* doc = GetOwnerDocument(); nsCOMPtr attrURI; rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(attrURI), @@ -3124,11 +3115,7 @@ nsGenericHTMLElement::ParseStyleAttribute(const nsAString& aValue, nsHTMLValue& nsresult result = NS_OK; NS_ASSERTION(mNodeInfo, "If we don't have a nodeinfo, we are very screwed"); - nsCOMPtr doc = mDocument; - - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } + nsIDocument* doc = GetOwnerDocument(); if (doc) { PRBool isCSS = PR_TRUE; // assume CSS until proven otherwise diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index c72a4715736..0edd0658772 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -384,10 +384,9 @@ nsHTMLAnchorElement::GetProtocol(nsAString& aProtocol) if (NS_FAILED(rv)) return rv; - nsCOMPtr doc; - mNodeInfo->GetDocument(getter_AddRefs(doc)); - - return GetProtocolFromHrefString(href, aProtocol, doc); + // XXX this should really use GetHrefURI and not do so much string stuff + return GetProtocolFromHrefString(href, aProtocol, + nsGenericHTMLContainerElement::GetOwnerDocument()); } NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLAreaElement.cpp b/content/html/content/src/nsHTMLAreaElement.cpp index da203f5a715..fd846ed2e0f 100644 --- a/content/html/content/src/nsHTMLAreaElement.cpp +++ b/content/html/content/src/nsHTMLAreaElement.cpp @@ -344,10 +344,9 @@ nsHTMLAreaElement::GetProtocol(nsAString& aProtocol) if (NS_FAILED(rv)) return rv; - nsCOMPtr doc; - mNodeInfo->GetDocument(getter_AddRefs(doc)); - - return GetProtocolFromHrefString(href, aProtocol, doc); + // XXX this should really use GetHrefURI and not do so much string stuff + return GetProtocolFromHrefString(href, aProtocol, + nsGenericHTMLLeafElement::GetOwnerDocument()); } NS_IMETHODIMP diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index 75bca894510..1a58c98b372 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -485,11 +485,8 @@ nsHTMLBodyElement::StringToAttribute(nsIAtom* aAttribute, (aAttribute == nsHTMLAtoms::link) || (aAttribute == nsHTMLAtoms::alink) || (aAttribute == nsHTMLAtoms::vlink)) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLFontElement.cpp b/content/html/content/src/nsHTMLFontElement.cpp index 586f0714d3c..b66441fede5 100644 --- a/content/html/content/src/nsHTMLFontElement.cpp +++ b/content/html/content/src/nsHTMLFontElement.cpp @@ -183,11 +183,8 @@ nsHTMLFontElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::color) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLFrameElement.cpp b/content/html/content/src/nsHTMLFrameElement.cpp index 300e5a479da..501aba7d3d8 100644 --- a/content/html/content/src/nsHTMLFrameElement.cpp +++ b/content/html/content/src/nsHTMLFrameElement.cpp @@ -234,11 +234,8 @@ nsHTMLFrameElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLLeafElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLFrameSetElement.cpp b/content/html/content/src/nsHTMLFrameSetElement.cpp index 64d3394248e..1fab3be99b1 100644 --- a/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -350,11 +350,8 @@ nsHTMLFrameSetElement::StringToAttribute(nsIAtom* aAttribute, nsHTMLValue& aResult) { if (aAttribute == nsHTMLAtoms::bordercolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } @@ -512,14 +509,8 @@ nsHTMLFrameSetElement::ParseRowColSpec(nsString& aSpec, // Treat 0* as 1* in quirks mode (bug 40383) nsCompatibility mode = eCompatibility_FullStandards; - nsCOMPtr htmlDocument; - if (mDocument) { - htmlDocument = do_QueryInterface(mDocument); - } else { - nsCOMPtr doc; - mNodeInfo->GetDocument(getter_AddRefs(doc)); - htmlDocument = do_QueryInterface(doc); - } + nsCOMPtr htmlDocument = + do_QueryInterface(nsGenericHTMLContainerElement::GetOwnerDocument()); if (htmlDocument) { htmlDocument->GetCompatibilityMode(mode); } diff --git a/content/html/content/src/nsHTMLTableCellElement.cpp b/content/html/content/src/nsHTMLTableCellElement.cpp index e3f9a0c4686..14b39f8dc35 100644 --- a/content/html/content/src/nsHTMLTableCellElement.cpp +++ b/content/html/content/src/nsHTMLTableCellElement.cpp @@ -393,11 +393,8 @@ nsHTMLTableCellElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLTableElement.cpp b/content/html/content/src/nsHTMLTableElement.cpp index e130068ff68..c46c92b0677 100644 --- a/content/html/content/src/nsHTMLTableElement.cpp +++ b/content/html/content/src/nsHTMLTableElement.cpp @@ -1029,11 +1029,8 @@ nsHTMLTableElement::StringToAttribute(nsIAtom* aAttribute, } else if (aAttribute == nsHTMLAtoms::bgcolor || aAttribute == nsHTMLAtoms::bordercolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp index 9046e7b3f08..8d67a0953be 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/nsHTMLTableRowElement.cpp @@ -555,11 +555,8 @@ nsHTMLTableRowElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/content/src/nsHTMLTableSectionElement.cpp b/content/html/content/src/nsHTMLTableSectionElement.cpp index 1387a2e916b..6651c2c9b97 100644 --- a/content/html/content/src/nsHTMLTableSectionElement.cpp +++ b/content/html/content/src/nsHTMLTableSectionElement.cpp @@ -311,11 +311,8 @@ nsHTMLTableSectionElement::StringToAttribute(nsIAtom* aAttribute, } } else if (aAttribute == nsHTMLAtoms::bgcolor) { - nsCOMPtr doc(mDocument); - if (!doc) { - mNodeInfo->GetDocument(getter_AddRefs(doc)); - } - if (aResult.ParseColor(aValue, doc)) { + if (aResult.ParseColor(aValue, + nsGenericHTMLContainerElement::GetOwnerDocument())) { return NS_CONTENT_ATTR_HAS_VALUE; } } diff --git a/content/html/style/src/nsDOMCSSAttrDeclaration.cpp b/content/html/style/src/nsDOMCSSAttrDeclaration.cpp index e4130536955..15bb7878510 100644 --- a/content/html/style/src/nsDOMCSSAttrDeclaration.cpp +++ b/content/html/style/src/nsDOMCSSAttrDeclaration.cpp @@ -163,11 +163,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI, if (NS_FAILED(result)) { return result; } - nsCOMPtr doc; - result = nodeInfo->GetDocument(getter_AddRefs(doc)); - if (NS_FAILED(result)) { - return result; - } + // XXXbz GetOwnerDocument + nsIDocument* doc = nodeInfo->GetDocument(); mContent->GetBaseURL(aBaseURI); diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index f0e84cda0aa..88b40f73ab7 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -1620,8 +1620,7 @@ MathMLElementFactoryImpl::CreateInstanceByTag(nsINodeInfo* aNodeInfo, static const char kMathMLStyleSheetURI[] = "resource:///res/mathml.css"; // this bit of code is to load mathml.css on demand - nsCOMPtr doc; - aNodeInfo->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = aNodeInfo->GetDocument(); if (doc) { nsCOMPtr htmlContainer(do_QueryInterface(doc)); if (htmlContainer) { diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 8100ba08211..c830369a8c1 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -883,8 +883,7 @@ nsXULElement::GetOwnerDocument(nsIDOMDocument** aOwnerDocument) if (mDocument) { return CallQueryInterface(mDocument, aOwnerDocument); } - nsCOMPtr doc; - NodeInfo()->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = NodeInfo()->GetDocument(); if (doc) { return CallQueryInterface(doc, aOwnerDocument); } diff --git a/extensions/cookie/nsImgManager.cpp b/extensions/cookie/nsImgManager.cpp index db2e2da987e..053e30de98e 100644 --- a/extensions/cookie/nsImgManager.cpp +++ b/extensions/cookie/nsImgManager.cpp @@ -155,13 +155,15 @@ NS_IMETHODIMP nsImgManager::ShouldLoad(PRInt32 aContentType, nsCOMPtr content = do_QueryInterface(aContext); NS_ASSERTION(content, "no content available"); if (content) { + // XXXbz GetOwnerDocument rv = content->GetDocument(getter_AddRefs(doc)); if (NS_FAILED(rv) || !doc) { rv = content->GetNodeInfo(getter_AddRefs(nodeinfo)); if (NS_FAILED(rv) || !nodeinfo) return rv; - rv = nodeinfo->GetDocument(getter_AddRefs(doc)); - if (NS_FAILED(rv) || !doc) return rv; + doc = nodeinfo->GetDocument(); + // XXX what should this code do if there is really no document? + if (!doc) return NS_OK; } rv = doc->GetBaseURL(getter_AddRefs(baseURI)); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 275c3a47576..7cb85c87c1c 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1702,8 +1702,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext, nsCOMPtr nodeInfo; mContent->GetNodeInfo(getter_AddRefs(nodeInfo)); NS_ASSERTION(nodeInfo, "Image content without a nodeinfo?"); - nsCOMPtr doc; - nodeInfo->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString charset; if (doc) { doc->GetDocumentCharacterSet(charset); diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index 8189fd757cf..97d47e4aacb 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -452,8 +452,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) mArea->GetNodeInfo(getter_AddRefs(nodeInfo)); NS_ASSERTION(nodeInfo, "Element with no nodeinfo"); - nsCOMPtr doc; - nodeInfo->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString urlSpec; if (doc) { nsCOMPtr uri; diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index 275c3a47576..7cb85c87c1c 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -1702,8 +1702,7 @@ nsImageFrame::HandleEvent(nsIPresContext* aPresContext, nsCOMPtr nodeInfo; mContent->GetNodeInfo(getter_AddRefs(nodeInfo)); NS_ASSERTION(nodeInfo, "Image content without a nodeinfo?"); - nsCOMPtr doc; - nodeInfo->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString charset; if (doc) { doc->GetDocumentCharacterSet(charset); diff --git a/layout/html/base/src/nsImageMap.cpp b/layout/html/base/src/nsImageMap.cpp index 8189fd757cf..97d47e4aacb 100644 --- a/layout/html/base/src/nsImageMap.cpp +++ b/layout/html/base/src/nsImageMap.cpp @@ -452,8 +452,7 @@ void RectArea::ParseCoords(const nsAString& aSpec) mArea->GetNodeInfo(getter_AddRefs(nodeInfo)); NS_ASSERTION(nodeInfo, "Element with no nodeinfo"); - nsCOMPtr doc; - nodeInfo->GetDocument(getter_AddRefs(doc)); + nsIDocument* doc = nodeInfo->GetDocument(); nsCAutoString urlSpec; if (doc) { nsCOMPtr uri; diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index e4130536955..15bb7878510 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -163,11 +163,8 @@ nsDOMCSSAttributeDeclaration::GetCSSParsingEnvironment(nsIURI** aBaseURI, if (NS_FAILED(result)) { return result; } - nsCOMPtr doc; - result = nodeInfo->GetDocument(getter_AddRefs(doc)); - if (NS_FAILED(result)) { - return result; - } + // XXXbz GetOwnerDocument + nsIDocument* doc = nodeInfo->GetDocument(); mContent->GetBaseURL(aBaseURI);