bug 809871 - part 2/3 - outparamdel some nsTreeBodyFrame methods r=mats
authorTrevor Saunders <trev.saunders@gmail.com>
Sun, 18 Nov 2012 07:40:17 -0500
changeset 136707 eccae9f7fc4b0ac2410f108d9d5b30e18bb69602
parent 136706 04dfb021fe3f44608cc66a265632d42b28059bdb
child 136708 53743e639a879a003c5f6d78c51fe1985da45b08
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs809871
milestone22.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 809871 - part 2/3 - outparamdel some nsTreeBodyFrame methods r=mats
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
layout/xul/tree/nsTreeBoxObject.cpp
layout/xul/tree/nsTreeColFrame.cpp
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -542,65 +542,37 @@ nsTreeBodyFrame::GetTreeBody(nsIDOMEleme
   //NS_ASSERTION(mContent, "no content, see bug #104878");
   if (!mContent)
     return NS_ERROR_NULL_POINTER;
 
   return mContent->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
 }
 
 nsresult
-nsTreeBodyFrame::GetColumns(nsITreeColumns** aColumns)
-{
-  NS_IF_ADDREF(*aColumns = mColumns);
-  return NS_OK;
-}
-
-nsresult
 nsTreeBodyFrame::GetRowHeight(int32_t* _retval)
 {
   *_retval = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight);
   return NS_OK;
 }
 
 nsresult
 nsTreeBodyFrame::GetRowWidth(int32_t *aRowWidth)
 {
   *aRowWidth = nsPresContext::AppUnitsToIntCSSPixels(CalcHorzWidth(GetScrollParts()));
   return NS_OK;
 }
 
 nsresult
-nsTreeBodyFrame::GetFirstVisibleRow(int32_t *_retval)
-{
-  *_retval = mTopRowIndex;
-  return NS_OK;
-}
-
-nsresult
-nsTreeBodyFrame::GetLastVisibleRow(int32_t *_retval)
-{
-  *_retval = GetLastVisibleRow();
-  return NS_OK;
-}
-
-nsresult
 nsTreeBodyFrame::GetHorizontalPosition(int32_t *aHorizontalPosition)
 {
   *aHorizontalPosition = nsPresContext::AppUnitsToIntCSSPixels(mHorzPosition); 
   return NS_OK;
 }
 
 nsresult
