Bug 868726 - Outparamdel nsViewManager::GetDeviceContext; r=tn
authorMs2ger <ms2ger@gmail.com>
Fri, 10 May 2013 09:13:49 +0200
changeset 142326 e44c0b1eb2e3da774b4f7dc85667d71201276e80
parent 142325 1102bd83dc9d342a8a94023f2a068c3cb5d24164
child 142426 08be63954b6bce6e8aaa505352e11c4541d365c1
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs868726
milestone23.0a1
first release with
nightly win64
e44c0b1eb2e3 / 23.0a1 / 20130510031009 / files
nightly linux32
nightly linux64
nightly mac
nightly win32
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win64
Bug 868726 - Outparamdel nsViewManager::GetDeviceContext; r=tn
layout/generic/nsObjectFrame.cpp
view/public/nsViewManager.h
view/src/nsView.cpp
view/src/nsViewManager.cpp
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -415,18 +415,17 @@ nsObjectFrame::PrepForDrawing(nsIWidget 
     nsAutoTArray<nsIWidget::Configuration,1> configurations;
     nsIWidget::Configuration* configuration = configurations.AppendElement();
     nscoord appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
     configuration->mChild = mWidget;
     configuration->mBounds.width = NSAppUnitsToIntPixels(mRect.width, appUnitsPerDevPixel);
     configuration->mBounds.height = NSAppUnitsToIntPixels(mRect.height, appUnitsPerDevPixel);
     parentWidget->ConfigureChildren(configurations);
 
-    nsRefPtr<nsDeviceContext> dx;
-    viewMan->GetDeviceContext(*getter_AddRefs(dx));
+    nsRefPtr<nsDeviceContext> dx = viewMan->GetDeviceContext();
     mInnerView->AttachWidgetEventHandler(mWidget);
 
 #ifdef XP_MACOSX
     // On Mac, we need to invalidate ourselves since even windowed
     // plugins are painted through Thebes and we need to ensure
     // the Thebes layer containing the plugin is updated.
     if (parentWidget == GetNearestWidget()) {
       InvalidateFrame();
--- a/view/public/nsViewManager.h
+++ b/view/public/nsViewManager.h
@@ -227,19 +227,21 @@ public:
 
   /**
    * Get the pres shell associated with this manager
    */
   nsIPresShell* GetPresShell() { return mPresShell; }
 
   /**
    * Get the device context associated with this manager
-   * @result device context
    */
-  void GetDeviceContext(nsDeviceContext *&aContext);
+  nsDeviceContext* GetDeviceContext() const
+  {
+    return mContext;
+  }
 
   /**
    * A stack class for disallowing changes that would enter painting. For
    * example, popup widgets shouldn't be resized during reflow, since doing so
    * might cause synchronous painting inside reflow which is forbidden.
    * While refresh is disabled, widget geometry changes are deferred and will
    * be handled later, either from the refresh driver or from an NS_WILL_PAINT
    * event.
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -232,18 +232,17 @@ void nsView::DoResetWidgetBounds(bool aM
   NS_PRECONDITION(mWindow, "Why was this called??");
 
   // Hold this ref to make sure it stays alive.
   nsCOMPtr<nsIWidget> widget = mWindow;
 
   // Stash a copy of these and use them so we can handle this being deleted (say
   // from sync painting/flushing from Show/Move/Resize on the widget).
   nsIntRect newBounds;
-  nsRefPtr<nsDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   nsWindowType type;
   widget->GetWindowType(type);
 
   nsIntRect curBounds;
   widget->GetClientBounds(curBounds);
   bool invisiblePopup = type == eWindowType_popup &&
                         ((curBounds.IsEmpty() && mDimBounds.IsEmpty()) ||
@@ -514,18 +513,17 @@ nsresult nsView::CreateWidget(nsWidgetIn
   bool initDataPassedIn = !!aWidgetInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
   defaultInitData.mListenForResizes =
     (!initDataPassedIn && GetParent() &&
      GetParent()->GetViewManager() != mViewManager);
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   nsIWidget* parentWidget =
     GetParent() ? GetParent()->GetNearestWidget(nullptr) : nullptr;
   if (!parentWidget) {
     NS_ERROR("nsView::CreateWidget without suitable parent widget??");
     return NS_ERROR_FAILURE;
   }
 
@@ -553,18 +551,17 @@ nsresult nsView::CreateWidgetForParent(n
                     "Use CreateWidgetForPopup");
   NS_ABORT_IF_FALSE(aParentWidget, "Parent widget required");
 
   DefaultWidgetInitData defaultInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   mWindow =
     aParentWidget->CreateChild(trect, dx, aWidgetInitData).get();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
 
   InitializeWindow(aEnableDragDrop, aResetVisibility);
@@ -579,18 +576,17 @@ nsresult nsView::CreateWidgetForPopup(ns
 {
   AssertNoWindow();
   NS_ABORT_IF_FALSE(aWidgetInitData, "Widget init data required");
   NS_ABORT_IF_FALSE(aWidgetInitData->mWindowType == eWindowType_popup,
                     "Use one of the other CreateWidget methods");
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
-  nsRefPtr<nsDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   // XXX/cjones: having these two separate creation cases seems ... um
   // ... unnecessary, but it's the way the old code did it.  Please
   // unify them by first finding a suitable parent nsIWidget, then
   // getting rid of aForceUseIWidgetParent.
   if (aParentWidget) {
     // XXX: using aForceUseIWidgetParent=true to preserve previous
     // semantics.  It's not clear that it's actually needed.
@@ -648,18 +644,17 @@ nsresult nsView::AttachToTopLevelWidget(
   nsIWidgetListener* listener = aWidget->GetAttachedWidgetListener();
   if (listener) {
     nsView *oldView = listener->GetView();
     if (oldView) {
       oldView->DetachFromTopLevelWidget();
     }
   }
 
-  nsRefPtr<nsDeviceContext> dx;
-  mViewManager->GetDeviceContext(*getter_AddRefs(dx));
+  nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   // Note, the previous device context will be released. Detaching
   // will not restore the old one.
   nsresult rv = aWidget->AttachViewToTopLevel(!nsIWidget::UsePuppetWidgets(), dx);
   if (NS_FAILED(rv))
     return rv;
 
   mWindow = aWidget;
@@ -947,18 +942,17 @@ nsView::WindowMoved(nsIWidget* aWidget, 
 
 bool
 nsView::WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight)
 {
   // The root view may not be set if this is the resize associated with
   // window creation
   SetForcedRepaint(true);
   if (this == mViewManager->GetRootView()) {
-    nsRefPtr<nsDeviceContext> devContext;
-    mViewManager->GetDeviceContext(*getter_AddRefs(devContext));
+    nsRefPtr<nsDeviceContext> devContext = mViewManager->GetDeviceContext();
     // ensure DPI is up-to-date, in case of window being opened and sized
     // on a non-default-dpi display (bug 829963)
     devContext->CheckDPIChange();
     int32_t p2a = devContext->AppUnitsPerDevPixel();
     mViewManager->SetWindowDimensions(NSIntPixelsToAppUnits(aWidth, p2a),
                                       NSIntPixelsToAppUnits(aHeight, p2a));
     return true;
   }
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1031,23 +1031,16 @@ nsViewManager::SetViewZIndex(nsView *aVi
   aView->SetZIndex(aAutoZIndex, aZIndex, aTopMost);
 
   if (oldidx != aZIndex || oldTopMost != aTopMost ||
       oldIsAuto != aAutoZIndex) {
     InvalidateView(aView);
   }
 }
 
-void
-nsViewManager::GetDeviceContext(nsDeviceContext *&aContext)
-{
-  aContext = mContext;
-  NS_IF_ADDREF(aContext);
-}
-
 nsViewManager*
 nsViewManager::IncrementDisableRefreshCount()
 {
   if (!IsRootVM()) {
     return RootViewManager()->IncrementDisableRefreshCount();
   }
 
   ++mRefreshDisableCount;