Bug 508665 - part 12, Move nsIFrame::GetChildBox/GetNextBox/GetParentBox to XUL where they came from. r=roc
authorMats Palmgren <matspal@gmail.com>
Sat, 24 May 2014 22:20:41 +0000
changeset 184838 7b0a6a02b6f4a50e7990f13ed2c6f94363489188
parent 184837 2b2dee6f0b78d17d087ce47bfcabb45e8a232980
child 184839 8620fa86cceffe2412e86c27d491b79faee09454
push id26836
push usercbook@mozilla.com
push dateMon, 26 May 2014 12:37:49 +0000
treeherdermozilla-central@5cd52de816f9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs508665
milestone32.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 508665 - part 12, Move nsIFrame::GetChildBox/GetNextBox/GetParentBox to XUL where they came from. r=roc
layout/base/nsDisplayList.cpp
layout/generic/nsIFrame.h
layout/xul/grid/nsGrid.cpp
layout/xul/grid/nsGridRowGroupFrame.cpp
layout/xul/grid/nsGridRowGroupLayout.cpp
layout/xul/grid/nsGridRowLayout.cpp
layout/xul/grid/nsGridRowLeafLayout.cpp
layout/xul/nsBox.cpp
layout/xul/nsBox.h
layout/xul/nsBoxFrame.cpp
layout/xul/nsDeckFrame.cpp
layout/xul/nsGroupBoxFrame.cpp
layout/xul/nsListBoxLayout.cpp
layout/xul/nsMenuPopupFrame.cpp
layout/xul/nsScrollBoxObject.cpp
layout/xul/nsSliderFrame.cpp
layout/xul/nsSplitterFrame.cpp
layout/xul/nsSprocketLayout.cpp
layout/xul/nsStackLayout.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1440,17 +1440,17 @@ GetMouseThrough(const nsIFrame* aFrame)
 
   const nsIFrame* frame = aFrame;
   while (frame) {
     if (frame->GetStateBits() & NS_FRAME_MOUSE_THROUGH_ALWAYS) {
       return true;
     } else if (frame->GetStateBits() & NS_FRAME_MOUSE_THROUGH_NEVER) {
       return false;
     }
-    frame = frame->GetParentBox();
+    frame = nsBox::GetParentBox(frame);
   }
   return false;
 }
 
 static bool
 IsFrameReceivingPointerEvents(nsIFrame* aFrame)
 {
   nsSubDocumentFrame* frame = do_QueryFrame(aFrame);
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2653,30 +2653,16 @@ NS_PTR_TO_INT32(frame->Properties().Get(
   // This does not alter the overflow area. If the caller is changing
   // the box size, the caller is responsible for updating the overflow
   // area. It's enough to just call Layout or SyncLayout on the
   // box. You can pass true to aRemoveOverflowArea as a
   // convenience.
   virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
                          bool aRemoveOverflowAreas = false) = 0;
   NS_HIDDEN_(nsresult) Layout(nsBoxLayoutState& aBoxLayoutState);
-  nsIFrame* GetChildBox() const
-  {
-    // box layout ends at box-wrapped frames, so don't allow these frames
-    // to report child boxes.
-    return IsBoxFrame() ? GetFirstPrincipalChild() : nullptr;
-  }
-  nsIFrame* GetNextBox() const
-  {
-    return (mParent && mParent->IsBoxFrame()) ? mNextSibling : nullptr;
-  }
-  nsIFrame* GetParentBox() const
-  {
-    return (mParent && mParent->IsBoxFrame()) ? mParent : nullptr;
-  }
   // Box methods.  Note that these do NOT just get the CSS border, padding,
   // etc.  They also talk to nsITheme.
   virtual nsresult GetBorderAndPadding(nsMargin& aBorderAndPadding);
   virtual nsresult GetBorder(nsMargin& aBorder)=0;
   virtual nsresult GetPadding(nsMargin& aBorderAndPadding)=0;
   virtual nsresult GetMargin(nsMargin& aMargin)=0;
   virtual void SetLayoutManager(nsBoxLayout* aLayout) { }
   virtual nsBoxLayout* GetLayoutManager() { return nullptr; }
--- a/layout/xul/grid/nsGrid.cpp
+++ b/layout/xul/grid/nsGrid.cpp
@@ -250,17 +250,17 @@ nsGrid::FindRowsAndColumns(nsIFrame** aR
 {
   *aRows = nullptr;
   *aColumns = nullptr;
 
   // find the boxes that contain our rows and columns
   nsIFrame* child = nullptr;
   // if we have <grid></grid> then mBox will be null (bug 125689)
   if (mBox)
-    child = mBox->GetChildBox();
+    child = nsBox::GetChildBox(mBox);
 
   while(child)
   {
     nsIFrame* oldBox = child;
     nsIScrollableFrame *scrollFrame = do_QueryFrame(child);
     if (scrollFrame) {
        nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
        NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
@@ -282,17 +282,17 @@ nsGrid::FindRowsAndColumns(nsIFrame** aR
            return;
       }
     }
 
     if (scrollFrame) {
       child = oldBox;
     }
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 }
 
 /**
  * Count the number of rows and columns in the given box. aRowCount well become the actual number
  * rows defined in the xul. aComputedColumnCount will become the number of columns by counting the number
  * of cells in each row.
  */
@@ -414,17 +414,17 @@ nsGrid::PopulateCellMap(nsGridRow* aRows
      nsGridRow* row = &aRows[i];
 
      // skip bogus rows. They have no cells
      if (row->mIsBogus) 
        continue;
 
      child = row->mBox;
      if (child) {
-       child = child->GetChildBox();
+       child = nsBox::GetChildBox(child);
 
        j = 0;
 
        while(child && j < aColumnCount)
        {
          // skip bogus column. They have no cells
          nsGridRow* column = &aColumns[j];
          if (column->mIsBogus) 
@@ -433,17 +433,17 @@ nsGrid::PopulateCellMap(nsGridRow* aRows
            continue;
          }
 
          if (aIsHorizontal)
            GetCellAt(j,i)->SetBoxInRow(child);
          else
            GetCellAt(i,j)->SetBoxInColumn(child);
 
-         child = child->GetNextBox();
+         child = nsBox::GetNextBox(child);
 
          j++;
        }
      }
   }
 }
 
 /**
@@ -1110,23 +1110,23 @@ nsGrid::GetRowFlex(nsBoxLayoutState& aSt
     //   </rows>
     // </grid>
 
     // so the answer is simple: 1) Walk our parent chain. 2) If we find
     // someone who is not flexible and they aren't the rows immediately in
     // the grid. 3) Then we are not flexible
 
     box = GetScrollBox(box);
-    nsIFrame* parent = box->GetParentBox();
+    nsIFrame* parent = nsBox::GetParentBox(box);
     nsIFrame* parentsParent=nullptr;
 
     while(parent)
     {
       parent = GetScrollBox(parent);
-      parentsParent = parent->GetParentBox();
+      parentsParent = nsBox::GetParentBox(parent);
 
       // if our parents parent is not a grid
       // the get its flex. If its 0 then we are
       // not flexible.
       if (parentsParent) {
         if (!IsGrid(parentsParent)) {
           nscoord flex = parent->GetFlex(aState);
           nsIFrame::AddCSSFlex(aState, parent, flex);
@@ -1243,34 +1243,34 @@ nsGrid::GetScrolledBox(nsIFrame* aChild)
  */
 nsIFrame*
 nsGrid::GetScrollBox(nsIFrame* aChild)
 {
   if (!aChild)
     return nullptr;
 
   // get parent
-  nsIFrame* parent = aChild->GetParentBox();
+  nsIFrame* parent = nsBox::GetParentBox(aChild);
 
   // walk up until we find a scrollframe or a part
   // if it's a scrollframe return it.
   // if it's a parent then the child passed does not
   // have a scroll frame immediately wrapped around it.
   while (parent) {
     nsIScrollableFrame *scrollFrame = do_QueryFrame(parent);
     // scrollframe? Yep return it.
     if (scrollFrame)
       return parent;
 
     nsCOMPtr<nsIGridPart> parentGridRow = GetPartFromBox(parent);
     // if a part then just return the child
     if (parentGridRow) 
       break;
 
-    parent = parent->GetParentBox();
+    parent = nsBox::GetParentBox(parent);
   }
 
   return aChild;
 }
 
 
 
 #ifdef DEBUG_grid
--- a/layout/xul/grid/nsGridRowGroupFrame.cpp
+++ b/layout/xul/grid/nsGridRowGroupFrame.cpp
@@ -43,21 +43,21 @@ nsGridRowGroupFrame::GetFlex(nsBoxLayout
   if (!DoesNeedRecalc(mFlex))
      return mFlex;
 
   if (nsBoxFrame::GetFlex(aState) == 0)
     return 0;
 
   // ok we are flexible add up our children
   nscoord totalFlex = 0;
-  nsIFrame* child = GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(this);
   while (child)
   {
     totalFlex += child->GetFlex(aState);
-    child = child->GetNextBox();
+    child = GetNextBox(child);
   }
 
   mFlex = totalFlex;
 
   return totalFlex;
 }
 
 
--- a/layout/xul/grid/nsGridRowGroupLayout.cpp
+++ b/layout/xul/grid/nsGridRowGroupLayout.cpp
@@ -13,16 +13,17 @@
 
 /*
  * The nsGridRowGroupLayout implements the <rows> or <columns> tag in a grid. 
  */
 
 #include "nsGridRowGroupLayout.h"
 #include "nsCOMPtr.h"
 #include "nsIScrollableFrame.h"
+#include "nsBox.h"
 #include "nsBoxLayoutState.h"
 #include "nsGridLayout2.h"
 #include "nsGridRow.h"
 #include "nsHTMLReflowState.h"
 
 already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout()
 {
   nsRefPtr<nsBoxLayout> layout = new nsGridRowGroupLayout();
@@ -151,56 +152,56 @@ void
 nsGridRowGroupLayout::DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   if (aBox) {
     // mark us dirty
     // XXXldb We probably don't want to walk up the ancestor chain
     // calling MarkIntrinsicWidthsDirty for every row group.
     aState.PresShell()->FrameNeedsReflow(aBox, nsIPresShell::eTreeChange,
                                          NS_FRAME_IS_DIRTY);
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     while(child) {
 
       // walk into scrollframes
       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       // walk into other monuments
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) 
         monument->DirtyRows(deepChild, aState);
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
     }
   }
 }
 
 
 void
 nsGridRowGroupLayout::CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)
 {
   if (aBox) {
     int32_t startCount = aRowCount;
 
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     while(child) {
       
       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) {
         monument->CountRowsColumns(deepChild, aRowCount, aComputedColumnCount);
-        child = child->GetNextBox();
+        child = nsBox::GetNextBox(child);
         deepChild = child;
         continue;
       }
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
 
       // if not a monument. Then count it. It will be a bogus row
       aRowCount++;
     }
 
     mRowCount = aRowCount - startCount;
   }
 }