-nsTreeBodyFrame::GetPageLength(int32_t *_retval)
-{
-  *_retval = mPageLength;
-  return NS_OK;
-}
-
-nsresult
 nsTreeBodyFrame::GetSelectionRegion(nsIScriptableRegion **aRegion)
 {
   *aRegion = nullptr;
 
   nsCOMPtr<nsITreeSelection> selection;
   mView->GetSelection(getter_AddRefs(selection));
   NS_ENSURE_TRUE(selection, NS_OK);
 
@@ -614,17 +586,17 @@ nsTreeBodyFrame::GetSelectionRegion(nsIS
   nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
   nsPoint origin = GetOffsetTo(rootFrame);
 
   // iterate through the visible rows and add the selected ones to the
   // drag region
   int32_t x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
   int32_t y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);
   int32_t top = y;
-  int32_t end = GetLastVisibleRow();
+  int32_t end = LastVisibleRow();
   int32_t rowHeight = nsPresContext::AppUnitsToIntCSSPixels(mRowHeight);
   for (int32_t i = mTopRowIndex; i <= end; i++) {
     bool isSelected;
     selection->IsSelected(i, &isSelected);
     if (isSelected)
       region->UnionRect(x, y, rect.width, rowHeight);
     y += rowHeight;
   }
@@ -728,17 +700,17 @@ nsresult
 nsTreeBodyFrame::InvalidateRange(int32_t aStart, int32_t aEnd)
 {
   if (mUpdateBatchNest)
     return NS_OK;
 
   if (aStart == aEnd)
     return InvalidateRow(aStart);
 
-  int32_t last = GetLastVisibleRow();
+  int32_t last = LastVisibleRow();
   if (aStart > aEnd || aEnd < mTopRowIndex || aStart > last)
     return NS_OK;
 
   if (aStart < mTopRowIndex)
     aStart = mTopRowIndex;
 
   if (aEnd > last)
     aEnd = last;
@@ -765,17 +737,17 @@ nsTreeBodyFrame::InvalidateColumnRange(i
 
   nsRefPtr<nsTreeColumn> col = GetColumnImpl(aCol);
   if (!col)
     return NS_ERROR_INVALID_ARG;
 
   if (aStart == aEnd)
     return InvalidateCell(aStart, col);
 
-  int32_t last = GetLastVisibleRow();
+  int32_t last = LastVisibleRow();
   if (aStart > aEnd || aEnd < mTopRowIndex || aStart > last)
     return NS_OK;
 
   if (aStart < mTopRowIndex)
     aStart = mTopRowIndex;
 
   if (aEnd > last)
     aEnd = last;
@@ -1822,18 +1794,18 @@ nsTreeBodyFrame::RowCountChanged(int32_t
 
   mRowCount += aCount;
 #ifdef DEBUG
   int32_t rowCount = mRowCount;
   mView->GetRowCount(&rowCount);
   NS_ASSERTION(rowCount == mRowCount, "row count did not change by the amount suggested, check caller");
 #endif
 
-  int32_t count = DeprecatedAbs(aCount);
-  int32_t last = GetLastVisibleRow();
+  int32_t count = Abs(aCount);
+  int32_t last = LastVisibleRow();
   if (aIndex >= mTopRowIndex && aIndex <= last)
     InvalidateRange(aIndex, last);
     
   ScrollParts parts = GetScrollParts();
 
   if (mTopRowIndex == 0) {    
     // Just update the scrollbar and return.
     if (FullScrollbarsUpdate(false)) {
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -55,29 +55,38 @@ public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // Callback handler methods for refresh driver based animations.
   // Calls to these functions are forwarded from nsTreeImageListener. These
   // mirror how nsImageFrame works.
   nsresult OnImageIsAnimated(imgIRequest* aRequest);
 
   // non-virtual signatures like nsITreeBodyFrame
-  nsresult GetColumns(nsITreeColumns **aColumns);
+  already_AddRefed<nsTreeColumns> Columns() const
+  {
+    nsRefPtr<nsTreeColumns> cols = mColumns;
+    return cols.forget();
+  }
+  already_AddRefed<nsITreeView> GetExistingView() const
+  {
+    nsCOMPtr<nsITreeView> view = mView;
+    return view.forget();
+  }
   nsresult GetView(nsITreeView **aView);
   nsresult SetView(nsITreeView *aView);
   nsresult GetFocused(bool *aFocused);
   nsresult SetFocused(bool aFocused);
   nsresult GetTreeBody(nsIDOMElement **aElement);
   nsresult GetRowHeight(int32_t *aValue);
   nsresult GetRowWidth(int32_t *aValue);
   nsresult GetHorizontalPosition(int32_t *aValue);
   nsresult GetSelectionRegion(nsIScriptableRegion **aRegion);
-  nsresult GetFirstVisibleRow(int32_t *aValue);
-  nsresult GetLastVisibleRow(int32_t *aValue);
-  nsresult GetPageLength(int32_t *aValue);
+  int32_t FirstVisibleRow() const { return mTopRowIndex; }
+  int32_t LastVisibleRow() const { return mTopRowIndex + mPageLength; }
+  int32_t PageLength() const { return mPageLength; }
   nsresult EnsureRowIsVisible(int32_t aRow);
   nsresult EnsureCellIsVisible(int32_t aRow, nsITreeColumn *aCol);
   nsresult ScrollToRow(int32_t aRow);
   nsresult ScrollByLines(int32_t aNumLines);
   nsresult ScrollByPages(int32_t aNumPages);
   nsresult ScrollToCell(int32_t aRow, nsITreeColumn *aCol);
   nsresult ScrollToColumn(nsITreeColumn *aCol);
   nsresult ScrollToHorizontalPosition(int32_t aValue);
@@ -251,20 +260,16 @@ protected:
   // paint the background rect as if it were a full-blown frame.
   void PaintBackgroundLayer(nsStyleContext*      aStyleContext,
                             nsPresContext*      aPresContext, 
                             nsRenderingContext& aRenderingContext, 
                             const nsRect&        aRect,
                             const nsRect&        aDirtyRect);
 
 
-  int32_t GetLastVisibleRow() {
-    return mTopRowIndex + mPageLength;
-  }
-
   // An internal hit test.  aX and aY are expected to be in twips in the
   // coordinate system of this frame.
   int32_t GetRowAt(nscoord aX, nscoord aY);
 
   // Check for bidi characters in the text, and if there are any, ensure
   // that the prescontext is in bidi mode.
   void CheckTextForBidi(nsAutoString& aText);
 
--- a/layout/xul/tree/nsTreeBoxObject.cpp
+++ b/layout/xul/tree/nsTreeBoxObject.cpp
@@ -211,17 +211,17 @@ NS_IMETHODIMP nsTreeBoxObject::GetTreeBo
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetColumns(nsITreeColumns** aColumns)
 {
   *aColumns = nullptr;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body) 
-    return body->GetColumns(aColumns);
+    *aColumns = body->Columns().get();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetRowHeight(int32_t* aRowHeight)
 {
   *aRowHeight = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body) 
@@ -238,26 +238,26 @@ NS_IMETHODIMP nsTreeBoxObject::GetRowWid
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetFirstVisibleRow(int32_t *aFirstVisibleRow)
 {
   *aFirstVisibleRow = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body)
-    return body->GetFirstVisibleRow(aFirstVisibleRow);
+    *aFirstVisibleRow = body->FirstVisibleRow();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetLastVisibleRow(int32_t *aLastVisibleRow)
 {
   *aLastVisibleRow = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body)
-    return body->GetLastVisibleRow(aLastVisibleRow);
+    *aLastVisibleRow = body->LastVisibleRow();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetHorizontalPosition(int32_t *aHorizontalPosition)
 {
   *aHorizontalPosition = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body)
@@ -265,17 +265,17 @@ NS_IMETHODIMP nsTreeBoxObject::GetHorizo
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetPageLength(int32_t *aPageLength)
 {
   *aPageLength = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body)
-    return body->GetPageLength(aPageLength);
+    *aPageLength = body->PageLength();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetSelectionRegion(nsIScriptableRegion **aRegion)
 {
  *aRegion = nullptr;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body)
--- a/layout/xul/tree/nsTreeColFrame.cpp
+++ b/layout/xul/tree/nsTreeColFrame.cpp
@@ -184,16 +184,16 @@ nsTreeColFrame::InvalidateColumns(bool a
   if (treeBoxObject) {
     nsCOMPtr<nsITreeColumns> columns;
 
     if (aCanWalkFrameTree) {
       treeBoxObject->GetColumns(getter_AddRefs(columns));
     } else {
       nsTreeBodyFrame* body = static_cast<nsTreeBoxObject*>(treeBoxObject)->GetCachedTreeBody();
       if (body) {
-        body->GetColumns(getter_AddRefs(columns));
+        columns = body->Columns();
       }
     }
 
     if (columns)
       columns->InvalidateColumns();
   }
 }