From fd9001c40907c099a9a13e6584c0ec8a2591c95b Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 25 Mar 2010 14:17:11 +0100 Subject: [PATCH] Bug 554253 - Convert nsCOMPtr to nsRefPtr. r=roc --HG-- extra : rebase_source : d828daca07188864d055f3d1a72f5217632eb358 --- content/base/src/nsDocument.cpp | 4 +-- content/base/src/nsScriptElement.cpp | 4 +-- .../canvas/src/nsCanvasRenderingContext2D.cpp | 2 +- content/events/src/nsDOMEvent.cpp | 2 +- content/events/src/nsDOMEvent.h | 2 +- content/events/src/nsEventDispatcher.cpp | 2 +- content/events/src/nsEventListenerManager.cpp | 2 +- content/events/src/nsEventStateManager.cpp | 6 ++-- .../html/content/src/nsHTMLButtonElement.cpp | 2 +- .../html/content/src/nsHTMLFormElement.cpp | 2 +- .../html/content/src/nsHTMLInputElement.cpp | 10 +++---- .../content/src/nsHTMLTextAreaElement.cpp | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- .../document/src/nsXULCommandDispatcher.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 2 +- docshell/base/nsDocShell.cpp | 6 ++-- dom/base/nsDOMWindowUtils.cpp | 2 +- dom/base/nsFocusManager.cpp | 2 +- dom/base/nsGlobalWindow.cpp | 30 +++++++++---------- dom/base/nsJSEnvironment.cpp | 4 +-- .../src/nsComposerDocumentCommands.cpp | 4 +-- .../webBrowser/nsDocShellTreeOwner.cpp | 2 +- layout/base/nsDocumentViewer.cpp | 8 ++--- layout/base/nsPresContext.cpp | 2 +- layout/base/nsPresShell.cpp | 2 +- layout/generic/nsSelection.cpp | 14 ++++----- layout/printing/nsPrintObject.h | 2 +- layout/style/nsStyleContext.cpp | 2 +- layout/tables/nsCellMap.h | 3 +- layout/xul/base/src/nsBoxLayoutState.h | 2 +- layout/xul/base/src/nsImageBoxFrame.cpp | 2 +- layout/xul/base/src/nsMenuFrame.cpp | 2 +- xpfe/appshell/src/nsWebShellWindow.cpp | 2 +- 33 files changed, 69 insertions(+), 68 deletions(-) diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 12d296337d5d..7dfab1b4b017 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3998,7 +3998,7 @@ nsDocument::DispatchContentLoadedEvents() nsIPresShell *shell = parent->GetPrimaryShell(); if (shell) { - nsCOMPtr context = shell->GetPresContext(); + nsRefPtr context = shell->GetPresContext(); if (context) { nsEventDispatcher::Dispatch(parent, context, innerEvent, event, @@ -6198,7 +6198,7 @@ nsDocument::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) { // Obtain a presentation context nsIPresShell *shell = GetPrimaryShell(); - nsCOMPtr context; + nsRefPtr context; if (shell) { context = shell->GetPresContext(); } diff --git a/content/base/src/nsScriptElement.cpp b/content/base/src/nsScriptElement.cpp index a21c223814c2..dd671ae80361 100644 --- a/content/base/src/nsScriptElement.cpp +++ b/content/base/src/nsScriptElement.cpp @@ -58,7 +58,7 @@ nsScriptElement::ScriptAvailable(nsresult aResult, nsCOMPtr cont = do_QueryInterface((nsIScriptElement*) this); - nsCOMPtr presContext = + nsRefPtr presContext = nsContentUtils::GetContextForContent(cont); nsEventStatus status = nsEventStatus_eIgnore; @@ -91,7 +91,7 @@ nsScriptElement::ScriptEvaluated(nsresult aResult, nsCOMPtr cont = do_QueryInterface((nsIScriptElement*) this); - nsCOMPtr presContext = + nsRefPtr presContext = nsContentUtils::GetContextForContent(cont); nsEventStatus status = nsEventStatus_eIgnore; diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index d221b8ebd4de..b5cdde22fa21 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -3333,7 +3333,7 @@ nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) FlushLayoutForTree(aWindow); - nsCOMPtr presContext; + nsRefPtr presContext; nsCOMPtr win = do_QueryInterface(aWindow); if (win) { nsIDocShell* docshell = win->GetDocShell(); diff --git a/content/events/src/nsDOMEvent.cpp b/content/events/src/nsDOMEvent.cpp index 480465d6b99d..68e8bc26f7ed 100644 --- a/content/events/src/nsDOMEvent.cpp +++ b/content/events/src/nsDOMEvent.cpp @@ -231,7 +231,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMEvent) break; } } - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mPresContext) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NATIVE_MEMBER(mPresContext.get(), nsPresContext) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTmpRealOriginalTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mExplicitOriginalTarget) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END diff --git a/content/events/src/nsDOMEvent.h b/content/events/src/nsDOMEvent.h index 83d067812a28..ce4e752b1ea0 100644 --- a/content/events/src/nsDOMEvent.h +++ b/content/events/src/nsDOMEvent.h @@ -209,7 +209,7 @@ protected: nsresult ReportWrongPropertyAccessWarning(const char* aPropertyName); nsEvent* mEvent; - nsCOMPtr mPresContext; + nsRefPtr mPresContext; nsCOMPtr mTmpRealOriginalTarget; nsCOMPtr mExplicitOriginalTarget; nsString mCachedType; diff --git a/content/events/src/nsEventDispatcher.cpp b/content/events/src/nsEventDispatcher.cpp index fd5b28264068..86e5277008f9 100644 --- a/content/events/src/nsEventDispatcher.cpp +++ b/content/events/src/nsEventDispatcher.cpp @@ -507,7 +507,7 @@ nsEventDispatcher::Dispatch(nsISupports* aTarget, // If we have a PresContext, make sure it doesn't die before // event dispatching is finished. - nsCOMPtr kungFuDeathGrip(aPresContext); + nsRefPtr kungFuDeathGrip(aPresContext); ChainItemPool pool; NS_ENSURE_TRUE(pool.GetPool(), NS_ERROR_OUT_OF_MEMORY); diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 40e45b834931..22a78f14d1b2 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -1314,7 +1314,7 @@ nsEventListenerManager::DispatchEvent(nsIDOMEvent* aEvent, PRBool *_retval) // Obtain a presentation shell nsIPresShell *shell = document->GetPrimaryShell(); - nsCOMPtr context; + nsRefPtr context; if (shell) { context = shell->GetPresContext(); } diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 51e53b39d516..086caa9cd047 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -206,7 +206,7 @@ PrintDocTree(nsIDocShellTreeItem* aParentItem, int aLevel) aParentItem->GetItemType(&type); nsCOMPtr presShell; parentAsDocShell->GetPresShell(getter_AddRefs(presShell)); - nsCOMPtr presContext; + nsRefPtr presContext; parentAsDocShell->GetPresContext(getter_AddRefs(presContext)); nsCOMPtr cv; parentAsDocShell->GetContentViewer(getter_AddRefs(cv)); @@ -3469,9 +3469,9 @@ nsEventStateManager::NotifyMouseOut(nsGUIEvent* aEvent, nsIContent* aMovingInto) nsCOMPtr docshell; subdocFrame->GetDocShell(getter_AddRefs(docshell)); if (docshell) { - nsCOMPtr presContext; + nsRefPtr presContext; docshell->GetPresContext(getter_AddRefs(presContext)); - + if (presContext) { nsEventStateManager* kidESM = static_cast(presContext->EventStateManager()); diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 595ca9ee7296..fad24406ee6b 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -217,7 +217,7 @@ nsHTMLButtonElement::Click() if (doc) { nsIPresShell *shell = doc->GetPrimaryShell(); if (shell) { - nsCOMPtr context = shell->GetPresContext(); + nsRefPtr context = shell->GetPresContext(); if (context) { // Click() is never called from native code, but it may be // called from chrome JS. Mark this event trusted if Click() diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index a6d0d7a53e7c..3c04fb187321 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -392,7 +392,7 @@ nsHTMLFormElement::Submit() { // Send the submit event nsresult rv = NS_OK; - nsCOMPtr presContext = GetPresContext(); + nsRefPtr presContext = GetPresContext(); if (mPendingSubmission) { // aha, we have a pending submission that was not flushed // (this happens when form.submit() is called twice) diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 51a0712c2446..d5609da056fb 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -1397,7 +1397,7 @@ nsHTMLInputElement::FireOnChange() // nsEventStatus status = nsEventStatus_eIgnore; nsEvent event(PR_TRUE, NS_FORM_CHANGE); - nsCOMPtr presContext = GetPresContext(); + nsRefPtr presContext = GetPresContext(); nsEventDispatcher::Dispatch(static_cast(this), presContext, &event, nsnull, &status); } @@ -1455,7 +1455,7 @@ nsHTMLInputElement::Select() nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - nsCOMPtr presContext = GetPresContext(); + nsRefPtr presContext = GetPresContext(); if (state == eInactiveWindow) { if (fm) fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL); @@ -1536,9 +1536,9 @@ nsHTMLInputElement::Click() if (!doc) { return rv; } - + nsCOMPtr shell = doc->GetPrimaryShell(); - nsCOMPtr context = nsnull; + nsRefPtr context = nsnull; if (shell) { context = shell->GetPresContext(); } @@ -1876,7 +1876,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) fm->GetLastFocusMethod(document->GetWindow(), &lastFocusMethod); if (lastFocusMethod & (nsIFocusManager::FLAG_BYKEY | nsIFocusManager::FLAG_BYMOVEFOCUS)) { - nsCOMPtr presContext = GetPresContext(); + nsRefPtr presContext = GetPresContext(); if (DispatchSelectEvent(presContext)) { SelectAll(presContext); } diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index 92452acc6483..4c70af33dc47 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -313,7 +313,7 @@ nsHTMLTextAreaElement::Select() nsIFocusManager* fm = nsFocusManager::GetFocusManager(); - nsCOMPtr presContext = GetPresContext(); + nsRefPtr presContext = GetPresContext(); if (state == eInactiveWindow) { if (fm) fm->SetFocus(this, nsIFocusManager::FLAG_NOSCROLL); diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 5dccf318e849..31443e072f29 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -2058,7 +2058,7 @@ nsXULElement::Click() nsCOMPtr shell = doc->GetPrimaryShell(); if (shell) { // strong ref to PresContext so events don't destroy it - nsCOMPtr context = shell->GetPresContext(); + nsRefPtr context = shell->GetPresContext(); PRBool isCallerChrome = nsContentUtils::IsCallerChrome(); diff --git a/content/xul/document/src/nsXULCommandDispatcher.cpp b/content/xul/document/src/nsXULCommandDispatcher.cpp index 6a7a0e0933e7..988e2903d9e5 100644 --- a/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -437,7 +437,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName) if (shell) { // Retrieve the context in which our DOM event will fire. - nsCOMPtr context = shell->GetPresContext(); + nsRefPtr context = shell->GetPresContext(); // Handle the DOM event nsEventStatus status = nsEventStatus_eIgnore; diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 735f8615a5e6..914001b3826f 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -948,7 +948,7 @@ nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster, nsCOMPtr shell = GetPrimaryShell(); if (shell) { - nsCOMPtr aPresContext = shell->GetPresContext(); + nsRefPtr aPresContext = shell->GetPresContext(); // Handle the DOM event nsEventStatus status = nsEventStatus_eIgnore; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 37677b7e3e01..b874b4bd88de 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1606,7 +1606,7 @@ nsDocShell::GetPresShell(nsIPresShell ** aPresShell) NS_ENSURE_ARG_POINTER(aPresShell); *aPresShell = nsnull; - nsCOMPtr presContext; + nsRefPtr presContext; (void) GetPresContext(getter_AddRefs(presContext)); if (presContext) { @@ -1624,7 +1624,7 @@ nsDocShell::GetEldestPresShell(nsIPresShell** aPresShell) NS_ENSURE_ARG_POINTER(aPresShell); *aPresShell = nsnull; - nsCOMPtr presContext; + nsRefPtr presContext; (void) GetEldestPresContext(getter_AddRefs(presContext)); if (presContext) { @@ -2814,7 +2814,7 @@ PrintDocTree(nsIDocShellTreeItem * aParentNode, int aLevel) aParentNode->GetItemType(&type); nsCOMPtr presShell; parentAsDocShell->GetPresShell(getter_AddRefs(presShell)); - nsCOMPtr presContext; + nsRefPtr presContext; parentAsDocShell->GetPresContext(getter_AddRefs(presContext)); nsIDocument *doc = presShell->GetDocument(); diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index d1c0c0f8b7cf..0520402beacb 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -108,7 +108,7 @@ nsDOMWindowUtils::GetPresContext() nsIDocShell *docShell = mWindow->GetDocShell(); if (!docShell) return nsnull; - nsCOMPtr presContext; + nsRefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); return presContext; } diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 21139fe818b0..879d8dc30a50 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -1671,7 +1671,7 @@ public: nsCOMPtr mTarget; PRUint32 mType; - nsCOMPtr mContext; + nsRefPtr mContext; PRBool mWindowRaised; }; diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f5e4c9d37709..4a2a626047da 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -3202,8 +3202,8 @@ nsGlobalWindow::DevToCSSIntPixels(PRInt32 px) { if (!mDocShell) return px; // assume 1:1 - - nsCOMPtr presContext; + + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -3216,8 +3216,8 @@ nsGlobalWindow::CSSToDevIntPixels(PRInt32 px) { if (!mDocShell) return px; // assume 1:1 - - nsCOMPtr presContext; + + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; @@ -3230,12 +3230,12 @@ nsGlobalWindow::DevToCSSIntPixels(nsIntSize px) { if (!mDocShell) return px; // assume 1:1 - - nsCOMPtr presContext; + + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; - + return nsIntSize( presContext->DevPixelsToIntCSSPixels(px.width), presContext->DevPixelsToIntCSSPixels(px.height)); @@ -3246,12 +3246,12 @@ nsGlobalWindow::CSSToDevIntPixels(nsIntSize px) { if (!mDocShell) return px; // assume 1:1 - - nsCOMPtr presContext; + + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (!presContext) return px; - + return nsIntSize( presContext->CSSPixelsToDevPixels(px.width), presContext->CSSPixelsToDevPixels(px.height)); @@ -3268,7 +3268,7 @@ nsGlobalWindow::GetInnerWidth(PRInt32* aInnerWidth) EnsureSizeUpToDate(); nsCOMPtr docShellWin(do_QueryInterface(mDocShell)); - nsCOMPtr presContext; + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (docShellWin && presContext) { @@ -3331,7 +3331,7 @@ nsGlobalWindow::GetInnerHeight(PRInt32* aInnerHeight) EnsureSizeUpToDate(); nsCOMPtr docShellWin(do_QueryInterface(mDocShell)); - nsCOMPtr presContext; + nsRefPtr presContext; mDocShell->GetPresContext(getter_AddRefs(presContext)); if (docShellWin && presContext) { @@ -6579,7 +6579,7 @@ nsGlobalWindow::DispatchEvent(nsIDOMEvent* aEvent, PRBool* _retval) // Obtain a presentation shell nsIPresShell *shell = mDoc->GetPrimaryShell(); - nsCOMPtr presContext; + nsRefPtr presContext; if (shell) { // Retrieve the context presContext = shell->GetPresContext(); @@ -7089,7 +7089,7 @@ nsGlobalWindow::DispatchSyncPopState() // Obtain a presentation shell for use in creating a popstate event. nsIPresShell *shell = mDoc->GetPrimaryShell(); - nsCOMPtr presContext; + nsRefPtr presContext; if (shell) { presContext = shell->GetPresContext(); } @@ -9344,7 +9344,7 @@ nsGlobalChromeWindow::SetCursor(const nsAString& aCursor) } } - nsCOMPtr presContext; + nsRefPtr presContext; if (mDocShell) { mDocShell->GetPresContext(getter_AddRefs(presContext)); } diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index e1aadacd4d4b..b12700739b33 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -396,7 +396,7 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal, nsCOMPtr win(do_QueryInterface(aScriptGlobal)); nsIDocShell *docShell = win ? win->GetDocShell() : nsnull; if (docShell) { - nsCOMPtr presContext; + nsRefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); static PRInt32 errorDepth; // Recursion prevention @@ -439,7 +439,7 @@ public: !sHandlingScriptError) { sHandlingScriptError = PR_TRUE; // Recursion prevention - nsCOMPtr presContext; + nsRefPtr presContext; docShell->GetPresContext(getter_AddRefs(presContext)); if (presContext) { diff --git a/editor/composer/src/nsComposerDocumentCommands.cpp b/editor/composer/src/nsComposerDocumentCommands.cpp index c614835dc401..6d301d758af6 100644 --- a/editor/composer/src/nsComposerDocumentCommands.cpp +++ b/editor/composer/src/nsComposerDocumentCommands.cpp @@ -114,7 +114,7 @@ nsSetDocumentOptionsCommand::DoCommandParams(const char *aCommandName, nsCOMPtr editor = do_QueryInterface(refCon); if (!editor) return NS_ERROR_INVALID_ARG; - nsCOMPtr presContext; + nsRefPtr presContext; nsresult rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext)); if (NS_FAILED(rv)) return rv; if (!presContext) return NS_ERROR_FAILURE; @@ -165,7 +165,7 @@ nsSetDocumentOptionsCommand::GetCommandStateParams(const char *aCommandName, NS_ENSURE_SUCCESS(rv, rv); // get pres context - nsCOMPtr presContext; + nsRefPtr presContext; rv = GetPresContextFromEditor(editor, getter_AddRefs(presContext)); if (NS_FAILED(rv)) return rv; if (!presContext) return NS_ERROR_FAILURE; diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 27de2fc7901e..2debde9f4c6d 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -428,7 +428,7 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, Set the preferred size on the aShellItem. */ - nsCOMPtr presContext; + nsRefPtr presContext; mWebBrowser->mDocShell->GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index b4a4392a3627..f1b6714dcc85 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -428,7 +428,7 @@ protected: nsCOMPtr mDocument; nsCOMPtr mWindow; // may be null nsCOMPtr mViewManager; - nsCOMPtr mPresContext; + nsRefPtr mPresContext; nsCOMPtr mPresShell; nsCOMPtr mSelectionListener; @@ -1315,7 +1315,7 @@ AttachContainerRecurse(nsIDocShell* aShell) if (doc) { doc->SetContainer(aShell); } - nsCOMPtr pc; + nsRefPtr pc; docViewer->GetPresContext(getter_AddRefs(pc)); if (pc) { pc->SetContainer(aShell); @@ -1443,7 +1443,7 @@ DetachContainerRecurse(nsIDocShell *aShell) if (doc) { doc->SetContainer(nsnull); } - nsCOMPtr pc; + nsRefPtr pc; docViewer->GetPresContext(getter_AddRefs(pc)); if (pc) { pc->SetContainer(nsnull); @@ -3181,7 +3181,7 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() nsresult rv = presShell->ResizeReflow(prefWidth, NS_UNCONSTRAINEDSIZE); NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 48e4d9d195cf..a87282135612 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -320,7 +320,7 @@ nsPresContext::~nsPresContext() NS_IMPL_CYCLE_COLLECTION_CLASS(nsPresContext) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsPresContext) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver) + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_END diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index b1b6c94eaee9..7d2ef7396923 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -7908,7 +7908,7 @@ PresShell::VerifyIncrementalReflow() } // Create a presentation context to view the new frame tree - nsCOMPtr cx = + nsRefPtr cx = new nsRootPresContext(mDocument, mPresContext->IsPaginated() ? nsPresContext::eContext_PrintPreview : nsPresContext::eContext_Galley); diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 06c8b5731a9b..8f1bd5017a1b 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -4690,7 +4690,7 @@ nsTypedSelection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); @@ -4741,7 +4741,7 @@ nsTypedSelection::AddRange(nsIRange* aRange) if (mType == nsISelectionController::SELECTION_NORMAL) SetInterlinePosition(PR_TRUE); - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); selectFrames(presContext, aRange, PR_TRUE); @@ -4798,7 +4798,7 @@ nsTypedSelection::RemoveRange(nsIRange* aRange) } // clear the selected bit from the removed range's frames - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); selectFrames(presContext, aRange, PR_FALSE); @@ -4855,7 +4855,7 @@ nsTypedSelection::Collapse(nsINode* aParentNode, PRInt32 aOffset) return NS_ERROR_FAILURE; nsresult result; // Delete all of the current ranges - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); Clear(presContext); @@ -5022,7 +5022,7 @@ nsTypedSelection::CopyRangeToAnchorFocus(nsIRange *aRange) void nsTypedSelection::ReplaceAnchorFocusRange(nsIRange *aRange) { - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); if (presContext) { selectFrames(presContext, mAnchorFocusRange, PR_FALSE); @@ -5124,7 +5124,7 @@ nsTypedSelection::Extend(nsINode* aParentNode, PRInt32 aOffset) if (result2 == 0) //not selecting anywhere return NS_OK; - nsCOMPtr presContext; + nsRefPtr presContext; GetPresContext(getter_AddRefs(presContext)); if ((result1 == 0 && result3 < 0) || (result1 <= 0 && result2 < 0)){//a1,2 a,1,2 //select from 1 to 2 unless they are collapsed @@ -5693,7 +5693,7 @@ nsTypedSelection::SelectionLanguageChange(PRBool aLangRTL) PRInt32 frameStart, frameEnd; focusFrame->GetOffsets(frameStart, frameEnd); - nsCOMPtr context; + nsRefPtr context; PRUint8 levelBefore, levelAfter; result = GetPresContext(getter_AddRefs(context)); if (NS_FAILED(result) || !context) diff --git a/layout/printing/nsPrintObject.h b/layout/printing/nsPrintObject.h index cc573c941d77..c30032ef19d5 100644 --- a/layout/printing/nsPrintObject.h +++ b/layout/printing/nsPrintObject.h @@ -72,7 +72,7 @@ public: nsCOMPtr mDocShell; nsCOMPtr mDocument; - nsCOMPtr mPresContext; + nsRefPtr mPresContext; nsCOMPtr mPresShell; nsCOMPtr mViewManager; nsCOMPtr mWindow; diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index c7a55e4c45fc..d71ca4ec08cd 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -554,7 +554,7 @@ void nsStyleContext::Destroy() { // Get the pres context from our rule node. - nsCOMPtr presContext = mRuleNode->GetPresContext(); + nsRefPtr presContext = mRuleNode->GetPresContext(); // Call our destructor. this->~nsStyleContext(); diff --git a/layout/tables/nsCellMap.h b/layout/tables/nsCellMap.h index 32cb270a5bfc..0f5999d0e608 100644 --- a/layout/tables/nsCellMap.h +++ b/layout/tables/nsCellMap.h @@ -44,6 +44,7 @@ #include "nsRect.h" #include "nsCOMPtr.h" #include "nsAlgorithm.h" +#include "nsAutoPtr.h" #undef DEBUG_TABLE_CELLMAP @@ -610,7 +611,7 @@ protected: PRBool mIsBC; // Prescontext to deallocate and allocate celldata - nsCOMPtr mPresContext; + nsRefPtr mPresContext; }; /** diff --git a/layout/xul/base/src/nsBoxLayoutState.h b/layout/xul/base/src/nsBoxLayoutState.h index dac308ebdcb1..6ea3d804adac 100644 --- a/layout/xul/base/src/nsBoxLayoutState.h +++ b/layout/xul/base/src/nsBoxLayoutState.h @@ -87,7 +87,7 @@ public: PRUint16 GetReflowDepth() { return mReflowDepth; } private: - nsCOMPtr mPresContext; + nsRefPtr mPresContext; nsIRenderingContext *mRenderingContext; PRUint32 mLayoutFlags; PRUint16 mReflowDepth; diff --git a/layout/xul/base/src/nsImageBoxFrame.cpp b/layout/xul/base/src/nsImageBoxFrame.cpp index d152a1c35604..67736af14590 100644 --- a/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/layout/xul/base/src/nsImageBoxFrame.cpp @@ -117,7 +117,7 @@ nsImageBoxFrameEvent::Run() return NS_OK; } - nsCOMPtr pres_context = pres_shell->GetPresContext(); + nsRefPtr pres_context = pres_shell->GetPresContext(); if (!pres_context) { return NS_OK; } diff --git a/layout/xul/base/src/nsMenuFrame.cpp b/layout/xul/base/src/nsMenuFrame.cpp index b1e32e6c5bae..9f8d787f789d 100644 --- a/layout/xul/base/src/nsMenuFrame.cpp +++ b/layout/xul/base/src/nsMenuFrame.cpp @@ -145,7 +145,7 @@ public: private: nsCOMPtr mMenu; - nsCOMPtr mPresContext; + nsRefPtr mPresContext; PRBool mIsActivate; }; diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 221fdca68fa4..24e9d1d60e9f 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -736,7 +736,7 @@ PRBool nsWebShellWindow::ExecuteCloseHandler() nsCOMPtr docViewer(do_QueryInterface(contentViewer)); if (docViewer) { - nsCOMPtr presContext; + nsRefPtr presContext; docViewer->GetPresContext(getter_AddRefs(presContext)); nsEventStatus status = nsEventStatus_eIgnore;