@@ -210,34 +211,34 @@ nsGridRowGroupLayout::CountRowsColumns(n
  * Fill out the given row structure recursively
  */
 int32_t 
 nsGridRowGroupLayout::BuildRows(nsIFrame* aBox, nsGridRow* aRows)
 { 
   int32_t rowCount = 0;
 
   if (aBox) {
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     while(child) {
       
       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
       nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) {
         rowCount += monument->BuildRows(deepChild, &aRows[rowCount]);
-        child = child->GetNextBox();
+        child = nsBox::GetNextBox(child);
         deepChild = child;
         continue;
       }
 
       aRows[rowCount].Init(child, true);
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
 
       // if not a monument. Then count it. It will be a bogus row
       rowCount++;
     }
   }
 
   return rowCount;
 }
--- a/layout/xul/grid/nsGridRowLayout.cpp
+++ b/layout/xul/grid/nsGridRowLayout.cpp
@@ -55,17 +55,17 @@ nsGridRowLayout::GetParentGridPart(nsIFr
   // parents.
   *aParentBox = nullptr;
   
   // walk up through any scrollboxes
   aBox = nsGrid::GetScrollBox(aBox);
 
   // get the parent
   if (aBox)
-    aBox = aBox->GetParentBox();
+    aBox = nsBox::GetParentBox(aBox);
 
   if (aBox)
   {
     nsIGridPart* parentGridRow = nsGrid::GetPartFromBox(aBox);
     if (parentGridRow && parentGridRow->CanContain(this)) {
       *aParentBox = aBox;
       return parentGridRow;
     }
@@ -84,17 +84,17 @@ nsGridRowLayout::GetGrid(nsIFrame* aBox,
       nsIFrame* parentBox; // nsIFrame is implemented by nsIFrame and is not refcounted.
       nsIGridPart* parent = GetParentGridPart(aBox, &parentBox);
       if (parent)
          return parent->GetGrid(parentBox, aIndex, this);
       return nullptr;
    }
 
    int32_t index = -1;
-   nsIFrame* child = aBox->GetChildBox();
+   nsIFrame* child = nsBox::GetChildBox(aBox);
    int32_t count = 0;
    while(child)
    {
      // if there is a scrollframe walk inside it to its child
      nsIFrame* childBox = nsGrid::GetScrolledBox(child);
 
      nsBoxLayout* layout = childBox->GetLayoutManager();
      nsIGridPart* gridRow = nsGrid::GetPartFromBox(childBox);
@@ -103,17 +103,17 @@ nsGridRowLayout::GetGrid(nsIFrame* aBox,
        if (layout == aRequestor) {
           index = count;
           break;
        }
        count += gridRow->GetRowCount();
      } else 
        count++;
 
-     child = child->GetNextBox();
+     child = nsBox::GetNextBox(child);
    }
 
    // if we didn't find ourselves then the tree isn't properly formed yet
    // this could happen during initial construction so lets just
    // fail.
    if (index == -1) {
      *aIndex = -1;
      return nullptr;
@@ -138,20 +138,20 @@ nsGridRowLayout::GetTotalMargin(nsIFrame
   nsIGridPart* part = GetParentGridPart(aBox, &parent);
   if (part && parent) {
     // if we are the first or last child walk upward and add margins.
 
     // make sure we check for a scrollbox
     aBox = nsGrid::GetScrollBox(aBox);
 
     // see if we have a next to see if we are last
-    nsIFrame* next = aBox->GetNextBox();
+    nsIFrame* next = nsBox::GetNextBox(aBox);
 
     // get the parent first child to see if we are first
-    nsIFrame* child = parent->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(parent);
 
     margin = part->GetTotalMargin(parent, aIsHorizontal);
 
     // if first or last
     if (child == aBox || next == nullptr) {
 
        // if it's not the first child remove the top margin
        // we don't need it.
--- a/layout/xul/grid/nsGridRowLeafLayout.cpp
+++ b/layout/xul/grid/nsGridRowLeafLayout.cpp
@@ -109,17 +109,17 @@ nsGridRowLeafLayout::PopulateBoxSizes(ns
   // If we are a row lets change the sizes to match our columns. If we are a column then do the opposite
   // and make them match or rows.
   if (grid) {
     nsGridRow* column;
     int32_t count = grid->GetColumnCount(isHorizontal); 
     nsBoxSize* start = nullptr;
     nsBoxSize* last = nullptr;
     nsBoxSize* current = nullptr;
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
     for (int i=0; i < count; i++)
     {
       column = grid->GetColumnAt(i,isHorizontal); 
 
       // make sure the value was computed before we use it.
       // !isHorizontal is passed in to invert the behavior of these methods.
       nscoord pref =
         grid->GetPrefRowHeight(aState, i, !isHorizontal); // GetPrefColumnWidth
@@ -201,17 +201,17 @@ nsGridRowLeafLayout::PopulateBoxSizes(ns
         start = current;
         last = start;
       } else {
         last->next = current;
         last = current;
       }
 
       if (child && !column->mIsBogus)
-        child = child->GetNextBox();
+        child = nsBox::GetNextBox(child);
 
     }
     aBoxSizes = start;
   }
 
   nsSprocketLayout::PopulateBoxSizes(aBox, aState, aBoxSizes, aMinSize, aMaxSize, aFlexes);
 }
 
@@ -294,22 +294,22 @@ nsGridRowLeafLayout::DirtyRows(nsIFrame*
                                          NS_FRAME_IS_DIRTY);
   }
 }
 
 void
 nsGridRowLeafLayout::CountRowsColumns(nsIFrame* aBox, int32_t& aRowCount, int32_t& aComputedColumnCount)
 {
   if (aBox) {
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     // count the children
     int32_t columnCount = 0;
     while(child) {
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
       columnCount++;
     }
 
     // if our count is greater than the current column count
     if (columnCount > aComputedColumnCount) 
       aComputedColumnCount = columnCount;
 
     aRowCount++;
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -134,17 +134,17 @@ nsBox::BeginLayout(nsBoxLayoutState& aSt
   // XXXldb Is this still needed?
   mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
 
   if (GetStateBits() & NS_FRAME_IS_DIRTY)
   {
     // If the parent is dirty, all the children are dirty (nsHTMLReflowState
     // does this too).
     nsIFrame* box;
-    for (box = GetChildBox(); box; box = box->GetNextBox())
+    for (box = GetChildBox(this); box; box = GetNextBox(box))
       box->AddStateBits(NS_FRAME_IS_DIRTY);
   }
 
   // Another copy-over from nsHTMLReflowState.
   // Since we are in reflow, we don't need to store these properties anymore.
   FrameProperties props = Properties();
   props.Delete(UsedBorderProperty());
   props.Delete(UsedPaddingProperty());
@@ -920,42 +920,64 @@ nsBox::BoundsCheckMinMax(const nsSize& a
 
 nsSize
 nsBox::BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize)
 {
   return nsSize(BoundsCheck(aMinSize.width, aPrefSize.width, aMaxSize.width),
                 BoundsCheck(aMinSize.height, aPrefSize.height, aMaxSize.height));
 }
 
+/*static*/ nsIFrame*
+nsBox::GetChildBox(const nsIFrame* aFrame)
+{
+  // box layout ends at box-wrapped frames, so don't allow these frames
+  // to report child boxes.
+  return aFrame->IsBoxFrame() ? aFrame->GetFirstPrincipalChild() : nullptr;
+}
+
+/*static*/ nsIFrame*
+nsBox::GetNextBox(const nsIFrame* aFrame)
+{
+  return aFrame->GetParent() &&
+    aFrame->GetParent()->IsBoxFrame() ? aFrame->GetNextSibling() : nullptr;
+}
+
+/*static*/ nsIFrame*
+nsBox::GetParentBox(const nsIFrame* aFrame)
+{
+  return aFrame->GetParent() &&
+    aFrame->GetParent()->IsBoxFrame() ? aFrame->GetParent() : nullptr;
+}
+
 #ifdef DEBUG_LAYOUT
 nsresult
 nsBox::SetDebug(nsBoxLayoutState& aState, bool aDebug)
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBox::GetDebugBoxAt( const nsPoint& aPoint,
                       nsIFrame**     aBox)
 {
   nsRect thisRect(nsPoint(0,0), GetSize());
   if (!thisRect.Contains(aPoint))
     return NS_ERROR_FAILURE;
 
-  nsIFrame* child = GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(this);
   nsIFrame* hit = nullptr;
 
   *aBox = nullptr;
   while (nullptr != child) {
     nsresult rv = child->GetDebugBoxAt(aPoint - child->GetOffsetTo(this), &hit);
 
     if (NS_SUCCEEDED(rv) && hit) {
       *aBox = hit;
     }
-    child = child->GetNextBox();
+    child = GetNextBox(child);
   }
 
   // found a child
   if (*aBox) {
     return NS_OK;
   }
 
   return NS_ERROR_FAILURE;
--- a/layout/xul/nsBox.h
+++ b/layout/xul/nsBox.h
@@ -72,16 +72,20 @@ rollbox.
   static void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
   static void AddMargin(nsIFrame* aChild, nsSize& aSize);
   static void AddMargin(nsSize& aSize, const nsMargin& aMargin);
 
   static nsSize BoundsCheckMinMax(const nsSize& aMinSize, const nsSize& aMaxSize);
   static nsSize BoundsCheck(const nsSize& aMinSize, const nsSize& aPrefSize, const nsSize& aMaxSize);
   static nscoord BoundsCheck(nscoord aMinSize, nscoord aPrefSize, nscoord aMaxSize);
 
+  static nsIFrame* GetChildBox(const nsIFrame* aFrame);
+  static nsIFrame* GetNextBox(const nsIFrame* aFrame);
+  static nsIFrame* GetParentBox(const nsIFrame* aFrame);
+
 protected:
 
 #ifdef DEBUG_LAYOUT
   virtual void AppendAttribute(const nsAutoString& aAttribute, const nsAutoString& aValue, nsAutoString& aResult);
 
   virtual void ListBox(nsAutoString& aResult);
 #endif
   
--- a/layout/xul/nsBoxFrame.cpp
+++ b/layout/xul/nsBoxFrame.cpp
@@ -1220,17 +1220,17 @@ nsBoxFrame::AttributeChanged(int32_t aNa
       UpdateMouseThrough();
     }
 
     PresContext()->PresShell()->
       FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
   }
   else if (aAttribute == nsGkAtoms::ordinal) {
     nsBoxLayoutState state(PresContext());
-    nsIFrame* parent = GetParentBox();
+    nsIFrame* parent = GetParentBox(this);
     // If our parent is not a box, there's not much we can do... but in that
     // case our ordinal doesn't matter anyway, so that's ok.
     // Also don't bother with popup frames since they are kept on the 
     // kPopupList and RelayoutChildAtOrdinal() only handles
     // principal children.
     if (parent && !(GetStateBits() & NS_FRAME_OUT_OF_FLOW) &&
         StyleDisplay()->mDisplay != NS_STYLE_DISPLAY_POPUP) {
       parent->RelayoutChildAtOrdinal(state, this);
@@ -1473,17 +1473,17 @@ nsBoxFrame::PaintXULDebugOverlay(nsRende
 
   nsRect inner(mRect);
   inner.MoveTo(aPt);
   inner.Deflate(debugMargin);
   inner.Deflate(border);
 
   nscoord onePixel = GetPresContext()->IntScaledPixelsToTwips(1);
 
-  kid = GetChildBox();
+  kid = nsBox::GetChildBox(this);
   while (nullptr != kid) {
     bool isHorizontal = IsHorizontal();
 
     nscoord x, y, borderSize, spacerSize;
     
     nsRect cr(kid->mRect);
     nsMargin margin;
     kid->GetMargin(margin);
@@ -1511,17 +1511,17 @@ nsBoxFrame::PaintXULDebugOverlay(nsRende
       if (isHorizontal) 
           borderSize = cr.width;
       else 
           borderSize = cr.height;
     
       DrawSpacer(GetPresContext(), aRenderingContext, isHorizontal, flex, x, y, borderSize, spacerSize);
     }
 
-    kid = kid->GetNextBox();
+    kid = GetNextBox(kid);
   }
 }
 #endif
 
 #ifdef DEBUG_LAYOUT
 void
 nsBoxFrame::GetBoxName(nsAutoString& aName)
 {
@@ -1728,17 +1728,17 @@ nsBoxFrame::DisplayDebugInfoFor(nsIFrame
     bool isHorizontal = IsHorizontal();
 
     if (!insideBorder.Contains(nsPoint(x,y)))
         return NS_ERROR_FAILURE;
 
     //printf("%%%%%% inside box %%%%%%%\n");
 
     int count = 0;
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     nsMargin m;
     nsMargin m2;
     GetDebugBorder(m);
     PixelMarginToTwips(aPresContext, m);
 
     GetDebugMargin(m2);
     PixelMarginToTwips(aPresContext, m2);
@@ -1817,35 +1817,35 @@ nsBoxFrame::DisplayDebugInfoFor(nsIFrame
                         calc,
                         flex,
                         ascent
                     );
 
                     return NS_OK;   
             }
 
-          child = child->GetNextBox();
+          child = GetNextBox(child);
           count++;
         }
     } else {
     }
 
     mDebugChild = nullptr;
 
     return NS_OK;
 }
 
 void
 nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug)
 {
-    nsIFrame* child = GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(this);
      while (child)
      {
         child->SetDebug(aState, aDebug);
-        child = child->GetNextBox();
+        child = GetNextBox(child);
      }
 }
 
 nsresult
 nsBoxFrame::GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize)
 {
   nsRect rect(aBox->GetRect());
   nsMargin margin(0,0,0,0);
@@ -1952,17 +1952,17 @@ nsBoxFrame::RelayoutChildAtOrdinal(nsBox
     if (ord < child->GetOrdinal()) {
       break;
     }
 
     if (child != aChild) {
       newPrevSib = child;
     }
 
-    child = child->GetNextBox();
+    child = GetNextBox(child);
   }
 
   if (aChild->GetPrevSibling() == newPrevSib) {
     // This box is not moving.
     return NS_OK;
   }
 
   // Take |aChild| out of its old position in the child list.
--- a/layout/xul/nsDeckFrame.cpp
+++ b/layout/xul/nsDeckFrame.cpp
@@ -177,26 +177,26 @@ nsDeckFrame::DoLayout(nsBoxLayoutState& 
   // We will do that.
   uint32_t oldFlags = aState.LayoutFlags();
   aState.SetLayoutFlags(NS_FRAME_NO_SIZE_VIEW | NS_FRAME_NO_VISIBILITY);
 
   // do a normal layout
   nsresult rv = nsBoxFrame::DoLayout(aState);
 
   // run though each child. Hide all but the selected one
-  nsIFrame* box = GetChildBox();
+  nsIFrame* box = nsBox::GetChildBox(this);
 
   nscoord count = 0;
   while (box) 
   {
     // make collapsed children not show up
     if (count != mIndex) 
       HideBox(box);
 
-    box = box->GetNextBox();
+    box = GetNextBox(box);
     count++;
   }
 
   aState.SetLayoutFlags(oldFlags);
 
   return rv;
 }
 
--- a/layout/xul/nsGroupBoxFrame.cpp
+++ b/layout/xul/nsGroupBoxFrame.cpp
@@ -203,31 +203,31 @@ nsGroupBoxFrame::PaintBorderBackground(n
                                 mStyleContext, skipSides);
   }
 }
 
 nsIFrame*
 nsGroupBoxFrame::GetCaptionBox(nsPresContext* aPresContext, nsRect& aCaptionRect)
 {
     // first child is our grouped area
-    nsIFrame* box = GetChildBox();
+    nsIFrame* box = nsBox::GetChildBox(this);
 
     // no area fail.
     if (!box)
       return nullptr;
 
     // get the first child in the grouped area, that is the caption
-    box = box->GetChildBox();
+    box = nsBox::GetChildBox(box);
 
     // nothing in the area? fail
     if (!box)
       return nullptr;
 
     // now get the caption itself. It is in the caption frame.
-    nsIFrame* child = box->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(box);
 
     if (child) {
        // convert to our coordinates.
        nsRect parentRect(box->GetRect());
        aCaptionRect = child->GetRect();
        aCaptionRect.x += parentRect.x;
        aCaptionRect.y += parentRect.y;
     }
--- a/layout/xul/nsListBoxLayout.cpp
+++ b/layout/xul/nsListBoxLayout.cpp
@@ -131,17 +131,17 @@ nsListBoxLayout::LayoutInternal(nsIFrame
     bool fixed = (body->GetFixedRowSize() != -1);
     if (fixed)
       availableHeight = 10;
     else
       return NS_OK;
   }
 
   // run through all our currently created children
-  nsIFrame* box = body->GetChildBox();
+  nsIFrame* box = nsBox::GetChildBox(body);
 
   // if the reason is resize or initial we must relayout.
   nscoord rowHeight = body->GetRowHeightAppUnits();
 
   while (box) {
     // If this box is dirty or if it has dirty children, we
     // call layout on it.
     nsRect childRect(box->GetRect());
@@ -180,17 +180,17 @@ nsListBoxLayout::LayoutInternal(nsIFrame
 
     // Ok now the available size gets smaller and we move the
     // starting position of the next child down some.
     nscoord size = childRect.height + margin.top + margin.bottom;
 
     yOffset += size;
     availableHeight -= size;
     
-    box = box->GetNextBox();
+    box = nsBox::GetNextBox(box);
   }
   
   // We have enough available height left to add some more rows
   // Since we can't do this during layout, we post a callback
   // that will be processed after the reflow completes.
   body->PostReflowCallback();
     
   // if rows were pushed down or pulled up because some rows were added
--- a/layout/xul/nsMenuPopupFrame.cpp
+++ b/layout/xul/nsMenuPopupFrame.cpp
@@ -401,17 +401,17 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayou
     if (!shouldPosition && !aSizedToPopup) {
       RemoveStateBits(NS_FRAME_FIRST_REFLOW);
       return;
     }
   }
 
   // if the popup has just been opened, make sure the scrolled window is at 0,0
   if (mIsOpenChanged) {
-    nsIScrollableFrame *scrollframe = do_QueryFrame(GetChildBox());
+    nsIScrollableFrame *scrollframe = do_QueryFrame(nsBox::GetChildBox(this));
     if (scrollframe) {
       nsWeakFrame weakFrame(this);
       scrollframe->ScrollTo(nsPoint(0,0), nsIScrollableFrame::INSTANT);
       if (!weakFrame.IsAlive()) {
         return;
       }
     }
   }
--- a/layout/xul/nsScrollBoxObject.cpp
+++ b/layout/xul/nsScrollBoxObject.cpp
@@ -5,17 +5,17 @@
 
 #include "nsCOMPtr.h"
 #include "nsIScrollBoxObject.h"
 #include "nsBoxObject.h"
 #include "nsIPresShell.h"
 #include "nsIContent.h"
 #include "nsIDOMElement.h"
 #include "nsPresContext.h"
-#include "nsIFrame.h"
+#include "nsBox.h"
 #include "nsIScrollableFrame.h"
 
 using namespace mozilla;
 
 class nsScrollBoxObject : public nsIScrollBoxObject, public nsBoxObject
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
@@ -96,33 +96,33 @@ static nsIFrame* GetScrolledBox(nsBoxObj
   nsIScrollableFrame* scrollFrame = do_QueryFrame(frame);
   if (!scrollFrame) {
     NS_WARNING("nsIScrollBoxObject attached to something that's not a scroll frame!");
     return nullptr;
   }
   nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
   if (!scrolledFrame)
     return nullptr;
-  return scrolledFrame->GetChildBox();
+  return nsBox::GetChildBox(scrolledFrame);
 }
 
 /* void scrollByIndex (in long dindexes); */
 NS_IMETHODIMP nsScrollBoxObject::ScrollByIndex(int32_t dindexes)
 {
     nsIScrollableFrame* sf = GetScrollFrame();
     if (!sf)
        return NS_ERROR_FAILURE;
     nsIFrame* scrolledBox = GetScrolledBox(this);
     if (!scrolledBox)
        return NS_ERROR_FAILURE;
 
     nsRect rect;
 
     // now get the scrolled boxes first child.
-    nsIFrame* child = scrolledBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(scrolledBox);
 
     bool horiz = scrolledBox->IsHorizontal();
     nsPoint cp = sf->GetScrollPosition();
     nscoord diff = 0;
     int32_t curIndex = 0;
     bool isLTR = scrolledBox->IsNormalDirection();
 
     int32_t frameWidth = 0;
@@ -151,44 +151,44 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollB
           break;
         }
       } else {
         diff = rect.y + rect.height/2;// use the center, to avoid rounding errors
         if (diff > cp.y) {
           break;
         }
       }
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
       curIndex++;
     }
 
     int32_t count = 0;
 
     if (dindexes == 0)
        return NS_OK;
 
     if (dindexes > 0) {
       while(child) {
-        child = child->GetNextBox();
+        child = nsBox::GetNextBox(child);
         if (child)
           rect = child->GetRect();
         count++;
         if (count >= dindexes)
           break;
       }
 
    } else if (dindexes < 0) {
-      child = scrolledBox->GetChildBox();
+      child = nsBox::GetChildBox(scrolledBox);
       while(child) {
         rect = child->GetRect();
         if (count >= curIndex + dindexes)
           break;
 
         count++;
-        child = child->GetNextBox();
+        child = nsBox::GetNextBox(child);
 
       }
    }
 
    nscoord csspixel = nsPresContext::CSSPixelsToAppUnits(1);
    if (horiz) {
        // In the left-to-right case we scroll so that the left edge of the
        // selected child is scrolled to the left edge of the scrollbox.
--- a/layout/xul/nsSliderFrame.cpp
+++ b/layout/xul/nsSliderFrame.cpp
@@ -298,17 +298,17 @@ nsSliderFrame::BuildDisplayList(nsDispla
 }
 
 void
 nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                            const nsRect&           aDirtyRect,
                                            const nsDisplayListSet& aLists)
 {
   // if we are too small to have a thumb don't paint it.
-  nsIFrame* thumb = GetChildBox();
+  nsIFrame* thumb = nsBox::GetChildBox(this);
 
   if (thumb) {
     nsRect thumbRect(thumb->GetRect());
     nsMargin m;
     thumb->GetMargin(m);
     thumbRect.Inflate(m);
 
     nsRect crect;
@@ -320,17 +320,17 @@ nsSliderFrame::BuildDisplayListForChildr
   
   nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
 }
 
 NS_IMETHODIMP
 nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
 {
   // get the thumb should be our only child
-  nsIFrame* thumbBox = GetChildBox();
+  nsIFrame* thumbBox = nsBox::GetChildBox(this);
 
   if (!thumbBox) {
     SyncLayout(aState);
     return NS_OK;
   }
 
   EnsureOrient();
 
--- a/layout/xul/nsSplitterFrame.cpp
+++ b/layout/xul/nsSplitterFrame.cpp
@@ -300,28 +300,28 @@ nsSplitterFrame::Init(nsIContent*       
   mInner->mParentBox = nullptr;
 }
 
 NS_IMETHODIMP
 nsSplitterFrame::DoLayout(nsBoxLayoutState& aState)
 {
   if (GetStateBits() & NS_FRAME_FIRST_REFLOW) 
   {
-    mInner->mParentBox = GetParentBox();
+    mInner->mParentBox = nsBox::GetParentBox(this);
     mInner->UpdateState();
   }
 
   return nsBoxFrame::DoLayout(aState);
 }
 
 
 void
 nsSplitterFrame::GetInitialOrientation(bool& aIsHorizontal)
 {
-  nsIFrame* box = GetParentBox();
+  nsIFrame* box = nsBox::GetParentBox(this);
   if (box) {
     aIsHorizontal = !box->IsHorizontal();
   }
   else
     nsBoxFrame::GetInitialOrientation(aIsHorizontal);
 }
 
 NS_IMETHODIMP
@@ -609,17 +609,17 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
   if (button != 0)
      return NS_OK;
 
   if (mOuter->GetContent()->
         AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
                     nsGkAtoms::_true, eCaseMatters))
     return NS_OK;
 
-  mParentBox = mOuter->GetParentBox();
+  mParentBox = nsBox::GetParentBox(mOuter);
   if (!mParentBox)
     return NS_OK;
 
   // get our index
   nsPresContext* outerPresContext = mOuter->PresContext();
   const nsFrameList& siblingList(mParentBox->PrincipalChildList());
   int32_t childIndex = siblingList.IndexOf(mOuter);
   // if it's 0 (or not found) then stop right here.
@@ -651,17 +651,17 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
   mChildInfosBefore = new nsSplitterInfo[childCount];
   mChildInfosAfter  = new nsSplitterInfo[childCount];
 
   // create info 2 lists. One of the children before us and one after.
   int32_t count = 0;
   mChildInfosBeforeCount = 0;
   mChildInfosAfterCount = 0;
 
-  nsIFrame* childBox = mParentBox->GetChildBox();
+  nsIFrame* childBox = nsBox::GetChildBox(mParentBox);
 
   while (nullptr != childBox) 
   { 
     nsIContent* content = childBox->GetContent();
     nsIDocument* doc = content->OwnerDoc();
     int32_t dummy;
     nsIAtom* atom = doc->BindingManager()->ResolveTag(content, &dummy);
 
@@ -706,17 +706,17 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
                 mChildInfosAfter[mChildInfosAfterCount].flex    = flex;
                 mChildInfosAfter[mChildInfosAfterCount].index   = count;
                 mChildInfosAfter[mChildInfosAfterCount].changed = mChildInfosAfter[mChildInfosAfterCount].current;
                 mChildInfosAfterCount++;
             }
         } 
     }
     
-    childBox = childBox->GetNextBox();
+    childBox = nsBox::GetNextBox(childBox);
     count++;
   }
 
   if (!mParentBox->IsNormalDirection()) {
     // The before array is really the after array, and the order needs to be reversed.
     // First reverse both arrays.
     Reverse(mChildInfosBefore, mChildInfosBeforeCount);
     Reverse(mChildInfosAfter, mChildInfosAfterCount);
@@ -894,42 +894,42 @@ nsSplitterFrameInner::AdjustChildren(nsP
   bool isHorizontal = !mOuter->IsHorizontal();
 
   AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
   AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
 }
 
 static nsIFrame* GetChildBoxForContent(nsIFrame* aParentBox, nsIContent* aContent)
 {
-  nsIFrame* childBox = aParentBox->GetChildBox();
+  nsIFrame* childBox = nsBox::GetChildBox(aParentBox);
 
   while (nullptr != childBox) {
     if (childBox->GetContent() == aContent) {
       return childBox;
     }
-    childBox = childBox->GetNextBox();
+    childBox = nsBox::GetNextBox(childBox);
   }
   return nullptr;
 }
 
 void
 nsSplitterFrameInner::AdjustChildren(nsPresContext* aPresContext, nsSplitterInfo* aChildInfos, int32_t aCount, bool aIsHorizontal)
 {
   ///printf("------- AdjustChildren------\n");
 
   nsBoxLayoutState state(aPresContext);
 
   nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
 
   // first set all the widths.
-  nsIFrame* child =  mOuter->GetChildBox();
+  nsIFrame* child =  nsBox::GetChildBox(mOuter);
   while(child)
   {
     SetPreferredSize(state, child, onePixel, aIsHorizontal, nullptr);
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 
   // now set our changed widths.
   for (int i=0; i < aCount; i++) 
   {
     nscoord   pref       = aChildInfos[i].changed;
     nsIFrame* childBox     = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
 
--- a/layout/xul/nsSprocketLayout.cpp
+++ b/layout/xul/nsSprocketLayout.cpp
@@ -168,21 +168,21 @@ HandleBoxPack(nsIFrame* aBox, const nsFr
 }
 
 NS_IMETHODIMP
 nsSprocketLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   // See if we are collapsed. If we are, then simply iterate over all our
   // children and give them a rect of 0 width and height.
   if (aBox->IsCollapsed()) {
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
     while(child) 
     {
       nsBoxFrame::LayoutChildAt(aState, child, nsRect(0,0,0,0));  
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
     }
     return NS_OK;
   }
 
   nsBoxLayoutState::AutoReflowDepth depth(aState);
   mozilla::AutoStackArena arena;
 
   // ----- figure out our size ----------
@@ -297,17 +297,17 @@ nsSprocketLayout::Layout(nsIFrame* aBox,
     nscoord nextY = y;
 
     // Now we iterate over our box children and our box size lists in 
     // parallel.  For each child, we look at its sizes and figure out
     // where to place it.
     nsComputedBoxSize* childComputedBoxSize = computedBoxSizes;
     nsBoxSize* childBoxSize                 = boxSizes;
 
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     int32_t count = 0;
     while (child || (childBoxSize && childBoxSize->bogus))
     { 
       // If for some reason, our lists are not the same length, we guard
       // by bailing out of the loop.
       if (childBoxSize == nullptr) {
         NS_NOTREACHED("Lists not the same length.");
@@ -551,17 +551,17 @@ nsSprocketLayout::Layout(nsIFrame* aBox,
       // Now update our x/y finally.
       x = nextX;
       y = nextY;
      
       // Move to the next child.
       childComputedBoxSize = childComputedBoxSize->next;
       childBoxSize = childBoxSize->next;
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
       count++;
     }
 
     // Sanity-checking code to ensure we don't do an infinite # of passes.
     passes++;
     NS_ASSERTION(passes < 10, "A Box's child is constantly growing!!!!!");
     if (passes > 10)
       break;
@@ -606,26 +606,26 @@ nsSprocketLayout::Layout(nsIFrame* aBox,
   // Because our size grew, we now have to readjust because of box packing.  Repack
   // in order to update our x and y to the correct values.
   HandleBoxPack(aBox, frameState, x, y, originalClientRect, clientRect);
 
   // Compare against our original x and y and only worry about adjusting the children if
   // we really did have to change the positions because of packing (typically for 'center'
   // or 'end' pack values).
   if (x != origX || y != origY) {
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
 
     // reposition all our children
     while (child) 
     {
       nsRect childRect(child->GetRect());
       childRect.x += (x - origX);
       childRect.y += (y - origY);
       child->SetBounds(aState, childRect);
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
     }
   }
 
   // Perform out-of-axis alignment for non-stretch alignments
   if (!(frameState & NS_STATE_AUTO_STRETCH)) {
     AlignChildren(aBox, aState);
   }
   
@@ -663,17 +663,17 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
   // then it does not matter what its preferred size is
   // there is nothing to flex it relative. This is great
   // because we can avoid asking for a preferred size in this
   // case. Why is this good? Well you might have html inside it
   // and asking html for its preferred size is rather expensive.
   // so we can just optimize it out this way.
 
   // set flexes
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
 
   aFlexes = 0;
   nsBoxSize* currentBox = nullptr;
 
 #if 0
   nsBoxSize* start = aBoxSizes;
   
   while(child)
@@ -700,22 +700,22 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
     } else {
       flex = start->flex;
       start = start->next;
     }
     
     if (flex > 0) 
        aFlexes++;
    
-    child = child->GetNextBox();
+    child = GetNextBox(child);
   }
 #endif
 
   // get pref, min, max
-  child = aBox->GetChildBox();
+  child = nsBox::GetChildBox(aBox);
   currentBox = aBoxSizes;
   nsBoxSize* last = nullptr;
 
   nscoord maxFlex = 0;
   int32_t childCount = 0;
 
   while(child)
   {
@@ -824,17 +824,17 @@ nsSprocketLayout::PopulateBoxSizes(nsIFr
 
       if (maxSize.height < aMaxSize)
         aMaxSize = maxSize.height;
     }
 
     currentBox->collapsed = collapsed;
     aFlexes += currentBox->flex;
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
 
     last = currentBox;
     currentBox = currentBox->next;
 
   }
 
   if (childCount > 0) {
     nscoord maxAllowedFlex = nscoord_MAX / childCount;
@@ -931,17 +931,17 @@ nsSprocketLayout::AlignChildren(nsIFrame
     if (valign == nsBoxFrame::vAlign_BaseLine) {
       maxAscent = aBox->GetBoxAscent(aState);
     }
   } else {
     isLTR = GetFrameDirection(aBox) == NS_STYLE_DIRECTION_LTR;
     halign = aBox->GetHAlign();
   }
 
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
   while (child) {
 
     nsMargin margin;
     child->GetMargin(margin);
     nsRect childRect = child->GetRect();
 
     if (isHorizontal) {
       const nscoord startAlign = clientRect.y + margin.top;
@@ -992,17 +992,17 @@ nsSprocketLayout::AlignChildren(nsIFrame
 
       childRect.x = x;
     }
 
     if (childRect.TopLeft() != child->GetPosition()) {
       child->SetBounds(aState, childRect);
     }
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 }
 
 void
 nsSprocketLayout::ChildResized(nsIFrame* aBox,
                          nsBoxLayoutState& aState, 
                          nsIFrame* aChild,
                          nsBoxSize* aChildBoxSize,
@@ -1300,17 +1300,17 @@ nsSprocketLayout::GetPrefSize(nsIFrame* 
    nsSize vpref (0, 0); 
    bool isHorizontal = IsHorizontal(aBox);
 
    nscoord biggestPref = 0;
 
    // run through all the children and get their min, max, and preferred sizes
    // return us the size of the box
 
-   nsIFrame* child = aBox->GetChildBox();
+   nsIFrame* child = nsBox::GetChildBox(aBox);
    nsFrameState frameState = nsFrameState(0);
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    int32_t count = 0;
    
    while (child) 
    {  
       // ignore collapsed children
@@ -1329,17 +1329,17 @@ nsSprocketLayout::GetPrefSize(nsIFrame* 
               biggestPref = pref.height;
           }
         }
 
         AddLargestSize(vpref, pref, isHorizontal);
         count++;
       }
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
    }
 
    if (isEqual) {
       if (isHorizontal)
          vpref.width = biggestPref*count;
       else
          vpref.height = biggestPref*count;
    }
@@ -1357,17 +1357,17 @@ nsSprocketLayout::GetMinSize(nsIFrame* a
    bool isHorizontal = IsHorizontal(aBox);
 
    nscoord biggestMin = 0;
 
 
    // run through all the children and get their min, max, and preferred sizes
    // return us the size of the box
 
-   nsIFrame* child = aBox->GetChildBox();
+   nsIFrame* child = nsBox::GetChildBox(aBox);
    nsFrameState frameState = nsFrameState(0);
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    int32_t count = 0;
 
    while (child) 
    {  
        // ignore collapsed children
@@ -1397,17 +1397,17 @@ nsSprocketLayout::GetMinSize(nsIFrame* a
           }
         }
 
         AddMargin(child, min);
         AddLargestSize(minSize, min, isHorizontal);
         count++;
       }
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
    }
 
    
    if (isEqual) {
       if (isHorizontal)
          minSize.width = biggestMin*count;
       else
          minSize.height = biggestMin*count;
@@ -1426,17 +1426,17 @@ nsSprocketLayout::GetMaxSize(nsIFrame* a
   bool isHorizontal = IsHorizontal(aBox);
 
    nscoord smallestMax = NS_INTRINSICSIZE;
    nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
 
    // run through all the children and get their min, max, and preferred sizes
    // return us the size of the box
 
-   nsIFrame* child = aBox->GetChildBox();
+   nsIFrame* child = nsBox::GetChildBox(aBox);
    nsFrameState frameState = nsFrameState(0);
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    int32_t count = 0;
 
    while (child) 
    {  
       // ignore collapsed children
@@ -1457,17 +1457,17 @@ nsSprocketLayout::GetMaxSize(nsIFrame* a
           } else {
             if (max.height < smallestMax)
               smallestMax = max.height;
           }
         }
         count++;
       }
 
-      child = child->GetNextBox();
+      child = nsBox::GetNextBox(child);
    }
 
    if (isEqual) {
      if (isHorizontal) {
          if (smallestMax != NS_INTRINSICSIZE)
             maxSize.width = smallestMax*count;
          else
             maxSize.width = NS_INTRINSICSIZE;
@@ -1491,17 +1491,17 @@ nsSprocketLayout::GetAscent(nsIFrame* aB
 {
    nscoord vAscent = 0;
 
    bool isHorizontal = IsHorizontal(aBox);
 
    // run through all the children and get their min, max, and preferred sizes
    // return us the size of the box
    
-   nsIFrame* child = aBox->GetChildBox();
+   nsIFrame* child = nsBox::GetChildBox(aBox);
    
    while (child) 
    {  
       // ignore collapsed children
       //if (!child->IsCollapsed())
       //{
         // if completely redefined don't even ask our child for its size.
         nscoord ascent = child->GetBoxAscent(aState);
@@ -1515,17 +1515,17 @@ nsSprocketLayout::GetAscent(nsIFrame* aB
           if (ascent > vAscent)
             vAscent = ascent;
         } else {
           if (vAscent == 0)
             vAscent = ascent;
         }
       //}
 
-      child = child->GetNextBox();      
+      child = nsBox::GetNextBox(child);      
    }
 
    nsMargin borderPadding;
    aBox->GetBorderAndPadding(borderPadding);
 
    return vAscent + borderPadding.top;
 }
 
--- a/layout/xul/nsStackLayout.cpp
+++ b/layout/xul/nsStackLayout.cpp
@@ -58,108 +58,108 @@ nsStackLayout::nsStackLayout()
  * (the default) will be included in the size computations.
  */
 
 nsSize
 nsStackLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize prefSize (0, 0);
 
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
   while (child) {
     if (child->StyleXUL()->mStretchStack) {
       nsSize pref = child->GetPrefSize(aState);
 
       AddMargin(child, pref);
       nsMargin offset;
       GetOffset(aState, child, offset);
       pref.width += offset.LeftRight();
       pref.height += offset.TopBottom();
       AddLargestSize(prefSize, pref);
     }
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 
   AddBorderAndPadding(aBox, prefSize);
 
   return prefSize;
 }
 
 nsSize
 nsStackLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize minSize (0, 0);
 
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
   while (child) {
     if (child->StyleXUL()->mStretchStack) {
       nsSize min = child->GetMinSize(aState);
 
       AddMargin(child, min);
       nsMargin offset;
       GetOffset(aState, child, offset);
       min.width += offset.LeftRight();
       min.height += offset.TopBottom();
       AddLargestSize(minSize, min);
     }
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 
   AddBorderAndPadding(aBox, minSize);
 
   return minSize;
 }
 
 nsSize
 nsStackLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
 
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
   while (child) {
     if (child->StyleXUL()->mStretchStack) {
       nsSize min = child->GetMinSize(aState);
       nsSize max = child->GetMaxSize(aState);
 
       max = nsBox::BoundsCheckMinMax(min, max);
 
       AddMargin(child, max);
       nsMargin offset;
       GetOffset(aState, child, offset);
       max.width += offset.LeftRight();
       max.height += offset.TopBottom();
       AddSmallestSize(maxSize, max);
     }
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 
   AddBorderAndPadding(aBox, maxSize);
 
   return maxSize;
 }
 
 
 nscoord
 nsStackLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nscoord vAscent = 0;
 
-  nsIFrame* child = aBox->GetChildBox();
+  nsIFrame* child = nsBox::GetChildBox(aBox);
   while (child) {  
     nscoord ascent = child->GetBoxAscent(aState);
     nsMargin margin;
     child->GetMargin(margin);
     ascent += margin.top;
     if (ascent > vAscent)
       vAscent = ascent;
 
-    child = child->GetNextBox();
+    child = nsBox::GetNextBox(child);
   }
 
   return vAscent;
 }
 
 uint8_t
 nsStackLayout::GetOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsMargin& aOffset)
 {
@@ -255,17 +255,17 @@ NS_IMETHODIMP
 nsStackLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsRect clientRect;
   aBox->GetClientRect(clientRect);
 
   bool grow;
 
   do {
-    nsIFrame* child = aBox->GetChildBox();
+    nsIFrame* child = nsBox::GetChildBox(aBox);
     grow = false;
 
     while (child) 
     {  
       nsMargin margin;
       child->GetMargin(margin);
       nsRect childRect(clientRect);
       childRect.Deflate(margin);
@@ -352,17 +352,17 @@ nsStackLayout::Layout(nsIFrame* aBox, ns
 
             if (offset.TopBottom() + childRect.height > clientRect.height) {
               clientRect.height = childRect.height + offset.TopBottom();
               grow = true;
             }
           }
        }
 
-       child = child->GetNextBox();
+       child = nsBox::GetNextBox(child);
      }
    } while (grow);
    
    // if some HTML inside us got bigger we need to force ourselves to
    // get bigger
    nsRect bounds(aBox->GetRect());
    nsMargin bp;
    aBox->GetBorderAndPadding(bp);