Bug 826632. Part 2: Use nsRefPtr<nsViewManager> instead of nsCOMPtr. r=tnikkel
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 05 Jan 2013 16:12:42 +1300
changeset 126853 7b31621af1582255b787d742e21d17ec1c21b43e
parent 126852 1367089491f9e5cf9704f09396fdf1cef00be97a
child 126854 9e7027c6242a3e77facba24b4ce54cdd21d7536a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs826632
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 826632. Part 2: Use nsRefPtr<nsViewManager> instead of nsCOMPtr. r=tnikkel
extensions/widgetutils/src/nsWidgetUtils.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsDocumentViewer.cpp
layout/base/nsPresShell.cpp
layout/base/nsRefreshDriver.cpp
layout/printing/nsPrintObject.h
layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
layout/xul/base/src/nsXULPopupManager.cpp
view/public/nsViewManager.h
view/src/nsView.cpp
widget/gtk2/nsDragService.cpp
widget/tests/TestWinTSF.cpp
--- a/extensions/widgetutils/src/nsWidgetUtils.cpp
+++ b/extensions/widgetutils/src/nsWidgetUtils.cpp
@@ -84,17 +84,17 @@ private:
   nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
   nsresult MouseDown(nsIDOMEvent* aDOMEvent);
   nsresult MouseUp(nsIDOMEvent* aDOMEvent);
   nsresult MouseMove(nsIDOMEvent* aDOMEvent);
 
   static void StopPanningCallback(nsITimer *timer, void *closure);
 
   nsCOMPtr<nsIWidget> mWidget;
-  nsCOMPtr<nsViewManager> mViewManager;
+  nsRefPtr<nsViewManager> mViewManager;
   nsCOMPtr<nsITimer> mTimer;
 };
 
 nsWidgetUtils::nsWidgetUtils()
 {
   Init();
 }
 
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -12018,17 +12018,17 @@ nsCSSFrameConstructor::RebuildAllStyleDa
   mRebuildAllStyleData = false;
   NS_UpdateHint(aExtraHint, mRebuildAllExtraHint);
   mRebuildAllExtraHint = nsChangeHint(0);
 
   if (!mPresShell || !mPresShell->GetRootFrame())
     return;
 
   // Make sure that the viewmanager will outlive the presshell
-  nsCOMPtr<nsViewManager> vm = mPresShell->GetViewManager();
+  nsRefPtr<nsViewManager> vm = mPresShell->GetViewManager();
 
   // Processing the style changes could cause a flush that propagates to
   // the parent frame and thus destroys the pres shell.
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(mPresShell);
 
   // We may reconstruct frames below and hence process anything that is in the
   // tree. We don't want to get notified to process those items again after.
   mPresShell->GetDocument()->FlushPendingNotifications(Flush_ContentAndNotify);
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -392,17 +392,17 @@ protected:
   nsWeakPtr mContainer; // it owns me!
   nsWeakPtr mTopContainerWhilePrinting;
   nsRefPtr<nsDeviceContext> mDeviceContext;  // We create and own this baby
 
   // the following six items are explicitly in this order
   // so they will be destroyed in the reverse order (pinkerton, scc)
   nsCOMPtr<nsIDocument>    mDocument;
   nsCOMPtr<nsIWidget>      mWindow;      // may be null
