diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index a260bdc9e6b..73660b6221b 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -10182,7 +10182,8 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, // Is it a box? If so we can coelesce. nsresult rv; - nsCOMPtr box = do_QueryInterface(aFrame, &rv); + nsIBox *box; + rv = CallQueryInterface(aFrame, &box); if (NS_SUCCEEDED(rv) && box) { nsBoxLayoutState state(aPresContext); box->MarkStyleChange(state); diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index a260bdc9e6b..73660b6221b 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -10182,7 +10182,8 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIPresContext* aPresContext, // Is it a box? If so we can coelesce. nsresult rv; - nsCOMPtr box = do_QueryInterface(aFrame, &rv); + nsIBox *box; + rv = CallQueryInterface(aFrame, &box); if (NS_SUCCEEDED(rv) && box) { nsBoxLayoutState state(aPresContext); box->MarkStyleChange(state); diff --git a/mozilla/layout/xul/base/src/grid/nsGrid.cpp b/mozilla/layout/xul/base/src/grid/nsGrid.cpp index 6985d325169..651f21f257a 100644 --- a/mozilla/layout/xul/base/src/grid/nsGrid.cpp +++ b/mozilla/layout/xul/base/src/grid/nsGrid.cpp @@ -292,8 +292,8 @@ nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns) nsIFrame* scrolledFrame = nsnull; scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - nsCOMPtr b = do_QueryInterface(scrolledFrame); - child = b; + if (NS_FAILED(CallQueryInterface(scrolledFrame, &child))) + child = nsnull; } nsCOMPtr layout; @@ -1463,7 +1463,8 @@ nsGrid::GetScrolledBox(nsIBox* aChild) nsIFrame* scrolledFrame = nsnull; scrollFrame->GetScrolledFrame(nsnull, scrolledFrame); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - nsCOMPtr box = do_QueryInterface(scrolledFrame); + nsIBox *box = nsnull; + CallQueryInterface(scrolledFrame, &box); return box; } diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp index 12c8123d9e1..5e1bdc87dac 100644 --- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp @@ -364,9 +364,8 @@ nsBoxFrame::Init(nsIPresContext* aPresContext, nsresult rv = nsContainerFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); // see if we need a widget. Get our parent. Querty interface the parent we are given. - nsCOMPtr parent (do_QueryInterface(aParent)); - - if (parent) { + nsIBox *parent; + if (aParent && NS_SUCCEEDED(CallQueryInterface(aParent, &parent))) { PRBool needsWidget = PR_FALSE; parent->ChildrenMustHaveWidgets(needsWidget); if (needsWidget) { @@ -2055,7 +2054,7 @@ nsBoxFrame::GetFrameForPoint(nsIPresContext* aPresContext, // if the kid had a child before see if this child has mouse // though. PRBool isAdaptor = PR_FALSE; - nsCOMPtr box = mInner->GetBoxForFrame(hit, isAdaptor); + nsIBox *box = mInner->GetBoxForFrame(hit, isAdaptor); if (box) { PRBool mouseThrough = PR_FALSE; box->GetMouseThrough(mouseThrough); diff --git a/mozilla/layout/xul/base/src/nsIBox.h b/mozilla/layout/xul/base/src/nsIBox.h index 332869c0b8b..80a3c04944a 100644 --- a/mozilla/layout/xul/base/src/nsIBox.h +++ b/mozilla/layout/xul/base/src/nsIBox.h @@ -42,6 +42,9 @@ nsBoxFrame is a frame that can lay its children out either vertically or horizontally. It lays them out according to a min max or preferred size. + nsIBox is implemented on frames and thus should not be refcounted. + Eventually it should not inherit from nsISupports. + **/ #ifndef nsIBox_h___ diff --git a/mozilla/layout/xul/base/src/nsIMenuParent.h b/mozilla/layout/xul/base/src/nsIMenuParent.h index bc0854dbf52..ed64ebe405a 100644 --- a/mozilla/layout/xul/base/src/nsIMenuParent.h +++ b/mozilla/layout/xul/base/src/nsIMenuParent.h @@ -47,6 +47,11 @@ class nsIMenuFrame; class nsIDOMKeyEvent; +/* + * nsIMenuParent is implemented on frames and thus should not be + * refcounted. Eventually it should not inherit from nsISupports. + */ + class nsIMenuParent : public nsISupports { public: diff --git a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp index af72362ebfa..1682b755850 100644 --- a/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsLeafBoxFrame.cpp @@ -109,8 +109,8 @@ nsLeafBoxFrame::Init(nsIPresContext* aPresContext, nsresult rv = nsLeafFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); // see if we need a widget - nsCOMPtr parent (do_QueryInterface(aParent)); - if (parent) { + nsIBox *parent; + if (aParent && NS_SUCCEEDED(CallQueryInterface(aParent, &parent))) { PRBool needsWidget = PR_FALSE; parent->ChildrenMustHaveWidgets(needsWidget); if (needsWidget) { diff --git a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp index 0ee49dd4a8d..f09874e76c5 100644 --- a/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -1138,7 +1138,8 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated) mBottomFrame = mTopFrame; if (mTopFrame) { - nsCOMPtr box(do_QueryInterface(mTopFrame)); + nsIBox *box; + CallQueryInterface(mTopFrame, &box); return box; } @@ -1147,7 +1148,8 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated) mBottomFrame = mTopFrame; if (mTopFrame && mRowsToPrepend <= 0) { - nsCOMPtr box(do_QueryInterface(mTopFrame)); + nsIBox *box; + CallQueryInterface(mTopFrame, &box); return box; } @@ -1189,7 +1191,8 @@ nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated) mBottomFrame = mTopFrame; - nsCOMPtr box(do_QueryInterface(mTopFrame)); + nsIBox *box; + CallQueryInterface(mTopFrame, &box); return box; } else return GetFirstItemBox(++aOffset, 0); @@ -1244,10 +1247,13 @@ nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset, PRBool* aCreat } } - if (result) - mBottomFrame = result; + if (!result) + return nsnull; - nsCOMPtr box(do_QueryInterface(result)); + mBottomFrame = result; + + nsIBox *box; + CallQueryInterface(result, &box); return box; } diff --git a/mozilla/layout/xul/base/src/nsMenuDismissalListener.cpp b/mozilla/layout/xul/base/src/nsMenuDismissalListener.cpp index 7cb69861033..63d3e5faf49 100644 --- a/mozilla/layout/xul/base/src/nsMenuDismissalListener.cpp +++ b/mozilla/layout/xul/base/src/nsMenuDismissalListener.cpp @@ -133,7 +133,7 @@ NS_IMETHODIMP nsMenuDismissalListener::GetSubmenuWidgetChain(nsISupportsArray **_retval) { NS_NewISupportsArray ( _retval ); - nsCOMPtr curr ( dont_QueryInterface(mMenuParent) ); + nsIMenuParent *curr = mMenuParent; while ( curr ) { nsCOMPtr widget; curr->GetWidget ( getter_AddRefs(widget) ); @@ -142,14 +142,12 @@ nsMenuDismissalListener::GetSubmenuWidgetChain(nsISupportsArray **_retval) // move up the chain nsIFrame* currAsFrame = nsnull; - if ( NS_SUCCEEDED(curr->QueryInterface(NS_GET_IID(nsIFrame), NS_REINTERPRET_CAST(void**,&currAsFrame))) ) { + if ( NS_SUCCEEDED(CallQueryInterface(curr, &currAsFrame)) ) { nsIFrame* parentFrame = nsnull; currAsFrame->GetParent(&parentFrame); - nsIMenuParent* next; nsCOMPtr menuFrame ( do_QueryInterface(parentFrame) ); if ( menuFrame ) { - menuFrame->GetMenuParent ( &next ); // Advance to next parent - curr = dont_AddRef(next); + menuFrame->GetMenuParent ( &curr ); // Advance to next parent } else { // we are a menuParent but not a menuFrame. This is probably the case diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index af90bd25a1e..1582251fac7 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -170,8 +170,7 @@ nsMenuFrame::SetParent(const nsIFrame* aParent) nsIFrame* currFrame = (nsIFrame*)aParent; while (!mMenuParent && currFrame) { // Set our menu parent. - nsCOMPtr menuparent(do_QueryInterface(currFrame)); - mMenuParent = menuparent.get(); + CallQueryInterface(currFrame, &mMenuParent); currFrame->GetParent(&currFrame); } @@ -193,8 +192,7 @@ nsMenuFrame::Init(nsIPresContext* aPresContext, nsIFrame* currFrame = aParent; while (!mMenuParent && currFrame) { // Set our menu parent. - nsCOMPtr menuparent(do_QueryInterface(currFrame)); - mMenuParent = menuparent.get(); + CallQueryInterface(currFrame, &mMenuParent); currFrame->GetParent(&currFrame); } @@ -289,7 +287,8 @@ nsMenuFrame::SetInitialChildList(nsIPresContext* aPresContext, // the popup frame list. nsIFrame* frame = frames.FirstChild(); while (frame) { - nsCOMPtr menuPar(do_QueryInterface(frame)); + nsIMenuParent *menuPar; + CallQueryInterface(frame, &menuPar); if (menuPar) { // Remove this frame from the list and place it in the other list. frames.RemoveFrame(frame); @@ -849,7 +848,8 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag) ActivateMenu(PR_TRUE); - nsCOMPtr childPopup(do_QueryInterface(frame)); + nsIMenuParent *childPopup = nsnull; + CallQueryInterface(frame, &childPopup); UpdateDismissalListener(childPopup); OnCreated(); @@ -1931,9 +1931,10 @@ nsMenuFrame::InsertFrames(nsIPresContext* aPresContext, nsCOMPtr tag; nsresult rv; - nsCOMPtr menuPar(do_QueryInterface(aFrameList)); - if (menuPar) { - nsCOMPtr menupopup(do_QueryInterface(aFrameList)); + nsIMenuParent *menuPar; + if (aFrameList && NS_SUCCEEDED(CallQueryInterface(aFrameList, &menuPar))) { + nsIBox *menupopup; + CallQueryInterface(aFrameList, &menupopup); NS_ASSERTION(menupopup,"Popup is not a box!!!"); menupopup->SetParentBox(this); mPopupFrames.InsertFrames(nsnull, nsnull, aFrameList); @@ -1960,9 +1961,10 @@ nsMenuFrame::AppendFrames(nsIPresContext* aPresContext, nsCOMPtr tag; nsresult rv; - nsCOMPtr menuPar(do_QueryInterface(aFrameList)); - if (menuPar) { - nsCOMPtr menupopup(do_QueryInterface(aFrameList)); + nsIMenuParent *menuPar; + if (aFrameList && NS_SUCCEEDED(CallQueryInterface(aFrameList, &menuPar))) { + nsIBox *menupopup; + CallQueryInterface(aFrameList, &menupopup); NS_ASSERTION(menupopup,"Popup is not a box!!!"); menupopup->SetParentBox(this); @@ -2137,7 +2139,8 @@ nsMenuFrame::GetBoxInfo(nsIPresContext* aPresContext, const nsHTMLReflowState& a frame = mPopupFrames.FirstChild(); } - nsCOMPtr box(do_QueryInterface(frame)); + nsIBox *box; + CallQueryInterface(frame, &box); nsCalculatedBoxInfo childInfo(frame); box->GetBoxInfo(aPresContext, aReflowState, childInfo); GetRedefinedMinPrefMax(aPresContext, this, childInfo); diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.h b/mozilla/layout/xul/base/src/nsMenuFrame.h index cebb7a82515..c4f6af70008 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.h +++ b/mozilla/layout/xul/base/src/nsMenuFrame.h @@ -160,7 +160,7 @@ public: NS_IMETHOD SetParent(const nsIFrame* aParent); - NS_IMETHOD GetMenuParent(nsIMenuParent** aResult) { NS_IF_ADDREF(mMenuParent); *aResult = mMenuParent; return NS_OK; }; + NS_IMETHOD GetMenuParent(nsIMenuParent** aResult) { *aResult = mMenuParent; return NS_OK; }; NS_IMETHOD GetMenuChild(nsIFrame** aResult) { *aResult = mPopupFrames.FirstChild(); return NS_OK; } NS_IMETHOD GetRadioGroupName(nsString &aName) { aName = mGroupName; return NS_OK; }; NS_IMETHOD GetMenuType(nsMenuType &aType) { aType = mType; return NS_OK; }; diff --git a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp index 4f1b9b9e016..955f9b0ad29 100644 --- a/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -273,8 +273,8 @@ nsMenuPopupFrame::MarkStyleChange(nsBoxLayoutState& aState) return parent->RelayoutDirtyChild(aState, this); else { nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext); - nsCOMPtr box(do_QueryInterface(popupSet)); - if (box) { + nsIBox *box; + if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) { nsBoxLayoutState state(mPresContext); box->MarkDirtyChildren(state); // Mark the popupset as dirty. } @@ -333,8 +333,8 @@ nsMenuPopupFrame::MarkDirty(nsBoxLayoutState& aState) return parent->RelayoutDirtyChild(aState, this); else { nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext); - nsCOMPtr box(do_QueryInterface(popupSet)); - if (box) { + nsIBox *box; + if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) { nsBoxLayoutState state(mPresContext); box->MarkDirtyChildren(state); // Mark the popupset as dirty. } @@ -381,8 +381,8 @@ nsMenuPopupFrame::RelayoutDirtyChild(nsBoxLayoutState& aState, nsIBox* aChild) return parentBox->RelayoutDirtyChild(aState, this); else { nsIPopupSetFrame* popupSet = GetPopupSetFrame(mPresContext); - nsCOMPtr box(do_QueryInterface(popupSet)); - if (box) { + nsIBox *box; + if (popupSet && NS_SUCCEEDED(CallQueryInterface(popupSet, &box))) { nsBoxLayoutState state(mPresContext); box->MarkDirtyChildren(state); // Mark the popupset as dirty. } @@ -1894,7 +1894,8 @@ nsMenuPopupFrame::DismissChain() nsIFrame* frame; GetParent(&frame); if (frame) { - nsCOMPtr menuFrame = do_QueryInterface(frame); + nsIMenuFrame *menuFrame = nsnull; + CallQueryInterface(frame, &menuFrame); if (!menuFrame) { nsIPopupSetFrame* popupSetFrame = GetPopupSetFrame(mPresContext); if (popupSetFrame) { @@ -1910,8 +1911,8 @@ nsMenuPopupFrame::DismissChain() menuFrame->OpenMenu(PR_FALSE); // Get the parent. - nsCOMPtr menuParent; - menuFrame->GetMenuParent(getter_AddRefs(menuParent)); + nsIMenuParent* menuParent; + menuFrame->GetMenuParent(&menuParent); if (menuParent) menuParent->DismissChain(); } diff --git a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp index 5da48cc356d..c2eb4fc094f 100644 --- a/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/mozilla/layout/xul/base/src/nsPopupSetFrame.cpp @@ -364,7 +364,9 @@ nsPopupSetFrame::ShowPopup(nsIContent* aElementContent, nsIContent* aPopupConten // determine if this menu is a context menu and flag it nsIFrame* activeChild = entry->mPopupFrame; - nsCOMPtr childPopup ( do_QueryInterface(activeChild) ); + nsIMenuParent* childPopup = nsnull; + if (activeChild) + CallQueryInterface(activeChild, &childPopup); if ( childPopup && aPopupType == NS_LITERAL_STRING("context") ) childPopup->SetIsContextMenu(PR_TRUE); @@ -438,7 +440,9 @@ nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag) // register the rollup listeners, etc, but not if we're a tooltip nsIFrame* activeChild = aEntry->mPopupFrame; - nsCOMPtr childPopup = do_QueryInterface(activeChild); + nsIMenuParent* childPopup = nsnull; + if (activeChild) + CallQueryInterface(activeChild, &childPopup); if (aEntry->mPopupType != NS_LITERAL_STRING("tooltip")) UpdateDismissalListener(childPopup); @@ -462,7 +466,9 @@ nsPopupSetFrame::OpenPopup(nsPopupFrameList* aEntry, PRBool aActivateFlag) } // Remove any keyboard navigators - nsCOMPtr childPopup = do_QueryInterface(aEntry->mPopupFrame); + nsIMenuParent* childPopup = nsnull; + if (aEntry->mPopupFrame) + CallQueryInterface(aEntry->mPopupFrame, &childPopup); if (childPopup) childPopup->RemoveKeyboardNavigator(); diff --git a/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp b/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp index efca275db80..97fbeda7c0a 100644 --- a/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsScrollBoxObject.cpp @@ -119,7 +119,8 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(PRInt32 dindexes) // get our box nsIFrame* frame = GetFrame(); - nsCOMPtr box (do_QueryInterface(frame)); + nsIBox* box; + CallQueryInterface(frame, &box); nsRect rect; nsIBox* scrolledBox; @@ -219,7 +220,8 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) // get our box nsIFrame* frame = GetFrame(); - nsCOMPtr box (do_QueryInterface(frame)); + nsIBox *box; + CallQueryInterface(frame, &box); nsRect rect, crect; nsIBox* scrolledBox; @@ -298,7 +300,8 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) // get our box nsIFrame* frame = GetFrame(); - nsCOMPtr box (do_QueryInterface(frame)); + nsIBox* box; + CallQueryInterface(frame, &box); nsRect rect, crect; nsIBox* scrolledBox; diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 67df772afd8..3b81b1b8ab3 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -3376,7 +3376,8 @@ nsTreeBodyFrame::EnsureColumns() if (!colsFrame) return; - nsCOMPtr colsBox(do_QueryInterface(colsFrame)); + nsIBox* colsBox; + CallQueryInterface(colsFrame, &colsBox); nsIBox* colBox = nsnull; colsBox->GetChildBox(&colBox); nsTreeColumn* currCol = nsnull;