From ab59e4df7ac42c2cbd398ef0aaa48366e8ed2ddd Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Thu, 18 Feb 1999 23:55:10 +0000 Subject: [PATCH] updated for nsCOMPtr (no implicit construction from raw pointers) owners should check that they agree with my choices for |dont_QueryInterface|, |do_QueryInterface| and |dont_AddRef| --- content/base/src/nsContentIterator.cpp | 8 ++-- content/base/src/nsRange.cpp | 40 +++++++++---------- .../html/document/src/nsHTMLContentSink.cpp | 4 +- content/xml/document/src/nsXMLContentSink.cpp | 2 +- layout/base/nsCSSFrameConstructor.cpp | 6 +-- layout/base/src/nsContentIterator.cpp | 8 ++-- layout/base/src/nsRange.cpp | 40 +++++++++---------- layout/base/src/nsRangeList.cpp | 20 +++++----- layout/generic/nsObjectFrame.cpp | 2 +- layout/html/base/src/nsObjectFrame.cpp | 2 +- .../html/document/src/nsHTMLContentSink.cpp | 4 +- .../html/forms/src/nsButtonControlFrame.cpp | 12 +++--- .../html/style/src/nsCSSFrameConstructor.cpp | 6 +-- layout/xml/document/src/nsXMLContentSink.cpp | 2 +- layout/xul/base/src/nsProgressMeterFrame.cpp | 4 +- layout/xul/base/src/nsToolboxFrame.cpp | 4 +- layout/xul/base/src/nsToolboxFrame.h | 2 +- 17 files changed, 81 insertions(+), 85 deletions(-) diff --git a/content/base/src/nsContentIterator.cpp b/content/base/src/nsContentIterator.cpp index a56a00dc636..a686f8ee1bb 100644 --- a/content/base/src/nsContentIterator.cpp +++ b/content/base/src/nsContentIterator.cpp @@ -142,9 +142,7 @@ nsresult nsContentIterator::QueryInterface(const nsIID& aIID, ******************************************************/ nsContentIterator::nsContentIterator() : - mCurNode(nsnull), - mFirst(nsnull), - mLast(nsnull), + // don't need to explicitly initialize |nsCOMPtr|s, they will automatically be NULL mIsDone(PR_FALSE) { NS_INIT_REFCNT(); @@ -166,9 +164,9 @@ nsresult nsContentIterator::Init(nsIContent* aRoot) if (!aRoot) return NS_ERROR_NULL_POINTER; - nsCOMPtr root(aRoot); + nsCOMPtr root( dont_QueryInterface(aRoot) ); mFirst = GetDeepFirstChild(root); - mLast = aRoot; + mLast = root; mCurNode = mFirst; return NS_OK; } diff --git a/content/base/src/nsRange.cpp b/content/base/src/nsRange.cpp index f792188ff1a..dd2dffed8f0 100644 --- a/content/base/src/nsRange.cpp +++ b/content/base/src/nsRange.cpp @@ -208,7 +208,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode, if (!outEndOffset) return false; - nsCOMPtr theDOMNode(aNode); + nsCOMPtr theDOMNode( do_QueryInterface(aNode) ); PRInt32 indx; theDOMNode->GetParentNode(getter_AddRefs(*outParent)); @@ -217,7 +217,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode, // can't make a parent/offset pair to represent start or // end of the root node, becasue it has no parent. // so instead represent it by (node,0) and (node,numChildren) - *outParent = aNode; + *outParent = do_QueryInterface(aNode); nsCOMPtr cN(do_QueryInterface(*outParent)); if (!cN) return false; @@ -880,7 +880,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset) if (!aParent) return NS_ERROR_NULL_POINTER; - nsCOMPtrtheParent(aParent); + nsCOMPtrtheParent( dont_QueryInterface(aParent) ); // must be in same document as endpoint, else // endpoint is collapsed to new start. @@ -901,7 +901,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset) nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling); nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -910,7 +910,7 @@ nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling) nsresult nsRange::SetStartAfter(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling) + 1; nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -923,7 +923,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) if (!aParent) return NS_ERROR_NULL_POINTER; - nsCOMPtrtheParent(aParent); + nsCOMPtrtheParent( dont_QueryInterface(aParent) ); // must be in same document as startpoint, else // endpoint is collapsed to new end. @@ -944,7 +944,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling); nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -953,7 +953,7 @@ nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling) nsresult nsRange::SetEndAfter(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling) + 1; nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -984,7 +984,7 @@ nsresult nsRange::Unposition() nsresult nsRange::SelectNode(nsIDOMNode* aN) { nsCOMPtr parent; - nsCOMPtr theNode(aN); + nsCOMPtr theNode( dont_QueryInterface(aN) ); nsresult res = aN->GetParentNode(getter_AddRefs(parent)); if (!NS_SUCCEEDED(res)) @@ -996,7 +996,7 @@ nsresult nsRange::SelectNode(nsIDOMNode* aN) nsresult nsRange::SelectNodeContents(nsIDOMNode* aN) { - nsCOMPtr theNode(aN); + nsCOMPtr theNode( dont_QueryInterface(aN) ); nsCOMPtr aChildNodes; nsresult res = aN->GetChildNodes(getter_AddRefs(aChildNodes)); @@ -1120,7 +1120,7 @@ nsresult nsRange::DeleteContents() // remove the nodes on the delete list while (deleteList.Count()) { - cN = NS_STATIC_CAST(nsIContent*, deleteList.ElementAt(0)); + cN = do_QueryInterface(NS_STATIC_CAST(nsIContent*, deleteList.ElementAt(0))); res = cN->GetParent(*getter_AddRefs(cParent)); res = cParent->IndexOf(cN,indx); res = cParent->RemoveChildAt(indx, PR_TRUE); @@ -1502,7 +1502,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset) // sanity check - null nodes shouldn't have enclosed ranges if (!aParentNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr parent(aParentNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); // quick return if no range list nsVoidArray *theRangeList; parent->GetRangeList(theRangeList); @@ -1517,7 +1517,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset) if (NS_SUCCEEDED(res)) return res; if (!domNode) return NS_ERROR_UNEXPECTED; - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); @@ -1547,8 +1547,8 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns // sanity check - null nodes shouldn't have enclosed ranges if (!aParentNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr parent(aParentNode); - nsCOMPtr removed(aRemovedNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); + nsCOMPtr removed( dont_QueryInterface(aRemovedNode) ); // quick return if no range list nsVoidArray *theRangeList; parent->GetRangeList(theRangeList); @@ -1564,7 +1564,7 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns if (!domNode) return NS_ERROR_UNEXPECTED; // any ranges that are in the parentNode may need to have offsets updated - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); @@ -1605,8 +1605,8 @@ nsresult nsRange::OwnerChildReplaced(nsIContent* aParentNode, PRInt32 aOffset, n // but we do need to pop out any range endpoints inside the subtree // rooted by aReplacedNode. - nsCOMPtr parent(aParentNode); - nsCOMPtr replaced(aReplacedNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); + nsCOMPtr replaced( dont_QueryInterface(aReplacedNode) ); nsCOMPtr parentDomNode; nsresult res; @@ -1625,7 +1625,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged, // sanity check - null nodes shouldn't have enclosed ranges if (!aTextNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr textNode(aTextNode); + nsCOMPtr textNode( dont_QueryInterface(aTextNode) ); nsVoidArray *theRangeList; aTextNode->GetRangeList(theRangeList); // the caller already checked to see if there was a range list @@ -1640,7 +1640,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged, if (!domNode) return NS_ERROR_UNEXPECTED; // any ranges that are in the textNode may need to have offsets updated - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index e830bd3958a..c7ed9092cb4 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -2042,10 +2042,10 @@ void HTMLContentSink::ScrollToRef() { if (mNotAtRef && (nsnull != mRef) && (nsnull != mRefContent)) { - // See if the ref content has been reflowed by finding it's frame + // See if the ref content has been reflowed by finding its frame PRInt32 i, ns = mDocument->GetNumberOfShells(); for (i = 0; i < ns; i++) { - nsCOMPtr shell(mDocument->GetShellAt(i)); + nsCOMPtr shell( dont_AddRef(mDocument->GetShellAt(i)) ); if (shell) { nsIFrame* frame; shell->GetPrimaryFrameFor(mRefContent, &frame); diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp index 1d7027d9d4c..018819c91a0 100644 --- a/content/xml/document/src/nsXMLContentSink.cpp +++ b/content/xml/document/src/nsXMLContentSink.cpp @@ -230,7 +230,7 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) // XXX this is silly; who cares? PRInt32 i, ns = mDocument->GetNumberOfShells(); for (i = 0; i < ns; i++) { - nsCOMPtr shell(mDocument->GetShellAt(i)); + nsCOMPtr shell( dont_AddRef(mDocument->GetShellAt(i)) ); if (shell) { nsCOMPtr vm; shell->GetViewManager(getter_AddRefs(vm)); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 75e7e48567c..78d2a80e99b 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -581,7 +581,7 @@ nsCSSFrameConstructor::ConstructTableGroupFrame(nsIPresContext* aPresContext, (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == styleDisplay->mDisplay) : (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == styleDisplay->mDisplay); - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); nsCOMPtr parentStyleContext; aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); const nsStyleDisplay* parentDisplay = @@ -720,7 +720,7 @@ nsCSSFrameConstructor::ConstructTableRowFrame(nsIPresContext* aPresContext, // if groupStyleContext gets set, both it and styleContext need to be released nsCOMPtr groupStyleContext; - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); const nsStyleDisplay* parentDisplay = GetDisplay(aParentFrame); if ((NS_STYLE_DISPLAY_TABLE_ROW_GROUP == parentDisplay->mDisplay) || @@ -875,7 +875,7 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresContext* aPresContext, const nsStyleDisplay* parentDisplay = (const nsStyleDisplay*) parentStyleContext->GetStyleData(eStyleStruct_Display); - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); PRBool wrapContent = PR_FALSE; if (NS_STYLE_DISPLAY_TABLE_ROW == parentDisplay->mDisplay) { diff --git a/layout/base/src/nsContentIterator.cpp b/layout/base/src/nsContentIterator.cpp index a56a00dc636..a686f8ee1bb 100644 --- a/layout/base/src/nsContentIterator.cpp +++ b/layout/base/src/nsContentIterator.cpp @@ -142,9 +142,7 @@ nsresult nsContentIterator::QueryInterface(const nsIID& aIID, ******************************************************/ nsContentIterator::nsContentIterator() : - mCurNode(nsnull), - mFirst(nsnull), - mLast(nsnull), + // don't need to explicitly initialize |nsCOMPtr|s, they will automatically be NULL mIsDone(PR_FALSE) { NS_INIT_REFCNT(); @@ -166,9 +164,9 @@ nsresult nsContentIterator::Init(nsIContent* aRoot) if (!aRoot) return NS_ERROR_NULL_POINTER; - nsCOMPtr root(aRoot); + nsCOMPtr root( dont_QueryInterface(aRoot) ); mFirst = GetDeepFirstChild(root); - mLast = aRoot; + mLast = root; mCurNode = mFirst; return NS_OK; } diff --git a/layout/base/src/nsRange.cpp b/layout/base/src/nsRange.cpp index f792188ff1a..dd2dffed8f0 100644 --- a/layout/base/src/nsRange.cpp +++ b/layout/base/src/nsRange.cpp @@ -208,7 +208,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode, if (!outEndOffset) return false; - nsCOMPtr theDOMNode(aNode); + nsCOMPtr theDOMNode( do_QueryInterface(aNode) ); PRInt32 indx; theDOMNode->GetParentNode(getter_AddRefs(*outParent)); @@ -217,7 +217,7 @@ PRBool GetNodeBracketPoints(nsIContent* aNode, // can't make a parent/offset pair to represent start or // end of the root node, becasue it has no parent. // so instead represent it by (node,0) and (node,numChildren) - *outParent = aNode; + *outParent = do_QueryInterface(aNode); nsCOMPtr cN(do_QueryInterface(*outParent)); if (!cN) return false; @@ -880,7 +880,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset) if (!aParent) return NS_ERROR_NULL_POINTER; - nsCOMPtrtheParent(aParent); + nsCOMPtrtheParent( dont_QueryInterface(aParent) ); // must be in same document as endpoint, else // endpoint is collapsed to new start. @@ -901,7 +901,7 @@ nsresult nsRange::SetStart(nsIDOMNode* aParent, PRInt32 aOffset) nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling); nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -910,7 +910,7 @@ nsresult nsRange::SetStartBefore(nsIDOMNode* aSibling) nsresult nsRange::SetStartAfter(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling) + 1; nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -923,7 +923,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) if (!aParent) return NS_ERROR_NULL_POINTER; - nsCOMPtrtheParent(aParent); + nsCOMPtrtheParent( dont_QueryInterface(aParent) ); // must be in same document as startpoint, else // endpoint is collapsed to new end. @@ -944,7 +944,7 @@ nsresult nsRange::SetEnd(nsIDOMNode* aParent, PRInt32 aOffset) nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling); nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -953,7 +953,7 @@ nsresult nsRange::SetEndBefore(nsIDOMNode* aSibling) nsresult nsRange::SetEndAfter(nsIDOMNode* aSibling) { - nsCOMPtrtheSibling(aSibling); + nsCOMPtrtheSibling( dont_QueryInterface(aSibling) ); PRInt32 indx = IndexOf(theSibling) + 1; nsIDOMNode *nParent; theSibling->GetParentNode(&nParent); @@ -984,7 +984,7 @@ nsresult nsRange::Unposition() nsresult nsRange::SelectNode(nsIDOMNode* aN) { nsCOMPtr parent; - nsCOMPtr theNode(aN); + nsCOMPtr theNode( dont_QueryInterface(aN) ); nsresult res = aN->GetParentNode(getter_AddRefs(parent)); if (!NS_SUCCEEDED(res)) @@ -996,7 +996,7 @@ nsresult nsRange::SelectNode(nsIDOMNode* aN) nsresult nsRange::SelectNodeContents(nsIDOMNode* aN) { - nsCOMPtr theNode(aN); + nsCOMPtr theNode( dont_QueryInterface(aN) ); nsCOMPtr aChildNodes; nsresult res = aN->GetChildNodes(getter_AddRefs(aChildNodes)); @@ -1120,7 +1120,7 @@ nsresult nsRange::DeleteContents() // remove the nodes on the delete list while (deleteList.Count()) { - cN = NS_STATIC_CAST(nsIContent*, deleteList.ElementAt(0)); + cN = do_QueryInterface(NS_STATIC_CAST(nsIContent*, deleteList.ElementAt(0))); res = cN->GetParent(*getter_AddRefs(cParent)); res = cParent->IndexOf(cN,indx); res = cParent->RemoveChildAt(indx, PR_TRUE); @@ -1502,7 +1502,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset) // sanity check - null nodes shouldn't have enclosed ranges if (!aParentNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr parent(aParentNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); // quick return if no range list nsVoidArray *theRangeList; parent->GetRangeList(theRangeList); @@ -1517,7 +1517,7 @@ nsresult nsRange::OwnerChildInserted(nsIContent* aParentNode, PRInt32 aOffset) if (NS_SUCCEEDED(res)) return res; if (!domNode) return NS_ERROR_UNEXPECTED; - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); @@ -1547,8 +1547,8 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns // sanity check - null nodes shouldn't have enclosed ranges if (!aParentNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr parent(aParentNode); - nsCOMPtr removed(aRemovedNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); + nsCOMPtr removed( dont_QueryInterface(aRemovedNode) ); // quick return if no range list nsVoidArray *theRangeList; parent->GetRangeList(theRangeList); @@ -1564,7 +1564,7 @@ nsresult nsRange::OwnerChildRemoved(nsIContent* aParentNode, PRInt32 aOffset, ns if (!domNode) return NS_ERROR_UNEXPECTED; // any ranges that are in the parentNode may need to have offsets updated - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); @@ -1605,8 +1605,8 @@ nsresult nsRange::OwnerChildReplaced(nsIContent* aParentNode, PRInt32 aOffset, n // but we do need to pop out any range endpoints inside the subtree // rooted by aReplacedNode. - nsCOMPtr parent(aParentNode); - nsCOMPtr replaced(aReplacedNode); + nsCOMPtr parent( dont_QueryInterface(aParentNode) ); + nsCOMPtr replaced( dont_QueryInterface(aReplacedNode) ); nsCOMPtr parentDomNode; nsresult res; @@ -1625,7 +1625,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged, // sanity check - null nodes shouldn't have enclosed ranges if (!aTextNode) return NS_ERROR_UNEXPECTED; - nsCOMPtr textNode(aTextNode); + nsCOMPtr textNode( dont_QueryInterface(aTextNode) ); nsVoidArray *theRangeList; aTextNode->GetRangeList(theRangeList); // the caller already checked to see if there was a range list @@ -1640,7 +1640,7 @@ nsresult nsRange::TextOwnerChanged(nsIContent* aTextNode, PRInt32 aStartChanged, if (!domNode) return NS_ERROR_UNEXPECTED; // any ranges that are in the textNode may need to have offsets updated - while (theRange = NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop)))) + while (theRange = do_QueryInterface(NS_STATIC_CAST(nsRange*, (theRangeList->ElementAt(loop))))) { // sanity check - do range and content agree over ownership? res = theRange->ContentOwnsUs(domNode); diff --git a/layout/base/src/nsRangeList.cpp b/layout/base/src/nsRangeList.cpp index 5ce04dfeb4e..806e25db40d 100644 --- a/layout/base/src/nsRangeList.cpp +++ b/layout/base/src/nsRangeList.cpp @@ -421,7 +421,7 @@ PRInt32 nsRangeList::GetAnchorOffset() void nsRangeList::setAnchor(nsIDOMNode* node, PRInt32 offset) { - mAnchorNode = node; + mAnchorNode = dont_QueryInterface(node); mAnchorOffset = offset; } @@ -437,7 +437,7 @@ PRInt32 nsRangeList::GetFocusOffset() void nsRangeList::setFocus(nsIDOMNode* node, PRInt32 offset) { - mFocusNode = node; + mFocusNode = dont_QueryInterface(node); mFocusOffset = offset; } @@ -713,8 +713,8 @@ nsRangeList::TakeFocus(nsIFocusTracker *aTracker, nsIFrame *aFrame, PRInt32 aOff return NS_ERROR_FAILURE; if (NS_FAILED(parent->GetParentNode(getter_AddRefs(parent2))) || !parent2) return NS_ERROR_FAILURE; - parent = nsnull;//just force a release now even though we dont have to. - parent2 = nsnull; + parent = nsCOMPtr();//just force a release now even though we dont have to. + parent2 = nsCOMPtr(); nsIFrame *frame; nsIFrame *anchor; @@ -912,14 +912,14 @@ nsRangeList::ResetSelection(nsIFocusTracker *aTracker, nsIFrame *aStartFrame) nsCOMPtr anchorContent; nsCOMPtr frameContent; if (GetAnchorNode() && GetFocusNode()){ - anchorContent = GetAnchorNode(); - frameContent = GetFocusNode(); + anchorContent = do_QueryInterface(GetAnchorNode()); + frameContent = do_QueryInterface(GetFocusNode()); } for (PRInt32 i =0; iCount(); i++){ //end content and start content do NOT necessarily mean anchor and focus frame respectively PRInt32 anchorOffset = -1; //the frames themselves can talk to the presentation manager. we will tell them PRInt32 frameOffset = -1; // where we would "like" to have the anchor pt. actually we count on it. - range = (nsISupports *)mRangeArray->ElementAt(i); + range = do_QueryInterface((nsISupports *)mRangeArray->ElementAt(i)); DEBUG_OUT_RANGE(range); range->GetStartParent(getter_AddRefs(startNode)); range->GetStartOffset(&startOffset); @@ -1000,7 +1000,7 @@ nsresult nsRangeList::NotifySelectionListeners() for (PRInt32 i = 0; i < mSelectionListeners->Count();i++) { - nsCOMPtr thisEntry(mSelectionListeners->ElementAt(i)); + nsCOMPtr thisEntry(dont_QueryInterface(mSelectionListeners->ElementAt(i))); nsCOMPtr thisListener(do_QueryInterface(thisEntry)); if (thisListener) thisListener->NotifySelectionChanged(); @@ -1099,7 +1099,7 @@ nsRangeList::IsCollapsed(PRBool* aIsCollapsed) *aIsCollapsed = PR_FALSE; return NS_OK; } - nsCOMPtr nsisup (mRangeArray->ElementAt(0)); + nsCOMPtr nsisup (dont_QueryInterface(mRangeArray->ElementAt(0))); nsCOMPtr range; if (!NS_SUCCEEDED(nsisup->QueryInterface(kIDOMRangeIID, getter_AddRefs(range)))) @@ -1149,7 +1149,7 @@ nsRangeList::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) PRInt32 i; for (i = 0; i < mRangeArray->Count(); i++) { - nsCOMPtr range (mRangeArray->ElementAt(i)); + nsCOMPtr range (do_QueryInterface(mRangeArray->ElementAt(i))); nsCOMPtr endNode; PRInt32 endOffset; diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index efa560337d1..2684d067e39 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -1335,7 +1335,7 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetDocumentBase(const char* *result) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); - nsCOMPtr docURL(doc->GetDocumentURL()); + nsCOMPtr docURL( dont_AddRef(doc->GetDocumentURL()) ); nsresult rv = docURL->GetSpec(result); diff --git a/layout/html/base/src/nsObjectFrame.cpp b/layout/html/base/src/nsObjectFrame.cpp index efa560337d1..2684d067e39 100644 --- a/layout/html/base/src/nsObjectFrame.cpp +++ b/layout/html/base/src/nsObjectFrame.cpp @@ -1335,7 +1335,7 @@ NS_IMETHODIMP nsPluginInstanceOwner :: GetDocumentBase(const char* *result) nsCOMPtr doc; shell->GetDocument(getter_AddRefs(doc)); - nsCOMPtr docURL(doc->GetDocumentURL()); + nsCOMPtr docURL( dont_AddRef(doc->GetDocumentURL()) ); nsresult rv = docURL->GetSpec(result); diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp index e830bd3958a..c7ed9092cb4 100644 --- a/layout/html/document/src/nsHTMLContentSink.cpp +++ b/layout/html/document/src/nsHTMLContentSink.cpp @@ -2042,10 +2042,10 @@ void HTMLContentSink::ScrollToRef() { if (mNotAtRef && (nsnull != mRef) && (nsnull != mRefContent)) { - // See if the ref content has been reflowed by finding it's frame + // See if the ref content has been reflowed by finding its frame PRInt32 i, ns = mDocument->GetNumberOfShells(); for (i = 0; i < ns; i++) { - nsCOMPtr shell(mDocument->GetShellAt(i)); + nsCOMPtr shell( dont_AddRef(mDocument->GetShellAt(i)) ); if (shell) { nsIFrame* frame; shell->GetPrimaryFrameFor(mRefContent, &frame); diff --git a/layout/html/forms/src/nsButtonControlFrame.cpp b/layout/html/forms/src/nsButtonControlFrame.cpp index d5aec978a45..44be184cf99 100644 --- a/layout/html/forms/src/nsButtonControlFrame.cpp +++ b/layout/html/forms/src/nsButtonControlFrame.cpp @@ -328,8 +328,8 @@ nsButtonControlFrame::GetDesiredSize(nsIPresContext* aPresContext, aDesiredLayoutSize.descent = 0; } else { #ifdef NS_GFX_RENDER_FORM_ELEMENTS - nsCOMPtr outlineStyle(mStyleContext); - nsCOMPtr sbAtom (NS_NewAtom(":button-outline")); + nsCOMPtr outlineStyle( dont_QueryInterface(mStyleContext) ); + nsCOMPtr sbAtom ( dont_QueryInterface(NS_NewAtom(":button-outline")) ); aPresContext->ProbePseudoStyleContextFor(mContent, sbAtom, mStyleContext, PR_FALSE, getter_AddRefs(outlineStyle)); const nsStyleSpacing* outline = (const nsStyleSpacing*)outlineStyle->GetStyleData(eStyleStruct_Spacing); @@ -433,14 +433,14 @@ nsButtonControlFrame::PaintButton(nsIPresContext& aPresContext, //nsIStyleContext* kidSC; - nsCOMPtr outlineStyle(mStyleContext); - nsCOMPtr outlineAtom (NS_NewAtom(":button-outline")); + nsCOMPtr outlineStyle( dont_QueryInterface(mStyleContext) ); + nsCOMPtr outlineAtom ( dont_QueryInterface(NS_NewAtom(":button-outline")) ); aPresContext.ProbePseudoStyleContextFor(mContent, outlineAtom, mStyleContext, PR_FALSE, getter_AddRefs(outlineStyle)); - nsCOMPtr focusStyle(mStyleContext); - nsCOMPtr focusAtom (NS_NewAtom(":button-focus")); + nsCOMPtr focusStyle( dont_QueryInterface(mStyleContext) ); + nsCOMPtr focusAtom ( dont_QueryInterface(NS_NewAtom(":button-focus")) ); aPresContext.ProbePseudoStyleContextFor(mContent, focusAtom, mStyleContext, PR_FALSE, getter_AddRefs(focusStyle)); diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 75e7e48567c..78d2a80e99b 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -581,7 +581,7 @@ nsCSSFrameConstructor::ConstructTableGroupFrame(nsIPresContext* aPresContext, (NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP == styleDisplay->mDisplay) : (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == styleDisplay->mDisplay); - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); nsCOMPtr parentStyleContext; aParentFrame->GetStyleContext(getter_AddRefs(parentStyleContext)); const nsStyleDisplay* parentDisplay = @@ -720,7 +720,7 @@ nsCSSFrameConstructor::ConstructTableRowFrame(nsIPresContext* aPresContext, // if groupStyleContext gets set, both it and styleContext need to be released nsCOMPtr groupStyleContext; - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); const nsStyleDisplay* parentDisplay = GetDisplay(aParentFrame); if ((NS_STYLE_DISPLAY_TABLE_ROW_GROUP == parentDisplay->mDisplay) || @@ -875,7 +875,7 @@ nsCSSFrameConstructor::ConstructTableCellFrame(nsIPresContext* aPresContext, const nsStyleDisplay* parentDisplay = (const nsStyleDisplay*) parentStyleContext->GetStyleData(eStyleStruct_Display); - nsCOMPtr styleContext(aStyleContext); + nsCOMPtr styleContext( dont_QueryInterface(aStyleContext) ); PRBool wrapContent = PR_FALSE; if (NS_STYLE_DISPLAY_TABLE_ROW == parentDisplay->mDisplay) { diff --git a/layout/xml/document/src/nsXMLContentSink.cpp b/layout/xml/document/src/nsXMLContentSink.cpp index 1d7027d9d4c..018819c91a0 100644 --- a/layout/xml/document/src/nsXMLContentSink.cpp +++ b/layout/xml/document/src/nsXMLContentSink.cpp @@ -230,7 +230,7 @@ nsXMLContentSink::DidBuildModel(PRInt32 aQualityLevel) // XXX this is silly; who cares? PRInt32 i, ns = mDocument->GetNumberOfShells(); for (i = 0; i < ns; i++) { - nsCOMPtr shell(mDocument->GetShellAt(i)); + nsCOMPtr shell( dont_AddRef(mDocument->GetShellAt(i)) ); if (shell) { nsCOMPtr vm; shell->GetViewManager(getter_AddRefs(vm)); diff --git a/layout/xul/base/src/nsProgressMeterFrame.cpp b/layout/xul/base/src/nsProgressMeterFrame.cpp index 7778f926321..b0d0fbf209e 100644 --- a/layout/xul/base/src/nsProgressMeterFrame.cpp +++ b/layout/xul/base/src/nsProgressMeterFrame.cpp @@ -707,7 +707,7 @@ nsProgressMeterFrame :: RefreshStyleContext(nsIPresContext* aPresContext, PR_FALSE, &newStyleContext); if (newStyleContext != aCurrentStyle->get()) - *aCurrentStyle = newStyleContext; + *aCurrentStyle = dont_QueryInterface(newStyleContext); } // RefreshStyleContext @@ -720,7 +720,7 @@ nsProgressMeterFrame :: RefreshStyleContext(nsIPresContext* aPresContext, NS_IMETHODIMP nsProgressMeterFrame :: ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext) { - nsCOMPtr old ( mStyleContext ); + nsCOMPtr old ( dont_QueryInterface(mStyleContext) ); // this re-resolves |mStyleContext|, so it may change nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext); diff --git a/layout/xul/base/src/nsToolboxFrame.cpp b/layout/xul/base/src/nsToolboxFrame.cpp index 92592bbc19c..5e32a179e09 100644 --- a/layout/xul/base/src/nsToolboxFrame.cpp +++ b/layout/xul/base/src/nsToolboxFrame.cpp @@ -119,7 +119,7 @@ nsToolboxFrame :: RefreshStyleContext(nsIPresContext* aPresContext, PR_FALSE, &newStyleContext); if (newStyleContext != aCurrentStyle->get()) - *aCurrentStyle = newStyleContext; + *aCurrentStyle = dont_QueryInterface(newStyleContext); } // RefreshStyleContext @@ -132,7 +132,7 @@ nsToolboxFrame :: RefreshStyleContext(nsIPresContext* aPresContext, NS_IMETHODIMP nsToolboxFrame :: ReResolveStyleContext ( nsIPresContext* aPresContext, nsIStyleContext* aParentContext) { - nsCOMPtr old ( mStyleContext ); + nsCOMPtr old ( dont_QueryInterface(mStyleContext) ); // this re-resolves |mStyleContext|, so it may change nsresult rv = nsFrame::ReResolveStyleContext(aPresContext, aParentContext); diff --git a/layout/xul/base/src/nsToolboxFrame.h b/layout/xul/base/src/nsToolboxFrame.h index 4a8e9707399..70bce9da89b 100644 --- a/layout/xul/base/src/nsToolboxFrame.h +++ b/layout/xul/base/src/nsToolboxFrame.h @@ -71,7 +71,7 @@ protected: enum { kNoGrippyHilighted = -1 } ; struct TabInfo { - TabInfo ( ) : mToolbar(nsnull), mCollapsed(PR_TRUE) { }; + TabInfo ( ) : mCollapsed(PR_TRUE) { }; void SetProperties ( const nsRect & inBounds, const nsCOMPtr & inContent, PRBool inCollapsed )