-  nsCOMPtr<nsViewManager> mViewManager;
+  nsRefPtr<nsViewManager> mViewManager;
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
 
   nsCOMPtr<nsISelectionListener> mSelectionListener;
   nsRefPtr<nsDocViewerFocusListener> mFocusListener;
 
   nsCOMPtr<nsIContentViewer> mPreviousViewer;
   nsCOMPtr<nsISHEntry> mSHEntry;
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1852,17 +1852,17 @@ PresShell::ResizeReflowIgnoreOverride(ns
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
 
   if (!rootFrame && aHeight == NS_UNCONSTRAINEDSIZE) {
     // We can't do the work needed for SizeToContent without a root
     // frame, and we want to return before setting the visible area.
     return NS_ERROR_NOT_AVAILABLE;
   }
 
-  nsCOMPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
+  nsRefPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
   // Take this ref after viewManager so it'll make sure to go away first
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
   if (!mIsDestroying && !mResizeEvent.IsPending() &&
       !mAsyncResizeTimerIsActive) {
     FireBeforeResizeEvent();
   }
 
@@ -3803,17 +3803,17 @@ PresShell::FlushPendingNotifications(moz
   bool hasHadScriptObject;
   if (mDocument->GetScriptHandlingObject(hasHadScriptObject) ||
       hasHadScriptObject) {
     isSafeToFlush = isSafeToFlush && nsContentUtils::IsSafeToRunScript();
   }
 
   NS_ASSERTION(!isSafeToFlush || mViewManager, "Must have view manager");
   // Make sure the view manager stays alive.
-  nsCOMPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
+  nsRefPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
   if (isSafeToFlush && mViewManager) {
     // Processing pending notifications can kill us, and some callers only
     // hold weak refs when calling FlushPendingNotifications().  :(
     nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
     if (mResizeEvent.IsPending()) {
       FireResizeEvent();
       if (mIsDestroying) {
@@ -8265,17 +8265,17 @@ PresShell::VerifyIncrementalReflow()
   NS_ENSURE_SUCCESS(rv, false);
 
   // Get our scrolling preference
   nsView* rootView = mViewManager->GetRootView();
   NS_ENSURE_TRUE(rootView->HasWidget(), false);
   nsIWidget* parentWidget = rootView->GetWidget();
 
   // Create a new view manager.
-  nsCOMPtr<nsViewManager> vm = do_CreateInstance(kViewManagerCID);
+  nsRefPtr<nsViewManager> vm = do_CreateInstance(kViewManagerCID);
   NS_ENSURE_TRUE(vm, false);
   rv = vm->Init(dc);
   NS_ENSURE_SUCCESS(rv, false);
 
   // Create a child window of the parent that is our "root view/window"
   // Create a view
   nsRect tbounds = mPresContext->GetVisibleArea();
   nsView* view = vm->CreateView(tbounds, nullptr);
--- a/layout/base/nsRefreshDriver.cpp
+++ b/layout/base/nsRefreshDriver.cpp
@@ -946,17 +946,17 @@ nsRefreshDriver::Tick(int64_t aNowEpoch,
     // Waiting for bug 785597 to work on android.
     nsRefPtr<layers::LayerManager> mgr = mPresContext->GetPresShell()->GetLayerManager();
     if (mgr) {
       mgr->SetPaintStartTime(mMostRecentRefresh);
     }
 #endif
 
     mViewManagerFlushIsPending = false;
-    nsCOMPtr<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
+    nsRefPtr<nsViewManager> vm = mPresContext->GetPresShell()->GetViewManager();
     vm->ProcessPendingUpdates();
 #ifdef DEBUG_INVALIDATIONS
     printf("Ending ProcessPendingUpdates\n");
 #endif
   }
 }
 
 PLDHashOperator
--- a/layout/printing/nsPrintObject.h
+++ b/layout/printing/nsPrintObject.h
@@ -41,17 +41,17 @@ public:
 
   // Data Members
   nsCOMPtr<nsIDocShell>    mDocShell;
   nsCOMPtr<nsIDocShellTreeOwner> mTreeOwner;
   nsCOMPtr<nsIDocument>    mDocument;
 
   nsRefPtr<nsPresContext>  mPresContext;
   nsCOMPtr<nsIPresShell>   mPresShell;
-  nsCOMPtr<nsViewManager> mViewManager;
+  nsRefPtr<nsViewManager> mViewManager;
 
   nsCOMPtr<nsIContent>     mContent;
   PrintObjectType  mFrameType;
   
   nsTArray<nsPrintObject*> mKids;
   nsPrintObject*   mParent;
   bool             mHasBeenPrinted;
   bool             mDontPrint;
--- a/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
+++ b/layout/tools/layout-debug/src/nsLayoutDebuggingTools.cpp
@@ -428,17 +428,17 @@ nsLayoutDebuggingTools::DumpFrames()
 }
 
 static
 void
 DumpViewsRecur(nsIDocShell* aDocShell, FILE* out)
 {
 #ifdef DEBUG
     fprintf(out, "docshell=%p \n", static_cast<void*>(aDocShell));
-    nsCOMPtr<nsViewManager> vm(view_manager(aDocShell));
+    nsRefPtr<nsViewManager> vm(view_manager(aDocShell));
     if (vm) {
         nsView* root = vm->GetRootView();
         if (root) {
             root->List(out);
         }
     }
     else {
         fputs("null view manager\n", out);
@@ -519,17 +519,17 @@ nsLayoutDebuggingTools::DumpReflowStats(
 #endif
     }
 #endif
     return NS_OK;
 }
 
 void nsLayoutDebuggingTools::ForceRefresh()
 {
-    nsCOMPtr<nsViewManager> vm(view_manager(mDocShell));
+    nsRefPtr<nsViewManager> vm(view_manager(mDocShell));
     if (!vm)
         return;
     nsView* root = vm->GetRootView();
     if (root) {
         vm->InvalidateView(root);
     }
 }
 
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -2290,17 +2290,17 @@ nsXULMenuCommandEvent::Run()
         popup = popupFrame->GetContent();
         break;
       }
       frame = frame->GetParent();
     }
 
     nsPresContext* presContext = menuFrame->PresContext();
     nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
-    nsCOMPtr<nsViewManager> kungFuDeathGrip = shell->GetViewManager();
+    nsRefPtr<nsViewManager> kungFuDeathGrip = shell->GetViewManager();
 
     // Deselect ourselves.
     if (mCloseMenuMode != CloseMenuMode_None)
       menuFrame->SelectMenu(false);
 
     nsAutoHandlingUserInputStatePusher userInpStatePusher(mUserInput, nullptr,
                                                           shell->GetDocument());
     nsContentUtils::DispatchXULCommand(mMenu, mIsTrusted, nullptr, shell,
--- a/view/public/nsViewManager.h
+++ b/view/public/nsViewManager.h
@@ -271,17 +271,17 @@ public:
       if (mRootVM) {
         mRootVM->DecrementDisableRefreshCount();
       }
     }
   private:
     AutoDisableRefresh(const AutoDisableRefresh& aOther);
     const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther);
 
-    nsCOMPtr<nsViewManager> mRootVM;
+    nsRefPtr<nsViewManager> mRootVM;
   };
 
 private:
   friend class AutoDisableRefresh;
 
   virtual nsViewManager* IncrementDisableRefreshCount();
   virtual void DecrementDisableRefreshCount();
 
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -948,41 +948,41 @@ nsView::RequestWindowClose(nsIWidget* aW
   }
 
   return false;
 }
 
 void
 nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint)
 {
-  nsCOMPtr<nsViewManager> vm = mViewManager;
+  nsRefPtr<nsViewManager> vm = mViewManager;
   vm->WillPaintWindow(aWidget, aWillSendDidPaint);
 }
 
 bool
 nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags)
 {
   NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?");
 
   mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE;
-  nsCOMPtr<nsViewManager> vm = mViewManager;
+  nsRefPtr<nsViewManager> vm = mViewManager;
   bool result = vm->PaintWindow(aWidget, aRegion, aFlags);
   // PaintWindow can destroy this via WillPaintWindow notification, so we have
   // to re-get the view from the widget.
   nsView* view = nsView::GetViewFor(aWidget);
   if (view) {
     view->mInAlternatePaint = false;
   }
   return result;
 }
 
 void
 nsView::DidPaintWindow()
 {
-  nsCOMPtr<nsViewManager> vm = mViewManager;
+  nsRefPtr<nsViewManager> vm = mViewManager;
   vm->DidPaintWindow();
 }
 
 void
 nsView::RequestRepaint()
 {
   nsIPresShell* presShell = mViewManager->GetPresShell();
   if (presShell) {
@@ -1001,14 +1001,14 @@ nsView::HandleEvent(nsGUIEvent* aEvent, 
     nsIWidgetListener* listener = aEvent->widget->GetAttachedWidgetListener();
     view = listener ? listener->GetView() : nullptr;
   }
   else {
     view = GetViewFor(aEvent->widget);
   }
 
   if (view) {
-    nsCOMPtr<nsViewManager> vm = view->GetViewManager();
+    nsRefPtr<nsViewManager> vm = view->GetViewManager();
     vm->DispatchEvent(aEvent, view, &result);
   }
 
   return result;
 }
--- a/widget/gtk2/nsDragService.cpp
+++ b/widget/gtk2/nsDragService.cpp
@@ -264,17 +264,17 @@ GetGtkWindow(nsIDOMDocument *aDocument)
     nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
     if (!doc)
         return NULL;
 
     nsCOMPtr<nsIPresShell> presShell = doc->GetShell();
     if (!presShell)
         return NULL;
 
-    nsCOMPtr<nsViewManager> vm = presShell->GetViewManager();
+    nsRefPtr<nsViewManager> vm = presShell->GetViewManager();
     if (!vm)
         return NULL;
 
     nsCOMPtr<nsIWidget> widget;
     vm->GetRootWidget(getter_AddRefs(widget));
     if (!widget)
         return NULL;
 
--- a/widget/tests/TestWinTSF.cpp
+++ b/widget/tests/TestWinTSF.cpp
@@ -3139,17 +3139,17 @@ TestApp::GetWidget(nsIWidget** aWidget)
   }
 
   nsCOMPtr<nsIPresShell> presShell;
   rv = docShell->GetPresShell(getter_AddRefs(presShell));
   if (NS_FAILED(rv) || !presShell) {
     return false;
   }
 
-  nsCOMPtr<nsViewManager> viewManager = presShell->GetViewManager();
+  nsRefPtr<nsViewManager> viewManager = presShell->GetViewManager();
   if (!viewManager) {
     return false;
   }
 
   rv = viewManager->GetRootWidget(aWidget);
   return (NS_SUCCEEDED(rv) && aWidget);
 }