Bug 682744 - Sprinkle some do_QueryObject fairy dust around the tree; r=khuey

This commit is contained in:
Marco Castelluccio 2011-08-30 22:45:31 +01:00
Родитель 5f875ccc04
Коммит 54940238cd
17 изменённых файлов: 29 добавлений и 52 удалений

Просмотреть файл

@ -1170,8 +1170,7 @@ nsXULTreeGridCellAccessible::GetAttributesInternal(nsIPersistentProperties *aAtt
if (!grandParent)
return NS_OK;
nsCOMPtr<nsIAccessibleTable> tableAccessible =
do_QueryInterface(static_cast<nsIAccessible*>(grandParent));
nsCOMPtr<nsIAccessibleTable> tableAccessible = do_QueryObject(grandParent);
// XXX - temp fix for crash bug 516047
if (!tableAccessible)

Просмотреть файл

@ -2739,8 +2739,7 @@ nsDocument::GetActiveElement(nsIDOMElement **aElement)
}
// No focused element anywhere in this document. Try to get the BODY.
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc =
do_QueryInterface(static_cast<nsIDocument*>(this));
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryObject(this);
if (htmlDoc) {
nsCOMPtr<nsIDOMHTMLElement> bodyElement;
htmlDoc->GetBody(getter_AddRefs(bodyElement));

Просмотреть файл

@ -457,8 +457,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
// messageManager is wrapped in TabChildGlobal.
nsCOMPtr<nsISupports> defaultThisValue;
if (mChrome) {
defaultThisValue =
do_QueryInterface(static_cast<nsIContentFrameMessageManager*>(this));
defaultThisValue = do_QueryObject(this);
} else {
defaultThisValue = aTarget;
}

Просмотреть файл

@ -4874,8 +4874,7 @@ nsGenericElement::UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
NS_ENSURE_SUCCESS(rv, rv);
if (hasMutationListeners) {
nsCOMPtr<nsIDOMEventTarget> node =
do_QueryInterface(static_cast<nsIContent *>(this));
nsCOMPtr<nsIDOMEventTarget> node = do_QueryObject(this);
nsMutationEvent mutation(PR_TRUE, NS_MUTATION_ATTRMODIFIED);
mutation.mRelatedNode = attrNode;

Просмотреть файл

@ -597,8 +597,7 @@ protected:
* Gets the pres shell from either the canvas element or the doc shell
*/
nsIPresShell *GetPresShell() {
nsCOMPtr<nsIContent> content =
do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement));
nsCOMPtr<nsIContent> 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<nsIContent> content =
do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement));
nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement);
nsIDocument* ownerDoc = nsnull;
if (content)
ownerDoc = content->GetOwnerDoc();

Просмотреть файл

