From c0b8dd79be2e0d4e5db44a94229386cdad0c1d99 Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Mon, 12 Jan 2009 14:20:59 -0500 Subject: [PATCH] Bug 396185 - Make nsIFrame derivatives and helper abstract classes use a different dynamic-cast system than nsISupports: * we know all types frames may be cast to at compile time, so instead of extensible GUID IIDs, use a big enum (see nsQueryFrame::FrameIID) * eliminate all vestiges of refcounting, since frames aren't refcounted Some frames (SVG frames in particular) still implement nsISupports-derived interfaces, for example nsISVGValue. There is a FrameIID for nsISVGValue that lets you go from a frame to the XPCOM interface, but you can't query back. r+sr=roc nsITextControlFrame didn't have an IID the first time around, but this wasn't a compile error because nsITextControlFrame::kFrameIID inherited from nsIFormControlFrame::kFrameIID. I've added a static analysis pass to verify the correct behavior, since I can't figure out a way to make the compiler do it. --HG-- extra : rebase_source : 4894a2ca0278e2ab92f27459db77165f8348cf41 --- accessible/public/nsIAccessibilityService.idl | 34 +-- .../src/base/nsAccessibilityService.cpp | 99 +++---- accessible/src/base/nsAccessibilityService.h | 3 +- accessible/src/base/nsAccessible.cpp | 3 +- accessible/src/base/nsCoreUtils.cpp | 3 +- accessible/src/base/nsRootAccessible.cpp | 3 +- accessible/src/html/nsHTMLAreaAccessible.cpp | 6 +- .../src/html/nsHTMLFormControlAccessible.cpp | 3 +- .../src/html/nsHTMLSelectAccessible.cpp | 32 +-- accessible/src/html/nsHTMLTableAccessible.cpp | 9 +- accessible/src/html/nsHyperTextAccessible.cpp | 3 +- accessible/src/msaa/nsAccessibleWrap.cpp | 3 +- content/base/src/nsFrameLoader.cpp | 3 +- content/base/src/nsGenericElement.cpp | 9 +- content/base/src/nsObjectLoadingContent.cpp | 15 +- content/events/src/nsEventStateManager.cpp | 22 +- .../html/content/src/nsGenericHTMLElement.cpp | 8 +- .../html/content/src/nsHTMLButtonElement.cpp | 4 +- .../html/content/src/nsHTMLInputElement.cpp | 38 +-- .../html/content/src/nsHTMLObjectElement.cpp | 6 +- .../html/content/src/nsHTMLSelectElement.cpp | 12 +- .../content/src/nsHTMLTextAreaElement.cpp | 26 +- .../html/document/src/nsPluginDocument.cpp | 7 +- .../content/src/nsISVGTextContentMetrics.h | 14 +- content/svg/content/src/nsISVGValue.h | 2 + .../svg/content/src/nsSVGGraphicElement.cpp | 3 +- .../svg/content/src/nsSVGPatternElement.cpp | 3 +- content/svg/content/src/nsSVGSVGElement.cpp | 12 +- .../svg/content/src/nsSVGSwitchElement.cpp | 4 +- content/svg/content/src/nsSVGTSpanElement.cpp | 23 +- content/svg/content/src/nsSVGTextElement.cpp | 23 +- .../svg/content/src/nsSVGTextPathElement.cpp | 21 +- .../svg/content/src/nsSVGTextPathElement.h | 2 +- docshell/base/nsDocShell.cpp | 11 +- editor/libeditor/html/nsTableEditor.cpp | 8 +- embedding/components/find/src/nsFind.cpp | 3 +- .../components/find/src/nsWebBrowserFind.cpp | 2 +- layout/base/nsBidiPresUtils.cpp | 6 +- layout/base/nsCSSFrameConstructor.cpp | 66 ++--- layout/base/nsCSSRendering.cpp | 11 +- layout/base/nsCaret.cpp | 3 +- layout/base/nsDocumentViewer.cpp | 4 +- layout/base/nsFrameManager.cpp | 12 +- layout/base/nsIPercentHeightObserver.h | 13 +- layout/base/nsLayoutDebugger.cpp | 5 +- layout/base/nsLayoutUtils.cpp | 25 +- layout/base/nsPresShell.cpp | 55 ++-- layout/forms/nsComboboxControlFrame.cpp | 134 ++++----- layout/forms/nsComboboxControlFrame.h | 8 +- layout/forms/nsFileControlFrame.cpp | 21 +- layout/forms/nsFileControlFrame.h | 5 +- layout/forms/nsFormControlFrame.cpp | 16 +- layout/forms/nsFormControlFrame.h | 7 +- layout/forms/nsGfxButtonControlFrame.cpp | 16 +- layout/forms/nsGfxButtonControlFrame.h | 5 +- layout/forms/nsGfxCheckboxControlFrame.cpp | 19 +- layout/forms/nsGfxCheckboxControlFrame.h | 7 +- layout/forms/nsGfxRadioControlFrame.cpp | 16 +- layout/forms/nsGfxRadioControlFrame.h | 9 +- layout/forms/nsHTMLButtonControlFrame.cpp | 28 +- layout/forms/nsHTMLButtonControlFrame.h | 5 +- layout/forms/nsICheckboxControlFrame.h | 17 +- layout/forms/nsIComboboxControlFrame.h | 17 +- layout/forms/nsIFormControlFrame.h | 15 +- layout/forms/nsIListControlFrame.h | 15 +- layout/forms/nsIRadioControlFrame.h | 17 +- layout/forms/nsISelectControlFrame.h | 17 +- layout/forms/nsITextControlFrame.h | 10 +- layout/forms/nsImageControlFrame.cpp | 35 +-- layout/forms/nsIsIndexFrame.cpp | 18 +- layout/forms/nsIsIndexFrame.h | 5 +- layout/forms/nsLegendFrame.cpp | 18 +- layout/forms/nsLegendFrame.h | 7 +- layout/forms/nsListControlFrame.cpp | 32 +-- layout/forms/nsListControlFrame.h | 3 +- layout/forms/nsTextControlFrame.cpp | 46 +-- layout/forms/nsTextControlFrame.h | 2 +- layout/generic/Makefile.in | 1 + layout/generic/nsAbsoluteContainingBlock.cpp | 8 +- layout/generic/nsBRFrame.cpp | 2 +- layout/generic/nsBlockFrame.cpp | 24 +- layout/generic/nsBlockFrame.h | 11 +- layout/generic/nsContainerFrame.cpp | 4 +- layout/generic/nsFloatManager.cpp | 1 - layout/generic/nsFrame.cpp | 78 ++--- layout/generic/nsFrame.h | 13 +- layout/generic/nsFrameFrame.cpp | 27 +- layout/generic/nsFrameList.cpp | 4 +- layout/generic/nsFrameSetFrame.cpp | 22 +- layout/generic/nsFrameSetFrame.h | 11 +- layout/generic/nsGfxScrollFrame.cpp | 91 ++---- layout/generic/nsGfxScrollFrame.h | 11 +- layout/generic/nsHTMLFrame.cpp | 32 +-- layout/generic/nsIAnonymousContentCreator.h | 16 +- layout/generic/nsICanvasFrame.h | 12 +- layout/generic/nsIFrame.h | 12 +- layout/generic/nsIFrameDebug.h | 16 +- layout/generic/nsIFrameFrame.h | 10 +- layout/generic/nsIImageFrame.h | 12 +- layout/generic/nsIObjectFrame.h | 11 +- layout/generic/nsIPageSequenceFrame.h | 20 +- layout/generic/nsIScrollableFrame.h | 9 +- layout/generic/nsIScrollableViewProvider.h | 14 +- layout/generic/nsIStatefulFrame.h | 13 +- layout/generic/nsImageFrame.cpp | 15 +- layout/generic/nsImageFrame.h | 3 +- layout/generic/nsInlineFrame.cpp | 18 +- layout/generic/nsInlineFrame.h | 9 +- layout/generic/nsLineBox.cpp | 10 +- layout/generic/nsObjectFrame.cpp | 33 +-- layout/generic/nsObjectFrame.h | 7 +- layout/generic/nsQueryFrame.h | 268 ++++++++++++++++++ layout/generic/nsSelection.cpp | 11 +- layout/generic/nsSimplePageSequence.cpp | 14 +- layout/generic/nsSimplePageSequence.h | 6 +- layout/generic/nsVideoFrame.cpp | 22 +- layout/generic/nsVideoFrame.h | 2 +- layout/generic/nsViewportFrame.cpp | 2 +- layout/mathml/base/src/nsIMathMLFrame.h | 15 +- .../base/src/nsMathMLContainerFrame.cpp | 46 +-- .../mathml/base/src/nsMathMLContainerFrame.h | 2 +- .../base/src/nsMathMLForeignFrameWrapper.cpp | 6 +- .../base/src/nsMathMLForeignFrameWrapper.h | 2 +- layout/mathml/base/src/nsMathMLFrame.cpp | 14 +- layout/mathml/base/src/nsMathMLFrame.h | 17 +- .../mathml/base/src/nsMathMLmactionFrame.cpp | 21 +- .../mathml/base/src/nsMathMLmfencedFrame.cpp | 3 +- .../mathml/base/src/nsMathMLmtableFrame.cpp | 27 +- layout/mathml/base/src/nsMathMLmtableFrame.h | 10 +- layout/printing/nsPrintEngine.cpp | 32 +-- layout/style/nsComputedDOMStyle.cpp | 3 +- layout/style/nsICSSPseudoComparator.h | 12 +- layout/svg/base/src/nsISVGChildFrame.h | 14 +- layout/svg/base/src/nsISVGGlyphFragmentLeaf.h | 12 +- layout/svg/base/src/nsISVGGlyphFragmentNode.h | 13 +- layout/svg/base/src/nsISVGSVGFrame.h | 13 +- layout/svg/base/src/nsSVGClipPathFrame.cpp | 10 +- layout/svg/base/src/nsSVGContainerFrame.cpp | 24 +- layout/svg/base/src/nsSVGContainerFrame.h | 7 +- layout/svg/base/src/nsSVGFilterFrame.cpp | 2 +- .../svg/base/src/nsSVGForeignObjectFrame.cpp | 11 +- layout/svg/base/src/nsSVGForeignObjectFrame.h | 8 +- layout/svg/base/src/nsSVGGlyphFrame.cpp | 21 +- layout/svg/base/src/nsSVGGlyphFrame.h | 5 +- layout/svg/base/src/nsSVGInnerSVGFrame.cpp | 28 +- layout/svg/base/src/nsSVGIntegrationUtils.cpp | 5 +- layout/svg/base/src/nsSVGMarkerFrame.cpp | 6 +- layout/svg/base/src/nsSVGOuterSVGFrame.cpp | 26 +- layout/svg/base/src/nsSVGOuterSVGFrame.h | 7 +- .../svg/base/src/nsSVGPathGeometryFrame.cpp | 8 +- layout/svg/base/src/nsSVGPathGeometryFrame.h | 7 +- layout/svg/base/src/nsSVGPatternFrame.cpp | 4 +- layout/svg/base/src/nsSVGSwitchFrame.cpp | 9 +- layout/svg/base/src/nsSVGTSpanFrame.cpp | 20 +- layout/svg/base/src/nsSVGTSpanFrame.h | 8 +- .../svg/base/src/nsSVGTextContainerFrame.cpp | 15 +- layout/svg/base/src/nsSVGTextContainerFrame.h | 8 +- layout/svg/base/src/nsSVGUseFrame.cpp | 16 +- layout/svg/base/src/nsSVGUtils.cpp | 31 +- layout/tables/nsITableCellLayout.h | 14 +- layout/tables/nsITableLayout.h | 13 +- layout/tables/nsTableCellFrame.cpp | 23 +- layout/tables/nsTableCellFrame.h | 3 +- layout/tables/nsTableFrame.cpp | 23 +- layout/tables/nsTableFrame.h | 3 +- layout/tables/nsTableOuterFrame.cpp | 18 +- layout/tables/nsTableOuterFrame.h | 3 +- layout/tables/nsTableRowGroupFrame.cpp | 16 +- layout/tables/nsTableRowGroupFrame.h | 7 +- layout/xul/base/public/nsIMenuFrame.h | 15 +- layout/xul/base/public/nsIScrollbarMediator.h | 22 +- layout/xul/base/src/grid/nsGrid.cpp | 10 +- .../xul/base/src/grid/nsGridRowLeafLayout.cpp | 2 +- layout/xul/base/src/nsBoxObject.cpp | 10 - layout/xul/base/src/nsContainerBoxObject.cpp | 4 +- layout/xul/base/src/nsDocElementBoxFrame.cpp | 20 +- layout/xul/base/src/nsIRootBox.h | 16 +- layout/xul/base/src/nsIScrollbarFrame.h | 14 +- layout/xul/base/src/nsListBoxBodyFrame.cpp | 39 +-- layout/xul/base/src/nsListBoxBodyFrame.h | 16 +- layout/xul/base/src/nsListBoxObject.cpp | 6 +- layout/xul/base/src/nsListItemFrame.cpp | 15 - layout/xul/base/src/nsListItemFrame.h | 2 - layout/xul/base/src/nsMenuFrame.cpp | 25 +- layout/xul/base/src/nsMenuFrame.h | 2 +- layout/xul/base/src/nsMenuPopupFrame.cpp | 7 +- layout/xul/base/src/nsPopupSetFrame.cpp | 11 +- layout/xul/base/src/nsRootBoxFrame.cpp | 25 +- layout/xul/base/src/nsScrollBoxObject.cpp | 8 +- .../xul/base/src/nsScrollbarButtonFrame.cpp | 3 +- layout/xul/base/src/nsScrollbarFrame.cpp | 19 +- layout/xul/base/src/nsScrollbarFrame.h | 7 +- layout/xul/base/src/nsSliderFrame.cpp | 7 +- layout/xul/base/src/nsSplitterFrame.cpp | 7 - layout/xul/base/src/nsSplitterFrame.h | 4 - .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 62 +--- .../xul/base/src/tree/src/nsTreeBodyFrame.h | 16 +- .../xul/base/src/tree/src/nsTreeBoxObject.cpp | 3 +- .../xul/base/src/tree/src/nsTreeColFrame.cpp | 18 -- layout/xul/base/src/tree/src/nsTreeColFrame.h | 2 - widget/src/gtk2/nsNativeThemeGTK.cpp | 4 +- widget/src/windows/nsNativeThemeWin.cpp | 13 +- 202 files changed, 1156 insertions(+), 2106 deletions(-) create mode 100644 layout/generic/nsQueryFrame.h diff --git a/accessible/public/nsIAccessibilityService.idl b/accessible/public/nsIAccessibilityService.idl index e05a91c3fe1..ae19a782f8d 100644 --- a/accessible/public/nsIAccessibilityService.idl +++ b/accessible/public/nsIAccessibilityService.idl @@ -52,29 +52,29 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode); nsIAccessible createRootAccessible(in nsIPresShell aShell, in nsIDocument aDocument); - nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame); - nsIAccessible createHyperTextAccessible(in nsISupports aFrame); - nsIAccessible createHTMLBRAccessible(in nsISupports aFrame); - nsIAccessible createHTMLButtonAccessible(in nsISupports aFrame); + nsIAccessible createHTML4ButtonAccessible(in nsIFrame aFrame); + nsIAccessible createHyperTextAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLBRAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLButtonAccessible(in nsIFrame aFrame); nsIAccessible createHTMLAccessibleByMarkup(in nsIFrame aFrame, in nsIWeakReference aWeakShell, in nsIDOMNode aDOMNode); - nsIAccessible createHTMLLIAccessible(in nsISupports aFrame, in nsISupports aBulletFrame, in AString aBulletText); - nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame); + nsIAccessible createHTMLLIAccessible(in nsIFrame aFrame, in nsIFrame aBulletFrame, in AString aBulletText); + nsIAccessible createHTMLCheckboxAccessible(in nsIFrame aFrame); nsIAccessible createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsIWeakReference aPresShell); - nsIAccessible createHTMLGenericAccessible(in nsISupports aFrame); - nsIAccessible createHTMLGroupboxAccessible(in nsISupports aFrame); - nsIAccessible createHTMLHRAccessible(in nsISupports aFrame); - nsIAccessible createHTMLImageAccessible(in nsISupports aFrame); - nsIAccessible createHTMLLabelAccessible(in nsISupports aFrame); + nsIAccessible createHTMLGenericAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLGroupboxAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLHRAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLImageAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLLabelAccessible(in nsIFrame aFrame); nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsIWeakReference aPresShell); nsIAccessible createHTMLObjectFrameAccessible(in nsObjectFrame aFrame); - nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame); + nsIAccessible createHTMLRadioButtonAccessible(in nsIFrame aFrame); nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsIWeakReference aPresShell); - nsIAccessible createHTMLTableAccessible(in nsISupports aFrame); - nsIAccessible createHTMLTableCellAccessible(in nsISupports aFrame); + nsIAccessible createHTMLTableAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLTableCellAccessible(in nsIFrame aFrame); nsIAccessible createHTMLTableHeadAccessible(in nsIDOMNode aDOMNode); - nsIAccessible createHTMLTextAccessible(in nsISupports aFrame); - nsIAccessible createHTMLTextFieldAccessible(in nsISupports aFrame); - nsIAccessible createHTMLCaptionAccessible(in nsISupports aFrame); + nsIAccessible createHTMLTextAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLTextFieldAccessible(in nsIFrame aFrame); + nsIAccessible createHTMLCaptionAccessible(in nsIFrame aFrame); nsIAccessible getAccessible(in nsIDOMNode aNode, in nsIPresShell aPresShell, in nsIWeakReference aWeakShell, diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index 59096a4a666..07d67dcd1af 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -332,11 +332,10 @@ NS_IMETHODIMP nsAccessibilityService::OnSecurityChange(nsIWebProgress *aWebProgr nsresult -nsAccessibilityService::GetInfo(nsISupports* aFrame, nsIFrame** aRealFrame, nsIWeakReference** aShell, nsIDOMNode** aNode) +nsAccessibilityService::GetInfo(nsIFrame* aFrame, nsIWeakReference** aShell, nsIDOMNode** aNode) { NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!"); - *aRealFrame = static_cast(aFrame); - nsCOMPtr content = (*aRealFrame)->GetContent(); + nsCOMPtr content = aFrame->GetContent(); nsCOMPtr node(do_QueryInterface(content)); if (!content || !node) return NS_ERROR_FAILURE; @@ -474,12 +473,11 @@ nsAccessibilityService::CreateRootAccessible(nsIPresShell *aShell, * HTML widget creation */ NS_IMETHODIMP -nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTML4ButtonAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -492,12 +490,11 @@ nsAccessibilityService::CreateHTML4ButtonAccessible(nsISupports *aFrame, nsIAcce } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLButtonAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -565,15 +562,14 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame *aFrame, } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLLIAccessible(nsISupports *aFrame, - nsISupports *aBulletFrame, +nsAccessibilityService::CreateHTMLLIAccessible(nsIFrame *aFrame, + nsIFrame *aBulletFrame, const nsAString& aBulletText, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -586,12 +582,11 @@ nsAccessibilityService::CreateHTMLLIAccessible(nsISupports *aFrame, } NS_IMETHODIMP -nsAccessibilityService::CreateHyperTextAccessible(nsISupports *aFrame, nsIAccessible **aAccessible) +nsAccessibilityService::CreateHyperTextAccessible(nsIFrame *aFrame, nsIAccessible **aAccessible) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -606,12 +601,11 @@ nsAccessibilityService::CreateHyperTextAccessible(nsISupports *aFrame, nsIAccess } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLCheckboxAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLCheckboxAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -635,12 +629,11 @@ nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsIWe } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLImageAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -658,18 +651,17 @@ nsAccessibilityService::CreateHTMLImageAccessible(nsISupports *aFrame, nsIAccess } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLGenericAccessible(nsISupports *aFrame, nsIAccessible **aAccessible) +nsAccessibilityService::CreateHTMLGenericAccessible(nsIFrame *aFrame, nsIAccessible **aAccessible) { return CreateHyperTextAccessible(aFrame, aAccessible); } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLGroupboxAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLGroupboxAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -707,11 +699,10 @@ nsAccessibilityService::CreateHTMLObjectFrameAccessible(nsObjectFrame *aFrame, { nsCOMPtr node; nsCOMPtr weakShell; - nsIFrame *frame; - GetInfo(static_cast(aFrame), &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); *aAccessible = nsnull; - if (!frame || frame->GetRect().IsEmpty()) { + if (aFrame->GetRect().IsEmpty()) { return NS_ERROR_FAILURE; } // 1) for object elements containing either HTML or TXT documents @@ -743,7 +734,7 @@ nsAccessibilityService::CreateHTMLObjectFrameAccessible(nsObjectFrame *aFrame, // 3) for images and imagemaps, or anything else with a child frame // we have the object frame, get the image frame - frame = aFrame->GetFirstChild(nsnull); + nsIFrame *frame = aFrame->GetFirstChild(nsnull); if (frame) return frame->GetAccessible(aAccessible); @@ -751,12 +742,11 @@ nsAccessibilityService::CreateHTMLObjectFrameAccessible(nsObjectFrame *aFrame, } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLRadioButtonAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -783,12 +773,11 @@ nsAccessibilityService::CreateHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLTableAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLTableAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -828,12 +817,11 @@ nsAccessibilityService::CreateHTMLTableHeadAccessible(nsIDOMNode *aDOMNode, nsIA } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLTableCellAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -846,14 +834,13 @@ nsAccessibilityService::CreateHTMLTableCellAccessible(nsISupports *aFrame, nsIAc } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLTextAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { *_retval = nsnull; - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -867,12 +854,11 @@ nsAccessibilityService::CreateHTMLTextAccessible(nsISupports *aFrame, nsIAccessi } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLTextFieldAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -885,12 +871,11 @@ nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAc } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLLabelAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLLabelAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -903,12 +888,11 @@ nsAccessibilityService::CreateHTMLLabelAccessible(nsISupports *aFrame, nsIAccess } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLHRAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLHRAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -921,12 +905,11 @@ nsAccessibilityService::CreateHTMLHRAccessible(nsISupports *aFrame, nsIAccessibl } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLBRAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLBRAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -939,12 +922,11 @@ nsAccessibilityService::CreateHTMLBRAccessible(nsISupports *aFrame, nsIAccessibl } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLCaptionAccessible(nsISupports *aFrame, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLCaptionAccessible(nsIFrame *aFrame, nsIAccessible **_retval) { - nsIFrame* frame; nsCOMPtr node; nsCOMPtr weakShell; - nsresult rv = GetInfo(aFrame, &frame, getter_AddRefs(weakShell), getter_AddRefs(node)); + nsresult rv = GetInfo(aFrame, getter_AddRefs(weakShell), getter_AddRefs(node)); if (NS_FAILED(rv)) return rv; @@ -1410,8 +1392,7 @@ NS_IMETHODIMP nsAccessibilityService::GetAccessible(nsIDOMNode *aNode, // image frame is the image content. // Check if frame is an image frame, and content is - nsIImageFrame *imageFrame; - CallQueryInterface(frame, &imageFrame); + nsIImageFrame *imageFrame = do_QueryFrame(frame); nsCOMPtr areaElmt = do_QueryInterface(content); if (imageFrame && areaElmt) { nsCOMPtr imageAcc; diff --git a/accessible/src/base/nsAccessibilityService.h b/accessible/src/base/nsAccessibilityService.h index 59f3bca6f82..b98e04deed9 100644 --- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -89,12 +89,11 @@ private: * Return presentation shell, DOM node for the given frame. * * @param aFrame - the given frame - * @param aRealFrame [out] - the given frame casted to nsIFrame * @param aShell [out] - presentation shell for DOM node associated with the * given frame * @param aContent [out] - DOM node associated with the given frame */ - nsresult GetInfo(nsISupports *aFrame, nsIFrame **aRealFrame, + nsresult GetInfo(nsIFrame *aFrame, nsIWeakReference **aShell, nsIDOMNode **aContent); diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 9c03b474df8..836b93f9c0f 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -2785,8 +2785,7 @@ NS_IMETHODIMP nsAccessible::GetAccessibleRelated(PRUint32 aRelationType, nsIAcce if (frame) { nsIView *view = frame->GetViewExternal(); if (view) { - nsIScrollableFrame *scrollFrame = nsnull; - CallQueryInterface(frame, &scrollFrame); + nsIScrollableFrame *scrollFrame = do_QueryFrame(frame); if (scrollFrame || view->GetWidget()) { return GetParent(aRelated); } diff --git a/accessible/src/base/nsCoreUtils.cpp b/accessible/src/base/nsCoreUtils.cpp index 83042411117..285a7cdf1c2 100755 --- a/accessible/src/base/nsCoreUtils.cpp +++ b/accessible/src/base/nsCoreUtils.cpp @@ -331,8 +331,7 @@ nsCoreUtils::ScrollFrameToPoint(nsIFrame *aScrollableFrame, nsIFrame *aFrame, const nsIntPoint& aPoint) { - nsIScrollableFrame *scrollableFrame = nsnull; - CallQueryInterface(aScrollableFrame, &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(aScrollableFrame); if (!scrollableFrame) return; diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index a31bd5e65d7..96888116987 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -841,8 +841,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, nsIFrame* menuFrame = menuAccessNode->GetFrame(); NS_ENSURE_TRUE(menuFrame, NS_ERROR_FAILURE); - nsIMenuFrame* imenuFrame; - CallQueryInterface(menuFrame, &imenuFrame); + nsIMenuFrame* imenuFrame = do_QueryFrame(menuFrame); if (imenuFrame) fireFocus = PR_TRUE; // QI failed for nsIMenuFrame means it's not on menu bar diff --git a/accessible/src/html/nsHTMLAreaAccessible.cpp b/accessible/src/html/nsHTMLAreaAccessible.cpp index 29eaf2916e9..31ca00c4370 100644 --- a/accessible/src/html/nsHTMLAreaAccessible.cpp +++ b/accessible/src/html/nsHTMLAreaAccessible.cpp @@ -120,6 +120,8 @@ NS_IMETHODIMP nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height) { + nsresult rv; + // Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame *x = *y = *width = *height = 0; @@ -132,9 +134,7 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 *x, PRInt32 *y, nsIFrame *frame = GetFrame(); NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE); - nsIImageFrame *imageFrame; - nsresult rv = frame->QueryInterface(NS_GET_IID(nsIImageFrame), (void**)&imageFrame); - NS_ENSURE_SUCCESS(rv, rv); + nsIImageFrame *imageFrame = do_QueryFrame(frame); nsCOMPtr map; imageFrame->GetImageMap(presContext, getter_AddRefs(map)); diff --git a/accessible/src/html/nsHTMLFormControlAccessible.cpp b/accessible/src/html/nsHTMLFormControlAccessible.cpp index 56356972d6a..e1133b0decc 100644 --- a/accessible/src/html/nsHTMLFormControlAccessible.cpp +++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp @@ -292,8 +292,7 @@ nsHTMLButtonAccessible::GetNameInternal(nsAString& aName) // Use the button's (default) label if nothing else works nsIFrame* frame = GetFrame(); if (frame) { - nsIFormControlFrame* fcFrame = nsnull; - CallQueryInterface(frame, &fcFrame); + nsIFormControlFrame* fcFrame = do_QueryFrame(frame); if (fcFrame) fcFrame->GetFormProperty(nsAccessibilityAtoms::defaultLabel, name); } diff --git a/accessible/src/html/nsHTMLSelectAccessible.cpp b/accessible/src/html/nsHTMLSelectAccessible.cpp index f96a887e48e..06e6bcecc68 100644 --- a/accessible/src/html/nsHTMLSelectAccessible.cpp +++ b/accessible/src/html/nsHTMLSelectAccessible.cpp @@ -743,14 +743,12 @@ NS_IMETHODIMP nsHTMLSelectOptionAccessible::DoAction(PRUint8 index) return NS_ERROR_FAILURE; nsIFrame *selectFrame = presShell->GetPrimaryFrameFor(selectContent); - nsIComboboxControlFrame *comboBoxFrame = nsnull; - CallQueryInterface(selectFrame, &comboBoxFrame); + nsIComboboxControlFrame *comboBoxFrame = do_QueryFrame(selectFrame); if (comboBoxFrame) { nsIFrame *listFrame = comboBoxFrame->GetDropDown(); if (comboBoxFrame->IsDroppedDown() && listFrame) { // use this list control frame to roll up the list - nsIListControlFrame *listControlFrame = nsnull; - listFrame->QueryInterface(NS_GET_IID(nsIListControlFrame), (void**)&listControlFrame); + nsIListControlFrame *listControlFrame = do_QueryFrame(listFrame); if (listControlFrame) { PRInt32 newIndex = 0; option->GetIndex(&newIndex); @@ -797,8 +795,7 @@ nsresult nsHTMLSelectOptionAccessible::GetFocusedOptionNode(nsIDOMNode *aListNod nsresult rv = selectElement->GetOptions(getter_AddRefs(options)); if (NS_SUCCEEDED(rv)) { - nsIListControlFrame *listFrame = nsnull; - frame->QueryInterface(NS_GET_IID(nsIListControlFrame), (void**)&listFrame); + nsIListControlFrame *listFrame = do_QueryFrame(frame); if (listFrame) { // Get what's focused in listbox by asking frame for "selected item". // Can't use dom interface for this, because it will always return the first selected item @@ -1016,8 +1013,7 @@ void nsHTMLComboboxAccessible::CacheChildren() if (!frame) { return; } - nsIComboboxControlFrame *comboFrame = nsnull; - frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame); + nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame); if (!comboFrame) { return; } @@ -1076,11 +1072,7 @@ nsHTMLComboboxAccessible::GetStateInternal(PRUint32 *aState, NS_ENSURE_A11Y_SUCCESS(rv, rv); nsIFrame *frame = GetBoundsFrame(); - nsIComboboxControlFrame *comboFrame = nsnull; - if (frame) { - frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame); - } - + nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame); if (comboFrame && comboFrame->IsDroppedDown()) { *aState |= nsIAccessibleStates::STATE_EXPANDED; } @@ -1160,8 +1152,7 @@ NS_IMETHODIMP nsHTMLComboboxAccessible::DoAction(PRUint8 aIndex) if (!frame) { return NS_ERROR_FAILURE; } - nsIComboboxControlFrame *comboFrame = nsnull; - frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame); + nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame); if (!comboFrame) { return NS_ERROR_FAILURE; } @@ -1186,8 +1177,7 @@ NS_IMETHODIMP nsHTMLComboboxAccessible::GetActionName(PRUint8 aIndex, nsAString& if (!frame) { return NS_ERROR_FAILURE; } - nsIComboboxControlFrame *comboFrame = nsnull; - frame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame); + nsIComboboxControlFrame *comboFrame = do_QueryFrame(frame); if (!comboFrame) { return NS_ERROR_FAILURE; } @@ -1428,8 +1418,7 @@ nsHTMLComboboxListAccessible::GetFrame() nsIFrame* frame = nsHTMLSelectListAccessible::GetFrame(); if (frame) { - nsIComboboxControlFrame* comboBox; - CallQueryInterface(frame, &comboBox); + nsIComboboxControlFrame* comboBox = do_QueryFrame(frame); if (comboBox) { return comboBox->GetDropDown(); } @@ -1454,10 +1443,7 @@ nsHTMLComboboxListAccessible::GetStateInternal(PRUint32 *aState, NS_ENSURE_A11Y_SUCCESS(rv, rv); nsIFrame *boundsFrame = GetBoundsFrame(); - nsIComboboxControlFrame* comboFrame = nsnull; - if (boundsFrame) - boundsFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame), (void**)&comboFrame); - + nsIComboboxControlFrame* comboFrame = do_QueryFrame(boundsFrame); if (comboFrame && comboFrame->IsDroppedDown()) *aState |= nsIAccessibleStates::STATE_FLOATING; else diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index 13b56c4c42d..30b33d1903f 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -95,8 +95,7 @@ nsHTMLTableCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAttri NS_ASSERTION(frame, "The frame cannot be obtaied for HTML table cell."); NS_ENSURE_STATE(frame); - nsITableCellLayout *cellLayout = nsnull; - CallQueryInterface(frame, &cellLayout); + nsITableCellLayout *cellLayout = do_QueryFrame(frame); NS_ENSURE_STATE(cellLayout); PRInt32 rowIdx = -1, cellIdx = -1; @@ -928,7 +927,11 @@ nsHTMLTableAccessible::GetTableLayout(nsITableLayout **aTableLayout) NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); nsIFrame *frame = shell->GetPrimaryFrameFor(tableContent); - return frame ? CallQueryInterface(frame, aTableLayout) : NS_ERROR_FAILURE; + if (!frame) + return NS_ERROR_FAILURE; + + *aTableLayout = do_QueryFrame(frame); + return (*aTableLayout) ? NS_OK : NS_NOINTERFACE; } nsresult diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp index b720ee28ea1..4c6269d642a 100644 --- a/accessible/src/html/nsHyperTextAccessible.cpp +++ b/accessible/src/html/nsHyperTextAccessible.cpp @@ -2044,8 +2044,7 @@ nsHyperTextAccessible::ScrollSubstringToPoint(PRInt32 aStartIndex, PRBool initialScrolled = PR_FALSE; nsIFrame *parentFrame = frame; while ((parentFrame = parentFrame->GetParent())) { - nsIScrollableFrame *scrollableFrame = nsnull; - CallQueryInterface(parentFrame, &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(parentFrame); if (scrollableFrame) { if (!initialScrolled) { // Scroll substring to the given point. Turn the point into percents diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index 262bb782bce..ec3a25c9925 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -216,8 +216,7 @@ __try { else { // If a frame is a scrollable frame, then it has one window for the client area, // not an extra parent window for just the scrollbars - nsIScrollableFrame *scrollFrame = nsnull; - CallQueryInterface(frame, &scrollFrame); + nsIScrollableFrame *scrollFrame = do_QueryFrame(frame); if (scrollFrame) { hwnd = (HWND)scrollFrame->GetScrolledFrame()->GetWindow()->GetNativeData(NS_NATIVE_WINDOW); NS_ASSERTION(hwnd, "No window handle for window"); diff --git a/content/base/src/nsFrameLoader.cpp b/content/base/src/nsFrameLoader.cpp index 52a0be7605c..55afd1c295f 100644 --- a/content/base/src/nsFrameLoader.cpp +++ b/content/base/src/nsFrameLoader.cpp @@ -635,8 +635,7 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther, return NS_ERROR_NOT_IMPLEMENTED; } - nsIFrameFrame* ourFrameFrame = nsnull; - CallQueryInterface(ourFrame, &ourFrameFrame); + nsIFrameFrame* ourFrameFrame = do_QueryFrame(ourFrame); if (!ourFrameFrame) { mInSwap = aOther->mInSwap = PR_FALSE; FirePageShowEvent(ourTreeItem, ourChromeEventHandler, PR_TRUE); diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index f208c75e41d..237777434ed 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1117,12 +1117,9 @@ nsNSElementTearoff::GetScrollInfo(nsIScrollableView **aScrollableView, } // Get the scrollable frame - nsIScrollableFrame *scrollFrame = nsnull; - CallQueryInterface(frame, &scrollFrame); - + nsIScrollableFrame *scrollFrame = do_QueryFrame(frame); if (!scrollFrame) { - nsIScrollableViewProvider *scrollProvider = nsnull; - CallQueryInterface(frame, &scrollProvider); + nsIScrollableViewProvider *scrollProvider = do_QueryFrame(frame); // menu frames implement nsIScrollableViewProvider but we don't want // to use it here. if (scrollProvider && frame->GetType() != nsGkAtoms::menuFrame) { @@ -1151,7 +1148,7 @@ nsNSElementTearoff::GetScrollInfo(nsIScrollableView **aScrollableView, break; } - CallQueryInterface(frame, &scrollFrame); + scrollFrame = do_QueryFrame(frame); } while (!scrollFrame); } diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index a6e758ce833..c86a414f69b 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -561,8 +561,7 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest, } { - nsIFrame *nsiframe; - CallQueryInterface(frame, &nsiframe); + nsIFrame *nsiframe = do_QueryFrame(frame); nsWeakFrame weakFrame(nsiframe); @@ -751,8 +750,7 @@ nsObjectLoadingContent::EnsureInstantiation(nsIPluginInstance** aInstance) } } - nsIFrame *nsiframe; - CallQueryInterface(frame, &nsiframe); + nsIFrame *nsiframe = do_QueryFrame(frame); nsWeakFrame weakFrame(nsiframe); // We may have a plugin instance already; if so, do nothing @@ -805,8 +803,7 @@ nsObjectLoadingContent::HasNewFrame(nsIObjectFrame* aFrame) } } - nsIFrame* frame = nsnull; - CallQueryInterface(aFrame, &frame); + nsIFrame* frame = do_QueryFrame(aFrame); nsCOMPtr event = new nsAsyncInstantiateEvent(this, frame, mContentType, mURI); if (!event) { @@ -1652,8 +1649,7 @@ nsObjectLoadingContent::GetExistingFrame(FlushType aFlushType) aFlushType = eDontFlush; } while (1); - nsIObjectFrame* objFrame; - CallQueryInterface(frame, &objFrame); + nsIObjectFrame* objFrame = do_QueryFrame(frame); return objFrame; } @@ -1695,8 +1691,7 @@ nsObjectLoadingContent::TryInstantiate(const nsACString& aMIMEType, // frame does have a plugin instance already, be sure to // re-instantiate the plugin as its source or whatnot might have // chanced since it was instantiated. - nsIFrame* iframe; - CallQueryInterface(frame, &iframe); + nsIFrame* iframe = do_QueryFrame(frame); if (iframe->GetStateBits() & NS_FRAME_FIRST_REFLOW) { LOG(("OBJLC [%p]: Frame hasn't been reflown yet\n", this)); return NS_OK; // Not a failure to have no frame diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index be59679cc35..f6452299d47 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -2379,8 +2379,7 @@ nsEventStateManager::DoDefaultDragStart(nsPresContext* aPresContext, if (presShell) { nsIFrame* frame = presShell->GetPrimaryFrameFor(content); if (frame) { - nsTreeBodyFrame* treeBody; - CallQueryInterface(frame, &treeBody); + nsTreeBodyFrame* treeBody = do_QueryFrame(frame); treeBody->GetSelectionRegion(getter_AddRefs(region)); } } @@ -2535,8 +2534,7 @@ static nsIScrollableView* GetScrollableViewForFrame(nsPresContext* aPresContext, nsIFrame* aFrame) { for (; aFrame; aFrame = GetParentFrameToScroll(aPresContext, aFrame)) { - nsIScrollableViewProvider* svp; - CallQueryInterface(aFrame, &svp); + nsIScrollableViewProvider* svp = do_QueryFrame(aFrame); if (svp) { nsIScrollableView* scrollView = svp->GetScrollableView(); if (scrollView) @@ -2612,8 +2610,7 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext, // operation, even if the mouse hasn't moved. nsIFrame* lastScrollFrame = nsMouseWheelTransaction::GetTargetFrame(); if (lastScrollFrame) { - nsIScrollableViewProvider* svp; - CallQueryInterface(lastScrollFrame, &svp); + nsIScrollableViewProvider* svp = do_QueryFrame(lastScrollFrame); if (svp) { scrollView = svp->GetScrollableView(); nsMouseWheelTransaction::UpdateTransaction(); @@ -2628,8 +2625,7 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext, scrollFrame = GetParentFrameToScroll(aPresContext, scrollFrame)) { // Check whether the frame wants to provide us with a scrollable view. scrollView = nsnull; - nsIScrollableViewProvider* svp; - CallQueryInterface(scrollFrame, &svp); + nsIScrollableViewProvider* svp = do_QueryFrame(scrollFrame); if (svp) { scrollView = svp->GetScrollableView(); } @@ -2658,8 +2654,7 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext, } // Comboboxes need special care. - nsIComboboxControlFrame* comboBox = nsnull; - CallQueryInterface(scrollFrame, &comboBox); + nsIComboboxControlFrame* comboBox = do_QueryFrame(scrollFrame); if (comboBox) { if (comboBox->IsDroppedDown()) { // Don't propagate to parent when drop down menu is active. @@ -3593,8 +3588,7 @@ nsEventStateManager::NotifyMouseOut(nsGUIEvent* aEvent, nsIContent* aMovingInto) if (mLastMouseOverFrame) { // if the frame is associated with a subdocument, // tell the subdocument that we're moving out of it - nsIFrameFrame* subdocFrame; - CallQueryInterface(mLastMouseOverFrame.GetFrame(), &subdocFrame); + nsIFrameFrame* subdocFrame = do_QueryFrame(mLastMouseOverFrame.GetFrame()); if (subdocFrame) { nsCOMPtr docshell; subdocFrame->GetDocShell(getter_AddRefs(docshell)); @@ -5215,9 +5209,7 @@ nsEventStateManager::SendFocusBlur(nsPresContext* aPresContext, currentFocusFrame = presShell->GetPrimaryFrameFor(mCurrentFocus); if (!currentFocusFrame) currentFocusFrame = mCurrentTarget; - nsIObjectFrame* objFrame = nsnull; - if (currentFocusFrame) - CallQueryInterface(currentFocusFrame, &objFrame); + nsIObjectFrame* objFrame = do_QueryFrame(currentFocusFrame); if (objFrame) { nsIView* view = currentFocusFrame->GetViewExternal(); NS_ASSERTION(view, "Object frames must have views"); diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index ac181d8b567..644671ef60a 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -1326,8 +1326,7 @@ nsGenericHTMLElement::GetFormControlFrameFor(nsIContent* aContent, } nsIFrame* frame = GetPrimaryFrameFor(aContent, aDocument); if (frame) { - nsIFormControlFrame* form_frame = nsnull; - CallQueryInterface(frame, &form_frame); + nsIFormControlFrame* form_frame = do_QueryFrame(frame); if (form_frame) { return form_frame; } @@ -1337,7 +1336,7 @@ nsGenericHTMLElement::GetFormControlFrameFor(nsIContent* aContent, for (frame = frame->GetFirstChild(nsnull); frame; frame = frame->GetNextSibling()) { - CallQueryInterface(frame, &form_frame); + form_frame = do_QueryFrame(frame); if (form_frame) { return form_frame; } @@ -3552,8 +3551,7 @@ nsGenericHTMLElement::GetEditorInternal(nsIEditor** aEditor) nsIFormControlFrame *fcFrame = GetFormControlFrame(PR_FALSE); if (fcFrame) { - nsITextControlFrame *textFrame = nsnull; - CallQueryInterface(fcFrame, &textFrame); + nsITextControlFrame *textFrame = do_QueryFrame(fcFrame); if (textFrame) { return textFrame->GetEditor(aEditor); } diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 076f3634862..698fb781226 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -306,9 +306,7 @@ nsHTMLButtonElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_FALSE); if (formControlFrame) { - nsIFrame* formFrame = nsnull; - CallQueryInterface(formControlFrame, &formFrame); - + nsIFrame* formFrame = do_QueryFrame(formControlFrame); if (formFrame) { const nsStyleUserInterface* uiStyle = formFrame->GetStyleUserInterface(); diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 205b56b9933..fcfb24c4b7f 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -787,9 +787,7 @@ nsHTMLInputElement::GetValue(nsAString& aValue) PRBool frameOwnsValue = PR_FALSE; if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) { textControlFrame->OwnsValue(&frameOwnsValue); } else { @@ -993,7 +991,7 @@ nsHTMLInputElement::SetValueInternal(const nsAString& aValue, formControlFrame = GetFormControlFrame(PR_FALSE); if (formControlFrame) { - CallQueryInterface(formControlFrame, &textControlFrame); + textControlFrame = do_QueryFrame(formControlFrame); } } @@ -1266,14 +1264,12 @@ nsHTMLInputElement::SetCheckedInternal(PRBool aChecked, PRBool aNotify) nsPresContext *presContext = GetPresContext(); if (mType == NS_FORM_INPUT_CHECKBOX) { - nsICheckboxControlFrame* checkboxFrame = nsnull; - CallQueryInterface(frame, &checkboxFrame); + nsICheckboxControlFrame* checkboxFrame = do_QueryFrame(frame); if (checkboxFrame) { checkboxFrame->OnChecked(presContext, aChecked); } } else if (mType == NS_FORM_INPUT_RADIO) { - nsIRadioControlFrame* radioFrame = nsnull; - CallQueryInterface(frame, &radioFrame); + nsIRadioControlFrame* radioFrame = do_QueryFrame(frame); if (radioFrame) { radioFrame->OnChecked(presContext, aChecked); } @@ -1600,8 +1596,7 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) if (aVisitor.mEvent->message == NS_BLUR_CONTENT) { nsIFrame* primaryFrame = GetPrimaryFrame(); if (primaryFrame) { - nsITextControlFrame* textFrame = nsnull; - CallQueryInterface(primaryFrame, &textFrame); + nsITextControlFrame* textFrame = do_QueryFrame(primaryFrame); if (textFrame) { textFrame->CheckFireOnChange(); } @@ -1839,8 +1834,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) if (!isButton) { nsIFrame* primaryFrame = GetPrimaryFrame(); if (primaryFrame) { - nsITextControlFrame* textFrame = nsnull; - CallQueryInterface(primaryFrame, &textFrame); + nsITextControlFrame* textFrame = do_QueryFrame(primaryFrame); // Fire onChange (if necessary) if (textFrame) { @@ -2212,9 +2206,7 @@ nsHTMLInputElement::SetSelectionRange(PRInt32 aSelectionStart, nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd); } @@ -2238,9 +2230,7 @@ nsHTMLInputElement::SetSelectionStart(PRInt32 aSelectionStart) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionStart(aSelectionStart); } @@ -2265,9 +2255,7 @@ nsHTMLInputElement::SetSelectionEnd(PRInt32 aSelectionEnd) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionEnd(aSelectionEnd); } @@ -2304,9 +2292,7 @@ nsHTMLInputElement::GetSelectionRange(PRInt32* aSelectionStart, nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd); } @@ -2321,9 +2307,7 @@ nsHTMLInputElement::GetPhonetic(nsAString& aPhonetic) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) textControlFrame->GetPhonetic(aPhonetic); } diff --git a/content/html/content/src/nsHTMLObjectElement.cpp b/content/html/content/src/nsHTMLObjectElement.cpp index 1f737b37bb7..96e2435ed03 100644 --- a/content/html/content/src/nsHTMLObjectElement.cpp +++ b/content/html/content/src/nsHTMLObjectElement.cpp @@ -323,11 +323,7 @@ nsHTMLObjectElement::SubmitNamesValues(nsIFormSubmission *aFormSubmission, nsIFrame* frame = GetPrimaryFrame(); - nsIObjectFrame *objFrame = nsnull; - if (frame) { - CallQueryInterface(frame, &objFrame); - } - + nsIObjectFrame *objFrame = do_QueryFrame(frame); if (!objFrame) { // No frame, nothing to submit. diff --git a/content/html/content/src/nsHTMLSelectElement.cpp b/content/html/content/src/nsHTMLSelectElement.cpp index 8a39b8ec7d9..a3d95e4572a 100644 --- a/content/html/content/src/nsHTMLSelectElement.cpp +++ b/content/html/content/src/nsHTMLSelectElement.cpp @@ -601,7 +601,7 @@ nsHTMLSelectElement::GetSelectFrame() nsISelectControlFrame *select_frame = nsnull; if (form_control_frame) { - CallQueryInterface(form_control_frame, &select_frame); + select_frame = do_QueryFrame(form_control_frame); } return select_frame; @@ -1440,9 +1440,7 @@ nsHTMLSelectElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) nsIFrame* formFrame = nsnull; if (formControlFrame && - NS_SUCCEEDED(CallQueryInterface(formControlFrame, &formFrame)) && - formFrame) - { + (formFrame = do_QueryFrame(formControlFrame))) { const nsStyleUserInterface* uiStyle = formFrame->GetStyleUserInterface(); if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || @@ -1702,14 +1700,12 @@ void nsHTMLSelectElement::DispatchContentReset() { // Only dispatch content reset notification if this is a list control // frame or combo box control frame. if (IsCombobox()) { - nsIComboboxControlFrame* comboFrame = nsnull; - CallQueryInterface(formControlFrame, &comboFrame); + nsIComboboxControlFrame* comboFrame = do_QueryFrame(formControlFrame); if (comboFrame) { comboFrame->OnContentReset(); } } else { - nsIListControlFrame* listFrame = nsnull; - CallQueryInterface(formControlFrame, &listFrame); + nsIListControlFrame* listFrame = do_QueryFrame(formControlFrame); if (listFrame) { listFrame->OnContentReset(); } diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 478386f72fb..830ab702f24 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -410,7 +410,7 @@ nsHTMLTextAreaElement::GetValueInternal(nsAString& aValue, PRBool aIgnoreWrap) nsIFrame* primaryFrame = GetPrimaryFrame(); nsITextControlFrame* textControlFrame = nsnull; if (primaryFrame) { - CallQueryInterface(primaryFrame, &textControlFrame); + textControlFrame = do_QueryFrame(primaryFrame); } // If the frame exists and owns the value, get it from the frame. Otherwise @@ -453,7 +453,7 @@ nsHTMLTextAreaElement::SetValueInternal(const nsAString& aValue, formControlFrame = GetFormControlFrame(PR_FALSE); if (formControlFrame) { - CallQueryInterface(formControlFrame, &textControlFrame); + textControlFrame = do_QueryFrame(formControlFrame); } } @@ -593,8 +593,7 @@ nsHTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) nsIFrame* formFrame = nsnull; if (formControlFrame && - NS_SUCCEEDED(CallQueryInterface(formControlFrame, &formFrame)) && - formFrame) { + (formFrame = do_QueryFrame(formControlFrame))) { const nsStyleUserInterface* uiStyle = formFrame->GetStyleUserInterface(); if (uiStyle->mUserInput == NS_STYLE_USER_INPUT_NONE || @@ -628,8 +627,7 @@ nsHTMLTextAreaElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) if (aVisitor.mEvent->message == NS_BLUR_CONTENT) { nsIFrame* primaryFrame = GetPrimaryFrame(); if (primaryFrame) { - nsITextControlFrame* textFrame = nsnull; - CallQueryInterface(primaryFrame, &textFrame); + nsITextControlFrame* textFrame = do_QueryFrame(primaryFrame); if (textFrame) { textFrame->CheckFireOnChange(); } @@ -730,9 +728,7 @@ nsHTMLTextAreaElement::SetSelectionStart(PRInt32 aSelectionStart) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame){ - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionStart(aSelectionStart); } @@ -756,9 +752,7 @@ nsHTMLTextAreaElement::SetSelectionEnd(PRInt32 aSelectionEnd) nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionEnd(aSelectionEnd); } @@ -774,9 +768,7 @@ nsHTMLTextAreaElement::GetSelectionRange(PRInt32* aSelectionStart, nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->GetSelectionRange(aSelectionStart, aSelectionEnd); } @@ -791,9 +783,7 @@ nsHTMLTextAreaElement::SetSelectionRange(PRInt32 aSelectionStart, PRInt32 aSelec nsIFormControlFrame* formControlFrame = GetFormControlFrame(PR_TRUE); if (formControlFrame) { - nsITextControlFrame* textControlFrame = nsnull; - CallQueryInterface(formControlFrame, &textControlFrame); - + nsITextControlFrame* textControlFrame = do_QueryFrame(formControlFrame); if (textControlFrame) rv = textControlFrame->SetSelectionRange(aSelectionStart, aSelectionEnd); } diff --git a/content/html/document/src/nsPluginDocument.cpp b/content/html/document/src/nsPluginDocument.cpp index 44be07650cc..b8a32461b8c 100644 --- a/content/html/document/src/nsPluginDocument.cpp +++ b/content/html/document/src/nsPluginDocument.cpp @@ -144,8 +144,7 @@ nsPluginStreamListener::SetupPlugin() return NS_OK; } - nsIObjectFrame* objFrame; - CallQueryInterface(frame, &objFrame); + nsIObjectFrame* objFrame = do_QueryFrame(frame); if (!objFrame) { mPluginDoc->AllowNormalInstantiation(); return NS_ERROR_UNEXPECTED; @@ -342,9 +341,7 @@ nsPluginDocument::Print() nsIFrame* frame = shell->GetPrimaryFrameFor(mPluginContent); NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE); - nsIObjectFrame* objectFrame = nsnull; - CallQueryInterface(frame, &objectFrame); - + nsIObjectFrame* objectFrame = do_QueryFrame(frame); if (objectFrame) { nsCOMPtr pi; objectFrame->GetPluginInstance(*getter_AddRefs(pi)); diff --git a/content/svg/content/src/nsISVGTextContentMetrics.h b/content/svg/content/src/nsISVGTextContentMetrics.h index 294051fcfca..5657c657808 100644 --- a/content/svg/content/src/nsISVGTextContentMetrics.h +++ b/content/svg/content/src/nsISVGTextContentMetrics.h @@ -39,21 +39,18 @@ #ifndef __NS_ISVGTEXTCONTENTMETRICS_H__ #define __NS_ISVGTEXTCONTENTMETRICS_H__ -#include "nsISupports.h" +#include "nsQueryFrame.h" + class nsIDOMSVGRect; class nsIDOMSVGPoint; //////////////////////////////////////////////////////////////////////// // nsISVGTextContentMetrics -// {CBF0A774-4171-4112-BD9A-F49BEFC0CE18} -#define NS_ISVGTEXTCONTENTMETRICS_IID \ -{ 0xcbf0a774, 0x4171, 0x4112, { 0xbd, 0x9a, 0xf4, 0x9b, 0xef, 0xc0, 0xce, 0x18 } } - -class nsISVGTextContentMetrics : public nsISupports +class nsISVGTextContentMetrics { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGTEXTCONTENTMETRICS_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGTextContentMetrics) NS_IMETHOD GetNumberOfChars(PRInt32 *_retval)=0; NS_IMETHOD GetComputedTextLength(float *_retval)=0; @@ -65,7 +62,4 @@ public: NS_IMETHOD GetCharNumAtPosition(nsIDOMSVGPoint *point, PRInt32 *_retval)=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGTextContentMetrics, - NS_ISVGTEXTCONTENTMETRICS_IID) - #endif // __NS_ISVGTEXTCONTENTMETRICS_H__ diff --git a/content/svg/content/src/nsISVGValue.h b/content/svg/content/src/nsISVGValue.h index 9025e81ee46..89efc2b8a2d 100644 --- a/content/svg/content/src/nsISVGValue.h +++ b/content/svg/content/src/nsISVGValue.h @@ -41,6 +41,7 @@ #define __NS_ISVGVALUE_H__ #include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsString.h" class nsISVGValueObserver; @@ -72,6 +73,7 @@ public: }; NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGVALUE_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGValue) NS_IMETHOD SetValueString(const nsAString& aValue)=0; NS_IMETHOD GetValueString(nsAString& aValue)=0; diff --git a/content/svg/content/src/nsSVGGraphicElement.cpp b/content/svg/content/src/nsSVGGraphicElement.cpp index 14d07232c0c..2063cb6dacd 100644 --- a/content/svg/content/src/nsSVGGraphicElement.cpp +++ b/content/svg/content/src/nsSVGGraphicElement.cpp @@ -94,8 +94,7 @@ NS_IMETHODIMP nsSVGGraphicElement::GetBBox(nsIDOMSVGRect **_retval) if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) return NS_ERROR_FAILURE; - nsISVGChildFrame* svgframe; - CallQueryInterface(frame, &svgframe); + nsISVGChildFrame* svgframe = do_QueryFrame(frame); NS_ASSERTION(svgframe, "wrong frame type"); if (svgframe) { svgframe->SetMatrixPropagation(PR_FALSE); diff --git a/content/svg/content/src/nsSVGPatternElement.cpp b/content/svg/content/src/nsSVGPatternElement.cpp index 2a9fc36827e..c9cf099ab14 100644 --- a/content/svg/content/src/nsSVGPatternElement.cpp +++ b/content/svg/content/src/nsSVGPatternElement.cpp @@ -276,8 +276,7 @@ nsSVGPatternElement::PushUpdate() nsIFrame *frame = GetPrimaryFrame(); if (frame) { - nsISVGValue *value = nsnull; - CallQueryInterface(frame, &value); + nsISVGValue *value = do_QueryFrame(frame); if (value) { value->BeginBatchUpdate(); value->EndBatchUpdate(); diff --git a/content/svg/content/src/nsSVGSVGElement.cpp b/content/svg/content/src/nsSVGSVGElement.cpp index 05d9461fa78..ca54bd2fd26 100644 --- a/content/svg/content/src/nsSVGSVGElement.cpp +++ b/content/svg/content/src/nsSVGSVGElement.cpp @@ -365,8 +365,7 @@ nsSVGSVGElement::SuspendRedraw(PRUint32 max_wait_milliseconds, PRUint32 *_retval NS_ASSERTION(frame, "suspending redraw w/o frame"); #endif if (frame) { - nsISVGSVGFrame* svgframe; - CallQueryInterface(frame, &svgframe); + nsISVGSVGFrame* svgframe = do_QueryFrame(frame); NS_ASSERTION(svgframe, "wrong frame type"); if (svgframe) { svgframe->SuspendRedraw(); @@ -404,8 +403,7 @@ nsSVGSVGElement::UnsuspendRedrawAll() NS_ASSERTION(frame, "unsuspending redraw w/o frame"); #endif if (frame) { - nsISVGSVGFrame* svgframe; - CallQueryInterface(frame, &svgframe); + nsISVGSVGFrame* svgframe = do_QueryFrame(frame); NS_ASSERTION(svgframe, "wrong frame type"); if (svgframe) { svgframe->UnsuspendRedraw(); @@ -658,8 +656,7 @@ nsSVGSVGElement::GetBBox(nsIDOMSVGRect **_retval) if (!frame || (frame->GetStateBits() & NS_STATE_SVG_NONDISPLAY_CHILD)) return NS_ERROR_FAILURE; - nsISVGChildFrame* svgframe; - CallQueryInterface(frame, &svgframe); + nsISVGChildFrame* svgframe = do_QueryFrame(frame); if (svgframe) { svgframe->SetMatrixPropagation(PR_FALSE); svgframe->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION | @@ -1297,8 +1294,7 @@ nsSVGSVGElement::InvalidateTransformNotifyFrame() nsIFrame* frame = presShell->GetPrimaryFrameFor(this); if (frame) { - nsISVGSVGFrame* svgframe; - CallQueryInterface(frame, &svgframe); + nsISVGSVGFrame* svgframe = do_QueryFrame(frame); if (svgframe) { svgframe->NotifyViewportChange(); } diff --git a/content/svg/content/src/nsSVGSwitchElement.cpp b/content/svg/content/src/nsSVGSwitchElement.cpp index a2fb084b2ef..7b0edc0d079 100644 --- a/content/svg/content/src/nsSVGSwitchElement.cpp +++ b/content/svg/content/src/nsSVGSwitchElement.cpp @@ -97,9 +97,7 @@ nsSVGSwitchElement::MaybeInvalidate() nsIFrame *frame = GetPrimaryFrame(); if (frame) { - nsISVGChildFrame* svgFrame = nsnull; - - CallQueryInterface(frame, &svgFrame); + nsISVGChildFrame* svgFrame = do_QueryFrame(frame); if (svgFrame) { nsSVGUtils::UpdateGraphic(svgFrame); } diff --git a/content/svg/content/src/nsSVGTSpanElement.cpp b/content/svg/content/src/nsSVGTSpanElement.cpp index e3fdcab37c5..9a88df4b440 100644 --- a/content/svg/content/src/nsSVGTSpanElement.cpp +++ b/content/svg/content/src/nsSVGTSpanElement.cpp @@ -82,7 +82,7 @@ protected: // nsSVGElement overrides virtual PRBool IsEventName(nsIAtom* aName); - already_AddRefed GetTextContentMetrics(); + nsISVGTextContentMetrics* GetTextContentMetrics(); // nsIDOMSVGTextPositioning properties: nsCOMPtr mX; @@ -253,7 +253,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetLengthAdjust(nsIDOMSVGAnimatedEnumeration * /* long getNumberOfChars (); */ NS_IMETHODIMP nsSVGTSpanElement::GetNumberOfChars(PRInt32 *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetNumberOfChars(_retval); @@ -265,7 +265,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetNumberOfChars(PRInt32 *_retval) /* float getComputedTextLength (); */ NS_IMETHODIMP nsSVGTSpanElement::GetComputedTextLength(float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetComputedTextLength(_retval); @@ -277,7 +277,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetComputedTextLength(float *_retval) /* float getSubStringLength (in unsigned long charnum, in unsigned long nchars); */ NS_IMETHODIMP nsSVGTSpanElement::GetSubStringLength(PRUint32 charnum, PRUint32 nchars, float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetSubStringLength(charnum, nchars, _retval); @@ -290,7 +290,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetSubStringLength(PRUint32 charnum, PRUint32 n NS_IMETHODIMP nsSVGTSpanElement::GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -301,7 +301,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetStartPositionOfChar(PRUint32 charnum, nsIDOM NS_IMETHODIMP nsSVGTSpanElement::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -312,7 +312,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSV NS_IMETHODIMP nsSVGTSpanElement::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -324,7 +324,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetRotationOfChar(PRUint32 charnum, float *_ret { *_retval = 0.0; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -339,7 +339,7 @@ NS_IMETHODIMP nsSVGTSpanElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, if (!point) return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetCharNumAtPosition(point, _retval); @@ -385,7 +385,7 @@ nsSVGTSpanElement::IsEventName(nsIAtom* aName) //---------------------------------------------------------------------- // implementation helpers: -already_AddRefed +nsISVGTextContentMetrics* nsSVGTSpanElement::GetTextContentMetrics() { nsIFrame* frame = GetPrimaryFrame(Flush_Layout); @@ -394,7 +394,6 @@ nsSVGTSpanElement::GetTextContentMetrics() return nsnull; } - nsISVGTextContentMetrics* metrics; - CallQueryInterface(frame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(frame); return metrics; } diff --git a/content/svg/content/src/nsSVGTextElement.cpp b/content/svg/content/src/nsSVGTextElement.cpp index b992f43b48d..ef31d7f4f44 100644 --- a/content/svg/content/src/nsSVGTextElement.cpp +++ b/content/svg/content/src/nsSVGTextElement.cpp @@ -80,7 +80,7 @@ public: protected: - already_AddRefed GetTextContentMetrics(); + nsISVGTextContentMetrics* GetTextContentMetrics(); // nsIDOMSVGTextPositioning properties: nsCOMPtr mX; @@ -250,7 +250,7 @@ NS_IMETHODIMP nsSVGTextElement::GetLengthAdjust(nsIDOMSVGAnimatedEnumeration * * /* long getNumberOfChars (); */ NS_IMETHODIMP nsSVGTextElement::GetNumberOfChars(PRInt32 *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetNumberOfChars(_retval); @@ -262,7 +262,7 @@ NS_IMETHODIMP nsSVGTextElement::GetNumberOfChars(PRInt32 *_retval) /* float getComputedTextLength (); */ NS_IMETHODIMP nsSVGTextElement::GetComputedTextLength(float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetComputedTextLength(_retval); @@ -274,7 +274,7 @@ NS_IMETHODIMP nsSVGTextElement::GetComputedTextLength(float *_retval) /* float getSubStringLength (in unsigned long charnum, in unsigned long nchars); */ NS_IMETHODIMP nsSVGTextElement::GetSubStringLength(PRUint32 charnum, PRUint32 nchars, float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetSubStringLength(charnum, nchars, _retval); @@ -287,7 +287,7 @@ NS_IMETHODIMP nsSVGTextElement::GetSubStringLength(PRUint32 charnum, PRUint32 nc NS_IMETHODIMP nsSVGTextElement::GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -298,7 +298,7 @@ NS_IMETHODIMP nsSVGTextElement::GetStartPositionOfChar(PRUint32 charnum, nsIDOMS NS_IMETHODIMP nsSVGTextElement::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -309,7 +309,7 @@ NS_IMETHODIMP nsSVGTextElement::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVG NS_IMETHODIMP nsSVGTextElement::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -321,7 +321,7 @@ NS_IMETHODIMP nsSVGTextElement::GetRotationOfChar(PRUint32 charnum, float *_retv { *_retval = 0.0; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -335,7 +335,7 @@ NS_IMETHODIMP nsSVGTextElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, PRIn if (!point) return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetCharNumAtPosition(point, _retval); @@ -369,7 +369,7 @@ nsSVGTextElement::IsAttributeMapped(const nsIAtom* name) const //---------------------------------------------------------------------- // implementation helpers: -already_AddRefed +nsISVGTextContentMetrics* nsSVGTextElement::GetTextContentMetrics() { nsIFrame* frame = GetPrimaryFrame(Flush_Layout); @@ -378,7 +378,6 @@ nsSVGTextElement::GetTextContentMetrics() return nsnull; } - nsISVGTextContentMetrics* metrics; - CallQueryInterface(frame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(frame); return metrics; } diff --git a/content/svg/content/src/nsSVGTextPathElement.cpp b/content/svg/content/src/nsSVGTextPathElement.cpp index 5fbc2264a6e..0216963f566 100644 --- a/content/svg/content/src/nsSVGTextPathElement.cpp +++ b/content/svg/content/src/nsSVGTextPathElement.cpp @@ -155,7 +155,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetLengthAdjust(nsIDOMSVGAnimatedEnumeration /* long getNumberOfChars (); */ NS_IMETHODIMP nsSVGTextPathElement::GetNumberOfChars(PRInt32 *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetNumberOfChars(_retval); @@ -167,7 +167,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetNumberOfChars(PRInt32 *_retval) /* float getComputedTextLength (); */ NS_IMETHODIMP nsSVGTextPathElement::GetComputedTextLength(float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetComputedTextLength(_retval); @@ -179,7 +179,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetComputedTextLength(float *_retval) /* float getSubStringLength (in unsigned long charnum, in unsigned long nchars); */ NS_IMETHODIMP nsSVGTextPathElement::GetSubStringLength(PRUint32 charnum, PRUint32 nchars, float *_retval) { - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetSubStringLength(charnum, nchars, _retval); @@ -192,7 +192,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetSubStringLength(PRUint32 charnum, PRUint3 NS_IMETHODIMP nsSVGTextPathElement::GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -203,7 +203,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetStartPositionOfChar(PRUint32 charnum, nsI NS_IMETHODIMP nsSVGTextPathElement::GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -214,7 +214,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetEndPositionOfChar(PRUint32 charnum, nsIDO NS_IMETHODIMP nsSVGTextPathElement::GetExtentOfChar(PRUint32 charnum, nsIDOMSVGRect **_retval) { *_retval = nsnull; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -226,7 +226,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetRotationOfChar(PRUint32 charnum, float *_ { *_retval = 0.0; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (!metrics) return NS_ERROR_FAILURE; @@ -241,7 +241,7 @@ NS_IMETHODIMP nsSVGTextPathElement::GetCharNumAtPosition(nsIDOMSVGPoint *point, if (!point) return NS_ERROR_DOM_SVG_WRONG_TYPE_ERR; - nsCOMPtr metrics = GetTextContentMetrics(); + nsISVGTextContentMetrics *metrics = GetTextContentMetrics(); if (metrics) return metrics->GetCharNumAtPosition(point, _retval); @@ -307,7 +307,7 @@ nsSVGTextPathElement::GetStringInfo() //---------------------------------------------------------------------- // implementation helpers: -already_AddRefed +nsISVGTextContentMetrics* nsSVGTextPathElement::GetTextContentMetrics() { nsIFrame* frame = GetPrimaryFrame(Flush_Layout); @@ -316,7 +316,6 @@ nsSVGTextPathElement::GetTextContentMetrics() return nsnull; } - nsISVGTextContentMetrics* metrics; - CallQueryInterface(frame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(frame); return metrics; } diff --git a/content/svg/content/src/nsSVGTextPathElement.h b/content/svg/content/src/nsSVGTextPathElement.h index 1056a067685..362ae7e2397 100755 --- a/content/svg/content/src/nsSVGTextPathElement.h +++ b/content/svg/content/src/nsSVGTextPathElement.h @@ -82,7 +82,7 @@ protected: virtual PRBool IsEventName(nsIAtom* aName); - already_AddRefed GetTextContentMetrics(); + nsISVGTextContentMetrics* GetTextContentMetrics(); enum { STARTOFFSET }; nsSVGLength2 mLengthAttributes[1]; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index b373e945c81..b2e1ab23d85 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4345,8 +4345,7 @@ nsDocShell::GetScrollbarVisibility(PRBool * verticalVisible, static_cast(scrollView->View()->GetParent()->GetClientData()); if (!scrollFrame) return NS_ERROR_FAILURE; - nsIScrollableFrame* scrollable = nsnull; - CallQueryInterface(scrollFrame, &scrollable); + nsIScrollableFrame* scrollable = do_QueryFrame(scrollFrame); if (!scrollable) return NS_ERROR_FAILURE; @@ -9264,8 +9263,8 @@ nsDocShell::SetHasFocus(PRBool aHasFocus) // child lists. aFrame must be non-null. static nsICanvasFrame* FindCanvasFrame(nsIFrame* aFrame) { - nsICanvasFrame* canvasFrame; - if (NS_SUCCEEDED(CallQueryInterface(aFrame, &canvasFrame))) { + nsICanvasFrame* canvasFrame = do_QueryFrame(aFrame); + if (canvasFrame) { return canvasFrame; } @@ -9302,8 +9301,8 @@ nsDocShell::SetCanvasHasFocus(PRBool aCanvasHasFocus) if (frame) { frame = frame->GetParent(); if (frame) { - nsICanvasFrame* canvasFrame; - if (NS_SUCCEEDED(CallQueryInterface(frame, &canvasFrame))) { + nsICanvasFrame* canvasFrame = do_QueryFrame(frame); + if (canvasFrame) { return canvasFrame->SetHasFocus(aCanvasHasFocus); } } diff --git a/editor/libeditor/html/nsTableEditor.cpp b/editor/libeditor/html/nsTableEditor.cpp index 5cb19c7a07c..38d1b6fe9c5 100644 --- a/editor/libeditor/html/nsTableEditor.cpp +++ b/editor/libeditor/html/nsTableEditor.cpp @@ -2730,9 +2730,7 @@ nsHTMLEditor::GetCellIndexes(nsIDOMElement *aCell, nsIFrame *layoutObject = ps->GetPrimaryFrameFor(nodeAsContent); if (!layoutObject) return NS_ERROR_FAILURE; - nsITableCellLayout *cellLayoutObject=nsnull; // again, frames are not ref-counted - res = layoutObject->QueryInterface(NS_GET_IID(nsITableCellLayout), (void**)(&cellLayoutObject)); - if (NS_FAILED(res)) return res; + nsITableCellLayout *cellLayoutObject = do_QueryFrame(layoutObject); if (!cellLayoutObject) return NS_ERROR_FAILURE; return cellLayoutObject->GetCellIndexes(*aRowIndex, *aColIndex); } @@ -2752,8 +2750,8 @@ nsHTMLEditor::GetTableLayoutObject(nsIDOMElement* aTable, nsITableLayout **table nsIFrame *layoutObject = ps->GetPrimaryFrameFor(nodeAsContent); if (!layoutObject) return NS_ERROR_FAILURE; - return layoutObject->QueryInterface(NS_GET_IID(nsITableLayout), - (void**)(tableLayoutObject)); + *tableLayoutObject = do_QueryFrame(layoutObject); + return *tableLayoutObject ? NS_OK : NS_NOINTERFACE; } //Return actual number of cells (a cell with colspan > 1 counts as just 1) diff --git a/embedding/components/find/src/nsFind.cpp b/embedding/components/find/src/nsFind.cpp index 5282f6285e4..8c8e6c00546 100644 --- a/embedding/components/find/src/nsFind.cpp +++ b/embedding/components/find/src/nsFind.cpp @@ -378,8 +378,7 @@ nsFindContentIterator::SetupInnerIterator(nsIContent* aContent) if (!frame) return; - nsITextControlFrame* tcFrame = nsnull; - CallQueryInterface(frame, &tcFrame); + nsITextControlFrame* tcFrame = do_QueryFrame(frame); if (!tcFrame) return; diff --git a/embedding/components/find/src/nsWebBrowserFind.cpp b/embedding/components/find/src/nsWebBrowserFind.cpp index 11ed7e5694d..2087d4a7db4 100644 --- a/embedding/components/find/src/nsWebBrowserFind.cpp +++ b/embedding/components/find/src/nsWebBrowserFind.cpp @@ -440,7 +440,7 @@ void nsWebBrowserFind::SetSelectionAndScroll(nsIDOMWindow* aWindow, nsIFrame* f = presShell->GetPrimaryFrameFor(content); if (!f) return; - CallQueryInterface(f, &tcFrame); + tcFrame = do_QueryFrame(f); break; } } diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index 711e56509ce..bdbb664d00c 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -53,8 +53,6 @@ #include "nsInlineFrame.h" #include "nsPlaceholderFrame.h" -static NS_DEFINE_IID(kInlineFrameCID, NS_INLINE_FRAME_CID); - static const PRUnichar kSpace = 0x0020; static const PRUnichar kLineSeparator = 0x2028; static const PRUnichar kObjectSubstitute = 0xFFFC; @@ -852,9 +850,7 @@ nsBidiPresUtils::RepositionFrame(nsIFrame* aFrame, isLeftMost /* out */, isRightMost /* out */); - nsIFrame* testFrame; - aFrame->QueryInterface(kInlineFrameCID, (void**)&testFrame); - + nsInlineFrame* testFrame = do_QueryFrame(aFrame); if (testFrame) { aFrame->AddStateBits(NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 7de2261b03c..a518ebc7e1d 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -4518,8 +4518,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIContent* aDocElement, PR_TRUE, newFrame); - nsIScrollableFrame* scrollable; - CallQueryInterface(newFrame, &scrollable); + nsIScrollableFrame* scrollable = do_QueryFrame(newFrame); NS_ENSURE_TRUE(scrollable, NS_ERROR_FAILURE); nsIScrollableView* scrollableView = scrollable->GetScrollableView(); @@ -4674,8 +4673,8 @@ nsCSSFrameConstructor::ConstructRadioControlFrame(nsIFrame** aNewFrame, radioStyle = mPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, nsCSSAnonBoxes::radio, aStyleContext); - nsIRadioControlFrame* radio = nsnull; - if (*aNewFrame && NS_SUCCEEDED(CallQueryInterface(*aNewFrame, &radio))) { + nsIRadioControlFrame* radio = do_QueryFrame(*aNewFrame); + if (radio) { radio->SetRadioButtonFaceStyleContext(radioStyle); } return NS_OK; @@ -4695,8 +4694,8 @@ nsCSSFrameConstructor::ConstructCheckboxControlFrame(nsIFrame** aNewFrame, checkboxStyle = mPresShell->StyleSet()->ResolvePseudoStyleFor(aContent, nsCSSAnonBoxes::check, aStyleContext); - nsICheckboxControlFrame* checkbox = nsnull; - if (*aNewFrame && NS_SUCCEEDED(CallQueryInterface(*aNewFrame, &checkbox))) { + nsICheckboxControlFrame* checkbox = do_QueryFrame(*aNewFrame); + if (checkbox) { checkbox->SetCheckboxFaceStyleContext(checkboxStyle); } return NS_OK; @@ -4773,8 +4772,7 @@ nsCSSFrameConstructor::ConstructButtonFrame(nsFrameConstructorState& aState, #ifdef DEBUG // Make sure that we're an anonymous content creator exactly when we're a // leaf - nsIAnonymousContentCreator* creator = nsnull; - CallQueryInterface(buttonFrame, &creator); + nsIAnonymousContentCreator* creator = do_QueryFrame(buttonFrame); NS_ASSERTION(!creator == !isLeaf, "Should be creator exactly when we're a leaf"); #endif @@ -4792,8 +4790,7 @@ nsCSSFrameConstructor::ConstructButtonFrame(nsFrameConstructorState& aState, #ifdef DEBUG // Make sure that anonymous child creation will have no effect in this case - nsIAnonymousContentCreator* creator = nsnull; - CallQueryInterface(blockFrame, &creator); + nsIAnonymousContentCreator* creator = do_QueryFrame(blockFrame); NS_ASSERTION(!creator, "Shouldn't be an anonymous content creator!"); #endif @@ -4879,8 +4876,7 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState, /////////////////////////////////////////////////////////////////// // Combobox - Old Native Implementation /////////////////////////////////////////////////////////////////// - nsIComboboxControlFrame* comboBox = nsnull; - CallQueryInterface(comboboxFrame, &comboBox); + nsIComboboxControlFrame* comboBox = do_QueryFrame(comboboxFrame); NS_ASSERTION(comboBox, "NS_NewComboboxControlFrame returned frame that " "doesn't implement nsIComboboxControlFrame"); @@ -4894,9 +4890,8 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsFrameConstructorState& aState, nsIFrame* listFrame = NS_NewListControlFrame(mPresShell, listStyle); // Notify the listbox that it is being used as a dropdown list. - nsIListControlFrame * listControlFrame; - rv = CallQueryInterface(listFrame, &listControlFrame); - if (NS_SUCCEEDED(rv)) { + nsIListControlFrame * listControlFrame = do_QueryFrame(listFrame); + if (listControlFrame) { listControlFrame->SetComboboxFrame(comboboxFrame); } // Notify combobox that it should use the listbox as it's popup @@ -5116,13 +5111,12 @@ nsCSSFrameConstructor::ConstructFieldSetFrame(nsFrameConstructorState& aState, ProcessChildren(aState, aContent, aStyleContext, blockFrame, PR_TRUE, childItems, PR_TRUE); - static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); nsIFrame * child = childItems.childList; nsIFrame * previous = nsnull; - nsIFrame* legendFrame = nsnull; + nsLegendFrame* legendFrame = nsnull; while (nsnull != child) { - nsresult result = child->QueryInterface(kLegendFrameCID, (void**)&legendFrame); - if (NS_SUCCEEDED(result) && legendFrame) { + legendFrame = do_QueryFrame(child); + if (legendFrame) { // We want the legend to be the first frame in the fieldset child list. // That way the EventStateManager will do the right thing when tabbing // from a selection point within the legend (bug 236071), which is @@ -5189,8 +5183,7 @@ nsCSSFrameConstructor::ConstructTextFrame(nsFrameConstructorState& aState, if (aParentFrame->IsFrameOfType(nsIFrame::eSVG)) { nsIFrame *ancestorFrame = SVG_GetFirstNonAAncestorFrame(aParentFrame); if (ancestorFrame) { - nsISVGTextContentMetrics* metrics; - CallQueryInterface(ancestorFrame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(ancestorFrame); if (!metrics) { return NS_OK; } @@ -5580,8 +5573,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsFrameConstructorState& aState, nsIFrame* aParentFrame, nsFrameItems& aChildItems) { - nsIAnonymousContentCreator* creator = nsnull; - CallQueryInterface(aParentFrame, &creator); + nsIAnonymousContentCreator* creator = do_QueryFrame(aParentFrame); if (!creator) return NS_OK; @@ -6994,8 +6986,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState, else if (aTag == nsGkAtoms::text) { nsIFrame *ancestorFrame = SVG_GetFirstNonAAncestorFrame(aParentFrame); if (ancestorFrame) { - nsISVGTextContentMetrics* metrics; - CallQueryInterface(ancestorFrame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(ancestorFrame); // Text cannot be nested if (!metrics) newFrame = NS_NewSVGTextFrame(mPresShell, aContent, aStyleContext); @@ -7004,8 +6995,7 @@ nsCSSFrameConstructor::ConstructSVGFrame(nsFrameConstructorState& aState, else if (aTag == nsGkAtoms::tspan) { nsIFrame *ancestorFrame = SVG_GetFirstNonAAncestorFrame(aParentFrame); if (ancestorFrame) { - nsISVGTextContentMetrics* metrics; - CallQueryInterface(ancestorFrame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(ancestorFrame); if (metrics) newFrame = NS_NewSVGTSpanFrame(mPresShell, aContent, ancestorFrame, aStyleContext); @@ -8500,8 +8490,7 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, #ifdef DEBUG if (gReallyNoisyContentUpdates) { - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(parentFrame, &fdbg); + nsIFrameDebug* fdbg = do_QueryFrame(parentFrame); if (fdbg) { printf("nsCSSFrameConstructor::ContentAppended: resulting frame model:\n"); fdbg->List(stdout, 0); @@ -8648,8 +8637,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer, InvalidateCanvasIfNeeded(docElementFrame); #ifdef DEBUG if (gReallyNoisyContentUpdates) { - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(docElementFrame, &fdbg); + nsIFrameDebug* fdbg = do_QueryFrame(docElementFrame); if (fdbg) { printf("nsCSSFrameConstructor::ContentInserted: resulting frame model:\n"); fdbg->List(stdout, 0); @@ -8941,8 +8929,7 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer, #ifdef DEBUG if (gReallyNoisyContentUpdates && parentFrame) { - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(parentFrame, &fdbg); + nsIFrameDebug* fdbg = do_QueryFrame(parentFrame); if (fdbg) { printf("nsCSSFrameConstructor::ContentInserted: resulting frame model:\n"); fdbg->List(stdout, 0); @@ -9320,8 +9307,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, nsFrame::ListTag(stdout, childFrame); printf("\n"); - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(parentFrame, &fdbg); + nsIFrameDebug* fdbg = do_QueryFrame(parentFrame); if (fdbg) fdbg->List(stdout, 0); } @@ -9385,8 +9371,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, #ifdef DEBUG if (gReallyNoisyContentUpdates && parentFrame) { - nsIFrameDebug* fdbg = nsnull; - CallQueryInterface(parentFrame, &fdbg); + nsIFrameDebug* fdbg = do_QueryFrame(parentFrame); if (fdbg) { printf("nsCSSFrameConstructor::ContentRemoved: resulting frame model:\n"); fdbg->List(stdout, 0); @@ -12537,16 +12522,15 @@ nsCSSFrameConstructor::ConstructInline(nsFrameConstructorState& aState, nsIFrameDebug* frameDebug; printf("nsCSSFrameConstructor::ConstructInline:\n"); - if (NS_SUCCEEDED(CallQueryInterface(aNewFrame, &frameDebug))) { + if ( (frameDebug = do_QueryFrame(aNewFrame)) ) { printf(" ==> leading inline frame:\n"); frameDebug->List(stdout, 2); } - if (NS_SUCCEEDED(CallQueryInterface(blockFrame, &frameDebug))) { + if ( (frameDebug = do_QueryFrame(blockFrame)) ) { printf(" ==> block frame:\n"); frameDebug->List(stdout, 2); } - if (inlineFrame && - NS_SUCCEEDED(CallQueryInterface(inlineFrame, &frameDebug))) { + if ( (frameDebug = do_QueryFrame(inlineFrame)) ) { printf(" ==> trailing inline frame:\n"); frameDebug->List(stdout, 2); } diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index eaf89e6947f..dba9557796e 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -240,14 +240,13 @@ protected: if (mBidiEnabled) { // Find the containing block frame nsIFrame* frame = aFrame; - nsresult rv = NS_ERROR_FAILURE; - while (frame && - frame->IsFrameOfType(nsIFrame::eLineParticipant) && - NS_FAILED(rv)) { + do { frame = frame->GetParent(); - rv = frame->QueryInterface(kBlockFrameCID, (void**)&mBlockFrame); + mBlockFrame = do_QueryFrame(frame); } - NS_ASSERTION(NS_SUCCEEDED(rv) && mBlockFrame, "Cannot find containing block."); + while (frame && frame->IsFrameOfType(nsIFrame::eLineParticipant)); + + NS_ASSERTION(mBlockFrame, "Cannot find containing block."); mLineContinuationPoint = mContinuationPoint; } diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index bf0b3559668..eeb414e58cf 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -1184,8 +1184,7 @@ nsresult nsCaret::UpdateCaretRects(nsIFrame* aFrame, PRInt32 aFrameOffset) if (scrollFrame) { // First, use the scrollFrame to get at the scrollable view that we're in. - nsIScrollableFrame *scrollable; - CallQueryInterface(scrollFrame, &scrollable); + nsIScrollableFrame *scrollable = do_QueryFrame(scrollFrame); nsIScrollableView *scrollView = scrollable->GetScrollableView(); nsIView *view; scrollView->GetScrolledView(view); diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 786809aa4fe..6cc646e7b73 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -3737,8 +3737,8 @@ DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum) if (fndPageFrame && scrollableView) { nscoord deadSpaceGapTwips = 0; - nsIPageSequenceFrame * sqf; - if (NS_SUCCEEDED(CallQueryInterface(seqFrame, &sqf))) { + nsIPageSequenceFrame * sqf = do_QueryFrame(seqFrame); + if (sqf) { sqf->GetDeadSpaceValue(&deadSpaceGapTwips); } diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 8ffe769e1f2..a1f708fec2d 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -734,9 +734,8 @@ DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) if (aFrame) { fputs("frame: ", stdout); nsAutoString name; - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(aFrame); + if (frameDebug) { frameDebug->GetFrameName(name); fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout); } @@ -1585,9 +1584,7 @@ nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame, } // Only capture state for stateful frames - nsIStatefulFrame* statefulFrame; - CallQueryInterface(aFrame, &statefulFrame); - + nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame); if (!statefulFrame) { return; } @@ -1652,8 +1649,7 @@ nsFrameManager::RestoreFrameStateFor(nsIFrame* aFrame, } // Only restore state for stateful frames - nsIStatefulFrame* statefulFrame; - CallQueryInterface(aFrame, &statefulFrame); + nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame); if (!statefulFrame) { return; } diff --git a/layout/base/nsIPercentHeightObserver.h b/layout/base/nsIPercentHeightObserver.h index e7201cf0523..c80d6b89ee7 100644 --- a/layout/base/nsIPercentHeightObserver.h +++ b/layout/base/nsIPercentHeightObserver.h @@ -38,22 +38,20 @@ #ifndef nsIPercentHeightObserver_h___ #define nsIPercentHeightObserver_h___ +#include "nsQueryFrame.h" + struct nsHTMLReflowState; class nsPresContext; -// IID for the nsIPercentHeightObserver interface -#define NS_IPERCENTHEIGHTOBSERVER_IID \ - { 0x9cdc174b, 0x4f39, 0x41ad, {0xbc, 0x16, 0x5a, 0xc5, 0xa8, 0x64, 0x14, 0xa1}} - /** * This interface is supported by frames that need to provide computed height * values to children during reflow which would otherwise not happen. Currently only * table cells support this. */ -class nsIPercentHeightObserver : public nsISupports +class nsIPercentHeightObserver { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPERCENTHEIGHTOBSERVER_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIPercentHeightObserver) // Notify the observer that aReflowState has no computed height, but it has a percent height virtual void NotifyPercentHeight(const nsHTMLReflowState& aReflowState) = 0; @@ -62,7 +60,4 @@ public: virtual PRBool NeedsToObserve(const nsHTMLReflowState& aReflowState) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIPercentHeightObserver, - NS_IPERCENTHEIGHTOBSERVER_IID) - #endif // nsIPercentHeightObserver_h___ diff --git a/layout/base/nsLayoutDebugger.cpp b/layout/base/nsLayoutDebugger.cpp index 3c694eeb6b8..7977f874ba2 100644 --- a/layout/base/nsLayoutDebugger.cpp +++ b/layout/base/nsLayoutDebugger.cpp @@ -159,10 +159,7 @@ PrintDisplayListTo(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList, fputc(' ', aOutput); } nsIFrame* f = i->GetUnderlyingFrame(); - nsIFrameDebug* fDebug = nsnull; - if (f) { - CallQueryInterface(f, &fDebug); - } + nsIFrameDebug* fDebug = do_QueryFrame(f); nsAutoString fName; if (fDebug) { fDebug->GetFrameName(fName); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 80150bb8e9d..60402565175 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -546,8 +546,7 @@ nsLayoutUtils::GetScrollableFrameFor(nsIFrame *aScrolledFrame) if (!frame) { return nsnull; } - nsIScrollableFrame *sf; - CallQueryInterface(frame, &sf); + nsIScrollableFrame *sf = do_QueryFrame(frame); return sf; } @@ -556,12 +555,8 @@ nsIScrollableFrame* nsLayoutUtils::GetScrollableFrameFor(nsIScrollableView *aScrollableView) { nsIFrame *frame = GetFrameFor(aScrollableView->View()->GetParent()); - if (frame) { - nsIScrollableFrame *sf; - CallQueryInterface(frame, &sf); - return sf; - } - return nsnull; + nsIScrollableFrame *sf = do_QueryFrame(frame); + return sf; } //static @@ -1534,10 +1529,8 @@ nsLayoutUtils::FindChildContainingDescendant(nsIFrame* aParent, nsIFrame* aDesce nsBlockFrame* nsLayoutUtils::GetAsBlock(nsIFrame* aFrame) { - nsBlockFrame* block; - if (NS_SUCCEEDED(aFrame->QueryInterface(kBlockFrameCID, (void**)&block))) - return block; - return nsnull; + nsBlockFrame* block = do_QueryFrame(aFrame); + return block; } nsBlockFrame* @@ -1682,8 +1675,7 @@ nsLayoutUtils::IsViewportScrollbarFrame(nsIFrame* aFrame) if (!rootScrollFrame) return PR_FALSE; - nsIScrollableFrame* rootScrollableFrame = nsnull; - CallQueryInterface(rootScrollFrame, &rootScrollableFrame); + nsIScrollableFrame* rootScrollableFrame = do_QueryFrame(rootScrollFrame); NS_ASSERTION(rootScrollableFrame, "The root scorollable frame is null"); if (!IsProperAncestorFrame(rootScrollFrame, aFrame)) @@ -2526,9 +2518,8 @@ nsLayoutUtils::GetFirstLineBaseline(const nsIFrame* aFrame, nscoord* aResult) // For first-line baselines, we have to consider scroll frames. if (fType == nsGkAtoms::scrollFrame) { - nsIScrollableFrame *sFrame; - if (NS_FAILED(CallQueryInterface(const_cast - (aFrame), &sFrame)) || !sFrame) { + nsIScrollableFrame *sFrame = do_QueryFrame(const_cast(aFrame)); + if (!sFrame) { NS_NOTREACHED("not scroll frame"); } nscoord kidBaseline; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 39e149c3a7d..9ea3773641c 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -2930,8 +2930,7 @@ nsIPresShell::GetRootScrollFrameAsScrollable() const nsIFrame* frame = GetRootScrollFrame(); if (!frame) return nsnull; - nsIScrollableFrame* scrollableFrame = nsnull; - CallQueryInterface(frame, &scrollableFrame); + nsIScrollableFrame* scrollableFrame = do_QueryFrame(frame); NS_ASSERTION(scrollableFrame, "All scroll frames must implement nsIScrollableFrame"); return scrollableFrame; @@ -2947,9 +2946,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const *aResult = nsnull; nsIFrame* frame = mFrameConstructor->GetPageSequenceFrame(); - if (frame) { - CallQueryInterface(frame, aResult); - } + *aResult = do_QueryFrame(frame); return *aResult ? NS_OK : NS_ERROR_FAILURE; } @@ -3003,8 +3000,7 @@ PresShell::RestoreRootScrollPosition() if (historyState) { nsIFrame* scrollFrame = GetRootScrollFrame(); if (scrollFrame) { - nsIScrollableFrame* scrollableFrame; - CallQueryInterface(scrollFrame, &scrollableFrame); + nsIScrollableFrame* scrollableFrame = do_QueryFrame(scrollFrame); if (scrollableFrame) { FrameManager()->RestoreFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState); @@ -3222,8 +3218,7 @@ PresShell::GetViewToScroll(nsLayoutUtils::Direction aDirection) if (focusedContent) { nsIFrame* startFrame = GetPrimaryFrameFor(focusedContent); if (startFrame) { - nsIScrollableViewProvider* svp; - CallQueryInterface(startFrame, &svp); + nsIScrollableViewProvider* svp = do_QueryFrame(startFrame); // If this very frame provides a scroll view, start there instead of frame's // closest view, because the scroll view may be inside a child frame. // For example, this happens in the case of overflow:scroll. @@ -5995,9 +5990,7 @@ StopPluginInstance(PresShell *aShell, nsIContent *aContent) { nsIFrame *frame = aShell->FrameManager()->GetPrimaryFrameFor(aContent, -1); - nsIObjectFrame *objectFrame = nsnull; - if (frame) - CallQueryInterface(frame, &objectFrame); + nsIObjectFrame *objectFrame = do_QueryFrame(frame); if (!objectFrame) return; @@ -6281,10 +6274,9 @@ void PresShell::DoVerifyReflow() { if (nsIFrameDebug::GetVerifyTreeEnable()) { - nsIFrameDebug* frameDebug; nsIFrame* rootFrame = FrameManager()->GetRootFrame(); - if (NS_SUCCEEDED(rootFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), - (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(rootFrame); + if (frameDebug) { frameDebug->VerifyTree(); } } @@ -6426,8 +6418,7 @@ ReResolveMenusAndTrees(nsIFrame *aFrame, void *aClosure) { // Trees have a special style cache that needs to be flushed when // the theme changes. - nsTreeBodyFrame *treeBody = nsnull; - CallQueryInterface(aFrame, &treeBody); + nsTreeBodyFrame *treeBody = do_QueryFrame(aFrame); if (treeBody) treeBody->ClearStyleAndImageCaches(); @@ -6601,10 +6592,8 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg) printf("verifyreflow: "); nsAutoString name; if (nsnull != k1) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(k1->QueryInterface(NS_GET_IID(nsIFrameDebug), - (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(k1); + if (frameDebug) { frameDebug->GetFrameName(name); } } @@ -6618,10 +6607,8 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg) printf(" != "); if (nsnull != k2) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(k2->QueryInterface(NS_GET_IID(nsIFrameDebug), - (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(k2); + if (frameDebug) { frameDebug->GetFrameName(name); } } @@ -6641,10 +6628,8 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg, { printf("VerifyReflow Error:\n"); nsAutoString name; - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(k1->QueryInterface(NS_GET_IID(nsIFrameDebug), - (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(k1); + if (frameDebug) { fprintf(stdout, " "); frameDebug->GetFrameName(name); fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout); @@ -6654,8 +6639,8 @@ LogVerifyMessage(nsIFrame* k1, nsIFrame* k2, const char* aMsg, printf(" != \n"); - if (NS_SUCCEEDED(k2->QueryInterface(NS_GET_IID(nsIFrameDebug), - (void**)&frameDebug))) { + frameDebug = do_QueryFrame(k2); + if (frameDebug) { fprintf(stdout, " "); frameDebug->GetFrameName(name); fputs(NS_LossyConvertUTF16toASCII(name).get(), stdout); @@ -7013,13 +6998,13 @@ PresShell::VerifyIncrementalReflow() PRBool ok = CompareTrees(mPresContext, root1, cx, root2); if (!ok && (VERIFY_REFLOW_NOISY & gVerifyReflowFlags)) { printf("Verify reflow failed, primary tree:\n"); - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(CallQueryInterface(root1, &frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(root1); + if (frameDebug) { frameDebug->List(stdout, 0); } printf("Verification tree:\n"); - if (NS_SUCCEEDED(CallQueryInterface(root2, &frameDebug))) { + frameDebug = do_QueryFrame(root2); + if (frameDebug) { frameDebug->List(stdout, 0); } } diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index a5bed373bd1..140956e1f57 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -287,36 +287,28 @@ nsComboboxControlFrame::~nsComboboxControlFrame() } //-------------------------------------------------------------- -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsComboboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - if (aIID.Equals(NS_GET_IID(nsIComboboxControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsIRollupListener))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } else if (aIID.Equals(NS_GET_IID(nsIScrollableViewProvider))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsBlockFrame::QueryInterface(aIID, aInstancePtr); +NS_QUERYFRAME_HEAD(nsComboboxControlFrame) + NS_QUERYFRAME_ENTRY(nsIComboboxControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsISelectControlFrame) + NS_QUERYFRAME_ENTRY(nsIStatefulFrame) + NS_QUERYFRAME_ENTRY(nsIScrollableViewProvider) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) + +NS_IMPL_QUERY_INTERFACE1(nsComboboxControlFrame, nsIRollupListener) + +NS_IMETHODIMP_(nsrefcnt) +nsComboboxControlFrame::AddRef() +{ + return 2; +} + +NS_IMETHODIMP_(nsrefcnt) +nsComboboxControlFrame::Release() +{ + return 1; } #ifdef ACCESSIBILITY @@ -425,8 +417,7 @@ nsComboboxControlFrame::ShowList(nsPresContext* aPresContext, PRBool aShowList) return PR_FALSE; } - nsIFrame* listFrame; - CallQueryInterface(mListControlFrame, &listFrame); + nsIFrame* listFrame = do_QueryFrame(mListControlFrame); if (listFrame) { nsIView* view = listFrame->GetView(); NS_ASSERTION(view, "nsComboboxControlFrame view is null"); @@ -570,8 +561,7 @@ nsComboboxControlFrame::GetIntrinsicWidth(nsIRenderingContext* aRenderingContext nscoord scrollbarWidth = 0; nsPresContext* presContext = PresContext(); if (mListControlFrame) { - nsIScrollableFrame* scrollable; - CallQueryInterface(mListControlFrame, &scrollable); + nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame); NS_ASSERTION(scrollable, "List must be a scrollable frame"); scrollbarWidth = scrollable->GetDesiredScrollbarSizes(presContext, aRenderingContext).LeftRight(); @@ -676,8 +666,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext, buttonWidth = 0; } else { - nsIScrollableFrame* scrollable; - CallQueryInterface(mListControlFrame, &scrollable); + nsIScrollableFrame* scrollable = do_QueryFrame(mListControlFrame); NS_ASSERTION(scrollable, "List must be a scrollable frame"); buttonWidth = scrollable->GetDesiredScrollbarSizes(PresContext(), @@ -774,8 +763,7 @@ void nsComboboxControlFrame::SetDropDown(nsIFrame* aDropDownFrame) { mDropdownFrame = aDropDownFrame; - - CallQueryInterface(mDropdownFrame, &mListControlFrame); + mListControlFrame = do_QueryFrame(mDropdownFrame); } nsIFrame* @@ -878,15 +866,11 @@ nsComboboxControlFrame::GetIndexOfDisplayArea() NS_IMETHODIMP nsComboboxControlFrame::DoneAddingChildren(PRBool aIsDone) { - nsISelectControlFrame* listFrame = nsnull; - nsresult rv = NS_ERROR_FAILURE; - if (mDropdownFrame != nsnull) { - rv = CallQueryInterface(mDropdownFrame, &listFrame); - if (listFrame) { - rv = listFrame->DoneAddingChildren(aIsDone); - } - } - return rv; + nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame); + if (!listFrame) + return NS_ERROR_FAILURE; + + return listFrame->DoneAddingChildren(aIsDone); } NS_IMETHODIMP @@ -924,10 +908,9 @@ nsComboboxControlFrame::RemoveOption(nsPresContext* aPresContext, PRInt32 aIndex NS_IMETHODIMP nsComboboxControlFrame::GetOptionSelected(PRInt32 aIndex, PRBool* aValue) { - nsISelectControlFrame* listFrame = nsnull; NS_ASSERTION(mDropdownFrame, "No dropdown frame!"); - CallQueryInterface(mDropdownFrame, &listFrame); + nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame); NS_ASSERTION(listFrame, "No list frame!"); return listFrame->GetOptionSelected(aIndex, aValue); @@ -937,11 +920,9 @@ NS_IMETHODIMP nsComboboxControlFrame::OnSetSelectedIndex(PRInt32 aOldIndex, PRInt32 aNewIndex) { RedisplayText(aNewIndex); - - nsISelectControlFrame* listFrame = nsnull; NS_ASSERTION(mDropdownFrame, "No dropdown frame!"); - - CallQueryInterface(mDropdownFrame, &listFrame); + + nsISelectControlFrame* listFrame = do_QueryFrame(mDropdownFrame); NS_ASSERTION(listFrame, "No list frame!"); return listFrame->OnSetSelectedIndex(aOldIndex, aNewIndex); @@ -977,29 +958,23 @@ nsComboboxControlFrame::HandleEvent(nsPresContext* aPresContext, nsresult nsComboboxControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { - nsIFormControlFrame* fcFrame = nsnull; - nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame); - if (NS_FAILED(result)) { - return result; + nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame); + if (!fcFrame) { + return NS_NOINTERFACE; } - if (fcFrame) { - return fcFrame->SetFormProperty(aName, aValue); - } - return NS_OK; + + return fcFrame->SetFormProperty(aName, aValue); } nsresult nsComboboxControlFrame::GetFormProperty(nsIAtom* aName, nsAString& aValue) const { - nsIFormControlFrame* fcFrame = nsnull; - nsresult result = CallQueryInterface(mDropdownFrame, &fcFrame); - if(NS_FAILED(result)) { - return result; + nsIFormControlFrame* fcFrame = do_QueryFrame(mDropdownFrame); + if (!fcFrame) { + return NS_ERROR_FAILURE; } - if (fcFrame) { - return fcFrame->GetFormProperty(aName, aValue); - } - return NS_OK; + + return fcFrame->GetFormProperty(aName, aValue); } nsIFrame* @@ -1229,8 +1204,8 @@ nsComboboxControlFrame::Destroy() if (mDroppedDown) { // Get parent view - nsIFrame * listFrame; - if (NS_OK == mListControlFrame->QueryInterface(NS_GET_IID(nsIFrame), (void **)&listFrame)) { + nsIFrame * listFrame = do_QueryFrame(mListControlFrame); + if (listFrame) { nsIView* view = listFrame->GetView(); NS_ASSERTION(view, "nsComboboxControlFrame view is null"); if (view) { @@ -1446,9 +1421,8 @@ nsIScrollableView* nsComboboxControlFrame::GetScrollableView() if (!mDropdownFrame) return nsnull; - nsIScrollableFrame* scrollable = nsnull; - nsresult rv = CallQueryInterface(mDropdownFrame, &scrollable); - if (NS_FAILED(rv)) + nsIScrollableFrame* scrollable = do_QueryFrame(mDropdownFrame); + if (!scrollable) return nsnull; return scrollable->GetScrollableView(); @@ -1464,8 +1438,7 @@ nsComboboxControlFrame::OnOptionSelected(nsPresContext* aPresContext, PRBool aSelected) { if (mDroppedDown) { - nsCOMPtr selectFrame - = do_QueryInterface(mListControlFrame); + nsISelectControlFrame *selectFrame = do_QueryFrame(mListControlFrame); if (selectFrame) { selectFrame->OnOptionSelected(aPresContext, aIndex, aSelected); } @@ -1517,8 +1490,7 @@ nsComboboxControlFrame::SaveState(SpecialStateID aStateID, if (!mListControlFrame) return NS_ERROR_FAILURE; - nsIStatefulFrame* stateful; - CallQueryInterface(mListControlFrame, &stateful); + nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame); return stateful->SaveState(aStateID, aState); } @@ -1528,11 +1500,9 @@ nsComboboxControlFrame::RestoreState(nsPresState* aState) if (!mListControlFrame) return NS_ERROR_FAILURE; - nsIStatefulFrame* stateful; - nsresult rv = CallQueryInterface(mListControlFrame, &stateful); - NS_ASSERTION(NS_SUCCEEDED(rv), "Must implement nsIStatefulFrame"); - rv = stateful->RestoreState(aState); - return rv; + nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame); + NS_ASSERTION(stateful, "Must implement nsIStatefulFrame"); + return stateful->RestoreState(aState); } diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index 08e70aef97b..5f5f5ccc396 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -96,8 +96,8 @@ public: nsComboboxControlFrame(nsStyleContext* aContext); ~nsComboboxControlFrame(); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME + NS_DECL_ISUPPORTS_INHERITED // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent(nsTArray& aElements); @@ -292,10 +292,6 @@ protected: #ifdef DO_REFLOW_COUNTER PRInt32 mReflowId; #endif - -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } }; #endif diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index a670ba54d0f..2ed1e297273 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -228,23 +228,10 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) return NS_OK; } -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsBlockFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsFileControlFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) void nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint) diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index 18e36f66ede..b957fd3d036 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -63,7 +63,7 @@ public: const nsRect& aDirtyRect, const nsDisplayListSet& aLists); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME // nsIFormControlFrame virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); @@ -183,9 +183,6 @@ private: */ void SyncAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aWhichControls); - - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } }; #endif diff --git a/layout/forms/nsFormControlFrame.cpp b/layout/forms/nsFormControlFrame.cpp index 75da5959c4f..359a9bda3b4 100644 --- a/layout/forms/nsFormControlFrame.cpp +++ b/layout/forms/nsFormControlFrame.cpp @@ -62,19 +62,9 @@ nsFormControlFrame::Destroy() nsLeafFrame::Destroy(); } -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsFormControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsLeafFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsFormControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame) nscoord nsFormControlFrame::GetIntrinsicWidth() diff --git a/layout/forms/nsFormControlFrame.h b/layout/forms/nsFormControlFrame.h index 7a819189a32..86ee407d3f1 100644 --- a/layout/forms/nsFormControlFrame.h +++ b/layout/forms/nsFormControlFrame.h @@ -64,7 +64,7 @@ public: ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); } - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME /** * Respond to a gui event @@ -124,11 +124,6 @@ protected: */ void GetCurrentCheckState(PRBool* aState); - -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } - }; #endif diff --git a/layout/forms/nsGfxButtonControlFrame.cpp b/layout/forms/nsGfxButtonControlFrame.cpp index 40e5eeb6d5e..bfa4a784d26 100644 --- a/layout/forms/nsGfxButtonControlFrame.cpp +++ b/layout/forms/nsGfxButtonControlFrame.cpp @@ -186,19 +186,9 @@ NS_IMETHODIMP nsGfxButtonControlFrame::GetAccessible(nsIAccessible** aAccessible } #endif -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsGfxButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLButtonControlFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsGfxButtonControlFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLButtonControlFrame) // Initially we hardcoded the default strings here. // Next, we used html.css to store the default label for various types diff --git a/layout/forms/nsGfxButtonControlFrame.h b/layout/forms/nsGfxButtonControlFrame.h index 98fc5d6fa22..6c5d9892178 100644 --- a/layout/forms/nsGfxButtonControlFrame.h +++ b/layout/forms/nsGfxButtonControlFrame.h @@ -74,8 +74,8 @@ public: #ifdef DEBUG NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent(nsTArray& aElements); @@ -101,9 +101,6 @@ protected: PRBool IsFileBrowseButton(PRInt32 type); // Browse button of file input private: - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } - nsSize mSuggestedSize; nsCOMPtr mTextContent; }; diff --git a/layout/forms/nsGfxCheckboxControlFrame.cpp b/layout/forms/nsGfxCheckboxControlFrame.cpp index 06b9ae6bed5..6a77e8f2ddc 100644 --- a/layout/forms/nsGfxCheckboxControlFrame.cpp +++ b/layout/forms/nsGfxCheckboxControlFrame.cpp @@ -93,22 +93,9 @@ nsGfxCheckboxControlFrame::~nsGfxCheckboxControlFrame() } -//---------------------------------------------------------------------- -// nsISupports -//---------------------------------------------------------------------- -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsGfxCheckboxControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsICheckboxControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsFormControlFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsGfxCheckboxControlFrame) + NS_QUERYFRAME_ENTRY(nsICheckboxControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsFormControlFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsGfxCheckboxControlFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/forms/nsGfxCheckboxControlFrame.h b/layout/forms/nsGfxCheckboxControlFrame.h index 19d6a3d03f3..301a6622d95 100644 --- a/layout/forms/nsGfxCheckboxControlFrame.h +++ b/layout/forms/nsGfxCheckboxControlFrame.h @@ -78,7 +78,7 @@ public: virtual void SetAdditionalStyleContext(PRInt32 aIndex, nsStyleContext* aStyleContext); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME void PaintCheckBox(nsIRenderingContext& aRenderingContext, nsPoint aPt, const nsRect& aDirtyRect); @@ -91,11 +91,6 @@ protected: PRBool GetCheckboxState(); nsRefPtr mCheckButtonFaceStyle; - -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } - }; #endif diff --git a/layout/forms/nsGfxRadioControlFrame.cpp b/layout/forms/nsGfxRadioControlFrame.cpp index b9ff00fbd5b..38aabb05f4d 100644 --- a/layout/forms/nsGfxRadioControlFrame.cpp +++ b/layout/forms/nsGfxRadioControlFrame.cpp @@ -61,19 +61,9 @@ nsGfxRadioControlFrame::~nsGfxRadioControlFrame() { } -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsGfxRadioControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIRadioControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsFormControlFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsGfxRadioControlFrame) + NS_QUERYFRAME_ENTRY(nsIRadioControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsFormControlFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsGfxRadioControlFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/forms/nsGfxRadioControlFrame.h b/layout/forms/nsGfxRadioControlFrame.h index e4d90027b58..8922376014f 100644 --- a/layout/forms/nsGfxRadioControlFrame.h +++ b/layout/forms/nsGfxRadioControlFrame.h @@ -60,8 +60,9 @@ public: nsGfxRadioControlFrame(nsStyleContext* aContext); ~nsGfxRadioControlFrame(); - //nsIRadioControlFrame methods - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME + + //nsIRadioControlFrame methods NS_IMETHOD SetRadioButtonFaceStyleContext(nsStyleContext *aRadioButtonFaceStyleContext); #ifdef ACCESSIBILITY NS_IMETHOD GetAccessible(nsIAccessible** aAccessible); @@ -81,10 +82,6 @@ public: protected: nsRefPtr mRadioButtonFaceStyle; - -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } }; #endif diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index 1c2cd7f03cb..1964b9c0bc1 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -105,31 +105,9 @@ nsHTMLButtonControlFrame::Init( return rv; } -nsrefcnt nsHTMLButtonControlFrame::AddRef(void) -{ - NS_WARNING("not supported"); - return 1; -} - -nsrefcnt nsHTMLButtonControlFrame::Release(void) -{ - NS_WARNING("not supported"); - return 1; -} - -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsHTMLButtonControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsHTMLButtonControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsHTMLButtonControlFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index 0581b8cb46b..4473d2633d9 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -65,7 +65,7 @@ public: virtual void Destroy(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, @@ -142,9 +142,6 @@ protected: nsMargin aFocusPadding, nsReflowStatus& aStatus); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - PRIntn GetSkipSides() const; nsButtonFrameRenderer mRenderer; }; diff --git a/layout/forms/nsICheckboxControlFrame.h b/layout/forms/nsICheckboxControlFrame.h index 8cf81ffd346..f553a0f72ef 100644 --- a/layout/forms/nsICheckboxControlFrame.h +++ b/layout/forms/nsICheckboxControlFrame.h @@ -38,24 +38,18 @@ #ifndef nsICheckControlFrame_h___ #define nsICheckControlFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsStyleContext; class nsPresContext; -// IID for the nsICheckControlFrame class -// {401347ED-0101-11d4-9706-0060B0FB9956} -#define NS_ICHECKBOXCONTROLFRAME_IID \ -{ 0x401347ed, 0x101, 0x11d4, \ - { 0x97, 0x6, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56 } } - /** * nsICheckControlFrame is the common interface radio buttons. * @see nsFromControlFrame and its base classes for more info */ -class nsICheckboxControlFrame : public nsISupports { - +class nsICheckboxControlFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICHECKBOXCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsICheckboxControlFrame) /** * Sets the Pseudo Style Contexts for the Check button @@ -69,8 +63,5 @@ public: NS_IMETHOD OnChecked(nsPresContext* aPresContext, PRBool aChecked) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsICheckboxControlFrame, - NS_ICHECKBOXCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsIComboboxControlFrame.h b/layout/forms/nsIComboboxControlFrame.h index 48aa1ee81e5..ec8067c0a07 100644 --- a/layout/forms/nsIComboboxControlFrame.h +++ b/layout/forms/nsIComboboxControlFrame.h @@ -38,7 +38,7 @@ #ifndef nsIComboboxControlFrame_h___ #define nsIComboboxControlFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsFont.h" class nsPresContext; @@ -47,21 +47,15 @@ class nsIContent; class nsVoidArray; class nsCSSFrameConstructor; - -// IID for the nsIComboboxControlFrame class -#define NS_ICOMBOBOXCONTROLFRAME_IID \ - { 0x23f75e9c, 0x6850, 0x11da, \ - { 0x95, 0x2c, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } - /** * nsIComboboxControlFrame is the common interface for frames of form controls. It * provides a uniform way of creating widgets, resizing, and painting. * @see nsLeafFrame and its base classes for more info */ -class nsIComboboxControlFrame : public nsISupports { - +class nsIComboboxControlFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICOMBOBOXCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIComboboxControlFrame) /** * Indicates whether the list is dropped down @@ -127,8 +121,5 @@ public: virtual PRInt32 GetIndexOfDisplayArea() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIComboboxControlFrame, - NS_ICOMBOBOXCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsIFormControlFrame.h b/layout/forms/nsIFormControlFrame.h index af736bb47c4..6e757e70521 100644 --- a/layout/forms/nsIFormControlFrame.h +++ b/layout/forms/nsIFormControlFrame.h @@ -38,26 +38,21 @@ #ifndef nsIFormControlFrame_h___ #define nsIFormControlFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsAString; class nsIContent; class nsIAtom; struct nsSize; -// IID for the nsIFormControlFrame class -#define NS_IFORMCONTROLFRAME_IID \ - { 0x189e1565, 0x44f, 0x11da, \ - { 0x94, 0xfc, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } - /** * nsIFormControlFrame is the common interface for frames of form controls. It * provides a uniform way of creating widgets, resizing, and painting. * @see nsLeafFrame and its base classes for more info */ -class nsIFormControlFrame : public nsISupports { - +class nsIFormControlFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFORMCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIFormControlFrame) /** * @@ -86,7 +81,5 @@ public: virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIFormControlFrame, NS_IFORMCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsIListControlFrame.h b/layout/forms/nsIListControlFrame.h index 80d815d0c00..bea580ba0a6 100644 --- a/layout/forms/nsIListControlFrame.h +++ b/layout/forms/nsIListControlFrame.h @@ -38,24 +38,19 @@ #ifndef nsIListControlFrame_h___ #define nsIListControlFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsFont.h" class nsPresContext; class nsAString; class nsIContent; -// IID for the nsIListControlFrame class -#define NS_ILISTCONTROLFRAME_IID \ -{ 0x4de9ab73, 0x31b5, 0x4d92, \ - { 0xb7, 0xe4, 0x73, 0xb4, 0x4d, 0xcb, 0xfc, 0xda } } - /** * nsIListControlFrame is the interface for frame-based listboxes. */ -class nsIListControlFrame : public nsISupports { - +class nsIListControlFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ILISTCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIListControlFrame) /** * Sets the ComboBoxFrame @@ -126,7 +121,5 @@ public: virtual void OnContentReset() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIListControlFrame, NS_ILISTCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsIRadioControlFrame.h b/layout/forms/nsIRadioControlFrame.h index b205aff32b4..6301b61e859 100644 --- a/layout/forms/nsIRadioControlFrame.h +++ b/layout/forms/nsIRadioControlFrame.h @@ -38,24 +38,17 @@ #ifndef nsIRadioControlFrame_h___ #define nsIRadioControlFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsStyleContext; -// IID for the nsIRadioControlFrame class -// {06450E00-24D9-11d3-966B-00105A1B1B76} -#define NS_IRADIOCONTROLFRAME_IID \ -{ 0x6450e00, 0x24d9, 0x11d3, \ - { 0x96, 0x6b, 0x0, 0x10, 0x5a, 0x1b, 0x1b, 0x76 } } - - /** * nsIRadioControlFrame is the common interface radio buttons. * @see nsFormControlFrame and its base classes for more info */ -class nsIRadioControlFrame : public nsISupports { - +class nsIRadioControlFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRADIOCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIRadioControlFrame) /** * Sets the Pseudo Style Contexts for the Radio button @@ -69,7 +62,5 @@ public: NS_IMETHOD OnChecked(nsPresContext* aPresContext, PRBool aChecked) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIRadioControlFrame, NS_IRADIOCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsISelectControlFrame.h b/layout/forms/nsISelectControlFrame.h index cb9b0914ec0..278cd31e1f2 100644 --- a/layout/forms/nsISelectControlFrame.h +++ b/layout/forms/nsISelectControlFrame.h @@ -39,23 +39,17 @@ #ifndef nsISelectControlFrame_h___ #define nsISelectControlFrame_h___ -#include "nsISupports.h" - -// IID for the nsISelectControlFrame class -// f8a1b329-d0d8-4bd5-a9ab-08c3c0f2f166 -#define NS_ISELECTCONTROLFRAME_IID \ -{ 0xf8a1b329, 0xd0d8, 0x4bd5, \ - { 0xa9, 0xab, 0x08, 0xc3, 0xc0, 0xf2, 0xf1, 0x66 } } +#include "nsQueryFrame.h" class nsIDOMHTMLOptionElement; /** * nsISelectControlFrame is the interface for combo boxes and listboxes */ -class nsISelectControlFrame : public nsISupports { - +class nsISelectControlFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISELECTCONTROLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISelectControlFrame) /** * Adds an option to the list at index @@ -94,7 +88,4 @@ public: }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISelectControlFrame, - NS_ISELECTCONTROLFRAME_IID) - #endif diff --git a/layout/forms/nsITextControlFrame.h b/layout/forms/nsITextControlFrame.h index 1a45fde87d7..85c677b8393 100644 --- a/layout/forms/nsITextControlFrame.h +++ b/layout/forms/nsITextControlFrame.h @@ -45,15 +45,10 @@ class nsIDocShell; class nsISelectionController; class nsFrameSelection; -#define NS_IGFXTEXTCONTROLFRAME2_IID \ -{/* 0c3b64da-4431-11da-94fd-00e08161165f*/ \ -0xc3b64da, 0x4431, 0x11da, \ -{ 0x94, 0xfd, 0x0, 0xe0, 0x81, 0x61, 0x16, 0x5f } } - class nsITextControlFrame : public nsIFormControlFrame { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGFXTEXTCONTROLFRAME2_IID) + NS_DECLARE_FRAME_ACCESSOR(nsITextControlFrame) NS_IMETHOD GetEditor(nsIEditor **aEditor) = 0; @@ -94,7 +89,4 @@ public: virtual nsresult GetPhonetic(nsAString& aPhonetic) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsITextControlFrame, - NS_IGFXTEXTCONTROLFRAME2_IID) - #endif diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index b124708d59f..2d7645fe037 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -81,7 +81,8 @@ public: NS_IMETHOD Init(nsIContent* aContent, nsIFrame* aParent, nsIFrame* aPrevInFlow); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + + NS_DECL_QUERYFRAME NS_IMETHOD Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, @@ -110,10 +111,6 @@ public: virtual void SetFocus(PRBool aOn, PRBool aRepaint); virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue); virtual nsresult GetFormProperty(nsIAtom* aName, nsAString& aValue) const; - -protected: - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); }; @@ -160,19 +157,9 @@ nsImageControlFrame::Init(nsIContent* aContent, IntPointDtorFunc); } -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsImageControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsImageControlFrameSuper::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsImageControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsImageControlFrameSuper) #ifdef ACCESSIBILITY NS_IMETHODIMP nsImageControlFrame::GetAccessible(nsIAccessible** aAccessible) @@ -192,18 +179,6 @@ NS_IMETHODIMP nsImageControlFrame::GetAccessible(nsIAccessible** aAccessible) } #endif -nsrefcnt nsImageControlFrame::AddRef(void) -{ - NS_WARNING("not supported"); - return 1; -} - -nsrefcnt nsImageControlFrame::Release(void) -{ - NS_WARNING("not supported"); - return 1; -} - nsIAtom* nsImageControlFrame::GetType() const { diff --git a/layout/forms/nsIsIndexFrame.cpp b/layout/forms/nsIsIndexFrame.cpp index 0485587ec2c..df24668ae4f 100644 --- a/layout/forms/nsIsIndexFrame.cpp +++ b/layout/forms/nsIsIndexFrame.cpp @@ -147,7 +147,8 @@ nsIsIndexFrame::GetInputFrame(nsIFormControlFrame** oFrame) if (presShell && mInputContent) { nsIFrame *frame = presShell->GetPrimaryFrameFor(mInputContent); if (frame) { - return CallQueryInterface(frame, oFrame); + *oFrame = do_QueryFrame(frame); + return *oFrame ? NS_OK : NS_NOINTERFACE; } } return NS_OK; @@ -233,20 +234,17 @@ nsIsIndexFrame::CreateAnonymousContent(nsTArray& aElements) return NS_OK; } +NS_QUERYFRAME_HEAD(nsIsIndexFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsIStatefulFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) + // Frames are not refcounted, no need to AddRef NS_IMETHODIMP nsIsIndexFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) { NS_PRECONDITION(aInstancePtr, "null out param"); - if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } if (aIID.Equals(NS_GET_IID(nsIDOMKeyListener))) { *aInstancePtr = static_cast(this); return NS_OK; @@ -256,7 +254,7 @@ nsIsIndexFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) return NS_OK; } - return nsBlockFrame::QueryInterface(aIID, aInstancePtr); + return NS_NOINTERFACE; } nscoord diff --git a/layout/forms/nsIsIndexFrame.h b/layout/forms/nsIsIndexFrame.h index c5ef853a9e9..42e1cd385de 100644 --- a/layout/forms/nsIsIndexFrame.h +++ b/layout/forms/nsIsIndexFrame.h @@ -81,9 +81,12 @@ public: */ NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent); // we only care when a key is pressed - // nsIFormControlFrame + NS_DECL_QUERYFRAME + + // nsISupports NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + // nsIFormControlFrame virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext); virtual PRBool IsLeaf() const; diff --git a/layout/forms/nsLegendFrame.cpp b/layout/forms/nsLegendFrame.cpp index e66cae2d738..5556ee2ca65 100644 --- a/layout/forms/nsLegendFrame.cpp +++ b/layout/forms/nsLegendFrame.cpp @@ -52,8 +52,6 @@ #include "nsFont.h" #include "nsFormControlFrame.h" -static NS_DEFINE_IID(kLegendFrameCID, NS_LEGEND_FRAME_CID); - nsIFrame* NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { @@ -77,19 +75,9 @@ nsLegendFrame::Destroy() nsBlockFrame::Destroy(); } -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsLegendFrame::QueryInterface(REFNSIID aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(kLegendFrameCID)) { - *aInstancePtr = this; - return NS_OK; - } - - return nsBlockFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsLegendFrame) + NS_QUERYFRAME_ENTRY(nsLegendFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) NS_IMETHODIMP nsLegendFrame::Reflow(nsPresContext* aPresContext, diff --git a/layout/forms/nsLegendFrame.h b/layout/forms/nsLegendFrame.h index b616847092c..971fddd9801 100644 --- a/layout/forms/nsLegendFrame.h +++ b/layout/forms/nsLegendFrame.h @@ -49,14 +49,13 @@ struct nsHTMLReflowMetrics; class nsIRenderingContext; struct nsRect; -#define NS_LEGEND_FRAME_CID \ -{ 0x73805d40, 0x5a24, 0x11d2, { 0x80, 0x46, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } } - class nsLegendFrame : public nsBlockFrame { public: + NS_DECLARE_FRAME_ACCESSOR(nsLegendFrame) + nsLegendFrame(nsStyleContext* aContext) : nsBlockFrame(aContext) {} - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME NS_IMETHOD Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index ee4cadb4b67..0b43268afe2 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -386,28 +386,11 @@ nsListControlFrame::InvalidateFocus() } } -//--------------------------------------------------------- -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsListControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIListControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsISelectControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLScrollFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsListControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) + NS_QUERYFRAME_ENTRY(nsIListControlFrame) + NS_QUERYFRAME_ENTRY(nsISelectControlFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLScrollFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsListControlFrame::GetAccessible(nsIAccessible** aAccessible) @@ -1366,7 +1349,7 @@ void nsListControlFrame::SetComboboxFrame(nsIFrame* aComboboxFrame) { if (nsnull != aComboboxFrame) { - aComboboxFrame->QueryInterface(NS_GET_IID(nsIComboboxControlFrame),(void**) &mComboboxFrame); + mComboboxFrame = do_QueryFrame(aComboboxFrame); } } @@ -2201,8 +2184,7 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) if (!nsComboboxControlFrame::ToolkitHasNativePopup()) { PRBool isDroppedDown = mComboboxFrame->IsDroppedDown(); - nsIFrame* comboFrame; - CallQueryInterface(mComboboxFrame, &comboFrame); + nsIFrame* comboFrame = do_QueryFrame(mComboboxFrame); nsWeakFrame weakFrame(comboFrame); mComboboxFrame->ShowDropDown(!isDroppedDown); if (!weakFrame.IsAlive()) diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index 5f6201d1db7..77a7adeece7 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -80,8 +80,7 @@ class nsListControlFrame : public nsHTMLScrollFrame, public: friend nsIFrame* NS_NewListControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME // nsIFrame NS_IMETHOD HandleEvent(nsPresContext* aPresContext, diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index f56c451561a..55564658a22 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1004,34 +1004,13 @@ NS_NewTextControlFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) return new (aPresShell) nsTextControlFrame(aPresShell, aContext); } -NS_IMPL_ADDREF_INHERITED(nsTextControlFrame, nsBoxFrame) -NS_IMPL_RELEASE_INHERITED(nsTextControlFrame, nsBoxFrame) - - -NS_IMETHODIMP -nsTextControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsITextControlFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIScrollableViewProvider)) && IsScrollable()) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsBoxFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsTextControlFrame) + NS_QUERYFRAME_ENTRY(nsIFormControlFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsITextControlFrame) + if (nsIScrollableViewProvider::kFrameIID == id && IsScrollable()) + return static_cast(this); +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsTextControlFrame::GetAccessible(nsIAccessible** aAccessible) @@ -1394,8 +1373,7 @@ nsTextControlFrame::CalcIntrinsicSize(nsIRenderingContext* aRenderingContext, if (IsTextArea()) { nsIFrame* first = GetFirstChild(nsnull); - nsIScrollableFrame *scrollableFrame; - CallQueryInterface(first, &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(first); NS_ASSERTION(scrollableFrame, "Child must be scrollable"); nsMargin scrollbarSizes = @@ -2818,8 +2796,7 @@ nsTextControlFrame::SetInitialChildList(nsIAtom* aListName, // than descending from the root frame of the frame hierarchy. first->AddStateBits(NS_FRAME_REFLOW_ROOT); - nsIScrollableFrame *scrollableFrame = nsnull; - CallQueryInterface(first, &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(first); NS_ASSERTION(scrollableFrame, "Child must be scrollable"); // we must turn off scrollbars for singleline text controls @@ -2864,10 +2841,7 @@ nsTextControlFrame::SetInitialChildList(nsIAtom* aListName, nsIScrollableView* nsTextControlFrame::GetScrollableView() { nsIFrame* first = GetFirstChild(nsnull); - nsIScrollableFrame* scrollableFrame = nsnull; - if (first) { - CallQueryInterface(first, &scrollableFrame); - } + nsIScrollableFrame* scrollableFrame = do_QueryFrame(first); return scrollableFrame ? scrollableFrame->GetScrollableView() : nsnull; } diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 8ca8bb1f03c..a87cfd5f3b1 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -168,7 +168,7 @@ public: NS_IMETHOD GetText(nsString* aText); - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME public: //for methods who access nsTextControlFrame directly /** diff --git a/layout/generic/Makefile.in b/layout/generic/Makefile.in index 423de86dba8..403e1483fc6 100644 --- a/layout/generic/Makefile.in +++ b/layout/generic/Makefile.in @@ -83,6 +83,7 @@ REQUIRES += accessibility endif EXPORTS = \ + nsQueryFrame.h \ nsFrameList.h \ nsHTMLParts.h \ nsHTMLReflowMetrics.h \ diff --git a/layout/generic/nsAbsoluteContainingBlock.cpp b/layout/generic/nsAbsoluteContainingBlock.cpp index 7f30889a9f3..ff2ded318b2 100644 --- a/layout/generic/nsAbsoluteContainingBlock.cpp +++ b/layout/generic/nsAbsoluteContainingBlock.cpp @@ -369,8 +369,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent); printf("abs pos "); if (nsnull != aKidFrame) { - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(CallQueryInterface(aKidFrame, &frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(aKidFrame); + if (frameDebug) { nsAutoString name; frameDebug->GetFrameName(name); printf("%s ", NS_LossyConvertUTF16toASCII(name).get()); @@ -513,8 +513,8 @@ nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegat nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1); printf("abs pos "); if (nsnull != aKidFrame) { - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(CallQueryInterface(aKidFrame, &frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(aKidFrame); + if (frameDebug) { nsAutoString name; frameDebug->GetFrameName(name); printf("%s ", NS_LossyConvertUTF16toASCII(name).get()); diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 23c0f32d551..33b05bf898a 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -281,7 +281,7 @@ NS_IMETHODIMP BRFrame::GetAccessible(nsIAccessible** aAccessible) // "bogus node" used when there is no text in the control return NS_ERROR_FAILURE; } - return accService->CreateHTMLBRAccessible(static_cast(this), aAccessible); + return accService->CreateHTMLBRAccessible(this, aAccessible); } #endif diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 6d5ddf06b3a..ebb82097a46 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -266,8 +266,6 @@ RecordReflowStatus(PRBool aChildIsBlock, nsReflowStatus aFrameReflowStatus) //---------------------------------------------------------------------- -const nsIID kBlockFrameCID = NS_BLOCK_FRAME_CID; - nsIFrame* NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags) { @@ -330,17 +328,9 @@ nsBlockFrame::GetLineIterator() return it; } -NS_IMETHODIMP -nsBlockFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(kBlockFrameCID)) { - *aInstancePtr = static_cast(static_cast(this)); - return NS_OK; - } - return nsBlockFrameSuper::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsBlockFrame) + NS_QUERYFRAME_ENTRY(nsBlockFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrameSuper) nsSplittableType nsBlockFrame::GetSplittableType() const @@ -449,9 +439,8 @@ nsBlockFrame::List(FILE* out, PRInt32 aIndent) const } fputs("<\n", out); while (kid) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(CallQueryInterface(kid, &frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(kid); + if (frameDebug) { frameDebug->List(out, aIndent + 1); } kid = kid->GetNextSibling(); @@ -832,8 +821,7 @@ CalculateContainingBlockSizeForAbsolutes(const nsHTMLReflowState& aReflowState, if (aLastRS != &aReflowState) { // Scrollbars need to be specifically excluded, if present, because they are outside the // padding-edge. We need better APIs for getting the various boxes from a frame. - nsIScrollableFrame* scrollFrame; - CallQueryInterface(aLastRS->frame, &scrollFrame); + nsIScrollableFrame* scrollFrame = do_QueryFrame(aLastRS->frame); nsMargin scrollbars(0,0,0,0); if (scrollFrame) { scrollbars = diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index 14dad1551c4..a3713fa493e 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -127,11 +127,6 @@ class nsIntervalSet; #define nsBlockFrameSuper nsHTMLContainerFrame -#define NS_BLOCK_FRAME_CID \ - { 0xa6cf90df, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - -extern const nsIID kBlockFrameCID; - /* * Base class for block and inline frames. * The block frame has an additional named child list: @@ -142,6 +137,8 @@ extern const nsIID kBlockFrameCID; class nsBlockFrame : public nsBlockFrameSuper { public: + NS_DECLARE_FRAME_ACCESSOR(nsBlockFrame) + typedef nsLineList::iterator line_iterator; typedef nsLineList::const_iterator const_line_iterator; typedef nsLineList::reverse_iterator reverse_line_iterator; @@ -158,8 +155,8 @@ public: friend nsIFrame* NS_NewBlockFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFlags); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + // nsQueryFrame + NS_DECL_QUERYFRAME // nsIFrame NS_IMETHOD Init(nsIContent* aContent, diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 04e0a8297f4..7a139feaf51 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -1643,8 +1643,8 @@ nsContainerFrame::List(FILE* out, PRInt32 aIndent) const NS_ASSERTION(kid->GetParent() == (nsIFrame*)this, "bad parent frame pointer"); // Have the child frame list - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(kid); + if (frameDebug) { frameDebug->List(out, aIndent + 1); } kid = kid->GetNextSibling(); diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp index c9f70a2712e..c32def160e7 100644 --- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -372,7 +372,6 @@ nsFloatManager::List(FILE* out) const fi.mRect.x, fi.mRect.y, fi.mRect.width, fi.mRect.height, fi.mLeftYMost, fi.mRightYMost); } - return NS_OK; } #endif diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index c9987442d39..0bbdb8fe416 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -273,10 +273,8 @@ nsIFrameDebug::RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aIn if (nsnull != shell) { nsIFrame* frame = shell->FrameManager()->GetRootFrame(); if(nsnull != frame) { - nsIFrameDebug* debugFrame; - nsresult rv; - rv = frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&debugFrame); - if(NS_SUCCEEDED(rv)) + nsIFrameDebug* debugFrame = do_QueryFrame(frame); + if (debugFrame) debugFrame->List(out, aIndent); } } @@ -366,42 +364,12 @@ nsFrame::~nsFrame() mStyleContext->Release(); } -///////////////////////////////////////////////////////////////////////////// -// nsISupports - -NS_IMETHODIMP -nsFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - +NS_QUERYFRAME_HEAD(nsFrame) + NS_QUERYFRAME_ENTRY(nsIFrame) #ifdef DEBUG - if (aIID.Equals(NS_GET_IID(nsIFrameDebug))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } + NS_QUERYFRAME_ENTRY(nsIFrameDebug) #endif - - if (aIID.Equals(NS_GET_IID(nsIFrame)) || - aIID.Equals(NS_GET_IID(nsISupports))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - *aInstancePtr = nsnull; - return NS_ERROR_NO_INTERFACE; -} - -nsrefcnt nsFrame::AddRef(void) -{ - NS_WARNING("not supported for frames"); - return 1; -} - -nsrefcnt nsFrame::Release(void) -{ - NS_WARNING("not supported for frames"); - return 1; -} +NS_QUERYFRAME_TAIL ///////////////////////////////////////////////////////////////////////////// // nsIFrame @@ -1725,9 +1693,8 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection, while (frame && NS_SUCCEEDED(result)) { // Check for a table cell by querying to a known CellFrame interface - nsITableCellLayout *cellElement; - result = (frame)->QueryInterface(NS_GET_IID(nsITableCellLayout), (void **)&cellElement); - if (NS_SUCCEEDED(result) && cellElement) + nsITableCellLayout *cellElement = do_QueryFrame(frame); + if (cellElement) { foundCell = PR_TRUE; //TODO: If we want to use proximity to top or left border @@ -1739,9 +1706,8 @@ nsFrame::GetDataForTableSelection(const nsFrameSelection *aFrameSelection, // If not a cell, check for table // This will happen when starting frame is the table or child of a table, // such as a row (we were inbetween cells or in table border) - nsITableLayout *tableElement; - result = (frame)->QueryInterface(NS_GET_IID(nsITableLayout), (void **)&tableElement); - if (NS_SUCCEEDED(result) && tableElement) + nsITableLayout *tableElement = do_QueryFrame(frame); + if (tableElement) { foundTable = PR_TRUE; //TODO: How can we select row when along left table edge @@ -4293,8 +4259,8 @@ nsFrame::GetSelectionController(nsPresContext *aPresContext, nsISelectionControl nsIFrame *frame = this; while (frame && (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION)) { - nsITextControlFrame *tcf; - if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITextControlFrame),(void**)&tcf))) { + nsITextControlFrame *tcf = do_QueryFrame(frame); + if (tcf) { NS_IF_ADDREF(*aSelCon = tcf->GetOwnedSelectionController()); return NS_OK; } @@ -4318,8 +4284,8 @@ nsIFrame::GetConstFrameSelection() { nsIFrame *frame = this; while (frame && (frame->GetStateBits() & NS_FRAME_INDEPENDENT_SELECTION)) { - nsITextControlFrame *tcf; - if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITextControlFrame),(void**)&tcf))) { + nsITextControlFrame *tcf = do_QueryFrame(frame); + if (tcf) { return tcf->GetOwnedFrameSelection(); } frame = frame->GetParent(); @@ -4407,9 +4373,8 @@ nsFrame::DumpBaseRegressionData(nsPresContext* aPresContext, FILE* out, PRInt32 } aIndent++; while (kid) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(kid); + if (kid) { frameDebug->DumpRegressionData(aPresContext, out, aIndent, aIncludeStyleData); } kid = kid->GetNextSibling(); @@ -4818,9 +4783,8 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsDirection aDirection) // Treat form controls as inline leaves // XXX we really need a way to determine whether a frame is inline-level - nsIFormControlFrame* fcf; // used only for QI - nsresult rv = aFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcf); - if (NS_SUCCEEDED(rv)) + nsIFormControlFrame* fcf = do_QueryFrame(aFrame); + if (fcf) return result; // Check the frame itself @@ -6086,7 +6050,7 @@ nsIFrame::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse) // because the extra focus outlines are considered unnecessarily ugly. // When clicked on, the selection position within the element // will be enough to make them keyboard scrollable. - nsCOMPtr scrollFrame = do_QueryInterface(this); + nsIScrollableFrame *scrollFrame = do_QueryFrame(this); if (scrollFrame) { nsMargin margin = scrollFrame->GetActualScrollbarSizes(); if (margin.top || margin.right || margin.bottom || margin.left) { @@ -7372,8 +7336,8 @@ void DR_State::DisplayFrameTypeInfo(nsIFrame* aFrame, } if(!strcmp(frameTypeInfo->mNameAbbrev, "unknown")) { nsAutoString name; - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(aFrame); + if (frameDebug) { frameDebug->GetFrameName(name); printf("%s %p ", NS_LossyConvertUTF16toASCII(name).get(), (void*)aFrame); } diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 334ddd0f1b9..f464934b256 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -156,8 +156,8 @@ private: public: - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + // nsQueryFrame + NS_DECL_QUERYFRAME // nsIFrame NS_IMETHOD Init(nsIContent* aContent, @@ -442,9 +442,8 @@ public: static void ListTag(FILE* out, nsIFrame* aFrame) { nsAutoString tmp; - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(aFrame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(aFrame); + if (frameDebug) { frameDebug->GetFrameName(tmp); } fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); @@ -622,10 +621,6 @@ private: NS_IMETHODIMP RefreshSizeCache(nsBoxLayoutState& aState); virtual nsILineIterator* GetLineIterator(); - -protected: - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); }; // Start Display Reflow Debugging diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index a336f2dbca8..def4ca94ca7 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -120,10 +120,7 @@ public: NS_IMETHOD GetFrameName(nsAString& aResult) const; #endif - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void) { return 2; } - NS_IMETHOD_(nsrefcnt) Release(void) { return 1; } + NS_DECL_QUERYFRAME virtual nsIAtom* GetType() const; @@ -242,20 +239,9 @@ NS_IMETHODIMP nsSubDocumentFrame::GetAccessible(nsIAccessible** aAccessible) } #endif -//-------------------------------------------------------------- -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -nsSubDocumentFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIFrameFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsLeafFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsSubDocumentFrame) + NS_QUERYFRAME_ENTRY(nsIFrameFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsLeafFrame) NS_IMETHODIMP nsSubDocumentFrame::Init(nsIContent* aContent, @@ -656,10 +642,7 @@ nsSubDocumentFrame::AttributeChanged(PRInt32 aNameSpaceID, if (parentFrame) { // There is no interface for nsHTMLFramesetFrame so QI'ing to // concrete class, yay! - nsHTMLFramesetFrame* framesetFrame = nsnull; - parentFrame->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame), - (void **)&framesetFrame); - + nsHTMLFramesetFrame* framesetFrame = do_QueryFrame(parentFrame); if (framesetFrame) { framesetFrame->RecalculateBorderResize(); } diff --git a/layout/generic/nsFrameList.cpp b/layout/generic/nsFrameList.cpp index 4c230850c1f..2beaad5c026 100644 --- a/layout/generic/nsFrameList.cpp +++ b/layout/generic/nsFrameList.cpp @@ -414,8 +414,8 @@ nsFrameList::List(FILE* out) const fputs("<\n", out); for (nsIFrame* frame = mFirstChild; frame; frame = frame->GetNextSibling()) { - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug *frameDebug = do_QueryFrame(frame); + if (frameDebug) { frameDebug->List(out, 1); } } diff --git a/layout/generic/nsFrameSetFrame.cpp b/layout/generic/nsFrameSetFrame.cpp index 956fdc3fc77..5c75c8f8eaf 100644 --- a/layout/generic/nsFrameSetFrame.cpp +++ b/layout/generic/nsFrameSetFrame.cpp @@ -253,18 +253,9 @@ nsHTMLFramesetFrame::~nsHTMLFramesetFrame() FrameResizePrefCallback, this); } -NS_IMETHODIMP -nsHTMLFramesetFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsHTMLFramesetFrame))) { - *aInstancePtr = (void*)this; - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame) + NS_QUERYFRAME_ENTRY(nsHTMLFramesetFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) // static int @@ -311,9 +302,7 @@ nsHTMLFramesetFrame::Init(nsIContent* aContent, nsIFrame* parentFrame = GetParent(); mTopLevelFrameset = (nsHTMLFramesetFrame*)this; while (parentFrame) { - nsHTMLFramesetFrame* frameset = nsnull; - CallQueryInterface(parentFrame, &frameset); - + nsHTMLFramesetFrame* frameset = do_QueryFrame(parentFrame); if (frameset) { mTopLevelFrameset = frameset; parentFrame = parentFrame->GetParent(); @@ -1309,8 +1298,7 @@ nsHTMLFramesetFrame::IsLeaf() const PRBool nsHTMLFramesetFrame::ChildIsFrameset(nsIFrame* aChild) { - nsIFrame* childFrame = nsnull; - aChild->QueryInterface(NS_GET_IID(nsHTMLFramesetFrame), (void**)&childFrame); + nsHTMLFramesetFrame* childFrame = do_QueryFrame(aChild); if (childFrame) { return PR_TRUE; } diff --git a/layout/generic/nsFrameSetFrame.h b/layout/generic/nsFrameSetFrame.h index 4b7de877a43..286b9f66474 100644 --- a/layout/generic/nsFrameSetFrame.h +++ b/layout/generic/nsFrameSetFrame.h @@ -59,10 +59,6 @@ class nsHTMLFramesetBorderFrame; class nsGUIEvent; class nsHTMLFramesetFrame; -#define NS_IFRAMESETFRAME_IID \ -{ 0xf47deac0, 0x4200, 0x11d2, \ - { 0x80, 0x3c, 0x0, 0x60, 0x8, 0x15, 0xa7, 0x91 } } - #define NO_COLOR 0xFFFFFFFA struct nsBorderColor @@ -108,14 +104,13 @@ struct nsFramesetDrag { class nsHTMLFramesetFrame : public nsHTMLContainerFrame { public: - // Woohoo, concrete class with an IID! - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMESETFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsHTMLFramesetFrame) nsHTMLFramesetFrame(nsStyleContext* aContext); virtual ~nsHTMLFramesetFrame(); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME NS_IMETHOD Init(nsIContent* aContent, nsIFrame* aParent, @@ -272,6 +267,4 @@ protected: PRBool mForceFrameResizability; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsHTMLFramesetFrame, NS_IFRAMESETFRAME_IID) - #endif diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 5bbb766efc5..b7a834d94d2 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -878,18 +878,6 @@ nsHTMLScrollFrame::Reflow(nsPresContext* aPresContext, return rv; } -NS_IMETHODIMP_(nsrefcnt) -nsHTMLScrollFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsHTMLScrollFrame::Release(void) -{ - return NS_OK; -} - #ifdef NS_DEBUG NS_IMETHODIMP nsHTMLScrollFrame::GetFrameName(nsAString& aResult) const @@ -923,15 +911,15 @@ nsHTMLScrollFrame::CurPosAttributeChanged(nsIContent* aChild, mInner.CurPosAttributeChanged(aChild); } -NS_INTERFACE_MAP_BEGIN(nsHTMLScrollFrame) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) -#ifdef NS_DEBUG - NS_INTERFACE_MAP_ENTRY(nsIFrameDebug) +NS_QUERYFRAME_HEAD(nsHTMLScrollFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsIScrollableFrame) + NS_QUERYFRAME_ENTRY(nsIScrollableViewProvider) + NS_QUERYFRAME_ENTRY(nsIStatefulFrame) +#ifdef DEBUG + NS_QUERYFRAME_ENTRY(nsIFrameDebug) #endif - NS_INTERFACE_MAP_ENTRY(nsIScrollableFrame) - NS_INTERFACE_MAP_ENTRY(nsIScrollableViewProvider) - NS_INTERFACE_MAP_ENTRY(nsIStatefulFrame) -NS_INTERFACE_MAP_END_INHERITING(nsHTMLContainerFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) //----------nsXULScrollFrame------------------------------------------- @@ -1242,18 +1230,6 @@ nsXULScrollFrame::GetMinWidth(nsIRenderingContext *aRenderingContext) } #endif -NS_IMETHODIMP_(nsrefcnt) -nsXULScrollFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsXULScrollFrame::Release(void) -{ - return NS_OK; -} - #ifdef NS_DEBUG NS_IMETHODIMP nsXULScrollFrame::GetFrameName(nsAString& aResult) const @@ -1278,18 +1254,16 @@ nsXULScrollFrame::DoLayout(nsBoxLayoutState& aState) return rv; } -NS_INTERFACE_MAP_BEGIN(nsXULScrollFrame) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) -#ifdef NS_DEBUG - NS_INTERFACE_MAP_ENTRY(nsIFrameDebug) +NS_QUERYFRAME_HEAD(nsXULScrollFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) + NS_QUERYFRAME_ENTRY(nsIScrollableFrame) + NS_QUERYFRAME_ENTRY(nsIScrollableViewProvider) + NS_QUERYFRAME_ENTRY(nsIStatefulFrame) +#ifdef DEBUG + NS_QUERYFRAME_ENTRY(nsIFrameDebug) #endif - NS_INTERFACE_MAP_ENTRY(nsIScrollableFrame) - NS_INTERFACE_MAP_ENTRY(nsIScrollableViewProvider) - NS_INTERFACE_MAP_ENTRY(nsIStatefulFrame) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) - - - +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) + //-------------------- Inner ---------------------- nsGfxScrollFrameInner::nsGfxScrollFrameInner(nsContainerFrame* aOuter, @@ -1328,16 +1302,6 @@ nsGfxScrollFrameInner::~nsGfxScrollFrameInner() { } -NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::AddRef(void) -{ - return 2; -} - -NS_IMETHODIMP_(nsrefcnt) nsGfxScrollFrameInner::Release(void) -{ - return 1; -} - NS_IMPL_QUERY_INTERFACE1(nsGfxScrollFrameInner, nsIScrollPositionListener) nsresult @@ -1412,16 +1376,15 @@ nsGfxScrollFrameInner::NeedsClipWidget() const return PR_FALSE; /* If we're a form element, we don't need a widget. */ - nsIFormControlFrame* fcFrame; - if ((NS_SUCCEEDED(parentFrame->QueryInterface(NS_GET_IID(nsIFormControlFrame), (void**)&fcFrame)))) { + nsIFormControlFrame* fcFrame = do_QueryFrame(parentFrame); + if (fcFrame) { return PR_FALSE; } } // Scrollports that don't ever show associated scrollbars don't get // widgets, because they will seldom actually be scrolled. - nsIScrollableFrame *scrollableFrame; - CallQueryInterface(mOuter, &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(mOuter); ScrollbarStyles scrollbars = scrollableFrame->GetScrollbarStyles(); if ((scrollbars.mHorizontal == NS_STYLE_OVERFLOW_HIDDEN || scrollbars.mHorizontal == NS_STYLE_OVERFLOW_VISIBLE) @@ -1687,8 +1650,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray& aElements) } } - nsIScrollableFrame *scrollable; - CallQueryInterface(mOuter, &scrollable); + nsIScrollableFrame *scrollable = do_QueryFrame(mOuter); // At this stage in frame construction, the document element and/or // BODY overflow styles have not yet been propagated to the @@ -1713,8 +1675,7 @@ nsGfxScrollFrameInner::CreateAnonymousContent(nsTArray& aElements) } // The anonymous
used by never gets scrollbars. - nsITextControlFrame* textFrame = nsnull; - CallQueryInterface(parent, &textFrame); + nsITextControlFrame* textFrame = do_QueryFrame(parent); if (textFrame) { // Make sure we are not a text area. nsCOMPtr textAreaElement(do_QueryInterface(parent->GetContent())); @@ -2714,14 +2675,13 @@ nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, PRBool aVisibl if (!aScrollbar) return; - nsIScrollbarFrame* scrollbar; - CallQueryInterface(aScrollbar, &scrollbar); + nsIScrollbarFrame* scrollbar = do_QueryFrame(aScrollbar); if (scrollbar) { // See if we have a mediator. nsIScrollbarMediator* mediator = scrollbar->GetScrollbarMediator(); if (mediator) { // Inform the mediator of the visibility change. - mediator->VisibilityChanged(scrollbar, aVisible); + mediator->VisibilityChanged(aVisible); } } } @@ -2819,8 +2779,7 @@ nsGfxScrollFrameInner::SaveState(nsIStatefulFrame::SpecialStateID aStateID) return nsnull; } - nsIScrollbarMediator* mediator; - CallQueryInterface(GetScrolledFrame(), &mediator); + nsIScrollbarMediator* mediator = do_QueryFrame(GetScrolledFrame()); if (mediator) { // child handles its own scroll state, so don't bother saving state here return nsnull; diff --git a/layout/generic/nsGfxScrollFrame.h b/layout/generic/nsGfxScrollFrame.h index 6bfcb180982..fed84dd7d9a 100644 --- a/layout/generic/nsGfxScrollFrame.h +++ b/layout/generic/nsGfxScrollFrame.h @@ -66,8 +66,8 @@ class nsGfxScrollFrameInner : public nsIScrollPositionListener, public nsIReflowCallback { public: NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); + NS_IMETHOD_(nsrefcnt) AddRef(void) { return 2; } + NS_IMETHOD_(nsrefcnt) Release(void) { return 1; } nsGfxScrollFrameInner(nsContainerFrame* aOuter, PRBool aIsRoot, PRBool aIsXUL); @@ -248,7 +248,7 @@ class nsHTMLScrollFrame : public nsHTMLContainerFrame, public: friend nsIFrame* NS_NewHTMLScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRBool aIsRoot); - NS_DECL_ISUPPORTS + NS_DECL_QUERYFRAME // Called to set the child frames. We typically have three: the scroll area, // the vertical scrollbar, and the horizontal scrollbar. @@ -433,6 +433,8 @@ class nsXULScrollFrame : public nsBoxFrame, public nsIAnonymousContentCreator, public nsIStatefulFrame { public: + NS_DECL_QUERYFRAME + friend nsIFrame* NS_NewXULScrollFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRBool aIsRoot); // Called to set the child frames. We typically have three: the scroll area, @@ -493,9 +495,6 @@ public: // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent(nsTArray& aElements); - // nsIBox methods - NS_DECL_ISUPPORTS - virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState); virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState); virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState); diff --git a/layout/generic/nsHTMLFrame.cpp b/layout/generic/nsHTMLFrame.cpp index 40cf6d15e5f..aed861f0508 100644 --- a/layout/generic/nsHTMLFrame.cpp +++ b/layout/generic/nsHTMLFrame.cpp @@ -87,7 +87,9 @@ public: : nsHTMLContainerFrame(aContext), mDoPaintFocus(PR_FALSE), mAbsoluteContainer(nsGkAtoms::absoluteList) {} - // nsISupports + NS_DECL_QUERYFRAME + + // nsISupports (nsIScrollPositionListener) NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); NS_IMETHOD Init(nsIContent* aContent, @@ -188,24 +190,11 @@ NS_NewCanvasFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) return new (aPresShell)CanvasFrame(aContext); } -//-------------------------------------------------------------- -// Frames are not refcounted, no need to AddRef -NS_IMETHODIMP -CanvasFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); +NS_IMPL_QUERY_INTERFACE1(CanvasFrame, nsIScrollPositionListener) - if (aIID.Equals(NS_GET_IID(nsIScrollPositionListener))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsICanvasFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(CanvasFrame) + NS_QUERYFRAME_ENTRY(nsICanvasFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) NS_IMETHODIMP CanvasFrame::Init(nsIContent* aContent, @@ -407,8 +396,7 @@ nsRect CanvasFrame::CanvasArea() const { nsRect result(GetOverflowRect()); - nsIScrollableFrame *scrollableFrame; - CallQueryInterface(GetParent(), &scrollableFrame); + nsIScrollableFrame *scrollableFrame = do_QueryFrame(GetParent()); if (scrollableFrame) { nsIScrollableView* scrollableView = scrollableFrame->GetScrollableView(); nsRect vcr = scrollableView->View()->GetBounds(); @@ -549,9 +537,7 @@ CanvasFrame::PaintFocus(nsIRenderingContext& aRenderingContext, nsPoint aPt) { nsRect focusRect(aPt, GetSize()); - nsIScrollableFrame *scrollableFrame; - CallQueryInterface(GetParent(), &scrollableFrame); - + nsIScrollableFrame *scrollableFrame = do_QueryFrame(GetParent()); if (scrollableFrame) { nsIScrollableView* scrollableView = scrollableFrame->GetScrollableView(); nsRect vcr = scrollableView->View()->GetBounds(); diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h index 9f69dd2ffc1..9518062e019 100644 --- a/layout/generic/nsIAnonymousContentCreator.h +++ b/layout/generic/nsIAnonymousContentCreator.h @@ -43,19 +43,13 @@ #ifndef nsIAnonymousContentCreator_h___ #define nsIAnonymousContentCreator_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsIContent.h" class nsPresContext; class nsIFrame; template class nsTArray; -// {7568a516-3831-4db4-88a7-a42578acc136} -#define NS_IANONYMOUS_CONTENT_CREATOR_IID \ -{ 0x7568a516, 0x3831, 0x4db4, \ - { 0x88, 0xa7, 0xa4, 0x25, 0x78, 0xac, 0xc1, 0x36 } } - - /** * Any source for anonymous content can implement this interface to provide it. * HTML frames like nsFileControlFrame currently use this as well as XUL frames @@ -63,9 +57,10 @@ template class nsTArray; * * @see nsCSSFrameConstructor */ -class nsIAnonymousContentCreator : public nsISupports { +class nsIAnonymousContentCreator +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IANONYMOUS_CONTENT_CREATOR_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIAnonymousContentCreator) /** * Creates "native" anonymous content and adds the created content to @@ -93,8 +88,5 @@ public: virtual void PostCreateFrames() {} }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIAnonymousContentCreator, - NS_IANONYMOUS_CONTENT_CREATOR_IID) - #endif diff --git a/layout/generic/nsICanvasFrame.h b/layout/generic/nsICanvasFrame.h index 0beb4142687..0a7693af0c4 100644 --- a/layout/generic/nsICanvasFrame.h +++ b/layout/generic/nsICanvasFrame.h @@ -40,16 +40,12 @@ #ifndef nsICanvasFrame_h__ #define nsICanvasFrame_h__ -#include "nsISupports.h" +#include "nsQueryFrame.h" -// IID for the nsICanvasFrame interface -#define NS_ICANVASFRAME_IID \ -{ 0x9df7db77, 0x49a2, 0x11d5, {0x97, 0x92, 0x0, 0x60, 0xb0, 0xfb, 0x99, 0x56} } - -class nsICanvasFrame : public nsISupports +class nsICanvasFrame { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICANVASFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsICanvasFrame) /** SetHasFocus tells the CanvasFrame to draw with focus ring * @param aHasFocus PR_TRUE to show focus ring, PR_FALSE to hide it @@ -58,7 +54,5 @@ public: }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsICanvasFrame, NS_ICANVASFRAME_IID) - #endif // nsICanvasFrame_h__ diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index d5539e44b1c..f1c02ff7994 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -47,7 +47,7 @@ variables in this file. -dwh */ #include -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsEvent.h" #include "nsStyleStruct.h" #include "nsStyleContext.h" @@ -464,10 +464,10 @@ typedef PRBool nsDidReflowStatus; * If you're not in layout but you must call functions in here, at least * restrict yourself to calling virtual methods, which won't hurt you as badly. */ -class nsIFrame : public nsISupports +class nsIFrame : public nsQueryFrame { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIFrame) nsPresContext* PresContext() const { return GetStyleContext()->GetRuleNode()->GetPresContext(); @@ -2348,9 +2348,6 @@ protected: nsresult PeekOffsetParagraph(nsPeekOffsetStruct *aPos); private: - NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; - NS_IMETHOD_(nsrefcnt) Release(void) = 0; - nsRect* GetOverflowAreaProperty(PRBool aCreateIfNecessary = PR_FALSE); }; @@ -2425,7 +2422,4 @@ private: nsIFrame* mFrame; }; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrame, NS_IFRAME_IID) - #endif /* nsIFrame_h___ */ diff --git a/layout/generic/nsIFrameDebug.h b/layout/generic/nsIFrameDebug.h index e75d4685968..7dc035a088d 100644 --- a/layout/generic/nsIFrameDebug.h +++ b/layout/generic/nsIFrameDebug.h @@ -40,23 +40,17 @@ #ifndef nsIFrameDebug_h___ #define nsIFrameDebug_h___ -#include "nsISupports.h" #include "nsIFrame.h" class nsPresContext; struct PRLogModuleInfo; -// IID for the nsIFrameDebug interface {a6cf9069-15b3-11d2-932e-00805f8add32} -#define NS_IFRAMEDEBUG_IID \ -{ 0xa6cf9069, 0x15b3, 0x11d2, \ - {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - /** * Debug related functions */ -class nsIFrameDebug : public nsISupports { +class nsIFrameDebug { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMEDEBUG_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIFrameDebug) NS_IMETHOD List(FILE* out, PRInt32 aIndent) const = 0; /** @@ -134,12 +128,6 @@ public: static PRBool GetShowEventTargetFrameBorder(); static void PrintDisplayList(nsDisplayListBuilder* aBuilder, const nsDisplayList& aList); - -private: - NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; - NS_IMETHOD_(nsrefcnt) Release(void) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameDebug, NS_IFRAMEDEBUG_IID) - #endif /* nsIFrameDebug_h___ */ diff --git a/layout/generic/nsIFrameFrame.h b/layout/generic/nsIFrameFrame.h index 3f081cb81f5..7bcf14f1c14 100644 --- a/layout/generic/nsIFrameFrame.h +++ b/layout/generic/nsIFrameFrame.h @@ -45,14 +45,10 @@ class nsIDocShell; -#define NS_IFRAMEFRAME_IID \ -{ 0x22e34108, 0xc24b, 0x40ea, { \ - 0xb9, 0x79, 0x50, 0x18, 0x38, 0x8d, 0xd5, 0x88 } } - -class nsIFrameFrame : public nsISupports +class nsIFrameFrame { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFRAMEFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIFrameFrame) NS_IMETHOD GetDocShell(nsIDocShell **aDocShell) = 0; @@ -65,6 +61,4 @@ public: virtual void EndSwapDocShells(nsIFrame* aOther) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIFrameFrame, NS_IFRAMEFRAME_IID) - #endif diff --git a/layout/generic/nsIImageFrame.h b/layout/generic/nsIImageFrame.h index 8637bfc3121..d015ec6ed7a 100644 --- a/layout/generic/nsIImageFrame.h +++ b/layout/generic/nsIImageFrame.h @@ -43,25 +43,19 @@ #ifndef nsIImageFrame_h___ #define nsIImageFrame_h___ -#include "nsISupports.h" struct nsSize; class imgIRequest; class nsPresContext; class nsIImageMap; -// {B261A0D5-E696-11d4-9885-00C04FA0CF4B} -#define NS_IIMAGEFRAME_IID \ -{ 0xb261a0d5, 0xe696, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } - -class nsIImageFrame : public nsISupports { +class nsIImageFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIMAGEFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIImageFrame) NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize) = 0; NS_IMETHOD GetImageMap(nsPresContext *aPresContext, nsIImageMap **aImageMap) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIImageFrame, NS_IIMAGEFRAME_IID) - #endif /* nsIImageFrame_h___ */ diff --git a/layout/generic/nsIObjectFrame.h b/layout/generic/nsIObjectFrame.h index c3d0a7df264..90d05a59a8e 100644 --- a/layout/generic/nsIObjectFrame.h +++ b/layout/generic/nsIObjectFrame.h @@ -47,13 +47,10 @@ class nsIPluginInstance; -// {3e2df1fe-a898-4e2e-8763-4ca904fa338e} -#define NS_IOBJECTFRAME_IID \ -{ 0x3e2df1fe, 0xa898, 0x4e2e, { 0x87, 0x63, 0x4c, 0xa9, 0x4, 0xfa, 0x33, 0x8e } } - -class nsIObjectFrame : public nsISupports { +class nsIObjectFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IOBJECTFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIObjectFrame) NS_IMETHOD GetPluginInstance(nsIPluginInstance*& aPluginInstance) = 0; @@ -94,6 +91,4 @@ public: virtual void StopPlugin() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIObjectFrame, NS_IOBJECTFRAME_IID) - #endif /* nsIObjectFrame_h___ */ diff --git a/layout/generic/nsIPageSequenceFrame.h b/layout/generic/nsIPageSequenceFrame.h index 108975b8694..5a008ab2097 100644 --- a/layout/generic/nsIPageSequenceFrame.h +++ b/layout/generic/nsIPageSequenceFrame.h @@ -37,27 +37,21 @@ #ifndef nsIPageSequenceFrame_h___ #define nsIPageSequenceFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsRect.h" class nsPresContext; class nsIPrintSettings; -// IID for the nsIPageSequenceFrame interface -// a6cf90d2-15b3-11d2-932e-00805f8add32 -#define NS_IPAGESEQUENCEFRAME_IID \ - { 0xa6cf90d2, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} - -//---------------------------------------------------------------------- - /** * Interface for accessing special capabilities of the page sequence frame. * * Today all that exists are member functions for printing. */ -class nsIPageSequenceFrame : public nsISupports { +class nsIPageSequenceFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPAGESEQUENCEFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIPageSequenceFrame) /** * Print the set of pages. @@ -92,14 +86,8 @@ public: // For Shrink To Fit NS_IMETHOD GetSTFPercent(float& aSTFPercent) = 0; - -private: - NS_IMETHOD_(nsrefcnt) AddRef(void) = 0; - NS_IMETHOD_(nsrefcnt) Release(void) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIPageSequenceFrame, NS_IPAGESEQUENCEFRAME_IID) - #endif /* nsIPageSequenceFrame_h___ */ diff --git a/layout/generic/nsIScrollableFrame.h b/layout/generic/nsIScrollableFrame.h index 83800841180..21ec24816b2 100644 --- a/layout/generic/nsIScrollableFrame.h +++ b/layout/generic/nsIScrollableFrame.h @@ -52,15 +52,10 @@ class nsBoxLayoutState; -// IID for the nsIScrollableFrame interface -#define NS_ISCROLLABLE_FRAME_IID \ -{ 0xf285c180, 0x8492, 0x48d5, \ -{ 0xb1, 0xb5, 0x03, 0x28, 0x21, 0xc9, 0x72, 0x02 } } - class nsIScrollableFrame : public nsIScrollableViewProvider { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLABLE_FRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIScrollableFrame) /** * Get the frame that we are scrolling within the scrollable frame. @@ -126,6 +121,4 @@ public: virtual void ScrollToRestoredPosition() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollableFrame, NS_ISCROLLABLE_FRAME_IID) - #endif diff --git a/layout/generic/nsIScrollableViewProvider.h b/layout/generic/nsIScrollableViewProvider.h index d9d9d26da91..eb229d01fef 100644 --- a/layout/generic/nsIScrollableViewProvider.h +++ b/layout/generic/nsIScrollableViewProvider.h @@ -39,22 +39,16 @@ #ifndef _nsIScrollableViewProvider_h #define _nsIScrollableViewProvider_h -#include "nsISupports.h" - -#define NS_ISCROLLABLEVIEWPROVIDER_IID \ -{0xdafcbf5f, 0x701f, 0x4697, \ -{0xa5, 0x13, 0x81, 0xd8, 0x0e, 0x01, 0x41, 0x2c}} +#include "nsQueryFrame.h" class nsIScrollableView; -class nsIScrollableViewProvider : public nsISupports { +class nsIScrollableViewProvider : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLABLEVIEWPROVIDER_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIScrollableViewProvider) virtual nsIScrollableView* GetScrollableView() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollableViewProvider, - NS_ISCROLLABLEVIEWPROVIDER_IID) - #endif /* _nsIScrollableViewProvider_h */ diff --git a/layout/generic/nsIStatefulFrame.h b/layout/generic/nsIStatefulFrame.h index f8475beefb0..ba2d870e833 100644 --- a/layout/generic/nsIStatefulFrame.h +++ b/layout/generic/nsIStatefulFrame.h @@ -6,18 +6,15 @@ #ifndef _nsIStatefulFrame_h #define _nsIStatefulFrame_h -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsPresContext; class nsPresState; -#define NS_ISTATEFULFRAME_IID \ -{ 0x25c232cf, 0x40ba, 0x4394, \ - { 0x84, 0xe4, 0x73, 0xa2, 0xf7, 0x4d, 0x8b, 0x64 } } - -class nsIStatefulFrame : public nsISupports { +class nsIStatefulFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISTATEFULFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIStatefulFrame) // If you create a special type stateful frame (e.g. scroll) that needs // to be captured outside of the standard pass through the frames, you'll need @@ -34,6 +31,4 @@ class nsIStatefulFrame : public nsISupports { NS_IMETHOD RestoreState(nsPresState* aState) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIStatefulFrame, NS_ISTATEFULFRAME_IID) - #endif /* _nsIStatefulFrame_h */ diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 2d0e1537a6b..c0cdfdae3d5 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -186,18 +186,9 @@ nsImageFrame::~nsImageFrame() { } -NS_IMETHODIMP -nsImageFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIImageFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return ImageFrameSuper::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsImageFrame) + NS_QUERYFRAME_ENTRY(nsIImageFrame) +NS_QUERYFRAME_TAIL_INHERITING(ImageFrameSuper) #ifdef ACCESSIBILITY NS_IMETHODIMP nsImageFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index fd17a3eb22d..aeb74a1448e 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -96,8 +96,7 @@ class nsImageFrame : public ImageFrameSuper, public nsIImageFrame { public: nsImageFrame(nsStyleContext* aContext); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME virtual void Destroy(); NS_IMETHOD Init(nsIContent* aContent, diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 77d1c941cae..1173df2205c 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -62,9 +62,6 @@ #endif -NS_DEFINE_IID(kInlineFrameCID, NS_INLINE_FRAME_CID); - - ////////////////////////////////////////////////////////////////////// // Basic nsInlineFrame methods @@ -75,18 +72,9 @@ NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) return new (aPresShell) nsInlineFrame(aContext); } -NS_IMETHODIMP -nsInlineFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(kInlineFrameCID)) { - *aInstancePtr = this; - return NS_OK; - } - - return nsInlineFrameSuper::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsInlineFrame) + NS_QUERYFRAME_ENTRY(nsInlineFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsInlineFrameSuper) #ifdef DEBUG NS_IMETHODIMP diff --git a/layout/generic/nsInlineFrame.h b/layout/generic/nsInlineFrame.h index aa7836ecf91..1a613cf4a10 100644 --- a/layout/generic/nsInlineFrame.h +++ b/layout/generic/nsInlineFrame.h @@ -46,9 +46,6 @@ class nsAnonymousBlockFrame; -#define NS_INLINE_FRAME_CID \ - { 0x88b298af, 0x8b0e, 0x4592,{0x9e, 0xc6, 0xea, 0x4c, 0x4b, 0x3f, 0xf7, 0xa4}} - #define nsInlineFrameSuper nsHTMLContainerFrame // NS_INLINE_FRAME_HARD_TEXT_OFFSETS is used for access keys, where what @@ -79,10 +76,10 @@ class nsAnonymousBlockFrame; class nsInlineFrame : public nsInlineFrameSuper { public: - friend nsIFrame* NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); + NS_DECLARE_FRAME_ACCESSOR(nsInlineFrame) + NS_DECL_QUERYFRAME - // nsISupports overrides - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + friend nsIFrame* NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); // nsIFrame overrides NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder, diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index 629b4a3c2c4..f9f39611027 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -145,9 +145,8 @@ ListFloats(FILE* out, PRInt32 aIndent, const nsFloatCacheList& aFloats) fprintf(out, "placeholder@%p ", static_cast(ph)); nsIFrame* frame = ph->GetOutOfFlowFrame(); if (frame) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(frame); + if (frameDebug) { frameDebug->GetFrameName(frameName); fputs(NS_LossyConvertUTF16toASCII(frameName).get(), out); } @@ -225,9 +224,8 @@ nsLineBox::List(FILE* out, PRInt32 aIndent) const nsIFrame* frame = mFirstChild; PRInt32 n = GetChildCount(); while (--n >= 0) { - nsIFrameDebug* frameDebug; - - if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(frame); + if (frameDebug) { frameDebug->List(out, aIndent + 1); } frame = frame->GetNextSibling(); diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index 03770b64fff..427d2d70c88 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -581,30 +581,9 @@ nsObjectFrame::~nsObjectFrame() ("nsObjectFrame %p deleted\n", this)); } -NS_IMETHODIMP -nsObjectFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIObjectFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsObjectFrameSuper::QueryInterface(aIID, aInstancePtr); -} - -NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::AddRef(void) -{ - NS_WARNING("not supported for frames"); - return 1; -} - -NS_IMETHODIMP_(nsrefcnt) nsObjectFrame::Release(void) -{ - NS_WARNING("not supported for frames"); - return 1; -} +NS_QUERYFRAME_HEAD(nsObjectFrame) + NS_QUERYFRAME_ENTRY(nsIObjectFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsObjectFrameSuper) #ifdef ACCESSIBILITY NS_IMETHODIMP nsObjectFrame::GetAccessible(nsIAccessible** aAccessible) @@ -1193,8 +1172,7 @@ nsObjectFrame::PrintPlugin(nsIRenderingContext& aRenderingContext, nsPresContext* presContext = PresContext(); // make sure this is REALLY an nsIObjectFrame // we may need to go through the children to get it - nsIObjectFrame* objectFrame = nsnull; - CallQueryInterface(frame,&objectFrame); + nsIObjectFrame* objectFrame = do_QueryFrame(frame); if (!objectFrame) objectFrame = GetNextObjectFrame(presContext,frame); if (!objectFrame) @@ -2157,8 +2135,7 @@ nsObjectFrame::GetNextObjectFrame(nsPresContext* aPresContext, nsIFrame* aRoot) nsIFrame* child = aRoot->GetFirstChild(nsnull); while (child) { - nsIObjectFrame* outFrame = nsnull; - CallQueryInterface(child, &outFrame); + nsIObjectFrame* outFrame = do_QueryFrame(child); if (outFrame) { nsCOMPtr pi; outFrame->GetPluginInstance(*getter_AddRefs(pi)); // make sure we have a REAL plugin diff --git a/layout/generic/nsObjectFrame.h b/layout/generic/nsObjectFrame.h index a4c1fc4fda4..e57723f745d 100644 --- a/layout/generic/nsObjectFrame.h +++ b/layout/generic/nsObjectFrame.h @@ -62,8 +62,7 @@ class nsObjectFrame : public nsObjectFrameSuper, public nsIObjectFrame { public: friend nsIFrame* NS_NewObjectFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME NS_IMETHOD Init(nsIContent* aContent, nsIFrame* aParent, @@ -140,10 +139,6 @@ public: nsIFrame* aRoot); protected: - // nsISupports - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - nsObjectFrame(nsStyleContext* aContext); virtual ~nsObjectFrame(); diff --git a/layout/generic/nsQueryFrame.h b/layout/generic/nsQueryFrame.h new file mode 100644 index 00000000000..3d68f300c33 --- /dev/null +++ b/layout/generic/nsQueryFrame.h @@ -0,0 +1,268 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the Mozilla layout engine. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation . + * + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsQueryFrame_h +#define nsQueryFrame_h + +#include "nscore.h" + +#define NS_DECLARE_FRAME_ACCESSOR(classname) \ + static const nsQueryFrame::FrameIID kFrameIID = nsQueryFrame::classname##_id; + +#define NS_DECL_QUERYFRAME \ + virtual void* QueryFrame(FrameIID id); + +#define NS_QUERYFRAME_HEAD(class) \ + void* class::QueryFrame(FrameIID id) { + +#define NS_QUERYFRAME_ENTRY(class) \ + if (class::kFrameIID == id) \ + return static_cast(this); + +#define NS_QUERYFRAME_TAIL_INHERITING(class) \ + return class::QueryFrame(id); } + +#define NS_QUERYFRAME_TAIL return nsnull; } + +class nsQueryFrame +{ +public: + enum FrameIID { + BRFrame_id, + CanvasFrame_id, + nsAreaFrame_id, + nsAutoRepeatBoxFrame_id, + nsBCTableCellFrame_id, + nsBlockFrame_id, + nsBox_id, + nsBoxFrame_id, + nsBulletFrame_id, + nsButtonBoxFrame_id, + nsColumnSetFrame_id, + nsComboboxControlFrame_id, + nsComboboxDisplayFrame_id, + nsContainerFrame_id, + nsContinuingTextFrame_id, + nsDeckFrame_id, + nsDirectionalFrame_id, + nsDocElementBoxFrame_id, + nsFieldSetFrame_id, + nsFileControlFrame_id, + nsFirstLetterFrame_id, + nsFirstLineFrame_id, + nsFormControlFrame_id, + nsFrame_id, + nsGfxButtonControlFrame_id, + nsGfxCheckboxControlFrame_id, + nsGfxRadioControlFrame_id, + nsGridRowGroupFrame_id, + nsGridRowLeafFrame_id, + nsGroupBoxFrame_id, + nsHTMLButtonControlFrame_id, + nsHTMLCanvasFrame_id, + nsHTMLContainerFrame_id, + nsHTMLFramesetBlankFrame_id, + nsHTMLFramesetBorderFrame_id, + nsHTMLFramesetFrame_id, + nsHTMLScrollFrame_id, + nsIAnonymousContentCreator_id, + nsICSSPseudoComparator_id, + nsICanvasFrame_id, + nsICheckboxControlFrame_id, + nsIComboboxControlFrame_id, + nsIFormControlFrame_id, + nsIFrame_id, + nsIFrameDebug_id, + nsIFrameFrame_id, + nsIImageFrame_id, + nsIListControlFrame_id, + nsIMathMLFrame_id, + nsIMenuFrame_id, + nsIObjectFrame_id, + nsIPageSequenceFrame_id, + nsIPercentHeightObserver_id, + nsIRadioControlFrame_id, + nsIRootBox_id, + nsISVGChildFrame_id, + nsISVGGlyphFragmentLeaf_id, + nsISVGGlyphFragmentNode_id, + nsISVGSVGFrame_id, + nsISVGTextContentMetrics_id, + nsISVGValue_id, + nsIScrollableFrame_id, + nsIScrollableViewProvider_id, + nsIScrollbarFrame_id, + nsIScrollbarMediator_id, + nsIScrollPositionListener_id, + nsISelectControlFrame_id, + nsIStatefulFrame_id, + nsITableCellLayout_id, + nsITableLayout_id, + nsITextControlFrame_id, + nsITreeBoxObject_id, + nsImageBoxFrame_id, + nsImageControlFrame_id, + nsImageFrame_id, + nsInlineFrame_id, + nsIsIndexFrame_id, + nsLeafBoxFrame_id, + nsLeafFrame_id, + nsLegendFrame_id, + nsListBoxBodyFrame_id, + nsListControlFrame_id, + nsListItemFrame_id, + nsMathMLContainerFrame_id, + nsMathMLForeignFrameWrapper_id, + nsMathMLFrame_id, + nsMathMLmactionFrame_id, + nsMathMLmathBlockFrame_id, + nsMathMLmathInlineFrame_id, + nsMathMLmfencedFrame_id, + nsMathMLmfracFrame_id, + nsMathMLmmultiscriptsFrame_id, + nsMathMLmoFrame_id, + nsMathMLmoverFrame_id, + nsMathMLmpaddedFrame_id, + nsMathMLmphantomFrame_id, + nsMathMLmrootFrame_id, + nsMathMLmrowFrame_id, + nsMathMLmspaceFrame_id, + nsMathMLmsqrtFrame_id, + nsMathMLmstyleFrame_id, + nsMathMLmsubFrame_id, + nsMathMLmsubsupFrame_id, + nsMathMLmsupFrame_id, + nsMathMLmtableFrame_id, + nsMathMLmtableOuterFrame_id, + nsMathMLmtdFrame_id, + nsMathMLmtdInnerFrame_id, + nsMathMLmtrFrame_id, + nsMathMLmunderFrame_id, + nsMathMLmunderoverFrame_id, + nsMathMLTokenFrame_id, + nsMenuBarFrame_id, + nsMenuFrame_id, + nsMenuPopupFrame_id, + nsObjectFrame_id, + nsPageBreakFrame_id, + nsPageContentFrame_id, + nsPageFrame_id, + nsPlaceholderFrame_id, + nsPopupSetFrame_id, + nsPositionedInlineFrame_id, + nsProgressMeterFrame_id, + nsResizerFrame_id, + nsRootBoxFrame_id, + nsScrollbarButtonFrame_id, + nsScrollbarFrame_id, + nsSelectsAreaFrame_id, + nsSimplePageSequenceFrame_id, + nsSliderFrame_id, + nsSplittableFrame_id, + nsSplitterFrame_id, + nsStackFrame_id, + nsSubDocumentFrame_id, + nsSVGAFrame_id, + nsSVGClipPathFrame_id, + nsSVGContainerFrame_id, + nsSVGDisplayContainerFrame_id, + nsSVGFilterFrame_id, + nsSVGForeignObjectFrame_id, + nsSVGGenericContainerFrame_id, + nsSVGGeometryFrame_id, + nsSVGGFrame_id, + nsSVGGlyphFrame_id, + nsSVGGradientFrame_id, + nsSVGImageFrame_id, + nsSVGInnerSVGFrame_id, + nsSVGLeafFrame_id, + nsSVGLinearGradientFrame_id, + nsSVGMarkerFrame_id, + nsSVGMaskFrame_id, + nsSVGOuterSVGFrame_id, + nsSVGPaintServerFrame_id, + nsSVGPathGeometryFrame_id, + nsSVGPatternFrame_id, + nsSVGRadialGradientFrame_id, + nsSVGStopFrame_id, + nsSVGSwitchFrame_id, + nsSVGTextContainerFrame_id, + nsSVGTextFrame_id, + nsSVGTextPathFrame_id, + nsSVGTSpanFrame_id, + nsSVGUseFrame_id, + nsTableCaptionFrame_id, + nsTableCellFrame_id, + nsTableColFrame_id, + nsTableColGroupFrame_id, + nsTableFrame_id, + nsTableOuterFrame_id, + nsTableRowFrame_id, + nsTableRowGroupFrame_id, + nsTextBoxFrame_id, + nsTextControlFrame_id, + nsTextFrame_id, + nsTitleBarFrame_id, + nsTreeBodyFrame_id, + nsTreeColFrame_id, + nsVideoFrame_id, + nsXULScrollFrame_id, + SpacerFrame_id, + ViewportFrame_id + }; + + virtual void* QueryFrame(FrameIID id) = 0; +}; + +class do_QueryFrame +{ +public: + do_QueryFrame(nsQueryFrame *s) : mRawPtr(s) { } + + template + operator Dest*() { + if (!mRawPtr) + return nsnull; + + return reinterpret_cast(mRawPtr->QueryFrame(Dest::kFrameIID)); + } + +private: + nsQueryFrame *mRawPtr; +}; + +#endif // nsQueryFrame_h diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 9a5e8e323b8..7a2578ceb13 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -2433,9 +2433,7 @@ nsFrameSelection::GetCellLayout(nsIContent *aCellContent) const if (!cellFrame) return nsnull; - nsITableCellLayout *cellLayoutObject = nsnull; - CallQueryInterface(cellFrame, &cellLayoutObject); - + nsITableCellLayout *cellLayoutObject = do_QueryFrame(cellFrame); return cellLayoutObject; } @@ -2448,9 +2446,7 @@ nsFrameSelection::GetTableLayout(nsIContent *aTableContent) const if (!tableFrame) return nsnull; - nsITableLayout *tableLayoutObject = nsnull; - CallQueryInterface(tableFrame, &tableLayoutObject); - + nsITableLayout *tableLayoutObject = do_QueryFrame(tableFrame); return tableLayoutObject; } @@ -4596,8 +4592,7 @@ nsTypedSelection::selectFrames(nsPresContext* aPresContext, frame->SetSelected(aPresContext, nsnull, aFlags, eSpreadDown, mType); if (mFrameSelection->GetTableCellSelection()) { - nsITableCellLayout *tcl = nsnull; - CallQueryInterface(frame, &tcl); + nsITableCellLayout *tcl = do_QueryFrame(frame); if (tcl) { return NS_OK; diff --git a/layout/generic/nsSimplePageSequence.cpp b/layout/generic/nsSimplePageSequence.cpp index e8952d2cfc5..64740430fa3 100644 --- a/layout/generic/nsSimplePageSequence.cpp +++ b/layout/generic/nsSimplePageSequence.cpp @@ -137,17 +137,9 @@ nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame() if (mPageData) delete mPageData; } -NS_IMETHODIMP -nsSimplePageSequenceFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsIPageSequenceFrame))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - return nsContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsSimplePageSequenceFrame) + NS_QUERYFRAME_ENTRY(nsIPageSequenceFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) //---------------------------------------------------------------------- diff --git a/layout/generic/nsSimplePageSequence.h b/layout/generic/nsSimplePageSequence.h index a3937b482e7..629831c80ba 100644 --- a/layout/generic/nsSimplePageSequence.h +++ b/layout/generic/nsSimplePageSequence.h @@ -84,8 +84,7 @@ class nsSimplePageSequenceFrame : public nsContainerFrame, public: friend nsIFrame* NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - // nsISupports - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); + NS_DECL_QUERYFRAME // nsIFrame NS_IMETHOD Reflow(nsPresContext* aPresContext, @@ -149,9 +148,6 @@ protected: void SetDateTimeStr(PRUnichar * aDateTimeStr); void SetPageNumberFormat(PRUnichar * aFormatStr, PRBool aForPageNumOnly); - NS_IMETHOD_(nsrefcnt) AddRef(void) {return nsContainerFrame::AddRef();} - NS_IMETHOD_(nsrefcnt) Release(void) {return nsContainerFrame::Release();} - nsMargin mMargin; PRBool mIsPrintingSelection; diff --git a/layout/generic/nsVideoFrame.cpp b/layout/generic/nsVideoFrame.cpp index 106d3e3da75..48194394e51 100644 --- a/layout/generic/nsVideoFrame.cpp +++ b/layout/generic/nsVideoFrame.cpp @@ -71,24 +71,12 @@ nsVideoFrame::~nsVideoFrame() { } -NS_INTERFACE_MAP_BEGIN(nsVideoFrame) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) -#ifdef NS_DEBUG - NS_INTERFACE_MAP_ENTRY(nsIFrameDebug) +NS_QUERYFRAME_HEAD(nsVideoFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) +#ifdef DEBUG + NS_QUERYFRAME_ENTRY(nsIFrameDebug) #endif -NS_INTERFACE_MAP_END_INHERITING(nsContainerFrame) - -NS_IMETHODIMP_(nsrefcnt) -nsVideoFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsVideoFrame::Release(void) -{ - return NS_OK; -} +NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame) nsresult nsVideoFrame::CreateAnonymousContent(nsTArray& aElements) diff --git a/layout/generic/nsVideoFrame.h b/layout/generic/nsVideoFrame.h index 53a29b7b080..aecc737b7ac 100644 --- a/layout/generic/nsVideoFrame.h +++ b/layout/generic/nsVideoFrame.h @@ -57,7 +57,7 @@ class nsVideoFrame : public nsContainerFrame, public nsIAnonymousContentCreator public: nsVideoFrame(nsStyleContext* aContext); - NS_DECL_ISUPPORTS + NS_DECL_QUERYFRAME NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, diff --git a/layout/generic/nsViewportFrame.cpp b/layout/generic/nsViewportFrame.cpp index c25b603f913..a53409f8b66 100644 --- a/layout/generic/nsViewportFrame.cpp +++ b/layout/generic/nsViewportFrame.cpp @@ -224,7 +224,7 @@ ViewportFrame::AdjustReflowStateForScrollbars(nsHTMLReflowState* aReflowState) c // Get our prinicpal child frame and see if we're scrollable nsIFrame* kidFrame = mFrames.FirstChild(); - nsCOMPtr scrollingFrame(do_QueryInterface(kidFrame)); + nsIScrollableFrame *scrollingFrame = do_QueryFrame(kidFrame); if (scrollingFrame) { nsMargin scrollbars = scrollingFrame->GetActualScrollbarSizes(); diff --git a/layout/mathml/base/src/nsIMathMLFrame.h b/layout/mathml/base/src/nsIMathMLFrame.h index 042616d7f9c..642ad5ffd0c 100644 --- a/layout/mathml/base/src/nsIMathMLFrame.h +++ b/layout/mathml/base/src/nsIMathMLFrame.h @@ -46,13 +46,6 @@ struct nsPresentationData; struct nsEmbellishData; struct nsHTMLReflowMetrics; -// a781ed45-4338-43cb-9739-a7a8f8418ff3 -#define NS_IMATHMLFRAME_IID \ -{ 0xa781ed45, 0x4338, 0x43cb, \ - { 0x97, 0x39, 0xa7, 0xa8, 0xf8, 0x41, 0x8f, 0xf3 } } - -static NS_DEFINE_IID(kIMathMLFrameIID, NS_IMATHMLFRAME_IID); - // For MathML, this 'type' will be used to determine the spacing between frames // Subclasses can return a 'type' that will give them a particular spacing enum eMathMLFrameType { @@ -68,9 +61,10 @@ enum eMathMLFrameType { }; // Abstract base class that provides additional methods for MathML frames -class nsIMathMLFrame : public nsISupports { +class nsIMathMLFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMATHMLFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIMathMLFrame) /* SUPPORT FOR PRECISE POSITIONING */ /*====================================================================*/ @@ -309,9 +303,6 @@ struct nsPresentationData { } }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIMathMLFrame, NS_IMATHMLFRAME_IID) - - // ========================================================================== // Bits used for the presentation flags -- these bits are set // in their relevant situation as they become available diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/layout/mathml/base/src/nsMathMLContainerFrame.cpp index ac7ecd299ec..6309050d6c2 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -65,18 +65,13 @@ #include "nsCSSFrameConstructor.h" #include "nsIReflowCallback.h" -NS_DEFINE_CID(kInlineFrameCID, NS_INLINE_FRAME_CID); - // // nsMathMLContainerFrame implementation // -// nsISupports -// ============================================================================= - -NS_IMPL_ADDREF_INHERITED(nsMathMLContainerFrame, nsMathMLFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLContainerFrame, nsMathMLFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLContainerFrame, nsHTMLContainerFrame, nsMathMLFrame) +NS_QUERYFRAME_HEAD(nsMathMLContainerFrame) + NS_QUERYFRAME_ENTRY(nsMathMLFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) // ============================================================================= @@ -215,8 +210,7 @@ nsMathMLContainerFrame::GetReflowAndBoundingMetricsFor(nsIFrame* aFra if (aMathMLFrameType) { if (!IsForeignChild(aFrame)) { - nsIMathMLFrame* mathMLFrame; - CallQueryInterface(aFrame, &mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); if (mathMLFrame) { *aMathMLFrameType = mathMLFrame->GetMathMLFrameType(); return; @@ -267,8 +261,7 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsIRenderingContext& aRenderingC nsIFrame* childFrame = GetFirstChild(nsnull); while (childFrame) { // initializations in case this child happens not to be a MathML frame - nsIMathMLFrame* mathMLFrame; - childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(childFrame); if (mathMLFrame) { nsEmbellishData embellishData; nsPresentationData presentationData; @@ -280,8 +273,7 @@ nsMathMLContainerFrame::GetPreferredStretchSize(nsIRenderingContext& aRenderingC // embellishements are not included, only consider the inner first child itself // XXXkt Does that mean the core descendent frame should be used // instead of the base child? - nsIMathMLFrame* mathMLchildFrame; - presentationData.baseFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLchildFrame); + nsIMathMLFrame* mathMLchildFrame = do_QueryFrame(presentationData.baseFrame); if (mathMLchildFrame) { mathMLFrame = mathMLchildFrame; } @@ -359,8 +351,7 @@ nsMathMLContainerFrame::Stretch(nsIRenderingContext& aRenderingContext, nsIFrame* baseFrame = mPresentationData.baseFrame; if (baseFrame) { - nsIMathMLFrame* mathMLFrame; - baseFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(baseFrame); NS_ASSERTION(mathMLFrame, "Something is wrong somewhere"); if (mathMLFrame) { PRBool stretchAll = @@ -419,7 +410,7 @@ nsMathMLContainerFrame::Stretch(nsIRenderingContext& aRenderingContext, nsIFrame* childFrame = mFrames.FirstChild(); while (childFrame) { if (childFrame != mPresentationData.baseFrame) { - childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + mathMLFrame = do_QueryFrame(childFrame); if (mathMLFrame) { // retrieve the metrics that was stored at the previous pass GetReflowAndBoundingMetricsFor(childFrame, @@ -534,8 +525,7 @@ nsMathMLContainerFrame::FinalizeReflow(nsIRenderingContext& aRenderingContext, // This means the rect.x and rect.y of our children were not set!! // Don't go without checking to see if our parent will later fire a Stretch() command // targeted at us. The Stretch() will cause the rect.x and rect.y to clear... - nsIMathMLFrame* mathMLFrame; - mParent->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(mParent); if (mathMLFrame) { nsEmbellishData embellishData; nsPresentationData presentationData; @@ -617,8 +607,7 @@ nsMathMLContainerFrame::PropagatePresentationDataFor(nsIFrame* aFrame, { if (!aFrame || !aFlagsToUpdate) return; - nsIMathMLFrame* mathMLFrame; - aFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); if (mathMLFrame) { // update mathMLFrame->UpdatePresentationData(aFlagsValues, @@ -711,16 +700,14 @@ nsMathMLContainerFrame::RebuildAutomaticDataForChildren(nsIFrame* aParentFrame) // down the subtrees nsIFrame* childFrame = aParentFrame->GetFirstChild(nsnull); while (childFrame) { - nsIMathMLFrame* childMathMLFrame; - childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&childMathMLFrame); + nsIMathMLFrame* childMathMLFrame = do_QueryFrame(childFrame); if (childMathMLFrame) { childMathMLFrame->InheritAutomaticData(aParentFrame); } RebuildAutomaticDataForChildren(childFrame); childFrame = childFrame->GetNextSibling(); } - nsIMathMLFrame* mathMLFrame; - aParentFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(aParentFrame); if (mathMLFrame) { mathMLFrame->TransmitAutomaticData(); } @@ -741,8 +728,7 @@ nsMathMLContainerFrame::ReLayoutChildren(nsIFrame* aParentFrame, break; // stop if it is a MathML frame - nsIMathMLFrame* mathMLFrame; - frame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame); if (mathMLFrame) break; @@ -910,8 +896,7 @@ nsMathMLContainerFrame::ReflowChild(nsIFrame* aChildFrame, // frames may be reflowed generically, but nsInlineFrames need extra care. #ifdef DEBUG - nsInlineFrame* inlineFrame; - aChildFrame->QueryInterface(kInlineFrameCID, (void**)&inlineFrame); + nsInlineFrame* inlineFrame = do_QueryFrame(aChildFrame); NS_ASSERTION(!inlineFrame, "Inline frames should be wrapped in blocks"); #endif @@ -1007,8 +992,7 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext, // fire the stretch on each child childFrame = mFrames.FirstChild(); while (childFrame) { - nsIMathMLFrame* mathMLFrame; - childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(childFrame); if (mathMLFrame) { // retrieve the metrics that was stored at the previous pass nsHTMLReflowMetrics childDesiredSize; diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.h b/layout/mathml/base/src/nsMathMLContainerFrame.h index bcc46108a71..34437b32a47 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.h +++ b/layout/mathml/base/src/nsMathMLContainerFrame.h @@ -71,7 +71,7 @@ class nsMathMLContainerFrame : public nsHTMLContainerFrame, public: nsMathMLContainerFrame(nsStyleContext* aContext) : nsHTMLContainerFrame(aContext) {} - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // -------------------------------------------------------------------------- // Overloaded nsMathMLFrame methods -- see documentation in nsIMathMLFrame.h diff --git a/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp b/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp index 8a2230b83f2..171fb5fac53 100644 --- a/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp +++ b/layout/mathml/base/src/nsMathMLForeignFrameWrapper.cpp @@ -54,9 +54,9 @@ #include "nsMathMLForeignFrameWrapper.h" -NS_IMPL_ADDREF_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLForeignFrameWrapper, nsMathMLFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLForeignFrameWrapper, nsBlockFrame, nsMathMLFrame) +NS_QUERYFRAME_HEAD(nsMathMLForeignFrameWrapper) + NS_QUERYFRAME_ENTRY(nsMathMLFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) nsIFrame* NS_NewMathMLForeignFrameWrapper(nsIPresShell* aPresShell, nsStyleContext* aContext) diff --git a/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h b/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h index 9bd21b34c76..743d6328822 100644 --- a/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h +++ b/layout/mathml/base/src/nsMathMLForeignFrameWrapper.h @@ -52,7 +52,7 @@ class nsMathMLForeignFrameWrapper : public nsBlockFrame, public: friend nsIFrame* NS_NewMathMLForeignFrameWrapper(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // Overloaded nsIMathMLFrame methods diff --git a/layout/mathml/base/src/nsMathMLFrame.cpp b/layout/mathml/base/src/nsMathMLFrame.cpp index 6eeaea306e8..337f60e0c78 100644 --- a/layout/mathml/base/src/nsMathMLFrame.cpp +++ b/layout/mathml/base/src/nsMathMLFrame.cpp @@ -60,11 +60,6 @@ #include "nsDisplayList.h" #include "nsAttrName.h" -static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); - - -NS_IMPL_QUERY_INTERFACE1(nsMathMLFrame, nsIMathMLFrame) - eMathMLFrameType nsMathMLFrame::GetMathMLFrameType() { @@ -192,8 +187,7 @@ nsMathMLFrame::GetEmbellishDataFrom(nsIFrame* aFrame, aEmbellishData.rightSpace = 0; if (aFrame && aFrame->IsFrameOfType(nsIFrame::eMathML)) { - nsIMathMLFrame* mathMLFrame; - CallQueryInterface(aFrame, &mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); if (mathMLFrame) { mathMLFrame->GetEmbellishData(aEmbellishData); } @@ -215,8 +209,7 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame, nsIFrame* frame = aFrame; while (frame) { if (frame->IsFrameOfType(nsIFrame::eMathML)) { - nsIMathMLFrame* mathMLFrame; - CallQueryInterface(frame, &mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(frame); if (mathMLFrame) { mathMLFrame->GetPresentationData(aPresentationData); break; @@ -270,8 +263,7 @@ nsMathMLFrame::GetAttribute(nsIContent* aContent, mstyleParentData.mstyle = nsnull; if (mstyleParent) { - nsIMathMLFrame* mathMLFrame; - CallQueryInterface(mstyleParent, &mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(mstyleParent); if (mathMLFrame) { mathMLFrame->GetPresentationData(mstyleParentData); } diff --git a/layout/mathml/base/src/nsMathMLFrame.h b/layout/mathml/base/src/nsMathMLFrame.h index 5d4bfd1dbb0..a6cc52c4e9a 100644 --- a/layout/mathml/base/src/nsMathMLFrame.h +++ b/layout/mathml/base/src/nsMathMLFrame.h @@ -57,20 +57,6 @@ class nsMathMLChar; class nsMathMLFrame : public nsIMathMLFrame { public: - // nsISupports ------ - - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - - NS_IMETHOD_(nsrefcnt) AddRef() { - // not meaningfull for frames - return 1; - } - - NS_IMETHOD_(nsrefcnt) Release() { - // not meaningfull for frames - return 1; - } - // nsIMathMLFrame --- NS_IMETHOD @@ -229,8 +215,7 @@ public: GetMathMLFrameTypeFor(nsIFrame* aFrame) { if (aFrame->IsFrameOfType(nsIFrame::eMathML)) { - nsIMathMLFrame* mathMLFrame; - CallQueryInterface(aFrame, &mathMLFrame); + nsIMathMLFrame* mathMLFrame = do_QueryFrame(aFrame); if (mathMLFrame) return mathMLFrame->GetMathMLFrameType(); } diff --git a/layout/mathml/base/src/nsMathMLmactionFrame.cpp b/layout/mathml/base/src/nsMathMLmactionFrame.cpp index a65b58d5bb6..d01d731dfc5 100644 --- a/layout/mathml/base/src/nsMathMLmactionFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmactionFrame.cpp @@ -74,12 +74,21 @@ #define NS_MATHML_ACTION_TYPE_TOOLTIP 3 // unsupported #define NS_MATHML_ACTION_TYPE_RESTYLE 4 -NS_IMPL_ADDREF_INHERITED(nsMathMLmactionFrame, nsMathMLContainerFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmactionFrame, nsMathMLContainerFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED2(nsMathMLmactionFrame, - nsMathMLContainerFrame, - nsIDOMMouseListener, - nsIDOMEventListener) +NS_IMETHODIMP_(nsrefcnt) +nsMathMLmactionFrame::AddRef() +{ + return 2; +} + +NS_IMETHODIMP_(nsrefcnt) +nsMathMLmactionFrame::Release() +{ + return 1; +} + +NS_IMPL_QUERY_INTERFACE2(nsMathMLmactionFrame, + nsIDOMMouseListener, + nsIDOMEventListener) nsIFrame* NS_NewMathMLmactionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) diff --git a/layout/mathml/base/src/nsMathMLmfencedFrame.cpp b/layout/mathml/base/src/nsMathMLmfencedFrame.cpp index 6f617527f20..1109128a231 100644 --- a/layout/mathml/base/src/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmfencedFrame.cpp @@ -351,8 +351,7 @@ nsMathMLmfencedFrame::doReflow(nsPresContext* aPresContext, stretchDir, containerSize); childFrame = firstChild; while (childFrame) { - nsIMathMLFrame* mathmlChild; - childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathmlChild); + nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame); if (mathmlChild) { nsHTMLReflowMetrics childDesiredSize; // retrieve the metrics that was stored at the previous pass diff --git a/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/layout/mathml/base/src/nsMathMLmtableFrame.cpp index 39105914591..f301a6540e3 100644 --- a/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -349,9 +349,9 @@ ListMathMLTree(nsIFrame* atLeast) // -------- // implementation of nsMathMLmtableOuterFrame -NS_IMPL_ADDREF_INHERITED(nsMathMLmtableOuterFrame, nsMathMLFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmtableOuterFrame, nsMathMLFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLmtableOuterFrame, nsTableOuterFrame, nsMathMLFrame) +NS_QUERYFRAME_HEAD(nsMathMLmtableOuterFrame) + NS_QUERYFRAME_ENTRY(nsIMathMLFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsTableOuterFrame) nsIFrame* NS_NewMathMLmtableOuterFrame (nsIPresShell* aPresShell, nsStyleContext* aContext) @@ -647,13 +647,6 @@ nsMathMLmtableOuterFrame::Reflow(nsPresContext* aPresContext, return rv; } -// -------- -// implementation of nsMathMLmtableFrame - -NS_IMPL_ADDREF_INHERITED(nsMathMLmtableFrame, nsTableFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmtableFrame, nsTableFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED0(nsMathMLmtableFrame, nsTableFrame) - nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { @@ -688,10 +681,6 @@ nsMathMLmtableFrame::RestyleTable() // -------- // implementation of nsMathMLmtrFrame -NS_IMPL_ADDREF_INHERITED(nsMathMLmtrFrame, nsTableRowFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmtrFrame, nsTableRowFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED0(nsMathMLmtrFrame, nsTableRowFrame) - nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { @@ -749,10 +738,6 @@ nsMathMLmtrFrame::AttributeChanged(PRInt32 aNameSpaceID, // -------- // implementation of nsMathMLmtdFrame -NS_IMPL_ADDREF_INHERITED(nsMathMLmtdFrame, nsTableCellFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmtdFrame, nsTableCellFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED0(nsMathMLmtdFrame, nsTableCellFrame) - nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { @@ -835,9 +820,9 @@ nsMathMLmtdFrame::AttributeChanged(PRInt32 aNameSpaceID, // -------- // implementation of nsMathMLmtdInnerFrame -NS_IMPL_ADDREF_INHERITED(nsMathMLmtdInnerFrame, nsMathMLFrame) -NS_IMPL_RELEASE_INHERITED(nsMathMLmtdInnerFrame, nsMathMLFrame) -NS_IMPL_QUERY_INTERFACE_INHERITED1(nsMathMLmtdInnerFrame, nsBlockFrame, nsMathMLFrame) +NS_QUERYFRAME_HEAD(nsMathMLmtdInnerFrame) + NS_QUERYFRAME_ENTRY(nsIMathMLFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame) nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) diff --git a/layout/mathml/base/src/nsMathMLmtableFrame.h b/layout/mathml/base/src/nsMathMLmtableFrame.h index 9a67581ed15..f398a146f43 100644 --- a/layout/mathml/base/src/nsMathMLmtableFrame.h +++ b/layout/mathml/base/src/nsMathMLmtableFrame.h @@ -52,7 +52,7 @@ class nsMathMLmtableOuterFrame : public nsTableOuterFrame, public: friend nsIFrame* NS_NewMathMLmtableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // Overloaded nsIMathMLFrame methods @@ -107,8 +107,6 @@ class nsMathMLmtableFrame : public nsTableFrame public: friend nsIFrame* NS_NewMathMLmtableFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED - // Overloaded nsTableFrame methods NS_IMETHOD @@ -166,8 +164,6 @@ class nsMathMLmtrFrame : public nsTableRowFrame public: friend nsIFrame* NS_NewMathMLmtrFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED - // overloaded nsTableRowFrame methods NS_IMETHOD @@ -231,8 +227,6 @@ class nsMathMLmtdFrame : public nsTableCellFrame public: friend nsIFrame* NS_NewMathMLmtdFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED - // overloaded nsTableCellFrame methods NS_IMETHOD @@ -260,7 +254,7 @@ class nsMathMLmtdInnerFrame : public nsBlockFrame, public: friend nsIFrame* NS_NewMathMLmtdInnerFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // Overloaded nsIMathMLFrame methods diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 02c7cde2f4d..a23838a60dd 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -361,7 +361,7 @@ nsPrintEngine::GetSeqFrameAndCountPagesInternal(nsPrintObject* aPO, nsIPageSequenceFrame* seqFrame = nsnull; aPO->mPresShell->GetPageSequenceFrame(&seqFrame); if (seqFrame) { - CallQueryInterface(seqFrame, &aSeqFrame); + aSeqFrame = do_QueryFrame(seqFrame); } else { aSeqFrame = nsnull; } @@ -2064,8 +2064,8 @@ nsPrintEngine::CalcNumPrintablePages(PRInt32& aNumPages) if (po->mPresContext && po->mPresContext->IsRootPaginatedDocument()) { nsIPageSequenceFrame* pageSequence; po->mPresShell->GetPageSequenceFrame(&pageSequence); - nsIFrame * seqFrame; - if (NS_SUCCEEDED(CallQueryInterface(pageSequence, &seqFrame))) { + nsIFrame * seqFrame = do_QueryFrame(pageSequence); + if (seqFrame) { nsIFrame* frame = seqFrame->GetFirstChild(nsnull); while (frame) { aNumPages++; @@ -2148,10 +2148,9 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO) if (nsnull != mPrt->mDebugFilePtr) { #ifdef NS_DEBUG // output the regression test - nsIFrameDebug* fdbg; nsIFrame* root = poPresShell->FrameManager()->GetRootFrame(); - - if (NS_SUCCEEDED(CallQueryInterface(root, &fdbg))) { + nsIFrameDebug* fdbg = do_QueryFrame(root); + if (fdbg) { fdbg->DumpRegressionData(poPresContext, mPrt->mDebugFilePtr, 0, PR_TRUE); } fclose(mPrt->mDebugFilePtr); @@ -2249,8 +2248,8 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO) } } - nsIFrame * seqFrame; - if (NS_FAILED(CallQueryInterface(pageSequence, &seqFrame))) { + nsIFrame * seqFrame = do_QueryFrame(pageSequence); + if (!seqFrame) { SetIsPrinting(PR_FALSE); return NS_ERROR_FAILURE; } @@ -2505,8 +2504,8 @@ nsPrintEngine::GetPageRangeForSelection(nsIPresShell * aPresShell, NS_ASSERTION(aStartFrame, "Pointer is null!"); NS_ASSERTION(aEndFrame, "Pointer is null!"); - nsIFrame * seqFrame; - if (NS_FAILED(CallQueryInterface(aPageSeqFrame, &seqFrame))) { + nsIFrame * seqFrame = do_QueryFrame(aPageSeqFrame); + if (!seqFrame) { return NS_ERROR_FAILURE; } @@ -3296,9 +3295,8 @@ static void RootFrameList(nsPresContext* aPresContext, FILE* out, PRInt32 aInden if (shell) { nsIFrame* frame = shell->FrameManager()->GetRootFrame(); if (frame) { - nsIFrameDebug* debugFrame; - nsresult rv = CallQueryInterface(frame, &debugFrame); - if (NS_SUCCEEDED(rv)) + nsIFrameDebug* debugFrame = do_QueryFrame(frame); + if (debugFrame) debugFrame->List(aPresContext, out, aIndent); } } @@ -3324,9 +3322,9 @@ static void DumpFrames(FILE* out, fprintf(out, " "); } nsAutoString tmp; - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(CallQueryInterface(child, &frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(child); + if (frameDebug) { frameDebug->GetFrameName(tmp); } fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); @@ -3461,8 +3459,8 @@ static void DumpPrintObjectsList(nsVoidArray * aDocList) if (po->mPresShell) { rootFrame = po->mPresShell->FrameManager()->GetRootFrame(); while (rootFrame != nsnull) { - nsIPageSequenceFrame * sqf = nsnull; - if (NS_SUCCEEDED(CallQueryInterface(rootFrame, &sqf))) { + nsIPageSequenceFrame * sqf = do_QueryFrame(rootFrame); + if (sqf) { break; } rootFrame = rootFrame->GetFirstChild(nsnull); diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index bc887bfb672..ea38105b3f4 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -3078,8 +3078,7 @@ nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIDOMCSSValue** aValue) // scrollbars. We have to do some extra work. // the first child in the default frame list is what we want nsIFrame* scrollingChild = container->GetFirstChild(nsnull); - nsCOMPtr scrollFrame = - do_QueryInterface(scrollingChild); + nsIScrollableFrame *scrollFrame = do_QueryFrame(scrollingChild); if (scrollFrame) { scrollbarSizes = scrollFrame->GetActualScrollbarSizes(); } diff --git a/layout/style/nsICSSPseudoComparator.h b/layout/style/nsICSSPseudoComparator.h index 49d0e2f4741..ac8d5e38e10 100644 --- a/layout/style/nsICSSPseudoComparator.h +++ b/layout/style/nsICSSPseudoComparator.h @@ -40,21 +40,17 @@ #ifndef nsICSSPseudoComparator_h___ #define nsICSSPseudoComparator_h___ -// {4B122120-0F2D-4e88-AFE9-84A9AE2404E5} -#define NS_ICSS_PSEUDO_COMPARATOR_IID \ -{ 0x4b122120, 0xf2d, 0x4e88, { 0xaf, 0xe9, 0x84, 0xa9, 0xae, 0x24, 0x4, 0xe5 } } +#include "nsQueryFrame.h" class nsIAtom; struct nsCSSSelector; -class nsICSSPseudoComparator: public nsISupports { +class nsICSSPseudoComparator +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICSS_PSEUDO_COMPARATOR_IID) + NS_DECLARE_FRAME_ACCESSOR(nsICSSPseudoComparator) NS_IMETHOD PseudoMatches(nsIAtom* aTag, nsCSSSelector* aSelector, PRBool* aResult)=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsICSSPseudoComparator, - NS_ICSS_PSEUDO_COMPARATOR_IID) - #endif /* nsICSSPseudoComparator_h___ */ diff --git a/layout/svg/base/src/nsISVGChildFrame.h b/layout/svg/base/src/nsISVGChildFrame.h index 551c1b243a3..d3c81e4b130 100644 --- a/layout/svg/base/src/nsISVGChildFrame.h +++ b/layout/svg/base/src/nsISVGChildFrame.h @@ -40,7 +40,7 @@ #define __NS_ISVGCHILDFRAME_H__ -#include "nsISupports.h" +#include "nsQueryFrame.h" #include "nsCOMPtr.h" #include "nsRect.h" @@ -50,14 +50,10 @@ class nsIDOMSVGRect; class nsIDOMSVGMatrix; class nsSVGRenderState; -#define NS_ISVGCHILDFRAME_IID \ -{ 0xfc3ee9b2, 0xaf40, 0x416d, \ - { 0xa8, 0x51, 0xb4, 0x68, 0xa4, 0xe4, 0x8b, 0xcd } } - -class nsISVGChildFrame : public nsISupports { +class nsISVGChildFrame : public nsQueryFrame +{ public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGCHILDFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGChildFrame) // Paint this frame - aDirtyRect is the area being redrawn, in frame // offset pixel coordinates @@ -111,7 +107,5 @@ public: NS_IMETHOD_(PRBool) HasValidCoveredRect()=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGChildFrame, NS_ISVGCHILDFRAME_IID) - #endif // __NS_ISVGCHILDFRAME_H__ diff --git a/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h b/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h index 8c0da4fafbb..530e416b327 100644 --- a/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h +++ b/layout/svg/base/src/nsISVGGlyphFragmentLeaf.h @@ -46,17 +46,10 @@ class nsIDOMSVGPoint; class nsIDOMSVGRect; class nsSVGTextPathFrame; - -// {ec9a9965-3ff2-4bb5-b0e2-dd8830e9f41a} -#define NS_ISVGGLYPHFRAGMENTLEAF_IID \ - { 0xec9a9965, 0x3ff2, 0x4bb5, \ - { 0xb0, 0xe2, 0xdd, 0x88, 0x30, 0xe9, 0xf4, 0x1a } } - class nsISVGGlyphFragmentLeaf : public nsISVGGlyphFragmentNode { public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGGLYPHFRAGMENTLEAF_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGGlyphFragmentLeaf) NS_IMETHOD GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval)=0; NS_IMETHOD GetEndPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval)=0; @@ -89,7 +82,4 @@ public: NS_IMETHOD_(PRBool) IsAbsolutelyPositioned()=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGGlyphFragmentLeaf, - NS_ISVGGLYPHFRAGMENTLEAF_IID) - #endif // __NS_ISVGGLYPHFRAGMENTLEAF_H__ diff --git a/layout/svg/base/src/nsISVGGlyphFragmentNode.h b/layout/svg/base/src/nsISVGGlyphFragmentNode.h index bc8b3599238..4253a1f6d9c 100644 --- a/layout/svg/base/src/nsISVGGlyphFragmentNode.h +++ b/layout/svg/base/src/nsISVGGlyphFragmentNode.h @@ -40,7 +40,7 @@ #ifndef __NS_ISVGGLYPHFRAGMENTNODE_H__ #define __NS_ISVGGLYPHFRAGMENTNODE_H__ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsISVGGlyphFragmentLeaf; class nsIDOMSVGPoint; @@ -50,14 +50,10 @@ class nsIDOMSVGPoint; #define TRIM_LEADING_WHITESPACE 0x02 #define TRIM_TRAILING_WHITESPACE 0x04 -#define NS_ISVGGLYPHFRAGMENTNODE_IID \ -{ 0x1297716a, 0xd68d, 0x4c9d, { 0x8e, 0xf8, 0x9e, 0x01, 0x1d, 0x78, 0x21, 0xd0 } } - -class nsISVGGlyphFragmentNode : public nsISupports +class nsISVGGlyphFragmentNode : public nsQueryFrame { public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGGLYPHFRAGMENTNODE_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGGlyphFragmentNode) NS_IMETHOD_(PRUint32) GetNumberOfChars()=0; NS_IMETHOD_(float) GetComputedTextLength()=0; @@ -68,7 +64,4 @@ public: NS_IMETHOD_(void) SetWhitespaceHandling(PRUint8 aWhitespaceHandling)=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGGlyphFragmentNode, - NS_ISVGGLYPHFRAGMENTNODE_IID) - #endif // __NS_ISVGGLYPHFRAGMENTNODE_H__ diff --git a/layout/svg/base/src/nsISVGSVGFrame.h b/layout/svg/base/src/nsISVGSVGFrame.h index 0d6447802c5..8e1b5b0e485 100644 --- a/layout/svg/base/src/nsISVGSVGFrame.h +++ b/layout/svg/base/src/nsISVGSVGFrame.h @@ -39,21 +39,16 @@ #ifndef __NS_ISVGSVGFRAME_H__ #define __NS_ISVGSVGFRAME_H__ -#include "nsISupports.h" +#include "nsQueryFrame.h" -// {C38FDFC3-7030-47CB-BA69-D7C5F45E657C} -#define NS_ISVGSVGFRAME_IID \ -{ 0xc38fdfc3, 0x7030, 0x47cb, { 0xba, 0x69, 0xd7, 0xc5, 0xf4, 0x5e, 0x65, 0x7c } } - -class nsISVGSVGFrame : public nsISupports { +class nsISVGSVGFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGSVGFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsISVGSVGFrame) NS_IMETHOD SuspendRedraw()=0; NS_IMETHOD UnsuspendRedraw()=0; NS_IMETHOD NotifyViewportChange()=0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsISVGSVGFrame, NS_ISVGSVGFRAME_IID) - #endif // __NS_ISVGSVGFRAME_H__ diff --git a/layout/svg/base/src/nsSVGClipPathFrame.cpp b/layout/svg/base/src/nsSVGClipPathFrame.cpp index f5cb33291cb..70c2918b7a9 100644 --- a/layout/svg/base/src/nsSVGClipPathFrame.cpp +++ b/layout/svg/base/src/nsSVGClipPathFrame.cpp @@ -84,8 +84,7 @@ nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext, for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { // The CTM of each frame referencing us can be different. SVGFrame->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION | @@ -121,8 +120,7 @@ nsSVGClipPathFrame::ClipHitTest(nsIFrame* aParent, for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { // Notify the child frame that we may be working with a // different transform, so it can update its covered region @@ -143,9 +141,7 @@ nsSVGClipPathFrame::IsTrivial() for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame *svgChild = nsnull; - CallQueryInterface(kid, &svgChild); - + nsISVGChildFrame *svgChild = do_QueryFrame(kid); if (svgChild) { // We consider a non-trivial clipPath to be one containing // either more than one svg child and/or a svg container diff --git a/layout/svg/base/src/nsSVGContainerFrame.cpp b/layout/svg/base/src/nsSVGContainerFrame.cpp index b7b9c6e3d47..f1109f1d86d 100644 --- a/layout/svg/base/src/nsSVGContainerFrame.cpp +++ b/layout/svg/base/src/nsSVGContainerFrame.cpp @@ -38,12 +38,9 @@ #include "nsSVGUtils.h" #include "nsSVGOuterSVGFrame.h" -//---------------------------------------------------------------------- -// nsISupports methods - -NS_INTERFACE_MAP_BEGIN(nsSVGDisplayContainerFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGContainerFrame) +NS_QUERYFRAME_HEAD(nsSVGDisplayContainerFrame) + NS_QUERYFRAME_ENTRY(nsISVGChildFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGContainerFrame) nsIFrame* NS_NewSVGContainerFrame(nsIPresShell* aPresShell, @@ -130,8 +127,7 @@ nsSVGDisplayContainerFrame::InsertFrames(nsIAtom* aListName, for (nsIFrame* kid = aFrameList; kid != end; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->InitialUpdate(); } @@ -192,8 +188,7 @@ nsSVGDisplayContainerFrame::UpdateCoveredRegion() { for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->UpdateCoveredRegion(); } @@ -210,8 +205,7 @@ nsSVGDisplayContainerFrame::InitialUpdate() for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->InitialUpdate(); } @@ -241,8 +235,7 @@ nsSVGDisplayContainerFrame::NotifyRedrawSuspended() { for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame=nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifyRedrawSuspended(); } @@ -255,8 +248,7 @@ nsSVGDisplayContainerFrame::NotifyRedrawUnsuspended() { for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifyRedrawUnsuspended(); } diff --git a/layout/svg/base/src/nsSVGContainerFrame.h b/layout/svg/base/src/nsSVGContainerFrame.h index 9be1181d38e..505894f564e 100644 --- a/layout/svg/base/src/nsSVGContainerFrame.h +++ b/layout/svg/base/src/nsSVGContainerFrame.h @@ -84,13 +84,8 @@ protected: nsSVGContainerFrame(aContext) {} public: - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } + NS_DECL_QUERYFRAME -public: // nsIFrame: NS_IMETHOD InsertFrames(nsIAtom* aListName, nsIFrame* aPrevFrame, diff --git a/layout/svg/base/src/nsSVGFilterFrame.cpp b/layout/svg/base/src/nsSVGFilterFrame.cpp index 13868b2eeae..19fc008a2e0 100644 --- a/layout/svg/base/src/nsSVGFilterFrame.cpp +++ b/layout/svg/base/src/nsSVGFilterFrame.cpp @@ -110,7 +110,7 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget, { nsCOMPtr ctm = nsSVGUtils::GetCanvasTM(aTarget); - CallQueryInterface(aTarget, &mTarget); + mTarget = do_QueryFrame(aTarget); if (mTarget) { mTarget->SetMatrixPropagation(PR_FALSE); mTarget->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION | diff --git a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp index 566a73e601a..c541f06c62f 100644 --- a/layout/svg/base/src/nsSVGForeignObjectFrame.cpp +++ b/layout/svg/base/src/nsSVGForeignObjectFrame.cpp @@ -80,16 +80,13 @@ nsSVGForeignObjectFrame::nsSVGForeignObjectFrame(nsStyleContext* aContext) NS_FRAME_MAY_BE_TRANSFORMED_OR_HAVE_RENDERING_OBSERVERS); } -//---------------------------------------------------------------------- -// nsISupports methods - -NS_INTERFACE_MAP_BEGIN(nsSVGForeignObjectFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGForeignObjectFrameBase) - //---------------------------------------------------------------------- // nsIFrame methods +NS_QUERYFRAME_HEAD(nsSVGForeignObjectFrame) + NS_QUERYFRAME_ENTRY(nsISVGChildFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGForeignObjectFrameBase) + NS_IMETHODIMP nsSVGForeignObjectFrame::Init(nsIContent* aContent, nsIFrame* aParent, diff --git a/layout/svg/base/src/nsSVGForeignObjectFrame.h b/layout/svg/base/src/nsSVGForeignObjectFrame.h index 510ab9afc62..dee7fdc4f3a 100644 --- a/layout/svg/base/src/nsSVGForeignObjectFrame.h +++ b/layout/svg/base/src/nsSVGForeignObjectFrame.h @@ -57,13 +57,9 @@ class nsSVGForeignObjectFrame : public nsSVGForeignObjectFrameBase, protected: nsSVGForeignObjectFrame(nsStyleContext* aContext); - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_QUERYFRAME + // nsIFrame: NS_IMETHOD Init(nsIContent* aContent, nsIFrame* aParent, diff --git a/layout/svg/base/src/nsSVGGlyphFrame.cpp b/layout/svg/base/src/nsSVGGlyphFrame.cpp index 42656353a23..b1ac7ecedd4 100644 --- a/layout/svg/base/src/nsSVGGlyphFrame.cpp +++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp @@ -187,8 +187,7 @@ nsIFrame* NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* parentFrame, nsStyleContext* aContext) { NS_ASSERTION(parentFrame, "null parent"); - nsISVGTextContentMetrics *metrics; - CallQueryInterface(parentFrame, &metrics); + nsISVGTextContentMetrics *metrics = do_QueryFrame(parentFrame); NS_ASSERTION(metrics, "trying to construct an SVGGlyphFrame for an invalid container"); NS_ASSERTION(aContent->IsNodeOfType(nsINode::eTEXT), @@ -198,13 +197,13 @@ NS_NewSVGGlyphFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* pa } //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGGlyphFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentLeaf) - NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentNode) - NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGGlyphFrameBase) +NS_QUERYFRAME_HEAD(nsSVGGlyphFrame) + NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentLeaf) + NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentNode) + NS_QUERYFRAME_ENTRY(nsISVGChildFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGGlyphFrameBase) //---------------------------------------------------------------------- // nsIFrame methods @@ -1121,8 +1120,7 @@ nsSVGGlyphFrame::GetNextGlyphFragment() { nsIFrame* sibling = mNextSibling; while (sibling) { - nsISVGGlyphFragmentNode *node = nsnull; - CallQueryInterface(sibling, &node); + nsISVGGlyphFragmentNode *node = do_QueryFrame(sibling); if (node) return node->GetFirstGlyphFragment(); sibling = sibling->GetNextSibling(); @@ -1131,8 +1129,7 @@ nsSVGGlyphFrame::GetNextGlyphFragment() // no more siblings. go back up the tree. NS_ASSERTION(mParent, "null parent"); - nsISVGGlyphFragmentNode *node = nsnull; - CallQueryInterface(mParent, &node); + nsISVGGlyphFragmentNode *node = do_QueryFrame(mParent); return node ? node->GetNextGlyphFragment() : nsnull; } diff --git a/layout/svg/base/src/nsSVGGlyphFrame.h b/layout/svg/base/src/nsSVGGlyphFrame.h index 3a9223f7dc0..ed46f2bd03c 100644 --- a/layout/svg/base/src/nsSVGGlyphFrame.h +++ b/layout/svg/base/src/nsSVGGlyphFrame.h @@ -71,10 +71,7 @@ protected: } public: - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } + NS_DECL_QUERYFRAME // nsIFrame interface: NS_IMETHOD CharacterDataChanged(nsPresContext* aPresContext, diff --git a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp index 317fefc6105..cd01be50044 100644 --- a/layout/svg/base/src/nsSVGInnerSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGInnerSVGFrame.cpp @@ -57,13 +57,10 @@ protected: nsSVGInnerSVGFrame(nsStyleContext* aContext) : nsSVGInnerSVGFrameBase(aContext) {} - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME + // We don't define an AttributeChanged method since changes to the // 'x', 'y', 'width' and 'height' attributes of our content object // are handled in nsSVGSVGElement::DidModifySVGObservable @@ -129,14 +126,27 @@ NS_NewSVGInnerSVGFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsStyleCo NS_INTERFACE_MAP_BEGIN(nsSVGInnerSVGFrame) NS_INTERFACE_MAP_ENTRY(nsISVGValueObserver) - NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsISVGSVGFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGInnerSVGFrameBase) +NS_INTERFACE_MAP_END +NS_IMETHODIMP_(nsrefcnt) +nsSVGInnerSVGFrame::AddRef() +{ + return 2; +} + +NS_IMETHODIMP_(nsrefcnt) +nsSVGInnerSVGFrame::Release() +{ + return 1; +} //---------------------------------------------------------------------- // nsIFrame methods +NS_QUERYFRAME_HEAD(nsSVGInnerSVGFrame) + NS_QUERYFRAME_ENTRY(nsISVGSVGFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGInnerSVGFrameBase) + nsIAtom * nsSVGInnerSVGFrame::GetType() const { diff --git a/layout/svg/base/src/nsSVGIntegrationUtils.cpp b/layout/svg/base/src/nsSVGIntegrationUtils.cpp index 8842b32d82c..12cb624c6e3 100644 --- a/layout/svg/base/src/nsSVGIntegrationUtils.cpp +++ b/layout/svg/base/src/nsSVGIntegrationUtils.cpp @@ -244,10 +244,9 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsIRenderingContext* aCtx, nsDisplayList* aInnerList) { #ifdef DEBUG - nsISVGChildFrame *svgChildFrame; - CallQueryInterface(aEffectsFrame, &svgChildFrame); -#endif + nsISVGChildFrame *svgChildFrame = do_QueryFrame(aEffectsFrame); NS_ASSERTION(!svgChildFrame, "Should never be called on an SVG frame"); +#endif float opacity = aEffectsFrame->GetStyleDisplay()->mOpacity; if (opacity == 0.0f) diff --git a/layout/svg/base/src/nsSVGMarkerFrame.cpp b/layout/svg/base/src/nsSVGMarkerFrame.cpp index 7fec0c90707..8ba218c0df8 100644 --- a/layout/svg/base/src/nsSVGMarkerFrame.cpp +++ b/layout/svg/base/src/nsSVGMarkerFrame.cpp @@ -198,8 +198,7 @@ nsSVGMarkerFrame::PaintMark(nsSVGRenderState *aContext, for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { // The CTM of each frame referencing us may be different. SVGFrame->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION | @@ -236,8 +235,7 @@ nsSVGMarkerFrame::RegionMark(nsSVGPathGeometryFrame *aMarkedFrame, for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* child = nsnull; - CallQueryInterface(kid, &child); + nsISVGChildFrame* child = do_QueryFrame(kid); if (child) child->UpdateCoveredRegion(); } diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 6b9236bc50a..231d70f30ed 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -104,8 +104,7 @@ nsSVGMutationObserver::AttributeChanged(nsIDocument *aDocument, } // is the content a child of a text element - nsISVGTextContentMetrics* metrics; - CallQueryInterface(frame, &metrics); + nsISVGTextContentMetrics* metrics = do_QueryFrame(frame); if (metrics) { nsSVGTextContainerFrame *containerFrame = static_cast(frame); @@ -190,11 +189,11 @@ nsSVGOuterSVGFrame::Init(nsIContent* aContent, } //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGOuterSVGFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGSVGFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGOuterSVGFrameBase) +NS_QUERYFRAME_HEAD(nsSVGOuterSVGFrame) + NS_QUERYFRAME_ENTRY(nsISVGSVGFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGOuterSVGFrameBase) //---------------------------------------------------------------------- // nsIFrame methods @@ -406,8 +405,7 @@ nsSVGOuterSVGFrame::DidReflow(nsPresContext* aPresContext, // call InitialUpdate() on all frames: nsIFrame* kid = mFrames.FirstChild(); while (kid) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->InitialUpdate(); } @@ -636,8 +634,7 @@ nsSVGOuterSVGFrame::GetType() const void nsSVGOuterSVGFrame::InvalidateCoveredRegion(nsIFrame *aFrame) { - nsISVGChildFrame *svgFrame = nsnull; - CallQueryInterface(aFrame, &svgFrame); + nsISVGChildFrame *svgFrame = do_QueryFrame(aFrame); if (!svgFrame) return; @@ -648,8 +645,7 @@ nsSVGOuterSVGFrame::InvalidateCoveredRegion(nsIFrame *aFrame) PRBool nsSVGOuterSVGFrame::UpdateAndInvalidateCoveredRegion(nsIFrame *aFrame) { - nsISVGChildFrame *svgFrame = nsnull; - CallQueryInterface(aFrame, &svgFrame); + nsISVGChildFrame *svgFrame = do_QueryFrame(aFrame); if (!svgFrame) return PR_FALSE; @@ -685,8 +681,7 @@ nsSVGOuterSVGFrame::SuspendRedraw() for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame=nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifyRedrawSuspended(); } @@ -708,8 +703,7 @@ nsSVGOuterSVGFrame::UnsuspendRedraw() for (nsIFrame* kid = mFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* SVGFrame=nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifyRedrawUnsuspended(); } diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.h b/layout/svg/base/src/nsSVGOuterSVGFrame.h index f077fde951d..247060bb0c4 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.h +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.h @@ -59,13 +59,8 @@ class nsSVGOuterSVGFrame : public nsSVGOuterSVGFrameBase, protected: nsSVGOuterSVGFrame(nsStyleContext* aContext); - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_QUERYFRAME #ifdef DEBUG ~nsSVGOuterSVGFrame() { diff --git a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp index 9c9c0225ecb..bd13eaa3458 100644 --- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp +++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp @@ -60,11 +60,11 @@ NS_NewSVGPathGeometryFrame(nsIPresShell* aPresShell, } //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGPathGeometryFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGChildFrame) -NS_INTERFACE_MAP_END_INHERITING(nsSVGPathGeometryFrameBase) +NS_QUERYFRAME_HEAD(nsSVGPathGeometryFrame) + NS_QUERYFRAME_ENTRY(nsISVGChildFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGPathGeometryFrameBase) //---------------------------------------------------------------------- // nsIFrame methods diff --git a/layout/svg/base/src/nsSVGPathGeometryFrame.h b/layout/svg/base/src/nsSVGPathGeometryFrame.h index e0ebc96b235..ba343877d29 100644 --- a/layout/svg/base/src/nsSVGPathGeometryFrame.h +++ b/layout/svg/base/src/nsSVGPathGeometryFrame.h @@ -68,13 +68,8 @@ protected: nsSVGPathGeometryFrameBase(aContext) {} public: - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } + NS_DECL_QUERYFRAME -public: // nsIFrame interface: NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, diff --git a/layout/svg/base/src/nsSVGPatternFrame.cpp b/layout/svg/base/src/nsSVGPatternFrame.cpp index 94aacc64c0a..8541fbb3e6b 100644 --- a/layout/svg/base/src/nsSVGPatternFrame.cpp +++ b/layout/svg/base/src/nsSVGPatternFrame.cpp @@ -640,9 +640,9 @@ nsSVGPatternFrame::GetCallerGeometry(nsIDOMSVGMatrix **aCTM, // will be in *device coordinates* nsISVGChildFrame *callerSVGFrame; if (callerType == nsGkAtoms::svgGlyphFrame) - CallQueryInterface(aSource->GetParent(), &callerSVGFrame); + callerSVGFrame = do_QueryFrame(aSource->GetParent()); else - CallQueryInterface(aSource, &callerSVGFrame); + callerSVGFrame = do_QueryFrame(aSource); callerSVGFrame->SetMatrixPropagation(PR_FALSE); callerSVGFrame->NotifySVGChanged(nsISVGChildFrame::SUPPRESS_INVALIDATION | diff --git a/layout/svg/base/src/nsSVGSwitchFrame.cpp b/layout/svg/base/src/nsSVGSwitchFrame.cpp index 5e5ffeacb7d..7838c334c94 100644 --- a/layout/svg/base/src/nsSVGSwitchFrame.cpp +++ b/layout/svg/base/src/nsSVGSwitchFrame.cpp @@ -120,8 +120,7 @@ nsSVGSwitchFrame::GetFrameForPoint(const nsPoint &aPoint) { nsIFrame *kid = GetActiveChildFrame(); if (kid) { - nsISVGChildFrame* svgFrame; - CallQueryInterface(kid, &svgFrame); + nsISVGChildFrame* svgFrame = do_QueryFrame(kid); if (svgFrame) { return svgFrame->GetFrameForPoint(aPoint); } @@ -137,8 +136,7 @@ nsSVGSwitchFrame::GetCoveredRegion() nsIFrame *kid = GetActiveChildFrame(); if (kid) { - nsISVGChildFrame* child = nsnull; - CallQueryInterface(kid, &child); + nsISVGChildFrame* child = do_QueryFrame(kid); if (child) { rect = child->GetCoveredRegion(); } @@ -178,8 +176,7 @@ nsSVGSwitchFrame::GetBBox(nsIDOMSVGRect **aRect) nsIFrame *kid = GetActiveChildFrame(); if (kid) { - nsISVGChildFrame* svgFrame = nsnull; - CallQueryInterface(kid, &svgFrame); + nsISVGChildFrame* svgFrame = do_QueryFrame(kid); if (svgFrame) { nsCOMPtr box; svgFrame->GetBBox(getter_AddRefs(box)); diff --git a/layout/svg/base/src/nsSVGTSpanFrame.cpp b/layout/svg/base/src/nsSVGTSpanFrame.cpp index 500a29de967..a3ad5ce78ef 100644 --- a/layout/svg/base/src/nsSVGTSpanFrame.cpp +++ b/layout/svg/base/src/nsSVGTSpanFrame.cpp @@ -51,8 +51,7 @@ NS_NewSVGTSpanFrame(nsIPresShell* aPresShell, nsIContent* aContent, nsIFrame* parentFrame, nsStyleContext* aContext) { NS_ASSERTION(parentFrame, "null parent"); - nsISVGTextContentMetrics *metrics; - CallQueryInterface(parentFrame, &metrics); + nsISVGTextContentMetrics *metrics = do_QueryFrame(parentFrame); if (!metrics) { NS_ERROR("trying to construct an SVGTSpanFrame for an invalid container"); return nsnull; @@ -74,11 +73,11 @@ nsSVGTSpanFrame::GetType() const } //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGTSpanFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGGlyphFragmentNode) -NS_INTERFACE_MAP_END_INHERITING(nsSVGTSpanFrameBase) +NS_QUERYFRAME_HEAD(nsSVGTSpanFrame) + NS_QUERYFRAME_ENTRY(nsISVGGlyphFragmentNode) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGTSpanFrameBase) //---------------------------------------------------------------------- // nsIFrame methods @@ -150,8 +149,7 @@ nsSVGTSpanFrame::GetFirstGlyphFragment() // try children first: nsIFrame* kid = mFrames.FirstChild(); while (kid) { - nsISVGGlyphFragmentNode *node = nsnull; - CallQueryInterface(kid, &node); + nsISVGGlyphFragmentNode *node = do_QueryFrame(kid); if (node) return node->GetFirstGlyphFragment(); kid = kid->GetNextSibling(); @@ -167,8 +165,7 @@ nsSVGTSpanFrame::GetNextGlyphFragment() { nsIFrame* sibling = mNextSibling; while (sibling) { - nsISVGGlyphFragmentNode *node = nsnull; - CallQueryInterface(sibling, &node); + nsISVGGlyphFragmentNode *node = do_QueryFrame(sibling); if (node) return node->GetFirstGlyphFragment(); sibling = sibling->GetNextSibling(); @@ -177,8 +174,7 @@ nsSVGTSpanFrame::GetNextGlyphFragment() // no more siblings. go back up the tree. NS_ASSERTION(mParent, "null parent"); - nsISVGGlyphFragmentNode *node = nsnull; - CallQueryInterface(mParent, &node); + nsISVGGlyphFragmentNode *node = do_QueryFrame(mParent); return node ? node->GetNextGlyphFragment() : nsnull; } diff --git a/layout/svg/base/src/nsSVGTSpanFrame.h b/layout/svg/base/src/nsSVGTSpanFrame.h index 75692093c5c..db43c7fa6b3 100644 --- a/layout/svg/base/src/nsSVGTSpanFrame.h +++ b/layout/svg/base/src/nsSVGTSpanFrame.h @@ -54,13 +54,9 @@ protected: nsSVGTSpanFrame(nsStyleContext* aContext) : nsSVGTextContainerFrame(aContext) {} - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_QUERYFRAME + // nsIFrame: NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, diff --git a/layout/svg/base/src/nsSVGTextContainerFrame.cpp b/layout/svg/base/src/nsSVGTextContainerFrame.cpp index c3dc3f2f41b..4d29d65e5f9 100644 --- a/layout/svg/base/src/nsSVGTextContainerFrame.cpp +++ b/layout/svg/base/src/nsSVGTextContainerFrame.cpp @@ -45,11 +45,11 @@ #include "nsDOMError.h" //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGTextContainerFrame) - NS_INTERFACE_MAP_ENTRY(nsISVGTextContentMetrics) -NS_INTERFACE_MAP_END_INHERITING(nsSVGDisplayContainerFrame) +NS_QUERYFRAME_HEAD(nsSVGTextContainerFrame) + NS_QUERYFRAME_ENTRY(nsISVGTextContentMetrics) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGDisplayContainerFrame) void nsSVGTextContainerFrame::NotifyGlyphMetricsChange() @@ -308,7 +308,7 @@ nsSVGTextContainerFrame::GetFirstGlyphFragmentChildNode() nsISVGGlyphFragmentNode *retval = nsnull; nsIFrame* kid = mFrames.FirstChild(); while (kid) { - CallQueryInterface(kid, &retval); + retval = do_QueryFrame(kid); if (retval) break; kid = kid->GetNextSibling(); } @@ -319,12 +319,11 @@ nsISVGGlyphFragmentNode * nsSVGTextContainerFrame::GetNextGlyphFragmentChildNode(nsISVGGlyphFragmentNode *node) { nsISVGGlyphFragmentNode *retval = nsnull; - nsIFrame *frame = nsnull; - CallQueryInterface(node, &frame); + nsIFrame *frame = do_QueryFrame(node); NS_ASSERTION(frame, "interface not implemented"); frame = frame->GetNextSibling(); while (frame) { - CallQueryInterface(frame, &retval); + retval = do_QueryFrame(frame); if (retval) break; frame = frame->GetNextSibling(); } diff --git a/layout/svg/base/src/nsSVGTextContainerFrame.h b/layout/svg/base/src/nsSVGTextContainerFrame.h index 5d49c3e352c..677e34acfd1 100644 --- a/layout/svg/base/src/nsSVGTextContainerFrame.h +++ b/layout/svg/base/src/nsSVGTextContainerFrame.h @@ -59,13 +59,9 @@ public: NS_IMETHOD_(already_AddRefed) GetDx(); NS_IMETHOD_(already_AddRefed) GetDy(); - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_QUERYFRAME + // nsIFrame NS_IMETHOD InsertFrames(nsIAtom* aListName, nsIFrame* aPrevFrame, diff --git a/layout/svg/base/src/nsSVGUseFrame.cpp b/layout/svg/base/src/nsSVGUseFrame.cpp index cc1afb36856..c03a7681f7a 100644 --- a/layout/svg/base/src/nsSVGUseFrame.cpp +++ b/layout/svg/base/src/nsSVGUseFrame.cpp @@ -53,13 +53,9 @@ class nsSVGUseFrame : public nsSVGUseFrameBase, protected: nsSVGUseFrame(nsStyleContext* aContext) : nsSVGUseFrameBase(aContext) {} - // nsISupports interface: - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); -private: - NS_IMETHOD_(nsrefcnt) AddRef() { return 1; } - NS_IMETHOD_(nsrefcnt) Release() { return 1; } - public: + NS_DECL_QUERYFRAME + // nsIFrame interface: NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, @@ -110,11 +106,11 @@ nsSVGUseFrame::GetType() const } //---------------------------------------------------------------------- -// nsISupports methods +// nsQueryFrame methods -NS_INTERFACE_MAP_BEGIN(nsSVGUseFrame) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) -NS_INTERFACE_MAP_END_INHERITING(nsSVGUseFrameBase) +NS_QUERYFRAME_HEAD(nsSVGUseFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) +NS_QUERYFRAME_TAIL_INHERITING(nsSVGUseFrameBase) //---------------------------------------------------------------------- // nsIFrame methods: diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 2d175af17fe..942e41d2ebf 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -522,8 +522,7 @@ nsSVGUtils::GetBBox(nsFrameList *aFrames, nsIDOMSVGRect **_retval) nsIFrame* kid = aFrames->FirstChild(); while (kid) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(kid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { nsCOMPtr box; SVGFrame->GetBBox(getter_AddRefs(box)); @@ -598,8 +597,7 @@ nsSVGUtils::InvalidateCoveredRegion(nsIFrame *aFrame) void nsSVGUtils::UpdateGraphic(nsISVGChildFrame *aSVGFrame) { - nsIFrame *frame; - CallQueryInterface(aSVGFrame, &frame); + nsIFrame *frame = do_QueryFrame(aSVGFrame); nsSVGEffects::InvalidateRenderingObservers(frame); @@ -744,8 +742,7 @@ nsSVGUtils::GetOuterSVGFrame(nsIFrame *aFrame) nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, nsRect* aRect) { - nsISVGChildFrame* svg; - CallQueryInterface(aFrame, &svg); + nsISVGChildFrame* svg = do_QueryFrame(aFrame); if (!svg) return nsnull; *aRect = svg->GetCoveredRegion(); @@ -880,8 +877,7 @@ nsSVGUtils::NotifyChildrenOfSVGChange(nsIFrame *aFrame, PRUint32 aFlags) nsIFrame *aKid = aFrame->GetFirstChild(nsnull); while (aKid) { - nsISVGChildFrame* SVGFrame = nsnull; - CallQueryInterface(aKid, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(aKid); if (SVGFrame) { SVGFrame->NotifySVGChanged(aFlags); } else { @@ -924,8 +920,7 @@ public: virtual void Paint(nsSVGRenderState *aContext, nsIFrame *aTarget, const nsIntRect* aDirtyRect) { - nsISVGChildFrame *svgChildFrame; - CallQueryInterface(aTarget, &svgChildFrame); + nsISVGChildFrame *svgChildFrame = do_QueryFrame(aTarget); NS_ASSERTION(svgChildFrame, "Expected SVG frame here"); NS_ASSERTION(!svgChildFrame->GetMatrixPropagation(), "This should have been set to false already"); @@ -961,9 +956,7 @@ nsSVGUtils::PaintFrameWithEffects(nsSVGRenderState *aContext, const nsIntRect *aDirtyRect, nsIFrame *aFrame) { - nsISVGChildFrame *svgChildFrame; - CallQueryInterface(aFrame, &svgChildFrame); - + nsISVGChildFrame *svgChildFrame = do_QueryFrame(aFrame); if (!svgChildFrame) return; @@ -1144,8 +1137,7 @@ nsSVGUtils::HitTestChildren(nsIFrame *aFrame, const nsPoint &aPoint) // now do the backwards traversal while (current) { - nsISVGChildFrame* SVGFrame; - CallQueryInterface(current, &SVGFrame); + nsISVGChildFrame* SVGFrame = do_QueryFrame(current); if (SVGFrame) { result = SVGFrame->GetFrameForPoint(aPoint); if (result) @@ -1180,8 +1172,7 @@ nsSVGUtils::GetCoveredRegion(const nsFrameList &aFrames) for (nsIFrame* kid = aFrames.FirstChild(); kid; kid = kid->GetNextSibling()) { - nsISVGChildFrame* child = nsnull; - CallQueryInterface(kid, &child); + nsISVGChildFrame* child = do_QueryFrame(kid); if (child) { nsRect childRect = child->GetCoveredRegion(); rect.UnionRect(rect, childRect); @@ -1360,8 +1351,7 @@ nsSVGUtils::GfxRectToIntRect(const gfxRect& aIn, nsIntRect* aOut) already_AddRefed nsSVGUtils::GetBBox(nsIFrame *aFrame) { - nsISVGChildFrame *svg; - CallQueryInterface(aFrame, &svg); + nsISVGChildFrame *svg = do_QueryFrame(aFrame); if (!svg) { nsIDOMSVGRect *rect = nsnull; gfxRect r = nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame(aFrame); @@ -1456,8 +1446,7 @@ nsSVGUtils::AdjustMatrixForUnits(nsIDOMSVGMatrix *aMatrix, PRBool gotRect = PR_FALSE; if (aFrame->IsFrameOfType(nsIFrame::eSVG)) { - nsISVGChildFrame *svgFrame; - CallQueryInterface(aFrame, &svgFrame); + nsISVGChildFrame *svgFrame = do_QueryFrame(aFrame); nsCOMPtr rect; svgFrame->GetBBox(getter_AddRefs(rect)); if (rect) { diff --git a/layout/tables/nsITableCellLayout.h b/layout/tables/nsITableCellLayout.h index 4e9c18dcd23..f201d6bacc1 100644 --- a/layout/tables/nsITableCellLayout.h +++ b/layout/tables/nsITableCellLayout.h @@ -37,13 +37,7 @@ #ifndef nsITableCellLayout_h__ #define nsITableCellLayout_h__ -#include "nsISupports.h" - -// IID for the nsITableCellLayout interface -// 0238f187-033d-426b-bd03-96eb75af5129 -#define NS_ITABLECELLAYOUT_IID \ -{ 0x0238f187, 0x033d, 0x426b, \ - { 0xbd, 0x03, 0x96, 0xeb, 0x75, 0xaf, 0x51, 0x29 } } +#include "nsQueryFrame.h" /** * nsITableCellLayout @@ -51,11 +45,11 @@ * * @author sclark */ -class nsITableCellLayout : public nsISupports +class nsITableCellLayout { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITABLECELLAYOUT_IID) + NS_DECLARE_FRAME_ACCESSOR(nsITableCellLayout) /** return the mapped cell's row and column indexes (starting at 0 for each) */ NS_IMETHOD GetCellIndexes(PRInt32 &aRowIndex, PRInt32 &aColIndex)=0; @@ -67,8 +61,6 @@ public: virtual nsresult GetColIndex(PRInt32 &aColIndex) const = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsITableCellLayout, NS_ITABLECELLAYOUT_IID) - #endif diff --git a/layout/tables/nsITableLayout.h b/layout/tables/nsITableLayout.h index 72e304702c1..0d9e3aef874 100644 --- a/layout/tables/nsITableLayout.h +++ b/layout/tables/nsITableLayout.h @@ -37,14 +37,9 @@ #ifndef nsITableLayout_h__ #define nsITableLayout_h__ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsIDOMElement; -// IID for the nsITableLayout interface -// A9222E6B-437E-11d3-B227-004095E27A10 -#define NS_ITABLELAYOUT_IID \ - { 0xf8363dea, 0x11ad, 0x483a, { 0xba, 0xea, 0xf6, 0xf2, 0xc3, 0x58, 0x8d, 0xde }} - /** * nsITableLayout * interface for layout objects that act like tables. @@ -52,11 +47,11 @@ class nsIDOMElement; * * @author sclark */ -class nsITableLayout : public nsISupports +class nsITableLayout { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITABLELAYOUT_IID) + NS_DECLARE_FRAME_ACCESSOR(nsITableLayout) /** return all the relevant layout information about a cell. * @param aRowIndex a row which the cell intersects @@ -114,6 +109,4 @@ public: PRInt32 *aRow, PRInt32 *aColumn) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsITableLayout, NS_ITABLELAYOUT_IID) - #endif diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 5c2d660ec77..adb4053b58f 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -1015,25 +1015,10 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, /* ----- global methods ----- */ -NS_IMPL_ADDREF_INHERITED(nsTableCellFrame, nsHTMLContainerFrame) -NS_IMPL_RELEASE_INHERITED(nsTableCellFrame, nsHTMLContainerFrame) - -NS_IMETHODIMP -nsTableCellFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsITableCellLayout))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - if (aIID.Equals(NS_GET_IID(nsIPercentHeightObserver))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsTableCellFrame) + NS_QUERYFRAME_ENTRY(nsITableCellLayout) + NS_QUERYFRAME_ENTRY(nsIPercentHeightObserver) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsTableCellFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index 4a4870c75a2..b39548ba9f1 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -72,8 +72,7 @@ class nsTableCellFrame : public nsHTMLContainerFrame, { public: - // nsISupports - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // default constructor supplied by the compiler diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 042636b36f3..a61944e5bd2 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -196,21 +196,9 @@ nsTableFrame::nsTableFrame(nsStyleContext* aContext) mBits.mGeometryDirty = PR_FALSE; } -NS_IMPL_ADDREF_INHERITED(nsTableFrame, nsHTMLContainerFrame) -NS_IMPL_RELEASE_INHERITED(nsTableFrame, nsHTMLContainerFrame) - -NS_IMETHODIMP -nsTableFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsITableLayout))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsTableFrame) + NS_QUERYFRAME_ENTRY(nsITableLayout) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) NS_IMETHODIMP nsTableFrame::Init(nsIContent* aContent, @@ -1116,9 +1104,8 @@ nsTableFrame::GetRowGroupFrame(nsIFrame* aFrame, rgFrame = aFrame; } else if (nsGkAtoms::scrollFrame == frameType) { - nsIScrollableFrame* scrollable = nsnull; - nsresult rv = CallQueryInterface(aFrame, &scrollable); - if (NS_SUCCEEDED(rv) && (scrollable)) { + nsIScrollableFrame* scrollable = do_QueryFrame(aFrame); + if (scrollable) { nsIFrame* scrolledFrame = scrollable->GetScrolledFrame(); if (scrolledFrame) { if (nsGkAtoms::tableRowGroupFrame == scrolledFrame->GetType()) { diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index a548a26196c..95f7020182f 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -140,8 +140,7 @@ class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout { public: - // nsISupports - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME /** nsTableOuterFrame has intimate knowledge of the inner table frame */ friend class nsTableOuterFrame; diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index f3a9ad88db6..5c172e3c68a 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -176,9 +176,6 @@ NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) /* ----------- nsTableOuterFrame ---------- */ -NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) -NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame) - nsTableOuterFrame::nsTableOuterFrame(nsStyleContext* aContext): nsHTMLContainerFrame(aContext) { @@ -188,18 +185,9 @@ nsTableOuterFrame::~nsTableOuterFrame() { } -NS_IMETHODIMP -nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - if (aIID.Equals(NS_GET_IID(nsITableLayout))) { - *aInstancePtr = static_cast(this); - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsTableOuterFrame) + NS_QUERYFRAME_ENTRY(nsITableLayout) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) #ifdef ACCESSIBILITY NS_IMETHODIMP nsTableOuterFrame::GetAccessible(nsIAccessible** aAccessible) diff --git a/layout/tables/nsTableOuterFrame.h b/layout/tables/nsTableOuterFrame.h index 66ac343c5ea..725c7c23bde 100644 --- a/layout/tables/nsTableOuterFrame.h +++ b/layout/tables/nsTableOuterFrame.h @@ -87,8 +87,7 @@ class nsTableOuterFrame : public nsHTMLContainerFrame, public nsITableLayout { public: - // nsISupports - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME /** instantiate a new instance of nsTableRowFrame. * @param aPresShell the pres shell for this frame diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 2108a637315..3592c1ffb6c 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -64,19 +64,9 @@ nsTableRowGroupFrame::~nsTableRowGroupFrame() { } -NS_IMETHODIMP -nsTableRowGroupFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr) -{ - NS_PRECONDITION(aInstancePtr, "null out param"); - - static NS_DEFINE_IID(kITableRowGroupIID, NS_ITABLEROWGROUPFRAME_IID); - if (aIID.Equals(kITableRowGroupIID)) { - *aInstancePtr = (void*)this; - return NS_OK; - } - - return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr); -} +NS_QUERYFRAME_HEAD(nsTableRowGroupFrame) + NS_QUERYFRAME_ENTRY(nsTableRowGroupFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame) /* virtual */ PRBool nsTableRowGroupFrame::IsContainingBlock() const diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index 5319bf2e11a..586f5f5a6e3 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -72,10 +72,6 @@ struct nsRowGroupReflowState { ~nsRowGroupReflowState() {} }; -#define NS_ITABLEROWGROUPFRAME_IID \ -{ 0xe940e7bc, 0xb534, 0x11d2, \ - { 0x95, 0xa2, 0x0, 0x60, 0xb0, 0xc3, 0x44, 0x14 } } - // use the following bits from nsFrame's frame state // thead or tfoot should be repeated on every printed page @@ -101,7 +97,8 @@ class nsTableRowGroupFrame , public nsILineIterator { public: - NS_IMETHOD QueryInterface(const nsIID &aIID, void **aInstancePtr); + NS_DECLARE_FRAME_ACCESSOR(nsTableRowGroupFrame) + NS_DECL_QUERYFRAME /** instantiate a new instance of nsTableRowFrame. * @param aPresShell the pres shell for this frame diff --git a/layout/xul/base/public/nsIMenuFrame.h b/layout/xul/base/public/nsIMenuFrame.h index c17ff03e780..68419dd5e41 100644 --- a/layout/xul/base/public/nsIMenuFrame.h +++ b/layout/xul/base/public/nsIMenuFrame.h @@ -38,20 +38,15 @@ #ifndef nsIMenuFrame_h___ #define nsIMenuFrame_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" // this interface exists solely because native themes need to call into it. // Only menu frames should implement it -// {212521C8-1509-4F41-ADDB-6A0B9356770F} -#define NS_IMENUFRAME_IID \ -{ 0x212521C8, 0x1509, 0x4F41, { 0xAD, 0xDB, 0x6A, 0x0B, 0x93, 0x56, 0x77, 0x0F } } - -class nsIMenuFrame : public nsISupports { - +class nsIMenuFrame +{ public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IMENUFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIMenuFrame) virtual PRBool IsOpen() = 0; virtual PRBool IsMenu() = 0; @@ -59,7 +54,5 @@ public: virtual PRBool IsOnActiveMenuBar() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIMenuFrame, NS_IMENUFRAME_IID) - #endif diff --git a/layout/xul/base/public/nsIScrollbarMediator.h b/layout/xul/base/public/nsIScrollbarMediator.h index 2b63802d0a2..465e1242abd 100644 --- a/layout/xul/base/public/nsIScrollbarMediator.h +++ b/layout/xul/base/public/nsIScrollbarMediator.h @@ -40,28 +40,24 @@ #ifndef nsIScrollbarMediator_h___ #define nsIScrollbarMediator_h___ -// {b589027f-271b-4c68-91df-04f139885e9a} -#define NS_ISCROLLBARMEDIATOR_IID \ -{ 0xb589027f, 0x271b, 0x4c68, { 0x91, 0xdf, 0x04, 0xf1, 0x39, 0x88, 0x5e, 0x9a } } +#include "nsQueryFrame.h" -static NS_DEFINE_IID(kIScrollbarMediatorIID, NS_ISCROLLBARMEDIATOR_IID); - -class nsIScrollbarMediator : public nsISupports { +class nsIScrollbarFrame; +class nsIScrollbarMediator +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLBARMEDIATOR_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIScrollbarMediator) - // The nsISupports aScrollbar argument below denotes the + // The nsIFrame aScrollbar argument below denotes the // scrollbar that's firing the notification. It should be // where the same object as where nsIScrollbarFrame is implemented - NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) = 0; - NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) = 0; + NS_IMETHOD PositionChanged(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) = 0; + NS_IMETHOD ScrollbarButtonPressed(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) = 0; - NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) = 0; + NS_IMETHOD VisibilityChanged(PRBool aVisible) = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollbarMediator, NS_ISCROLLBARMEDIATOR_IID) - #endif diff --git a/layout/xul/base/src/grid/nsGrid.cpp b/layout/xul/base/src/grid/nsGrid.cpp index b3b6020f9a9..bcdcf661ece 100644 --- a/layout/xul/base/src/grid/nsGrid.cpp +++ b/layout/xul/base/src/grid/nsGrid.cpp @@ -290,13 +290,11 @@ nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns) while(child) { nsIBox* oldBox = child; - nsresult rv = NS_OK; - nsCOMPtr scrollFrame = do_QueryInterface(child, &rv); + nsIScrollableFrame *scrollFrame = do_QueryFrame(child); if (scrollFrame) { nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame(); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); - if (NS_FAILED(CallQueryInterface(scrolledFrame, &child))) - child = nsnull; + child = do_QueryFrame(scrolledFrame); } nsCOMPtr layout; @@ -1299,7 +1297,7 @@ nsIBox* nsGrid::GetScrolledBox(nsIBox* aChild) { // first see if it is a scrollframe. If so walk down into it and get the scrolled child - nsCOMPtr scrollFrame = do_QueryInterface(aChild); + nsIScrollableFrame *scrollFrame = do_QueryFrame(aChild); if (scrollFrame) { nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame(); NS_ASSERTION(scrolledFrame,"Error no scroll frame!!"); @@ -1329,7 +1327,7 @@ nsGrid::GetScrollBox(nsIBox* aChild) // if it's a parent then the child passed does not // have a scroll frame immediately wrapped around it. while (parent) { - nsCOMPtr scrollFrame = do_QueryInterface(parent); + nsIScrollableFrame *scrollFrame = do_QueryFrame(parent); // scrollframe? Yep return it. if (scrollFrame) return parent; diff --git a/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp b/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp index 0f6e58a485e..160826de2b2 100644 --- a/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp +++ b/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp @@ -269,7 +269,7 @@ nsGridRowLeafLayout::ComputeChildSizes(nsIBox* aBox, GetParentGridPart(aBox, &parentBox, getter_AddRefs(parent)); while (parentBox) { nsIBox* scrollbox = nsGrid::GetScrollBox(parentBox); - nsCOMPtr scrollable = do_QueryInterface(scrollbox); + nsIScrollableFrame *scrollable = do_QueryFrame(scrollbox); if (scrollable) { nsMargin scrollbarSizes = scrollable->GetActualScrollbarSizes(); diff --git a/layout/xul/base/src/nsBoxObject.cpp b/layout/xul/base/src/nsBoxObject.cpp index 159fe2922cf..083234cee1d 100644 --- a/layout/xul/base/src/nsBoxObject.cpp +++ b/layout/xul/base/src/nsBoxObject.cpp @@ -314,16 +314,6 @@ nsBoxObject::GetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports** NS_IMETHODIMP nsBoxObject::SetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports* aValue) { -#ifdef DEBUG - if (aValue) { - nsIFrame* frame; - CallQueryInterface(aValue, &frame); - NS_ASSERTION(!frame, - "Calling SetPropertyAsSupports on a frame. Prepare to crash " - "and be exploited any time some random website decides to " - "exploit you"); - } -#endif NS_ENSURE_ARG(aPropertyName && *aPropertyName); if (!mPropertyTable) { diff --git a/layout/xul/base/src/nsContainerBoxObject.cpp b/layout/xul/base/src/nsContainerBoxObject.cpp index e4192748aa8..982d3834f07 100644 --- a/layout/xul/base/src/nsContainerBoxObject.cpp +++ b/layout/xul/base/src/nsContainerBoxObject.cpp @@ -83,9 +83,7 @@ NS_IMETHODIMP nsContainerBoxObject::GetDocShell(nsIDocShell** aResult) nsIFrame *frame = GetFrame(PR_FALSE); if (frame) { - nsIFrameFrame *frame_frame = nsnull; - CallQueryInterface(frame, &frame_frame); - + nsIFrameFrame *frame_frame = do_QueryFrame(frame); if (frame_frame) { // Ok, the frame for mContent is a nsIFrameFrame, it knows how // to reach the docshell, so ask it... diff --git a/layout/xul/base/src/nsDocElementBoxFrame.cpp b/layout/xul/base/src/nsDocElementBoxFrame.cpp index 9d5d74205fd..f2d80a89553 100644 --- a/layout/xul/base/src/nsDocElementBoxFrame.cpp +++ b/layout/xul/base/src/nsDocElementBoxFrame.cpp @@ -72,7 +72,7 @@ public: nsDocElementBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext) :nsBoxFrame(aShell, aContext, PR_TRUE) {} - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent(nsTArray& aElements); @@ -148,21 +148,9 @@ nsDocElementBoxFrame::CreateAnonymousContent(nsTArray& aElements) return NS_OK; } -NS_IMETHODIMP_(nsrefcnt) -nsDocElementBoxFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsDocElementBoxFrame::Release(void) -{ - return NS_OK; -} - -NS_INTERFACE_MAP_BEGIN(nsDocElementBoxFrame) - NS_INTERFACE_MAP_ENTRY(nsIAnonymousContentCreator) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) +NS_QUERYFRAME_HEAD(nsDocElementBoxFrame) + NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator) +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) #ifdef DEBUG NS_IMETHODIMP diff --git a/layout/xul/base/src/nsIRootBox.h b/layout/xul/base/src/nsIRootBox.h index d6693b4ca23..142a284bd6e 100644 --- a/layout/xul/base/src/nsIRootBox.h +++ b/layout/xul/base/src/nsIRootBox.h @@ -40,21 +40,15 @@ #ifndef nsIRootBox_h___ #define nsIRootBox_h___ -#include "nsISupports.h" +#include "nsQueryFrame.h" class nsPopupSetFrame; class nsIContent; class nsIPresShell; -// {9777EC2A-9A46-4D01-8CEB-B9CEB2C262A5} -#define NS_IROOTBOX_IID \ -{ 0x9777EC2A, 0x9A46, 0x4D01, \ - { 0x8C, 0xEB, 0xB9, 0xCE, 0xB2, 0xC2, 0x62, 0xA5 } } - - -class nsIRootBox : public nsISupports { - +class nsIRootBox +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IROOTBOX_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIRootBox) virtual nsPopupSetFrame* GetPopupSetFrame() = 0; virtual void SetPopupSetFrame(nsPopupSetFrame* aPopupSet) = 0; @@ -68,7 +62,5 @@ public: static nsIRootBox* GetRootBox(nsIPresShell* aShell); }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIRootBox, NS_IROOTBOX_IID) - #endif diff --git a/layout/xul/base/src/nsIScrollbarFrame.h b/layout/xul/base/src/nsIScrollbarFrame.h index c0e48339b0a..74e5576d7f9 100644 --- a/layout/xul/base/src/nsIScrollbarFrame.h +++ b/layout/xul/base/src/nsIScrollbarFrame.h @@ -39,18 +39,14 @@ #ifndef nsIScrollbarFrame_h___ #define nsIScrollbarFrame_h___ -// {660e5ed6-1cf7-47ff-b094-c588c21986e8} -#define NS_ISCROLLBARFRAME_IID \ -{ 0x660e5ed6, 0x1cf7, 0x47ff, { 0xb0, 0x94, 0xc5, 0x88, 0xc2, 0x19, 0x86, 0xe8 } } - -static NS_DEFINE_IID(kIScrollbarFrameIID, NS_ISCROLLBARFRAME_IID); +#include "nsQueryFrame.h" class nsIScrollbarMediator; -class nsIScrollbarFrame : public nsISupports { - +class nsIScrollbarFrame : public nsQueryFrame +{ public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCROLLBARFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsIScrollbarFrame) // Sets the scrollbar mediator content. We will try to get its primary frame // and then QI that to nsIScrollbarMediator as necessary. @@ -60,6 +56,4 @@ public: virtual nsIScrollbarMediator* GetScrollbarMediator() = 0; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsIScrollbarFrame, NS_ISCROLLBARFRAME_IID) - #endif diff --git a/layout/xul/base/src/nsListBoxBodyFrame.cpp b/layout/xul/base/src/nsListBoxBodyFrame.cpp index 6e8cf9fce2f..31055c6d740 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.cpp +++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp @@ -206,32 +206,10 @@ nsListBoxBodyFrame::~nsListBoxBodyFrame() } -////////// nsISupports ///////////////// - -NS_IMETHODIMP_(nsrefcnt) -nsListBoxBodyFrame::AddRef(void) -{ - return 2; -} - -NS_IMETHODIMP_(nsrefcnt) -nsListBoxBodyFrame::Release(void) -{ - return 1; -} - -// -// QueryInterface -// -NS_INTERFACE_MAP_BEGIN(nsListBoxBodyFrame) - NS_INTERFACE_MAP_ENTRY(nsIScrollbarMediator) - if (aIID.Equals(NS_GET_IID(nsListBoxBodyFrame))) { - *aInstancePtr = this; - return NS_OK; - } - else -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) - +NS_QUERYFRAME_HEAD(nsListBoxBodyFrame) + NS_QUERYFRAME_ENTRY(nsIScrollbarMediator) + NS_QUERYFRAME_ENTRY(nsListBoxBodyFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) ////////// nsIFrame ///////////////// @@ -248,8 +226,7 @@ nsListBoxBodyFrame::Init(nsIContent* aContent, scrollableView->SetScrollProperties(NS_SCROLL_PROPERTY_ALWAYS_BLIT); nsIBox* verticalScrollbar = scrollFrame->GetScrollbarBox(PR_TRUE); if (verticalScrollbar) { - nsIScrollbarFrame* scrollbarFrame = nsnull; - CallQueryInterface(verticalScrollbar, &scrollbarFrame); + nsIScrollbarFrame* scrollbarFrame = do_QueryFrame(verticalScrollbar); scrollbarFrame->SetScrollbarMediatorContent(GetContent()); } } @@ -381,7 +358,7 @@ nsListBoxBodyFrame::GetPrefSize(nsBoxLayoutState& aBoxLayoutState) ///////////// nsIScrollbarMediator /////////////// NS_IMETHODIMP -nsListBoxBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) +nsListBoxBodyFrame::PositionChanged(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) { if (mScrolling || mRowHeight == 0) return NS_OK; @@ -433,7 +410,7 @@ nsListBoxBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, } NS_IMETHODIMP -nsListBoxBodyFrame::VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) +nsListBoxBodyFrame::VisibilityChanged(PRBool aVisible) { if (mRowHeight == 0) return NS_OK; @@ -451,7 +428,7 @@ nsListBoxBodyFrame::VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) } NS_IMETHODIMP -nsListBoxBodyFrame::ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) +nsListBoxBodyFrame::ScrollbarButtonPressed(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) { if (aOldIndex == aNewIndex) return NS_OK; diff --git a/layout/xul/base/src/nsListBoxBodyFrame.h b/layout/xul/base/src/nsListBoxBodyFrame.h index 9647206c5d4..9809ef6ad49 100644 --- a/layout/xul/base/src/nsListBoxBodyFrame.h +++ b/layout/xul/base/src/nsListBoxBodyFrame.h @@ -51,10 +51,6 @@ #include "nsThreadUtils.h" #include "nsPIBoxObject.h" -#define NS_LISTBOXBODYFRAME_IID \ -{ 0x6e0acf13, 0x0b07, 0x481d, \ - { 0xa3, 0x39, 0x4c, 0xb6, 0x44, 0xbc, 0x1b, 0xd8 } } - class nsListScrollSmoother; nsIFrame* NS_NewListBoxBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, @@ -69,9 +65,9 @@ class nsListBoxBodyFrame : public nsBoxFrame, virtual ~nsListBoxBodyFrame(); public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_LISTBOXBODYFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsListBoxBodyFrame) - NS_DECL_ISUPPORTS + NS_DECL_QUERYFRAME // non-virtual nsIListBoxObject nsresult GetRowCount(PRInt32 *aResult); @@ -97,9 +93,9 @@ public: NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID, nsIAtom* aAttribute, PRInt32 aModType); // nsIScrollbarMediator - NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); - NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); - NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible); + NS_IMETHOD PositionChanged(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); + NS_IMETHOD ScrollbarButtonPressed(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); + NS_IMETHOD VisibilityChanged(PRBool aVisible); // nsIReflowCallback virtual PRBool ReflowFinished(); @@ -226,6 +222,4 @@ protected: nsCOMPtr mBoxObject; }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsListBoxBodyFrame, NS_LISTBOXBODYFRAME_IID) - #endif // nsListBoxBodyFrame_h diff --git a/layout/xul/base/src/nsListBoxObject.cpp b/layout/xul/base/src/nsListBoxObject.cpp index 2fb640abf04..f87a48d3f30 100644 --- a/layout/xul/base/src/nsListBoxObject.cpp +++ b/layout/xul/base/src/nsListBoxObject.cpp @@ -206,8 +206,7 @@ nsListBoxObject::GetListBoxBody(PRBool aFlush) frame = shell->GetPrimaryFrameFor(content); if (!frame) return nsnull; - nsIScrollableFrame* scrollFrame; - CallQueryInterface(frame, &scrollFrame); + nsIScrollableFrame* scrollFrame = do_QueryFrame(frame); if (!scrollFrame) return nsnull; @@ -217,8 +216,7 @@ nsListBoxObject::GetListBoxBody(PRBool aFlush) return nsnull; // It's a frame. Refcounts are irrelevant. - nsListBoxBodyFrame* listBoxBody = nsnull; - CallQueryInterface(yeahBaby, &listBoxBody); + nsListBoxBodyFrame* listBoxBody = do_QueryFrame(yeahBaby); NS_ENSURE_TRUE(listBoxBody && listBoxBody->SetBoxObject(this), nsnull); diff --git a/layout/xul/base/src/nsListItemFrame.cpp b/layout/xul/base/src/nsListItemFrame.cpp index f2922bc106c..32249f3a98c 100644 --- a/layout/xul/base/src/nsListItemFrame.cpp +++ b/layout/xul/base/src/nsListItemFrame.cpp @@ -44,21 +44,6 @@ #include "nsGkAtoms.h" #include "nsDisplayList.h" -NS_IMETHODIMP_(nsrefcnt) -nsListItemFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsListItemFrame::Release(void) -{ - return NS_OK; -} - -NS_INTERFACE_MAP_BEGIN(nsListItemFrame) -NS_INTERFACE_MAP_END_INHERITING(nsGridRowLeafFrame) - nsListItemFrame::nsListItemFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRBool aIsRoot, diff --git a/layout/xul/base/src/nsListItemFrame.h b/layout/xul/base/src/nsListItemFrame.h index ac972e05525..af017ebb8ac 100644 --- a/layout/xul/base/src/nsListItemFrame.h +++ b/layout/xul/base/src/nsListItemFrame.h @@ -48,8 +48,6 @@ nsIFrame* NS_NewListItemFrame(nsIPresShell* aPresShell, class nsListItemFrame : public nsGridRowLeafFrame { public: - NS_DECL_ISUPPORTS - friend nsIFrame* NS_NewListItemFrame(nsIPresShell* aPresShell, nsStyleContext *aContext, PRBool aIsRoot, diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index 4d841075d2c..1f29a926886 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -168,25 +168,10 @@ NS_NewMenuFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRUint32 aFl return it; } -NS_IMETHODIMP_(nsrefcnt) -nsMenuFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsMenuFrame::Release(void) -{ - return NS_OK; -} - -// -// QueryInterface -// -NS_INTERFACE_MAP_BEGIN(nsMenuFrame) - NS_INTERFACE_MAP_ENTRY(nsIMenuFrame) - NS_INTERFACE_MAP_ENTRY(nsIScrollableViewProvider) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) +NS_QUERYFRAME_HEAD(nsMenuFrame) + NS_QUERYFRAME_ENTRY(nsIMenuFrame) + NS_QUERYFRAME_ENTRY(nsIScrollableViewProvider) +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) // // nsMenuFrame cntr @@ -770,7 +755,7 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState) nsRect bounds(mPopupFrame->GetRect()); - nsCOMPtr scrollframe(do_QueryInterface(child)); + nsIScrollableFrame *scrollframe = do_QueryFrame(child); if (scrollframe && scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) { if (bounds.height < prefSize.height) { diff --git a/layout/xul/base/src/nsMenuFrame.h b/layout/xul/base/src/nsMenuFrame.h index 6e6c750fcb1..ecee80248ac 100644 --- a/layout/xul/base/src/nsMenuFrame.h +++ b/layout/xul/base/src/nsMenuFrame.h @@ -110,7 +110,7 @@ class nsMenuFrame : public nsBoxFrame, public: nsMenuFrame(nsIPresShell* aShell, nsStyleContext* aContext); - NS_DECL_ISUPPORTS + NS_DECL_QUERYFRAME // nsIBox NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState); diff --git a/layout/xul/base/src/nsMenuPopupFrame.cpp b/layout/xul/base/src/nsMenuPopupFrame.cpp index 374fcc141f3..43e29022269 100644 --- a/layout/xul/base/src/nsMenuPopupFrame.cpp +++ b/layout/xul/base/src/nsMenuPopupFrame.cpp @@ -351,7 +351,7 @@ nsMenuPopupFrame::AdjustView() // if the popup has just opened, make sure the scrolled window is at 0,0 if (mIsOpenChanged) { nsIBox* child = GetChildBox(); - nsCOMPtr scrollframe(do_QueryInterface(child)); + nsIScrollableFrame *scrollframe = do_QueryFrame(child); if (scrollframe) scrollframe->ScrollTo(nsPoint(0,0)); } @@ -1119,9 +1119,8 @@ PRBool nsMenuPopupFrame::ConsumeOutsideClicks() static nsIScrollableView* GetScrollableViewForFrame(nsIFrame* aFrame) { - nsIScrollableFrame* sf; - nsresult rv = CallQueryInterface(aFrame, &sf); - if (NS_FAILED(rv)) + nsIScrollableFrame* sf = do_QueryFrame(aFrame); + if (!sf) return nsnull; return sf->GetScrollableView(); } diff --git a/layout/xul/base/src/nsPopupSetFrame.cpp b/layout/xul/base/src/nsPopupSetFrame.cpp index 7eea4e62211..b28b12fc4e0 100644 --- a/layout/xul/base/src/nsPopupSetFrame.cpp +++ b/layout/xul/base/src/nsPopupSetFrame.cpp @@ -180,7 +180,7 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState) nsRect bounds(popupChild->GetRect()); - nsCOMPtr scrollframe = do_QueryInterface(child); + nsIScrollableFrame *scrollframe = do_QueryFrame(child); if (scrollframe && scrollframe->GetScrollbarStyles().mVertical == NS_STYLE_OVERFLOW_AUTO) { // if our pref height @@ -365,8 +365,8 @@ nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const NS_ASSERTION(kid->GetParent() == (nsIFrame*)this, "bad parent frame pointer"); // Have the child frame list - nsIFrameDebug* frameDebug; - if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(kid); + if (frameDebug) { frameDebug->List(out, aIndent + 1); } kid = kid->GetNextSibling(); @@ -392,9 +392,8 @@ nsPopupSetFrame::List(FILE* out, PRInt32 aIndent) const fputs(" <\n", out); ++aIndent; for (nsPopupFrameList* l = mPopupList; l; l = l->mNextPopup) { - nsIFrameDebug* frameDebug; - if (l->mPopupFrame && - NS_SUCCEEDED(CallQueryInterface(l->mPopupFrame, &frameDebug))) { + nsIFrameDebug* frameDebug = do_QueryFrame(l->mPopupFrame); + if (frameDebug) { frameDebug->List(out, aIndent); } } diff --git a/layout/xul/base/src/nsRootBoxFrame.cpp b/layout/xul/base/src/nsRootBoxFrame.cpp index 47c013331b0..ace9dfe35a6 100644 --- a/layout/xul/base/src/nsRootBoxFrame.cpp +++ b/layout/xul/base/src/nsRootBoxFrame.cpp @@ -69,10 +69,7 @@ nsIRootBox::GetRootBox(nsIPresShell* aShell) rootFrame = rootFrame->GetFirstChild(nsnull); } - nsIRootBox* rootBox = nsnull; - if (rootFrame) { - CallQueryInterface(rootFrame, &rootBox); - } + nsIRootBox* rootBox = do_QueryFrame(rootFrame); return rootBox; } @@ -83,7 +80,7 @@ public: nsRootBoxFrame(nsIPresShell* aShell, nsStyleContext *aContext); - NS_DECL_ISUPPORTS_INHERITED + NS_DECL_QUERYFRAME virtual nsPopupSetFrame* GetPopupSetFrame(); virtual void SetPopupSetFrame(nsPopupSetFrame* aPopupSet); @@ -333,21 +330,9 @@ nsRootBoxFrame::RemoveTooltipSupport(nsIContent* aNode) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP_(nsrefcnt) -nsRootBoxFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsRootBoxFrame::Release(void) -{ - return NS_OK; -} - -NS_INTERFACE_MAP_BEGIN(nsRootBoxFrame) - NS_INTERFACE_MAP_ENTRY(nsIRootBox) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) +NS_QUERYFRAME_HEAD(nsRootBoxFrame) + NS_QUERYFRAME_ENTRY(nsIRootBox) +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) #ifdef DEBUG NS_IMETHODIMP diff --git a/layout/xul/base/src/nsScrollBoxObject.cpp b/layout/xul/base/src/nsScrollBoxObject.cpp index fcb6972f6a2..5b740a69d21 100644 --- a/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/layout/xul/base/src/nsScrollBoxObject.cpp @@ -125,8 +125,8 @@ static nsIFrame* GetScrolledBox(nsBoxObject* aScrollBox) { nsIFrame* frame = aScrollBox->GetFrame(PR_FALSE); if (!frame) return nsnull; - nsIScrollableFrame* scrollFrame; - if (NS_FAILED(CallQueryInterface(frame, &scrollFrame))) { + nsIScrollableFrame* scrollFrame = do_QueryFrame(frame); + if (!scrollFrame) { NS_WARNING("nsIScrollBoxObject attached to something that's not a scroll frame!"); return nsnull; } @@ -435,8 +435,8 @@ nsScrollBoxObject::GetScrollableView() if (!frame) return nsnull; - nsIScrollableFrame* scrollFrame; - if (NS_FAILED(CallQueryInterface(frame, &scrollFrame))) + nsIScrollableFrame* scrollFrame = do_QueryFrame(frame); + if (!scrollFrame) return nsnull; nsIScrollableView* scrollingView = scrollFrame->GetScrollableView(); diff --git a/layout/xul/base/src/nsScrollbarButtonFrame.cpp b/layout/xul/base/src/nsScrollbarButtonFrame.cpp index 19e930dbf6d..10c0d2fab88 100644 --- a/layout/xul/base/src/nsScrollbarButtonFrame.cpp +++ b/layout/xul/base/src/nsScrollbarButtonFrame.cpp @@ -230,8 +230,7 @@ nsScrollbarButtonFrame::DoButtonAction(PRBool aSmoothScroll) else if (curpos > maxpos) curpos = maxpos; - nsIScrollbarFrame* sb; - CallQueryInterface(scrollbar, &sb); + nsIScrollbarFrame* sb = do_QueryFrame(scrollbar); if (sb) { nsIScrollbarMediator* m = sb->GetScrollbarMediator(); if (m) { diff --git a/layout/xul/base/src/nsScrollbarFrame.cpp b/layout/xul/base/src/nsScrollbarFrame.cpp index 15641fc4e00..95d7738ede7 100644 --- a/layout/xul/base/src/nsScrollbarFrame.cpp +++ b/layout/xul/base/src/nsScrollbarFrame.cpp @@ -59,13 +59,9 @@ NS_NewScrollbarFrame (nsIPresShell* aPresShell, nsStyleContext* aContext) return new (aPresShell) nsScrollbarFrame (aPresShell, aContext); } // NS_NewScrollbarFrame -// -// QueryInterface -// -NS_INTERFACE_MAP_BEGIN(nsScrollbarFrame) - NS_INTERFACE_MAP_ENTRY(nsIScrollbarFrame) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) - +NS_QUERYFRAME_HEAD(nsScrollbarFrame) + NS_QUERYFRAME_ENTRY(nsIScrollbarFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame) NS_IMETHODIMP nsScrollbarFrame::Init(nsIContent* aContent, @@ -135,8 +131,7 @@ nsScrollbarFrame::AttributeChanged(PRInt32 aNameSpaceID, if (!parent) return rv; - nsIScrollableFrame* scrollable = nsnull; - parent->QueryInterface(NS_GET_IID(nsIScrollableFrame), (void**)&scrollable); + nsIScrollableFrame* scrollable = do_QueryFrame(parent); if (!scrollable) return rv; @@ -194,15 +189,13 @@ nsScrollbarFrame::GetScrollbarMediator() // check if the frame is a scroll frame. If so, get the scrollable frame // inside it. - nsIScrollableFrame* scrollFrame; - CallQueryInterface(f, &scrollFrame); + nsIScrollableFrame* scrollFrame = do_QueryFrame(f); if (scrollFrame) { f = scrollFrame->GetScrolledFrame(); if (!f) return nsnull; } - nsIScrollbarMediator* sbm; - CallQueryInterface(f, &sbm); + nsIScrollbarMediator* sbm = do_QueryFrame(f); return sbm; } diff --git a/layout/xul/base/src/nsScrollbarFrame.h b/layout/xul/base/src/nsScrollbarFrame.h index b7c9f84b3fb..947a2cec1e0 100644 --- a/layout/xul/base/src/nsScrollbarFrame.h +++ b/layout/xul/base/src/nsScrollbarFrame.h @@ -42,7 +42,6 @@ #ifndef nsScrollbarFrame_h__ #define nsScrollbarFrame_h__ - #include "nsBoxFrame.h" #include "nsIScrollbarFrame.h" @@ -68,11 +67,9 @@ public: nsIAtom* aAttribute, PRInt32 aModType); - NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef() { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; } + NS_DECL_QUERYFRAME - NS_IMETHOD HandlePress(nsPresContext* aPresContext, + NS_IMETHOD HandlePress(nsPresContext* aPresContext, nsGUIEvent * aEvent, nsEventStatus* aEventStatus); diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 82577b10a3f..a1557d67189 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -259,8 +259,7 @@ nsSliderFrame::AttributeChanged(PRInt32 aNameSpaceID, current = max; // set the new position and notify observers - nsIScrollbarFrame* scrollbarFrame; - CallQueryInterface(scrollbarBox, &scrollbarFrame); + nsIScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox); if (scrollbarFrame) { nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator(); if (mediator) { @@ -767,9 +766,7 @@ nsSliderFrame::SetCurrentPositionInternal(nsIContent* aScrollbar, PRInt32 aNewPo { nsCOMPtr scrollbar = aScrollbar; nsIBox* scrollbarBox = GetScrollbar(); - nsIScrollbarFrame* scrollbarFrame; - CallQueryInterface(scrollbarBox, &scrollbarFrame); - + nsIScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox); if (scrollbarFrame) { // See if we have a mediator. nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator(); diff --git a/layout/xul/base/src/nsSplitterFrame.cpp b/layout/xul/base/src/nsSplitterFrame.cpp index 8e2c19a4e06..f353d581b2e 100644 --- a/layout/xul/base/src/nsSplitterFrame.cpp +++ b/layout/xul/base/src/nsSplitterFrame.cpp @@ -280,13 +280,6 @@ nsSplitterFrame::Destroy() } -// -// QueryInterface -// -NS_INTERFACE_MAP_BEGIN(nsSplitterFrame) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) - - NS_IMETHODIMP nsSplitterFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor) diff --git a/layout/xul/base/src/nsSplitterFrame.h b/layout/xul/base/src/nsSplitterFrame.h index 58cbe36f185..748253955ac 100644 --- a/layout/xul/base/src/nsSplitterFrame.h +++ b/layout/xul/base/src/nsSplitterFrame.h @@ -76,10 +76,6 @@ public: NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState); - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void) { return NS_OK; } - NS_IMETHOD_(nsrefcnt) Release(void) { return NS_OK; } - NS_IMETHOD HandlePress(nsPresContext* aPresContext, nsGUIEvent * aEvent, nsEventStatus* aEventStatus); diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 21f7a707359..87848975174 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -134,19 +134,11 @@ NS_NewTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) } // NS_NewTreeFrame -// -// QueryInterface -// - -NS_INTERFACE_MAP_BEGIN(nsTreeBodyFrame) - NS_INTERFACE_MAP_ENTRY(nsICSSPseudoComparator) - NS_INTERFACE_MAP_ENTRY(nsIScrollbarMediator) - if (aIID.Equals(NS_GET_IID(nsTreeBodyFrame))) { - *aInstancePtr = this; - return NS_OK; - } - else -NS_INTERFACE_MAP_END_INHERITING(nsLeafBoxFrame) +NS_QUERYFRAME_HEAD(nsTreeBodyFrame) + NS_QUERYFRAME_ENTRY(nsICSSPseudoComparator) + NS_QUERYFRAME_ENTRY(nsIScrollbarMediator) + NS_QUERYFRAME_ENTRY(nsTreeBodyFrame) +NS_QUERYFRAME_TAIL_INHERITING(nsLeafBoxFrame) // Constructor nsTreeBodyFrame::nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) @@ -179,18 +171,6 @@ nsTreeBodyFrame::~nsTreeBodyFrame() delete mSlots; } -NS_IMETHODIMP_(nsrefcnt) -nsTreeBodyFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsTreeBodyFrame::Release(void) -{ - return NS_OK; -} - static void GetBorderPadding(nsStyleContext* aContext, nsMargin& aMargin) { @@ -863,16 +843,14 @@ static void FindScrollParts(nsIFrame* aCurrFrame, nsTreeBodyFrame::ScrollParts* aResult) { if (!aResult->mColumnsScrollableView) { - nsIScrollableFrame* f; - CallQueryInterface(aCurrFrame, &f); + nsIScrollableFrame* f = do_QueryFrame(aCurrFrame); if (f) { aResult->mColumnsFrame = aCurrFrame; aResult->mColumnsScrollableView = f->GetScrollableView(); } } - nsIScrollbarFrame *sf = nsnull; - CallQueryInterface(aCurrFrame, &sf); + nsIScrollbarFrame *sf = do_QueryFrame(aCurrFrame); if (sf) { if (!aCurrFrame->IsHorizontal()) { if (!aResult->mVScrollbar) { @@ -909,14 +887,12 @@ nsTreeBodyFrame::ScrollParts nsTreeBodyFrame::GetScrollParts() FindScrollParts(treeFrame, &result); if (result.mHScrollbar) { result.mHScrollbar->SetScrollbarMediatorContent(GetContent()); - nsIFrame* f; - CallQueryInterface(result.mHScrollbar, &f); + nsIFrame* f = do_QueryFrame(result.mHScrollbar); result.mHScrollbarContent = f->GetContent(); } if (result.mVScrollbar) { result.mVScrollbar->SetScrollbarMediatorContent(GetContent()); - nsIFrame* f; - CallQueryInterface(result.mVScrollbar, &f); + nsIFrame* f = do_QueryFrame(result.mVScrollbar); result.mVScrollbarContent = f->GetContent(); } } @@ -4131,16 +4107,11 @@ nsTreeBodyFrame::ScrollHorzInternal(const ScrollParts& aParts, PRInt32 aPosition } NS_IMETHODIMP -nsTreeBodyFrame::ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) +nsTreeBodyFrame::ScrollbarButtonPressed(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex) { - // Determine which scrollbar we're talking about - nsIScrollbarFrame* sf = nsnull; - CallQueryInterface(aScrollbar, &sf); - NS_ASSERTION(sf, "scrollbar has no frame"); - ScrollParts parts = GetScrollParts(); - if (sf == parts.mVScrollbar) { + if (aScrollbar == parts.mVScrollbar) { if (aNewIndex > aOldIndex) ScrollToRowInternal(parts, mTopRowIndex+1); else if (aNewIndex < aOldIndex) @@ -4155,26 +4126,21 @@ nsTreeBodyFrame::ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldInd } NS_IMETHODIMP -nsTreeBodyFrame::PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) +nsTreeBodyFrame::PositionChanged(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex) { ScrollParts parts = GetScrollParts(); if (aOldIndex == aNewIndex) return NS_OK; - // Determine which scrollbar we're talking about - nsIScrollbarFrame* sf = nsnull; - CallQueryInterface(aScrollbar, &sf); - NS_ASSERTION(sf, "scrollbar has no frame"); - // Vertical Scrollbar - if (parts.mVScrollbar == sf) { + if (parts.mVScrollbar == aScrollbar) { nscoord rh = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight); nscoord newrow = aNewIndex/rh; ScrollInternal(parts, newrow); // Horizontal Scrollbar - } else if (parts.mHScrollbar == sf) { + } else if (parts.mHScrollbar == aScrollbar) { ScrollHorzInternal(parts, aNewIndex); } diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h index 895fa568017..43429cf5305 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h @@ -76,10 +76,6 @@ struct nsTreeImageCacheEntry nsCOMPtr listener; }; -#define NS_TREEBODYFRAME_IID \ -{ 0xe35eb017, 0xa679, 0x4d4d, \ - { 0x83, 0xda, 0xce, 0xd6, 0x20, 0xae, 0x9e, 0x66 } } - // The actual frame that paints the cells and rows. class NS_FINAL_CLASS nsTreeBodyFrame : public nsLeafBoxFrame @@ -91,9 +87,9 @@ public: nsTreeBodyFrame(nsIPresShell* aPresShell, nsStyleContext* aContext); ~nsTreeBodyFrame(); - NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREEBODYFRAME_IID) + NS_DECLARE_FRAME_ACCESSOR(nsTreeBodyFrame) - NS_DECL_ISUPPORTS + NS_DECL_QUERYFRAME // non-virtual signatures like nsITreeBodyFrame nsresult GetColumns(nsITreeColumns **aColumns); @@ -150,9 +146,9 @@ public: NS_IMETHOD PseudoMatches(nsIAtom* aTag, nsCSSSelector* aSelector, PRBool* aResult); // nsIScrollbarMediator - NS_IMETHOD PositionChanged(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); - NS_IMETHOD ScrollbarButtonPressed(nsISupports* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); - NS_IMETHOD VisibilityChanged(nsISupports* aScrollbar, PRBool aVisible) { Invalidate(); return NS_OK; } + NS_IMETHOD PositionChanged(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex); + NS_IMETHOD ScrollbarButtonPressed(nsIScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex); + NS_IMETHOD VisibilityChanged(PRBool aVisible) { Invalidate(); return NS_OK; } // Overridden from nsIFrame to cache our pres context. NS_IMETHOD Init(nsIContent* aContent, @@ -603,6 +599,4 @@ protected: // Data Members nsRevocableEventPtr mScrollEvent; }; // class nsTreeBodyFrame -NS_DEFINE_STATIC_IID_ACCESSOR(nsTreeBodyFrame, NS_TREEBODYFRAME_IID) - #endif diff --git a/layout/xul/base/src/tree/src/nsTreeBoxObject.cpp b/layout/xul/base/src/tree/src/nsTreeBoxObject.cpp index a1942a5008a..73f2be612a7 100644 --- a/layout/xul/base/src/tree/src/nsTreeBoxObject.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBoxObject.cpp @@ -131,8 +131,7 @@ nsTreeBoxObject::GetTreeBody() return nsnull; // Make sure that the treebodyframe has a pointer to |this|. - nsTreeBodyFrame *treeBody = nsnull; - CallQueryInterface(frame, &treeBody); + nsTreeBodyFrame *treeBody = do_QueryFrame(frame); NS_ENSURE_TRUE(treeBody && treeBody->GetTreeBoxObject() == this, nsnull); mTreeBody = treeBody; diff --git a/layout/xul/base/src/tree/src/nsTreeColFrame.cpp b/layout/xul/base/src/tree/src/nsTreeColFrame.cpp index 5a6703c5847..b302744b767 100644 --- a/layout/xul/base/src/tree/src/nsTreeColFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeColFrame.cpp @@ -65,24 +65,6 @@ NS_NewTreeColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, return new (aPresShell) nsTreeColFrame(aPresShell, aContext, aIsRoot, aLayoutManager); } // NS_NewTreeColFrame -NS_IMETHODIMP_(nsrefcnt) -nsTreeColFrame::AddRef(void) -{ - return NS_OK; -} - -NS_IMETHODIMP_(nsrefcnt) -nsTreeColFrame::Release(void) -{ - return NS_OK; -} - -// -// QueryInterface -// -NS_INTERFACE_MAP_BEGIN(nsTreeColFrame) -NS_INTERFACE_MAP_END_INHERITING(nsBoxFrame) - // Destructor nsTreeColFrame::~nsTreeColFrame() { diff --git a/layout/xul/base/src/tree/src/nsTreeColFrame.h b/layout/xul/base/src/tree/src/nsTreeColFrame.h index 26bf0260417..aa6d5e03248 100644 --- a/layout/xul/base/src/tree/src/nsTreeColFrame.h +++ b/layout/xul/base/src/tree/src/nsTreeColFrame.h @@ -48,8 +48,6 @@ nsIFrame* NS_NewTreeColFrame(nsIPresShell* aPresShell, class nsTreeColFrame : public nsBoxFrame { public: - NS_DECL_ISUPPORTS - nsTreeColFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, PRBool aIsRoot = nsnull, diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index b837bb9742c..8ef946f2868 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -301,9 +301,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, aWidgetType == NS_THEME_MENUSEPARATOR || aWidgetType == NS_THEME_MENUARROW) { PRBool isTopLevel = PR_FALSE; - nsIMenuFrame *menuFrame; - CallQueryInterface(aFrame, &menuFrame); - + nsIMenuFrame *menuFrame = do_QueryFrame(aFrame); if (menuFrame) { isTopLevel = menuFrame->IsOnMenuBar(); } diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 31be94b093a..cff62c19e12 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -130,9 +130,7 @@ static void GetNativeRect(const nsRect& aSrc, RECT& aDst) static PRBool IsTopLevelMenu(nsIFrame *aFrame) { PRBool isTopLevel(PR_FALSE); - nsIMenuFrame *menuFrame(nsnull); - CallQueryInterface(aFrame, &menuFrame); - + nsIMenuFrame *menuFrame = do_QueryFrame(aFrame); if (menuFrame) { isTopLevel = menuFrame->IsOnMenuBar(); } @@ -817,8 +815,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, if (nsUXThemeData::sIsVistaOrLater) { if (isHTML) { - nsIComboboxControlFrame* ccf = nsnull; - CallQueryInterface(aFrame, &ccf); + nsIComboboxControlFrame* ccf = do_QueryFrame(aFrame); if (ccf && ccf->IsDroppedDown()) { /* Hover is propagated, but we need to know whether we're * hovering just the combobox frame, not the dropdown frame. @@ -856,8 +853,7 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, PRUint8 aWidgetType, PRBool isTopLevel = PR_FALSE; PRBool isOpen = PR_FALSE; PRBool isHover = PR_FALSE; - nsIMenuFrame *menuFrame; - CallQueryInterface(aFrame, &menuFrame); + nsIMenuFrame *menuFrame = do_QueryFrame(aFrame); isTopLevel = IsTopLevelMenu(aFrame); @@ -2042,8 +2038,7 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, PRUint8 PRBool isTopLevel = PR_FALSE; PRBool isOpen = PR_FALSE; PRBool isContainer = PR_FALSE; - nsIMenuFrame *menuFrame = nsnull; - CallQueryInterface(aFrame, &menuFrame); + nsIMenuFrame *menuFrame = do_QueryFrame(aFrame); // We indicate top-level-ness using aPart. 0 is a normal menu item, // 1 is a top-level menu item. The state of the item is composed of