From 54940238cd4c2438b9c83fb458590e23c627f198 Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 30 Aug 2011 22:45:31 +0100 Subject: [PATCH] Bug 682744 - Sprinkle some do_QueryObject fairy dust around the tree; r=khuey --- accessible/src/xul/nsXULTreeGridAccessible.cpp | 3 +-- content/base/src/nsDocument.cpp | 3 +-- content/base/src/nsFrameMessageManager.cpp | 3 +-- content/base/src/nsGenericElement.cpp | 3 +-- content/canvas/src/nsCanvasRenderingContext2D.cpp | 6 ++---- content/canvas/src/nsCanvasRenderingContext2DAzure.cpp | 6 ++---- content/html/content/src/nsHTMLFormElement.cpp | 9 +++------ content/html/content/src/nsHTMLMediaElement.cpp | 8 +++----- content/svg/content/src/nsSVGElement.cpp | 9 +++------ content/xul/content/src/nsXULElement.cpp | 7 +++---- docshell/base/nsDSURIContentListener.cpp | 2 +- dom/base/nsGlobalWindow.cpp | 6 ++---- dom/indexedDB/AsyncConnectionHelper.cpp | 3 +-- editor/libeditor/base/nsEditorEventListener.cpp | 2 +- editor/libeditor/html/nsHTMLEditorEventListener.cpp | 6 ++---- netwerk/protocol/http/HttpChannelParent.cpp | 3 +-- xpfe/appshell/src/nsXULWindow.cpp | 2 +- 17 files changed, 29 insertions(+), 52 deletions(-) diff --git a/accessible/src/xul/nsXULTreeGridAccessible.cpp b/accessible/src/xul/nsXULTreeGridAccessible.cpp index c84af3d4957..6d5d7ef1e23 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -1170,8 +1170,7 @@ nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt if (!grandParent) return NS_OK; - nsCOMPtr tableAccessible = - do_QueryInterface(static_cast(grandParent)); + nsCOMPtr tableAccessible = do_QueryObject(grandParent); // XXX - temp fix for crash bug 516047 if (!tableAccessible) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 392670328b4..7a0c6a01265 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -2739,8 +2739,7 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement) } // No focused element anywhere in this document. Try to get the BODY. - nsCOMPtr htmlDoc = - do_QueryInterface(static_cast(this)); + nsCOMPtr htmlDoc = do_QueryObject(this); if (htmlDoc) { nsCOMPtr bodyElement; htmlDoc->GetBody(getter_AddRefs(bodyElement)); diff --git a/content/base/src/nsFrameMessageManager.cpp b/content/base/src/nsFrameMessageManager.cpp index 9c0e9b57d29..480dc8c43b4 100644 --- a/content/base/src/nsFrameMessageManager.cpp +++ b/content/base/src/nsFrameMessageManager.cpp @@ -457,8 +457,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget, // messageManager is wrapped in TabChildGlobal. nsCOMPtr defaultThisValue; if (mChrome) { - defaultThisValue = - do_QueryInterface(static_cast(this)); + defaultThisValue = do_QueryObject(this); } else { defaultThisValue = aTarget; } diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index 3453d82c109..5a740643888 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -4874,8 +4874,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, NS_ENSURE_SUCCESS(rv, rv); if (hasMutationListeners) { - nsCOMPtr node = - do_QueryInterface(static_cast(this)); + nsCOMPtr node = do_QueryObject(this); nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED); mutation.mRelatedNode = attrNode; diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index c764f27bb18..fc4067b9068 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -597,8 +597,7 @@ protected: * Gets the pres shell from either the canvas element or the doc shell */ nsIPresShell *GetPresShell() { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); if (content) { nsIDocument* ownerDoc = content->GetOwnerDoc(); return ownerDoc ? ownerDoc->GetShell() : nsnull; @@ -1076,8 +1075,7 @@ nsCanvasRenderingContext2D::SetDimensions(PRInt32 width, PRInt32 height) gfxASurface::gfxImageFormat format = GetImageFormat(); if (!PR_GetEnv("MOZ_CANVAS_IMAGE_SURFACE")) { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); nsIDocument* ownerDoc = nsnull; if (content) ownerDoc = content->GetOwnerDoc(); diff --git a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp index a4b0ee49bdf..5fc2a303ac1 100644 --- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp @@ -605,8 +605,7 @@ protected: * Gets the pres shell from either the canvas element or the doc shell */ nsIPresShell *GetPresShell() { - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); if (content) { nsIDocument* ownerDoc = content->GetOwnerDoc(); return ownerDoc ? ownerDoc->GetShell() : nsnull; @@ -1235,8 +1234,7 @@ nsCanvasRenderingContext2DAzure::SetDimensions(PRInt32 width, PRInt32 height) if (size.width <= 0xFFFF && size.height <= 0xFFFF && size.width >= 0 && size.height >= 0) { SurfaceFormat format = GetSurfaceFormat(); - nsCOMPtr content = - do_QueryInterface(static_cast(mCanvasElement)); + nsCOMPtr content = do_QueryObject(mCanvasElement); nsIDocument* ownerDoc = nsnull; if (content) { ownerDoc = content->GetOwnerDoc(); diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index d976dca5758..9fbc66601a0 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -1214,8 +1214,7 @@ nsHTMLFormElement::AddElement(nsGenericHTMLFormElement* aChild, // If the element is subject to constraint validaton and is invalid, we need // to update our internal counter. if (aUpdateValidity) { - nsCOMPtr cvElmt = - do_QueryInterface(static_cast(aChild)); + nsCOMPtr cvElmt = do_QueryObject(aChild); if (cvElmt && cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) { UpdateValidity(PR_FALSE); @@ -1301,8 +1300,7 @@ nsHTMLFormElement::RemoveElement(nsGenericHTMLFormElement* aChild, // If the element was subject to constraint validaton and is invalid, we need // to update our internal counter. if (aUpdateValidity) { - nsCOMPtr cvElmt = - do_QueryInterface(static_cast(aChild)); + nsCOMPtr cvElmt = do_QueryObject(aChild); if (cvElmt && cvElmt->IsCandidateForConstraintValidation() && !cvElmt->IsValid()) { UpdateValidity(PR_TRUE); @@ -2350,8 +2348,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild, list->AppendElement(newFirst ? content : aChild); - nsCOMPtr listSupports = - do_QueryInterface(static_cast(list)); + nsCOMPtr listSupports = do_QueryObject(list); // Replace the element with the list. NS_ENSURE_TRUE(mNameLookupTable.Put(aName, listSupports), diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 5e4ab31b1c5..2e8e4316c7d 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -2255,8 +2255,7 @@ ImageContainer* nsHTMLMediaElement::GetImageContainer() return nsnull; // Only video frames need an image container. - nsCOMPtr video = - do_QueryInterface(static_cast(this)); + nsCOMPtr video = do_QueryObject(this); if (!video) return nsnull; @@ -2283,7 +2282,7 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer, nsAutoArrayPtr frameBuffer(aFrameBuffer); nsCOMPtr domDoc = do_QueryInterface(GetOwnerDoc()); - nsCOMPtr target(do_QueryInterface(static_cast(this))); + nsCOMPtr target(do_QueryObject(this)); NS_ENSURE_TRUE(domDoc && target, NS_ERROR_INVALID_ARG); nsCOMPtr event; @@ -2496,8 +2495,7 @@ void nsHTMLMediaElement::NotifyAddedSource() nsIContent* nsHTMLMediaElement::GetNextSource() { nsresult rv = NS_OK; - nsCOMPtr thisDomNode = - do_QueryInterface(static_cast(this)); + nsCOMPtr thisDomNode = do_QueryObject(this); mSourceLoadCandidate = nsnull; diff --git a/content/svg/content/src/nsSVGElement.cpp b/content/svg/content/src/nsSVGElement.cpp index 9cde1644f5e..eb4ac66131e 100644 --- a/content/svg/content/src/nsSVGElement.cpp +++ b/content/svg/content/src/nsSVGElement.cpp @@ -2343,16 +2343,14 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) // Transforms: nsCOMPtr transformList; if (aName == nsGkAtoms::transform) { - nsCOMPtr transformable( - do_QueryInterface(static_cast(this))); + nsCOMPtr transformable(do_QueryObject(this)); if (!transformable) return nsnull; nsresult rv = transformable->GetTransform(getter_AddRefs(transformList)); NS_ENSURE_SUCCESS(rv, nsnull); } if (aName == nsGkAtoms::gradientTransform) { - nsCOMPtr gradientElement( - do_QueryInterface(static_cast(this))); + nsCOMPtr gradientElement(do_QueryObject(this)); if (!gradientElement) return nsnull; @@ -2360,8 +2358,7 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName) NS_ENSURE_SUCCESS(rv, nsnull); } if (aName == nsGkAtoms::patternTransform) { - nsCOMPtr patternElement( - do_QueryInterface(static_cast(this))); + nsCOMPtr patternElement(do_QueryObject(this)); if (!patternElement) return nsnull; diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 4789ab9f066..5dce59212d5 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -580,8 +580,7 @@ nsXULElement::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse) return PR_FALSE; #endif - nsCOMPtr xulControl = - do_QueryInterface(static_cast(this)); + nsCOMPtr xulControl = do_QueryObject(this); if (xulControl) { // a disabled element cannot be focused and is not part of the tab order PRBool disabled; @@ -958,7 +957,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) // and cells going away. // First, retrieve the tree. // Check first whether this element IS the tree - controlElement = do_QueryInterface(static_cast(this)); + controlElement = do_QueryObject(this); // If it's not, look at our parent if (!controlElement) @@ -2057,7 +2056,7 @@ NS_IMETHODIMP nsXULElement::Focus() { nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - nsCOMPtr elem = do_QueryInterface(static_cast(this)); + nsCOMPtr elem = do_QueryObject(this); return fm ? fm->SetFocus(this, 0) : NS_OK; } diff --git a/docshell/base/nsDSURIContentListener.cpp b/docshell/base/nsDSURIContentListener.cpp index 49867123e17..e3f91b33ac3 100644 --- a/docshell/base/nsDSURIContentListener.cpp +++ b/docshell/base/nsDSURIContentListener.cpp @@ -379,7 +379,7 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest* request) // cancel the load and display about:blank httpChannel->Cancel(NS_BINDING_ABORTED); - nsCOMPtr webNav(do_QueryInterface(static_cast(mDocShell))); + nsCOMPtr webNav(do_QueryObject(mDocShell)); if (webNav) { webNav->LoadURI(NS_LITERAL_STRING("about:blank").get(), 0, nsnull, nsnull, nsnull); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index ff2efe0aa2d..2ff53998c8d 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1101,8 +1101,7 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog) { if (IsOuterWindow() && !aIgnoreModalDialog) { nsGlobalWindow* inner = GetCurrentInnerWindowInternal(); - nsCOMPtr - dlg(do_QueryInterface(static_cast(inner))); + nsCOMPtr dlg(do_QueryObject(inner)); if (dlg) { // The window we're trying to clean up is the outer window of a // modal dialog. Defer cleanup until the window closes, and let @@ -9779,8 +9778,7 @@ nsGlobalWindow::BuildURIfromBase(const char *aURL, nsIURI **aBuiltURI, if (!scx || !mDocument) return NS_ERROR_FAILURE; - nsCOMPtr chrome_win = - do_QueryInterface(static_cast(this)); + nsCOMPtr chrome_win = do_QueryObject(this); if (nsContentUtils::IsCallerChrome() && !chrome_win) { // If open() is called from chrome on a non-chrome window, we'll diff --git a/dom/indexedDB/AsyncConnectionHelper.cpp b/dom/indexedDB/AsyncConnectionHelper.cpp index 8dcd7eba1d8..d1f94fe9ed6 100644 --- a/dom/indexedDB/AsyncConnectionHelper.cpp +++ b/dom/indexedDB/AsyncConnectionHelper.cpp @@ -290,8 +290,7 @@ AsyncConnectionHelper::Run() #ifdef DEBUG if (NS_SUCCEEDED(rv)) { nsCOMPtr handlerSupports(do_QueryInterface(handler)); - nsCOMPtr thisSupports = - do_QueryInterface(static_cast(this)); + nsCOMPtr thisSupports = do_QueryObject(this); NS_ASSERTION(thisSupports == handlerSupports, "Mismatch!"); } #endif diff --git a/editor/libeditor/base/nsEditorEventListener.cpp b/editor/libeditor/base/nsEditorEventListener.cpp index 09d9453c490..a9d0718c918 100644 --- a/editor/libeditor/base/nsEditorEventListener.cpp +++ b/editor/libeditor/base/nsEditorEventListener.cpp @@ -408,7 +408,7 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent) nsCOMPtr mailEditor; if (ctrlKey) - mailEditor = do_QueryInterface(static_cast(mEditor)); + mailEditor = do_QueryObject(mEditor); PRInt32 clipboard; diff --git a/editor/libeditor/html/nsHTMLEditorEventListener.cpp b/editor/libeditor/html/nsHTMLEditorEventListener.cpp index 0df32c2b6a6..9632dda7514 100644 --- a/editor/libeditor/html/nsHTMLEditorEventListener.cpp +++ b/editor/libeditor/html/nsHTMLEditorEventListener.cpp @@ -67,10 +67,8 @@ nsresult nsHTMLEditorEventListener::Connect(nsEditor* aEditor) { - nsCOMPtr htmlEditor = - do_QueryInterface(static_cast(aEditor)); - nsCOMPtr htmlInlineTableEditor = - do_QueryInterface(static_cast(aEditor)); + nsCOMPtr htmlEditor = do_QueryObject(aEditor); + nsCOMPtr htmlInlineTableEditor = do_QueryObject(aEditor); NS_PRECONDITION(htmlEditor && htmlInlineTableEditor, "Set nsHTMLEditor or its sub class"); return nsEditorEventListener::Connect(aEditor); diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 5291d958d11..73c40275fc7 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -73,8 +73,7 @@ HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding) CallGetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &handler); NS_ASSERTION(handler, "no http handler"); - mTabParent = do_QueryInterface(static_cast( - static_cast(iframeEmbedding))); + mTabParent = do_QueryObject(static_cast(iframeEmbedding)); } HttpChannelParent::~HttpChannelParent() diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 8c2b8fefbc2..0e09a535f2e 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -1900,7 +1900,7 @@ PRBool nsXULWindow::ConstrainToZLevel(PRBool aImmediate, *aPlacement = nsWindowZRelative; if (aImmediate) { - nsCOMPtr ourBase = do_QueryInterface(static_cast(this)); + nsCOMPtr ourBase = do_QueryObject(this); if (ourBase) { nsCOMPtr ourWidget; ourBase->GetMainWidget(getter_AddRefs(ourWidget));