@ -605,8 +605,7 @@ protected:
* Gets the pres shell from either the canvas element or the doc shell
*/
nsIPresShell *GetPresShell() {
nsCOMPtr<nsIContent> content =
do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement));
nsCOMPtr<nsIContent> 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<nsIContent> content =
do_QueryInterface(static_cast<nsIDOMHTMLCanvasElement*>(mCanvasElement));
nsCOMPtr<nsIContent> content = do_QueryObject(mCanvasElement);
nsIDocument* ownerDoc = nsnull;
if (content) {
ownerDoc = content->GetOwnerDoc();

Просмотреть файл

@ -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<nsIConstraintValidation> cvElmt =
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
nsCOMPtr<nsIConstraintValidation> 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<nsIConstraintValidation> cvElmt =
do_QueryInterface(static_cast<nsGenericHTMLElement*>(aChild));
nsCOMPtr<nsIConstraintValidation> 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<nsISupports> listSupports =
do_QueryInterface(static_cast<nsIDOMNodeList*>(list));
nsCOMPtr<nsISupports> listSupports = do_QueryObject(list);
// Replace the element with the list.
NS_ENSURE_TRUE(mNameLookupTable.Put(aName, listSupports),

Просмотреть файл

@ -2255,8 +2255,7 @@ ImageContainer* nsHTMLMediaElement::GetImageContainer()
return nsnull;
// Only video frames need an image container.
nsCOMPtr<nsIDOMHTMLVideoElement> video =
do_QueryInterface(static_cast<nsIContent*>(this));
nsCOMPtr<nsIDOMHTMLVideoElement> video = do_QueryObject(this);
if (!video)
return nsnull;
@ -2283,7 +2282,7 @@ nsresult nsHTMLMediaElement::DispatchAudioAvailableEvent(float* aFrameBuffer,
nsAutoArrayPtr<float> frameBuffer(aFrameBuffer);
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(GetOwnerDoc());
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(static_cast<nsIContent*>(this)));
nsCOMPtr<nsIDOMEventTarget> target(do_QueryObject(this));
NS_ENSURE_TRUE(domDoc && target, NS_ERROR_INVALID_ARG);
nsCOMPtr<nsIDOMEvent> event;
@ -2496,8 +2495,7 @@ void nsHTMLMediaElement::NotifyAddedSource()
nsIContent* nsHTMLMediaElement::GetNextSource()
{
nsresult rv = NS_OK;
nsCOMPtr<nsIDOMNode> thisDomNode =
do_QueryInterface(static_cast<nsGenericElement*>(this));
nsCOMPtr<nsIDOMNode> thisDomNode = do_QueryObject(this);
mSourceLoadCandidate = nsnull;

Просмотреть файл

@ -2343,16 +2343,14 @@ nsSVGElement::GetAnimatedAttr(PRInt32 aNamespaceID, nsIAtom* aName)
// Transforms:
nsCOMPtr<nsIDOMSVGAnimatedTransformList> transformList;
if (aName == nsGkAtoms::transform) {
nsCOMPtr<nsIDOMSVGTransformable> transformable(
do_QueryInterface(static_cast<nsIContent*>(this)));
nsCOMPtr<nsIDOMSVGTransformable> 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<nsIDOMSVGGradientElement> gradientElement(
do_QueryInterface(static_cast<nsIContent*>(this)));
nsCOMPtr<nsIDOMSVGGradientElement> 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<nsIDOMSVGPatternElement> patternElement(
do_QueryInterface(static_cast<nsIContent*>(this)));
nsCOMPtr<nsIDOMSVGPatternElement> patternElement(do_QueryObject(this));
if (!patternElement)
return nsnull;

Просмотреть файл

@ -580,8 +580,7 @@ nsXULElement::IsFocusable(PRInt32 *aTabIndex, PRBool aWithMouse)
return PR_FALSE;
#endif
nsCOMPtr<nsIDOMXULControlElement> xulControl =
do_QueryInterface(static_cast<nsIContent*>(this));
nsCOMPtr<nsIDOMXULControlElement> 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<nsIContent*>(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<nsIDOMElement> elem = do_QueryInterface(static_cast<nsIContent*>(this));
nsCOMPtr<nsIDOMElement> elem = do_QueryObject(this);
return fm ? fm->SetFocus(this, 0) : NS_OK;
}

Просмотреть файл

@ -379,7 +379,7 @@ bool nsDSURIContentListener::CheckFrameOptions(nsIRequest* request)
// cancel the load and display about:blank
httpChannel->Cancel(NS_BINDING_ABORTED);
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(static_cast<nsIDocShell*>(mDocShell)));
nsCOMPtr<nsIWebNavigation> webNav(do_QueryObject(mDocShell));
if (webNav) {
webNav->LoadURI(NS_LITERAL_STRING("about:blank").get(),
0, nsnull, nsnull, nsnull);

Просмотреть файл

@ -1101,8 +1101,7 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreModalDialog)
{
if (IsOuterWindow() && !aIgnoreModalDialog) {
nsGlobalWindow* inner = GetCurrentInnerWindowInternal();
nsCOMPtr<nsIDOMModalContentWindow>
dlg(do_QueryInterface(static_cast<nsPIDOMWindow*>(inner)));
nsCOMPtr<nsIDOMModalContentWindow> 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<nsIDOMChromeWindow> chrome_win =
do_QueryInterface(static_cast<nsIDOMWindow *>(this));
nsCOMPtr<nsIDOMChromeWindow> chrome_win = do_QueryObject(this);
if (nsContentUtils::IsCallerChrome() && !chrome_win) {
// If open() is called from chrome on a non-chrome window, we'll

Просмотреть файл

@ -290,8 +290,7 @@ AsyncConnectionHelper::Run()
#ifdef DEBUG
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISupports> handlerSupports(do_QueryInterface(handler));
nsCOMPtr<nsISupports> thisSupports =
do_QueryInterface(static_cast<nsIRunnable*>(this));
nsCOMPtr<nsISupports> thisSupports = do_QueryObject(this);
NS_ASSERTION(thisSupports == handlerSupports, "Mismatch!");
}
#endif

Просмотреть файл

@ -408,7 +408,7 @@ nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIEditorMailSupport> mailEditor;
if (ctrlKey)
mailEditor = do_QueryInterface(static_cast<nsIEditor*>(mEditor));
mailEditor = do_QueryObject(mEditor);
PRInt32 clipboard;

Просмотреть файл

@ -67,10 +67,8 @@
nsresult
nsHTMLEditorEventListener::Connect(nsEditor* aEditor)
{
nsCOMPtr<nsIHTMLEditor> htmlEditor =
do_QueryInterface(static_cast<nsIEditor*>(aEditor));
nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor =
do_QueryInterface(static_cast<nsIEditor*>(aEditor));
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditor);
nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor = do_QueryObject(aEditor);
NS_PRECONDITION(htmlEditor && htmlInlineTableEditor,
"Set nsHTMLEditor or its sub class");
return nsEditorEventListener::Connect(aEditor);

Просмотреть файл

@ -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<nsITabParent*>(
static_cast<TabParent*>(iframeEmbedding)));
mTabParent = do_QueryObject(static_cast<TabParent*>(iframeEmbedding));
}
HttpChannelParent::~HttpChannelParent()

Просмотреть файл

@ -1900,7 +1900,7 @@ PRBool nsXULWindow::ConstrainToZLevel(PRBool aImmediate,
*aPlacement = nsWindowZRelative;
if (aImmediate) {
nsCOMPtr<nsIBaseWindow> ourBase = do_QueryInterface(static_cast<nsIXULWindow *>(this));
nsCOMPtr<nsIBaseWindow> ourBase = do_QueryObject(this);
if (ourBase) {
nsCOMPtr<nsIWidget> ourWidget;
ourBase->GetMainWidget(getter_AddRefs(ourWidget));