From 480f8e01d32f9b21c1b27927c4f061be46c949d9 Mon Sep 17 00:00:00 2001 From: "neil%parkwaycc.co.uk" Date: Fri, 2 Dec 2005 12:02:44 +0000 Subject: [PATCH] Bug 317937 Get rid of some unnecessary CIDs and change some possibly unsafe nsCOMPtr usage into the equivalently unsafe static casts r=darin sr=jst --- accessible/public/nsIAccessibilityService.idl | 8 ++--- .../src/base/nsAccessibilityService.cpp | 30 ++++--------------- content/base/src/nsDocumentEncoder.cpp | 4 --- docshell/base/nsDocShell.cpp | 6 ++-- layout/base/nsPresContext.cpp | 2 +- layout/base/nsPresContext.h | 11 +------ layout/forms/nsComboboxControlFrame.cpp | 3 +- layout/forms/nsListControlFrame.cpp | 4 +-- layout/style/nsCSSRules.cpp | 7 +++-- .../converters/mozTXTToHTMLConv.cpp | 2 +- .../streamconv/converters/mozTXTToHTMLConv.h | 3 -- 11 files changed, 24 insertions(+), 56 deletions(-) diff --git a/accessible/public/nsIAccessibilityService.idl b/accessible/public/nsIAccessibilityService.idl index 264a9eaebef..02cb45f2c46 100644 --- a/accessible/public/nsIAccessibilityService.idl +++ b/accessible/public/nsIAccessibilityService.idl @@ -45,7 +45,7 @@ interface nsIFrame; interface nsObjectFrame; interface nsIContent; -[scriptable, uuid(0e80f152-d676-4fba-8862-9dc4eb761442)] +[scriptable, uuid(09a39069-a138-40dd-91dd-79ce45742b52)] interface nsIAccessibilityService : nsIAccessibleRetrieval { nsIAccessible createOuterDocAccessible(in nsIDOMNode aNode); @@ -61,17 +61,17 @@ interface nsIAccessibilityService : nsIAccessibleRetrieval nsIAccessible createHTMLLIAccessible(in nsISupports aFrame, in nsISupports aBulletFrame, in AString aBulletText); nsIAccessible createHTMLCheckboxAccessible(in nsISupports aFrame); nsIAccessible createHTMLCheckboxAccessibleXBL(in nsIDOMNode aNode); - nsIAccessible createHTMLComboboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell); + 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 createHTMLListboxAccessible(in nsIDOMNode aNode, in nsISupports aPresShell); + nsIAccessible createHTMLListboxAccessible(in nsIDOMNode aNode, in nsIWeakReference aPresShell); nsIAccessible createHTMLObjectFrameAccessible(in nsObjectFrame aFrame); nsIAccessible createHTMLRadioButtonAccessible(in nsISupports aFrame); nsIAccessible createHTMLRadioButtonAccessibleXBL(in nsIDOMNode aNode); - nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsISupports aPresShell); + nsIAccessible createHTMLSelectOptionAccessible(in nsIDOMNode aNode, in nsIAccessible aAccParent, in nsIWeakReference aPresShell); nsIAccessible createHTMLTableAccessible(in nsISupports aFrame); nsIAccessible createHTMLTableCellAccessible(in nsISupports aFrame); nsIAccessible createHTMLTableCaptionAccessible(in nsIDOMNode aDOMNode); diff --git a/accessible/src/base/nsAccessibilityService.cpp b/accessible/src/base/nsAccessibilityService.cpp index cd4da4ad3a3..a1f06dfffee 100644 --- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -598,15 +598,9 @@ nsAccessibilityService::CreateHTMLCheckboxAccessibleXBL(nsIDOMNode *aNode, nsIAc } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresShell, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLComboboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aPresShell, nsIAccessible **_retval) { - nsCOMPtr presShell(do_QueryInterface(aPresShell)); - NS_ASSERTION(presShell,"Error non prescontext passed to accessible factory!!!"); - - nsCOMPtr weakShell = - do_GetWeakReference(presShell); - - *_retval = new nsHTMLComboboxAccessible(aDOMNode, weakShell); + *_retval = new nsHTMLComboboxAccessible(aDOMNode, aPresShell); if (! *_retval) return NS_ERROR_OUT_OF_MEMORY; @@ -683,15 +677,9 @@ nsAccessibilityService::CreateHTMLGroupboxAccessible(nsISupports *aFrame, nsIAcc } NS_IMETHODIMP -nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsISupports* aPresContext, nsIAccessible **_retval) +nsAccessibilityService::CreateHTMLListboxAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aPresShell, nsIAccessible **_retval) { - nsCOMPtr presContext(do_QueryInterface(aPresContext)); - NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!"); - - nsCOMPtr weakShell = - do_GetWeakReference(presContext->PresShell()); - - *_retval = new nsHTMLSelectListAccessible(aDOMNode, weakShell); + *_retval = new nsHTMLSelectListAccessible(aDOMNode, aPresShell); if (! *_retval) return NS_ERROR_OUT_OF_MEMORY; @@ -797,16 +785,10 @@ nsAccessibilityService::CreateHTMLRadioButtonAccessibleXBL(nsIDOMNode *aNode, ns NS_IMETHODIMP nsAccessibilityService::CreateHTMLSelectOptionAccessible(nsIDOMNode* aDOMNode, nsIAccessible *aParent, - nsISupports* aPresContext, + nsIWeakReference* aPresShell, nsIAccessible **_retval) { - nsCOMPtr presContext(do_QueryInterface(aPresContext)); - NS_ASSERTION(presContext,"Error non prescontext passed to accessible factory!!!"); - - nsCOMPtr weakShell = - do_GetWeakReference(presContext->PresShell()); - - *_retval = new nsHTMLSelectOptionAccessible(aDOMNode, weakShell); + *_retval = new nsHTMLSelectOptionAccessible(aDOMNode, aPresShell); if (! *_retval) return NS_ERROR_OUT_OF_MEMORY; diff --git a/content/base/src/nsDocumentEncoder.cpp b/content/base/src/nsDocumentEncoder.cpp index e29d2e1376d..2cd29615042 100644 --- a/content/base/src/nsDocumentEncoder.cpp +++ b/content/base/src/nsDocumentEncoder.cpp @@ -84,8 +84,6 @@ enum nsRangeIterationDirection { class nsDocumentEncoder : public nsIDocumentEncoder { public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_ENCODER_IID) - nsDocumentEncoder(); virtual ~nsDocumentEncoder(); @@ -160,8 +158,6 @@ protected: PRPackedBool mIsCopying; // Set to PR_TRUE only while copying }; -NS_DEFINE_STATIC_IID_ACCESSOR(nsDocumentEncoder, NS_IDOCUMENT_ENCODER_IID) - NS_IMPL_ADDREF(nsDocumentEncoder) NS_IMPL_RELEASE(nsDocumentEncoder) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 0a0a6807cc5..17933d7118d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4497,7 +4497,7 @@ nsDocShell::SuspendRefreshURIs() timer->Cancel(); - nsCOMPtr rt = do_QueryInterface(callback); + nsCOMPtr rt = do_QueryInterface(callback); NS_ASSERTION(rt, "RefreshURIList timer callbacks should only be RefreshTimer objects"); mRefreshURIList->ReplaceElementAt(rt, i); @@ -4544,13 +4544,13 @@ nsDocShell::RefreshURIFromQueue() while (n) { nsCOMPtr element; mRefreshURIList->GetElementAt(--n, getter_AddRefs(element)); - nsCOMPtr refreshInfo(do_QueryInterface(element)); + nsCOMPtr refreshInfo(do_QueryInterface(element)); if (refreshInfo) { // This is the nsRefreshTimer object, waiting to be // setup in a timer object and fired. // Create the timer and trigger it. - PRUint32 delay = refreshInfo->GetDelay(); + PRUint32 delay = NS_STATIC_CAST(nsRefreshTimer*, NS_STATIC_CAST(nsITimerCallback*, refreshInfo))->GetDelay(); nsCOMPtr timer = do_CreateInstance("@mozilla.org/timer;1"); if (timer) { // Replace the nsRefreshTimer element in the queue with diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index f44702b691c..0f03edcbe0c 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -267,7 +267,7 @@ nsPresContext::~nsPresContext() NS_IF_RELEASE(mLangGroup); } -NS_IMPL_ISUPPORTS2(nsPresContext, nsPresContext, nsIObserver) +NS_IMPL_ISUPPORTS1(nsPresContext, nsIObserver) #define MAKE_FONT_PREF_KEY(_pref, _s0, _s1) \ _pref.Assign(_s0); \ diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 41c83b7d607..ef91b34f23c 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -118,16 +118,7 @@ const PRUint8 kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fi // An interface for presentation contexts. Presentation contexts are // objects that provide an outer context for a presentation shell. -// hack to make egcs / gcc 2.95.2 happy -class nsPresContext_base : public nsIObserver -{ -public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID) -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsPresContext_base, NS_IPRESCONTEXT_IID) - -class nsPresContext : public nsPresContext_base { +class nsPresContext : public nsIObserver { public: NS_DECL_ISUPPORTS NS_DECL_NSIOBSERVER diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index b172da01814..9bf79be8f5b 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -397,7 +397,8 @@ NS_IMETHODIMP nsComboboxControlFrame::GetAccessible(nsIAccessible** aAccessible) if (accService) { nsCOMPtr node = do_QueryInterface(mContent); - return accService->CreateHTMLComboboxAccessible(node, GetPresContext()->PresShell(), aAccessible); + nsCOMPtr weakShell(do_GetWeakReference(GetPresContext()->PresShell())); + return accService->CreateHTMLComboboxAccessible(node, weakShell, aAccessible); } return NS_ERROR_FAILURE; diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index b09343e7326..44f4fb540f8 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -561,8 +561,8 @@ NS_IMETHODIMP nsListControlFrame::GetAccessible(nsIAccessible** aAccessible) if (accService) { nsCOMPtr node = do_QueryInterface(mContent); - return accService->CreateHTMLListboxAccessible(node, GetPresContext(), - aAccessible); + nsCOMPtr weakShell(do_GetWeakReference(GetPresContext()->PresShell())); + return accService->CreateHTMLListboxAccessible(node, weakShell, aAccessible); } return NS_ERROR_FAILURE; diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 3138ece85f1..1d98ad2d306 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -374,7 +374,7 @@ public: protected: nsString mURLSpec; - nsCOMPtr mMedia; + nsRefPtr mMedia; nsCOMPtr mChildSheet; }; @@ -513,7 +513,8 @@ CSSImportRuleImpl::SetSheet(nsICSSStyleSheet* aSheet) nsCOMPtr mediaList; rv = sheet->GetMedia(getter_AddRefs(mediaList)); NS_ENSURE_SUCCESS(rv, rv); - mMedia = do_QueryInterface(mediaList); + mMedia = NS_STATIC_CAST(nsMediaList*, + NS_STATIC_CAST(nsIDOMMediaList*, mediaList.get())); return NS_OK; } @@ -604,7 +605,7 @@ CSSImportRuleImpl::GetMedia(nsIDOMMediaList * *aMedia) return NS_OK; } - return CallQueryInterface(mMedia, aMedia); + return CallQueryInterface(mMedia.get(), aMedia); } NS_IMETHODIMP diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index b7193e83d43..a6da4227f53 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -1017,7 +1017,7 @@ mozTXTToHTMLConv::~mozTXTToHTMLConv() MOZ_TIMER_PRINT(mGlyphHitTimer); } -NS_IMPL_ISUPPORTS1(mozTXTToHTMLConv, mozTXTToHTMLConv) +NS_IMPL_ISUPPORTS0(mozTXTToHTMLConv) PRInt32 mozTXTToHTMLConv::CiteLevelTXT(const PRUnichar *line, diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.h b/netwerk/streamconv/converters/mozTXTToHTMLConv.h index 46771745bf7..946644945be 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.h +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.h @@ -59,9 +59,6 @@ public: virtual ~mozTXTToHTMLConv(); NS_DECL_ISUPPORTS - // XXX Is this really needed? This isn't an interface. - NS_DECLARE_STATIC_IID_ACCESSOR(MOZITXTTOHTMLCONV_IID) - NS_DECL_MOZITXTTOHTMLCONV NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSISTREAMLISTENER