[Bug 780439] Kill off the remains of nsIBox r=roc
authorDavid Zbarsky <dzbarsky@gmail.com>
Sun, 05 Aug 2012 23:00:57 -0400
changeset 101525 b398d42e2f116a73d2a19ee53be0c11c08191b68
parent 101524 3546da8a22abe4125baa5489545603a91dc18226
child 101526 8745c8473918aa1e882021d3306878a906377857
push id13030
push userdzbarsky@gmail.com
push dateMon, 06 Aug 2012 03:01:04 +0000
treeherdermozilla-inbound@b398d42e2f11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs780439
milestone17.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 780439] Kill off the remains of nsIBox r=roc
content/events/src/nsEventStateManager.h
layout/generic/nsFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
layout/generic/nsIFrame.h
layout/generic/nsIScrollableFrame.h
layout/xul/base/src/grid/nsGrid.cpp
layout/xul/base/src/grid/nsGrid.h
layout/xul/base/src/grid/nsGridCell.h
layout/xul/base/src/grid/nsGridLayout2.cpp
layout/xul/base/src/grid/nsGridLayout2.h
layout/xul/base/src/grid/nsGridRow.cpp
layout/xul/base/src/grid/nsGridRow.h
layout/xul/base/src/grid/nsGridRowGroupFrame.cpp
layout/xul/base/src/grid/nsGridRowGroupLayout.cpp
layout/xul/base/src/grid/nsGridRowGroupLayout.h
layout/xul/base/src/grid/nsGridRowLayout.cpp
layout/xul/base/src/grid/nsGridRowLayout.h
layout/xul/base/src/grid/nsGridRowLeafLayout.cpp
layout/xul/base/src/grid/nsGridRowLeafLayout.h
layout/xul/base/src/grid/nsIGridPart.h
layout/xul/base/src/nsBox.cpp
layout/xul/base/src/nsBox.h
layout/xul/base/src/nsBoxFrame.cpp
layout/xul/base/src/nsBoxFrame.h
layout/xul/base/src/nsBoxLayout.cpp
layout/xul/base/src/nsBoxLayout.h
layout/xul/base/src/nsDeckFrame.cpp
layout/xul/base/src/nsDeckFrame.h
layout/xul/base/src/nsGroupBoxFrame.cpp
layout/xul/base/src/nsImageBoxFrame.cpp
layout/xul/base/src/nsImageBoxFrame.h
layout/xul/base/src/nsListBoxBodyFrame.cpp
layout/xul/base/src/nsListBoxBodyFrame.h
layout/xul/base/src/nsListBoxLayout.cpp
layout/xul/base/src/nsListBoxLayout.h
layout/xul/base/src/nsListItemFrame.h
layout/xul/base/src/nsMenuFrame.cpp
layout/xul/base/src/nsMenuFrame.h
layout/xul/base/src/nsPopupSetFrame.h
layout/xul/base/src/nsSliderFrame.cpp
layout/xul/base/src/nsSliderFrame.h
layout/xul/base/src/nsSplitterFrame.cpp
layout/xul/base/src/nsSprocketLayout.cpp
layout/xul/base/src/nsSprocketLayout.h
layout/xul/base/src/nsStackLayout.cpp
layout/xul/base/src/nsStackLayout.h
layout/xul/base/src/nsTextBoxFrame.cpp
layout/xul/base/src/nsTextBoxFrame.h
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.h
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -20,16 +20,17 @@
 #include "nsCycleCollectionParticipant.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIScrollableFrame.h"
 #include "nsFocusManager.h"
 #include "nsIDocument.h"
 #include "nsEventStates.h"
 #include "mozilla/TimeStamp.h"
 #include "nsContentUtils.h"
+#include "nsIFrame.h"
 
 class nsIPresShell;
 class nsIDocShell;
 class nsIDocShellTreeNode;
 class nsIDocShellTreeItem;
 class imgIContainer;
 class nsDOMDataTransfer;
 class MouseEnterLeaveDispatcher;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -7610,17 +7610,17 @@ nsFrame::GetPrefSize(nsBoxLayoutState& a
     return metrics->mPrefSize;
   }
 
   if (IsCollapsed())
     return size;
 
   // get our size in CSS.
   bool widthSet, heightSet;
-  bool completelyRedefined = nsIBox::AddCSSPrefSize(this, size, widthSet, heightSet);
+  bool completelyRedefined = nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet);
 
   // Refresh our caches with new sizes.
   if (!completelyRedefined) {
     RefreshSizeCache(aState);
     nsSize blockSize = metrics->mBlockPrefSize;
 
     // notice we don't need to add our borders or padding
     // in. That's because the block did it for us.
@@ -7647,17 +7647,17 @@ nsFrame::GetMinSize(nsBoxLayoutState& aS
   }
 
   if (IsCollapsed())
     return size;
 
   // get our size in CSS.
   bool widthSet, heightSet;
   bool completelyRedefined =
-    nsIBox::AddCSSMinSize(aState, this, size, widthSet, heightSet);
+    nsIFrame::AddCSSMinSize(aState, this, size, widthSet, heightSet);
 
   // Refresh our caches with new sizes.
   if (!completelyRedefined) {
     RefreshSizeCache(aState);
     nsSize blockSize = metrics->mBlockMinSize;
 
     if (!widthSet)
       size.width = blockSize.width;
@@ -7810,17 +7810,17 @@ nsFrame::BoxReflow(nsBoxLayoutState&    
   printf("Reflowing: ");
   nsFrame::ListTag(stdout, mFrame);
   printf("\n");
   gIndent2++;
 #endif
 
   //printf("width=%d, height=%d\n", aWidth, aHeight);
   /*
-  nsIBox* parent;
+  nsIFrame* parent;
   GetParentBox(&parent);
 
  // if (parent->GetStateBits() & NS_STATE_CURRENTLY_IN_DEBUG)
   //   printf("In debug\n");
   */
 
   nsBoxLayoutMetrics *metrics = BoxMetrics();
   nsReflowStatus status = NS_FRAME_COMPLETE;
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -301,17 +301,17 @@ static nsSize ComputeInsideBorderSize(Sc
 
   contentWidth  = aState->mReflowState.ApplyMinMaxWidth(contentWidth);
   contentHeight = aState->mReflowState.ApplyMinMaxHeight(contentHeight);
   return nsSize(contentWidth + aState->mReflowState.mComputedPadding.LeftRight(),
                 contentHeight + aState->mReflowState.mComputedPadding.TopBottom());
 }
 
 static void
-GetScrollbarMetrics(nsBoxLayoutState& aState, nsIBox* aBox, nsSize* aMin,
+GetScrollbarMetrics(nsBoxLayoutState& aState, nsIFrame* aBox, nsSize* aMin,
                     nsSize* aPref, bool aVertical)
 {
   NS_ASSERTION(aState.GetRenderingContext(),
                "Must have rendering context in layout state for size "
                "computations");
   
   if (aMin) {
     *aMin = aBox->GetMinSize(aState);
@@ -1195,17 +1195,17 @@ nsXULScrollFrame::GetPrefSize(nsBoxLayou
       styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
     nsSize hSize = mInner.mHScrollbarBox->GetPrefSize(aState);
     nsBox::AddMargin(mInner.mHScrollbarBox, hSize);
     pref.height += hSize.height;
   }
 
   AddBorderAndPadding(pref);
   bool widthSet, heightSet;
-  nsIBox::AddCSSPrefSize(this, pref, widthSet, heightSet);
+  nsIFrame::AddCSSPrefSize(this, pref, widthSet, heightSet);
   return pref;
 }
 
 nsSize
 nsXULScrollFrame::GetMinSize(nsBoxLayoutState& aState)
 {
 #ifdef DEBUG_LAYOUT
   PropagateDebug(aState);
@@ -1230,32 +1230,32 @@ nsXULScrollFrame::GetMinSize(nsBoxLayout
      AddMargin(mInner.mHScrollbarBox, hSize);
      min.height += hSize.height;
      if (min.width < hSize.width)
         min.width = hSize.width;
   }
 
   AddBorderAndPadding(min);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMinSize(aState, this, min, widthSet, heightSet);
+  nsIFrame::AddCSSMinSize(aState, this, min, widthSet, heightSet);
   return min;
 }
 
 nsSize
 nsXULScrollFrame::GetMaxSize(nsBoxLayoutState& aState)
 {
 #ifdef DEBUG_LAYOUT
   PropagateDebug(aState);
 #endif
 
   nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
 
   AddBorderAndPadding(maxSize);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMaxSize(this, maxSize, widthSet, heightSet);
+  nsIFrame::AddCSSMaxSize(this, maxSize, widthSet, heightSet);
   return maxSize;
 }
 
 #ifdef DEBUG
 NS_IMETHODIMP
 nsXULScrollFrame::GetFrameName(nsAString& aResult) const
 {
   return MakeFrameName(NS_LITERAL_STRING("XULScroll"), aResult);
@@ -3947,31 +3947,31 @@ nsGfxScrollFrameInner::GetActualScrollba
   nsRect r = mOuter->GetPaddingRect() - mOuter->GetPosition();
 
   return nsMargin(mScrollPort.x - r.x, mScrollPort.y - r.y,
                   r.XMost() - mScrollPort.XMost(),
                   r.YMost() - mScrollPort.YMost());
 }
 
 void
-nsGfxScrollFrameInner::SetScrollbarVisibility(nsIBox* aScrollbar, bool aVisible)
+nsGfxScrollFrameInner::SetScrollbarVisibility(nsIFrame* aScrollbar, bool aVisible)
 {
   nsScrollbarFrame* scrollbar = do_QueryFrame(aScrollbar);
   if (scrollbar) {
     // See if we have a mediator.
     nsIScrollbarMediator* mediator = scrollbar->GetScrollbarMediator();
     if (mediator) {
       // Inform the mediator of the visibility change.
       mediator->VisibilityChanged(aVisible);
     }
   }
 }
 
 nscoord
-nsGfxScrollFrameInner::GetCoordAttribute(nsIBox* aBox, nsIAtom* aAtom,
+nsGfxScrollFrameInner::GetCoordAttribute(nsIFrame* aBox, nsIAtom* aAtom,
                                          nscoord aDefaultValue,
                                          nscoord* aRangeStart,
                                          nscoord* aRangeLength)
 {
   if (aBox) {
     nsIContent* content = aBox->GetContent();
 
     nsAutoString value;
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -117,17 +117,17 @@ public:
   };
 
   void FinishReflowForScrollbar(nsIContent* aContent, nscoord aMinXY,
                                 nscoord aMaxXY, nscoord aCurPosXY,
                                 nscoord aPageIncrement,
                                 nscoord aIncrement);
   static void SetScrollbarEnabled(nsIContent* aContent, nscoord aMaxPos);
   void SetCoordAttribute(nsIContent* aContent, nsIAtom* aAtom, nscoord aSize);
-  nscoord GetCoordAttribute(nsIBox* aFrame, nsIAtom* aAtom, nscoord aDefaultValue,
+  nscoord GetCoordAttribute(nsIFrame* aFrame, nsIAtom* aAtom, nscoord aDefaultValue,
                             nscoord* aRangeStart, nscoord* aRangeLength);
 
   // Update scrollbar curpos attributes to reflect current scroll position
   void UpdateScrollbarPosition();
 
   nsRect GetScrollPortRect() const { return mScrollPort; }
   nsPoint GetScrollPosition() const {
     return mScrollPort.TopLeft() - mScrolledFrame->GetPosition();
@@ -173,28 +173,28 @@ public:
   void ScrollToRestoredPosition();
   nsSize GetLineScrollAmount() const;
   nsSize GetPageScrollAmount() const;
 
   nsPresState* SaveState(nsIStatefulFrame::SpecialStateID aStateID);
   void RestoreState(nsPresState* aState);
 
   nsIFrame* GetScrolledFrame() const { return mScrolledFrame; }
-  nsIBox* GetScrollbarBox(bool aVertical) const {
+  nsIFrame* GetScrollbarBox(bool aVertical) const {
     return aVertical ? mVScrollbarBox : mHScrollbarBox;
   }
 
   void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
     mListeners.AppendElement(aListener);
   }
   void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
     mListeners.RemoveElement(aListener);
   }
 
-  static void SetScrollbarVisibility(nsIBox* aScrollbar, bool aVisible);
+  static void SetScrollbarVisibility(nsIFrame* aScrollbar, bool aVisible);
 
   /**
    * GetScrolledRect is designed to encapsulate deciding which
    * directions of overflow should be reachable by scrolling and which
    * should not.  Callers should NOT depend on it having any particular
    * behavior (although nsXULScrollFrame currently does).
    * 
    * This should only be called when the scrolled frame has been
@@ -260,21 +260,21 @@ public:
   nsCOMPtr<nsIContent> mHScrollbarContent;
   nsCOMPtr<nsIContent> mVScrollbarContent;
   nsCOMPtr<nsIContent> mScrollCornerContent;
   nsCOMPtr<nsIContent> mResizerContent;
 
   nsRevocableEventPtr<ScrollEvent> mScrollEvent;
   nsRevocableEventPtr<AsyncScrollPortEvent> mAsyncScrollPortEvent;
   nsRevocableEventPtr<ScrolledAreaEvent> mScrolledAreaEvent;
-  nsIBox* mHScrollbarBox;
-  nsIBox* mVScrollbarBox;
+  nsIFrame* mHScrollbarBox;
+  nsIFrame* mVScrollbarBox;
   nsIFrame* mScrolledFrame;
-  nsIBox* mScrollCornerBox;
-  nsIBox* mResizerBox;
+  nsIFrame* mScrollCornerBox;
+  nsIFrame* mResizerBox;
   nsContainerFrame* mOuter;
   nsRefPtr<AsyncScroll> mAsyncScroll;
   nsAutoPtr<mozilla::ScrollbarActivity> mScrollbarActivity;
   nsTArray<nsIScrollPositionListener*> mListeners;
   nsRect mScrollPort;
   // Where we're currently scrolling to, if we're scrolling asynchronously.
   // If we're not in the middle of an asynchronous scroll then this is
   // just the current scroll position. ScrollBy will choose its
@@ -488,17 +488,17 @@ public:
     mInner.ScrollToRestoredPosition();
   }
   virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
     mInner.AddScrollPositionListener(aListener);
   }
   virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
     mInner.RemoveScrollPositionListener(aListener);
   }
-  virtual nsIBox* GetScrollbarBox(bool aVertical) {
+  virtual nsIFrame* GetScrollbarBox(bool aVertical) {
     return mInner.GetScrollbarBox(aVertical);
   }
   virtual void CurPosAttributeChanged(nsIContent* aChild) {
     mInner.CurPosAttributeChanged(aChild);
   }
   NS_IMETHOD PostScrolledAreaEventForCurrentArea() {
     mInner.PostScrolledAreaEvent();
     return NS_OK;
@@ -733,17 +733,17 @@ public:
     mInner.ScrollToRestoredPosition();
   }
   virtual void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
     mInner.AddScrollPositionListener(aListener);
   }
   virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) {
     mInner.RemoveScrollPositionListener(aListener);
   }
-  virtual nsIBox* GetScrollbarBox(bool aVertical) {
+  virtual nsIFrame* GetScrollbarBox(bool aVertical) {
     return mInner.GetScrollbarBox(aVertical);
   }
   virtual void CurPosAttributeChanged(nsIContent* aChild) {
     mInner.CurPosAttributeChanged(aChild);
   }
   NS_IMETHOD PostScrolledAreaEventForCurrentArea() {
     mInner.PostScrolledAreaEvent();
     return NS_OK;
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -84,18 +84,16 @@ struct nsMargin;
 struct CharacterDataChangeInfo;
 
 namespace mozilla {
 namespace layers {
 class Layer;
 }
 }
 
-typedef class nsIFrame nsIBox;
-
 /**
  * Indication of how the frame can be split. This is used when doing runaround
  * of floats, and when pulling up child frames from a next-in-flow.
  *
  * The choices are splittable, not splittable at all, and splittable in
  * a non-rectangular fashion. This last type only applies to block-level
  * elements, and indicates whether splitting can be used when doing runaround.
  * If you can split across page boundaries, but you expect each continuing
@@ -2672,27 +2670,27 @@ 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);
-  nsIBox* GetChildBox() const
+  nsIFrame* GetChildBox() const
   {
     // box layout ends at box-wrapped frames, so don't allow these frames
     // to report child boxes.
     return IsBoxFrame() ? GetFirstPrincipalChild() : nullptr;
   }
-  nsIBox* GetNextBox() const
+  nsIFrame* GetNextBox() const
   {
     return (mParent && mParent->IsBoxFrame()) ? mNextSibling : nullptr;
   }
-  nsIBox* GetParentBox() const
+  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.
   NS_IMETHOD GetBorderAndPadding(nsMargin& aBorderAndPadding);
   NS_IMETHOD GetBorder(nsMargin& aBorder)=0;
   NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding)=0;
@@ -2704,38 +2702,38 @@ NS_PTR_TO_INT32(frame->Properties().Get(
   // For nsSprocketLayout
   virtual Valignment GetVAlign() const = 0;
   virtual Halignment GetHAlign() const = 0;
 
   bool IsHorizontal() const { return (mState & NS_STATE_IS_HORIZONTAL) != 0; }
   bool IsNormalDirection() const { return (mState & NS_STATE_IS_DIRECTION_NORMAL) != 0; }
 
   NS_HIDDEN_(nsresult) Redraw(nsBoxLayoutState& aState, const nsRect* aRect = nullptr);
-  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)=0;
+  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)=0;
   // XXX take this out after we've branched
   virtual bool GetMouseThrough() const { return false; }
 
 #ifdef DEBUG_LAYOUT
   NS_IMETHOD SetDebug(nsBoxLayoutState& aState, bool aDebug)=0;
   NS_IMETHOD GetDebug(bool& aDebug)=0;
 
   NS_IMETHOD DumpBox(FILE* out)=0;
 #endif
 
   /**
    * @return true if this text frame ends with a newline character.  It
    * should return false if this is not a text frame.
    */
   virtual bool HasTerminalNewline() const;
 
-  static bool AddCSSPrefSize(nsIBox* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
-  static bool AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox,
-                              nsSize& aSize, bool& aWidth, bool& aHeightSet);
-  static bool AddCSSMaxSize(nsIBox* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
-  static bool AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex);
+  static bool AddCSSPrefSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
+  static bool AddCSSMinSize(nsBoxLayoutState& aState, nsIFrame* aBox,
+                            nsSize& aSize, bool& aWidth, bool& aHeightSet);
+  static bool AddCSSMaxSize(nsIFrame* aBox, nsSize& aSize, bool& aWidth, bool& aHeightSet);
+  static bool AddCSSFlex(nsBoxLayoutState& aState, nsIFrame* aBox, nscoord& aFlex);
 
   // END OF BOX LAYOUT METHODS
   // The above methods have been migrated from nsIBox and are in the process of
   // being refactored. DO NOT USE OUTSIDE OF XUL.
 
   struct CaretPosition {
     CaretPosition() :
       mContentOffset(0)
--- a/layout/generic/nsIScrollableFrame.h
+++ b/layout/generic/nsIScrollableFrame.h
@@ -8,22 +8,22 @@
  */
 
 #ifndef nsIScrollFrame_h___
 #define nsIScrollFrame_h___
 
 #include "nsISupports.h"
 #include "nsCoord.h"
 #include "nsPresContext.h"
-#include "nsIFrame.h" // to get nsIBox, which is a typedef
 
 #define NS_DEFAULT_VERTICAL_SCROLL_DISTANCE 3
 
 class nsBoxLayoutState;
 class nsIScrollPositionListener;
+class nsIFrame;
 
 /**
  * Interface for frames that are scrollable. This interface exposes
  * APIs for examining scroll state, observing changes to scroll state,
  * and triggering scrolling.
  */
 class nsIScrollableFrame : public nsQueryFrame {
 public:
@@ -174,17 +174,17 @@ public:
   virtual void RemoveScrollPositionListener(nsIScrollPositionListener* aListener) = 0;
 
   /**
    * Obtain the XUL box for the horizontal or vertical scrollbar, or null
    * if there is no such box. Avoid using this, but may be useful for
    * setting up a scrollbar mediator if you want to redirect scrollbar
    * input.
    */
-  virtual nsIBox* GetScrollbarBox(bool aVertical) = 0;
+  virtual nsIFrame* GetScrollbarBox(bool aVertical) = 0;
 
   /**
    * Internal method used by scrollbars to notify their scrolling
    * container of changes.
    */
   virtual void CurPosAttributeChanged(nsIContent* aChild) = 0;
 
   /**
--- a/layout/xul/base/src/grid/nsGrid.cpp
+++ b/layout/xul/base/src/grid/nsGrid.cpp
@@ -241,30 +241,30 @@ nsGrid::FreeMap()
   mRowsBox = nullptr;
   mColumnsBox = nullptr;
 }
 
 /**
  * finds the first <rows> and <columns> tags in the <grid> tag
  */
 void
-nsGrid::FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns)
+nsGrid::FindRowsAndColumns(nsIFrame** aRows, nsIFrame** aColumns)
 {
   *aRows = nullptr;
   *aColumns = nullptr;
 
   // find the boxes that contain our rows and columns
-  nsIBox* child = nullptr;
+  nsIFrame* child = nullptr;
   // if we have <grid></grid> then mBox will be null (bug 125689)
   if (mBox)
     child = mBox->GetChildBox();
 
   while(child)
   {
-    nsIBox* oldBox = child;
+    nsIFrame* oldBox = child;
     nsIScrollableFrame *scrollFrame = do_QueryFrame(child);
     if (scrollFrame) {
        nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
        NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
        child = do_QueryFrame(scrolledFrame);
     }
 
     nsCOMPtr<nsIGridPart> monument = GetPartFromBox(child);
@@ -292,34 +292,34 @@ nsGrid::FindRowsAndColumns(nsIBox** aRow
 }
 
 /**
  * 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.
  */
 void
-nsGrid::CountRowsColumns(nsIBox* aRowBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
+nsGrid::CountRowsColumns(nsIFrame* aRowBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
 {
   aRowCount = 0;
   aComputedColumnCount = 0;
   // get the rowboxes layout manager. Then ask it to do the work for us
   if (aRowBox) {
     nsCOMPtr<nsIGridPart> monument = GetPartFromBox(aRowBox);
     if (monument) 
        monument->CountRowsColumns(aRowBox, aRowCount, aComputedColumnCount);
   }
 }
 
 
 /**
  * Given the number of rows create nsGridRow objects for them and full them out.
  */
 void
-nsGrid::BuildRows(nsIBox* aBox, PRInt32 aRowCount, nsGridRow** aRows, bool aIsHorizontal)
+nsGrid::BuildRows(nsIFrame* aBox, PRInt32 aRowCount, nsGridRow** aRows, bool aIsHorizontal)
 {
   // if no rows then return null
   if (aRowCount == 0) {
 
     // make sure we free up the memory.
     if (*aRows)
       delete[] (*aRows);
 
@@ -405,17 +405,17 @@ nsGrid::PopulateCellMap(nsGridRow* aRows
   if (!aRows)
     return;
 
    // look through the columns
   PRInt32 j = 0;
 
   for(PRInt32 i=0; i < aRowCount; i++) 
   {
-     nsIBox* child = nullptr;
+     nsIFrame* child = nullptr;
      nsGridRow* row = &aRows[i];
 
      // skip bogus rows. They have no cells
      if (row->mIsBogus) 
        continue;
 
      child = row->mBox;
      if (child) {
@@ -446,17 +446,17 @@ nsGrid::PopulateCellMap(nsGridRow* aRows
   }
 }
 
 /**
  * Run through the rows in the given box and mark them dirty so they 
  * will get recalculated and get a layout.
  */
 void 
-nsGrid::DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState)
+nsGrid::DirtyRows(nsIFrame* aRowBox, nsBoxLayoutState& aState)
 {
   // make sure we prevent others from dirtying things.
   mMarkingDirty = true;
 
   // if the box is a grid part have it recursively hand it.
   if (aRowBox) {
     nsCOMPtr<nsIGridPart> part = GetPartFromBox(aRowBox);
     if (part) 
@@ -555,27 +555,27 @@ nsGrid::GetMaxRowSize(nsBoxLayoutState& 
   nscoord height = GetMaxRowHeight(aState, aRowIndex, aIsHorizontal);
   SetSmallestSize(size, height, aIsHorizontal);
 
   return size;
 }
 
 // static
 nsIGridPart*
-nsGrid::GetPartFromBox(nsIBox* aBox)
+nsGrid::GetPartFromBox(nsIFrame* aBox)
 {
   if (!aBox)
     return nullptr;
 
   nsBoxLayout* layout = aBox->GetLayoutManager();
   return layout ? layout->AsGridPart() : nullptr;
 }
 
 nsMargin
-nsGrid::GetBoxTotalMargin(nsIBox* aBox, bool aIsHorizontal)
+nsGrid::GetBoxTotalMargin(nsIFrame* aBox, bool aIsHorizontal)
 {
   nsMargin margin(0,0,0,0);
   // walk the boxes parent chain getting the border/padding/margin of our parent rows
   
   // first get the layour manager
   nsIGridPart* part = GetPartFromBox(aBox);
   if (part)
     margin = part->GetTotalMargin(aBox, aIsHorizontal);
@@ -657,17 +657,17 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& 
   if (row->IsOffsetSet()) 
   {
     aTop    = row->mTop;
     aBottom = row->mBottom;
     return;
   }
 
   // first get the rows top and bottom border and padding
-  nsIBox* box = row->GetBox();
+  nsIFrame* box = row->GetBox();
 
   // add up all the padding
   nsMargin margin(0,0,0,0);
   nsMargin border(0,0,0,0);
   nsMargin padding(0,0,0,0);
   nsMargin totalBorderPadding(0,0,0,0);
   nsMargin totalMargin(0,0,0,0);
 
@@ -730,17 +730,17 @@ nsGrid::GetRowOffsets(nsBoxLayoutState& 
     // pick the largest top border or bottom border
     PRInt32 count = GetColumnCount(aIsHorizontal); 
 
     for (PRInt32 i=0; i < count; i++)
     {  
       nsMargin totalChildBorderPadding(0,0,0,0);
 
       nsGridRow* column = GetColumnAt(i,aIsHorizontal);
-      nsIBox* box = column->GetBox();
+      nsIFrame* box = column->GetBox();
 
       if (box) 
       {
         // ignore collapsed children
         if (!box->IsCollapsed())
         {
            // include the margin of the columns. To the row
            // at this point border/padding and margins all added
@@ -816,24 +816,24 @@ nsGrid::GetPrefRowHeight(nsBoxLayoutStat
   nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
 
   if (row->IsCollapsed())
     return 0;
 
   if (row->IsPrefSet()) 
     return row->mPref;
 
-  nsIBox* box = row->mBox;
+  nsIFrame* box = row->mBox;
 
   // set in CSS?
   if (box) 
   {
     bool widthSet, heightSet;
     nsSize cssSize(-1, -1);
-    nsIBox::AddCSSPrefSize(box, cssSize, widthSet, heightSet);
+    nsIFrame::AddCSSPrefSize(box, cssSize, widthSet, heightSet);
 
     row->mPref = GET_HEIGHT(cssSize, aIsHorizontal);
 
     // yep do nothing.
     if (row->mPref != -1)
       return row->mPref;
   }
 
@@ -893,23 +893,23 @@ nsGrid::GetMinRowHeight(nsBoxLayoutState
   nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
 
   if (row->IsCollapsed())
     return 0;
 
   if (row->IsMinSet()) 
     return row->mMin;
 
-  nsIBox* box = row->mBox;
+  nsIFrame* box = row->mBox;
 
   // set in CSS?
   if (box) {
     bool widthSet, heightSet;
     nsSize cssSize(-1, -1);
-    nsIBox::AddCSSMinSize(aState, box, cssSize, widthSet, heightSet);
+    nsIFrame::AddCSSMinSize(aState, box, cssSize, widthSet, heightSet);
 
     row->mMin = GET_HEIGHT(cssSize, aIsHorizontal);
 
     // yep do nothing.
     if (row->mMin != -1)
       return row->mMin;
   }
 
@@ -968,23 +968,23 @@ nsGrid::GetMaxRowHeight(nsBoxLayoutState
   nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
 
   if (row->IsCollapsed())
     return 0;
 
   if (row->IsMaxSet()) 
     return row->mMax;
 
-  nsIBox* box = row->mBox;
+  nsIFrame* box = row->mBox;
 
   // set in CSS?
   if (box) {
     bool widthSet, heightSet;
     nsSize cssSize(-1, -1);
-    nsIBox::AddCSSMaxSize(box, cssSize, widthSet, heightSet);
+    nsIFrame::AddCSSMaxSize(box, cssSize, widthSet, heightSet);
 
     row->mMax = GET_HEIGHT(cssSize, aIsHorizontal);
 
     // yep do nothing.
     if (row->mMax != -1)
       return row->mMax;
   }
 
@@ -1031,17 +1031,17 @@ nsGrid::GetMaxRowHeight(nsBoxLayoutState
   }
 
   row->mMax = GET_HEIGHT(size, aIsHorizontal) + top + bottom;
 
   return row->mMax;
 }
 
 bool
-nsGrid::IsGrid(nsIBox* aBox)
+nsGrid::IsGrid(nsIFrame* aBox)
 {
   nsIGridPart* part = GetPartFromBox(aBox);
   if (!part)
     return false;
 
   nsGridLayout2* grid = part->CastToGridLayout();
 
   if (grid)
@@ -1060,17 +1060,17 @@ nsGrid::GetRowFlex(nsBoxLayoutState& aSt
 {
   RebuildIfNeeded();
 
   nsGridRow* row = GetRowAt(aIndex, aIsHorizontal);
 
   if (row->IsFlexSet()) 
     return row->mFlex;
 
-  nsIBox* box = row->mBox;
+  nsIFrame* box = row->mBox;
   row->mFlex = 0;
 
   if (box) {
 
     // We need our flex but a inflexible row could be around us. If so
     // neither are we. However if its the row tag just inside the grid it won't 
     // affect us. We need to do this for this case:
     // <grid> 
@@ -1110,45 +1110,45 @@ 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);
-    nsIBox* parent = box->GetParentBox();
-    nsIBox* parentsParent=nullptr;
+    nsIFrame* parent = box->GetParentBox();
+    nsIFrame* parentsParent=nullptr;
 
     while(parent)
     {
       parent = GetScrollBox(parent);
       parentsParent = parent->GetParentBox();
 
       // 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);
-          nsIBox::AddCSSFlex(aState, parent, flex);
+          nsIFrame::AddCSSFlex(aState, parent, flex);
           if (flex == 0) {
             row->mFlex = 0;
             return row->mFlex;
           }
         } else 
           break;
       }
 
       parent = parentsParent;
     }
     
     // get the row flex.
     row->mFlex = box->GetFlex(aState);
-    nsIBox::AddCSSFlex(aState, box, row->mFlex);
+    nsIFrame::AddCSSFlex(aState, box, row->mFlex);
   }
 
   return row->mFlex;
 }
 
 void
 nsGrid::SetLargestSize(nsSize& aSize, nscoord aHeight, bool aIsHorizontal)
 {
@@ -1218,42 +1218,42 @@ nsGrid::RowAddedOrRemoved(nsBoxLayoutSta
 
   NeedsRebuild(aState);
 }
 
 /*
  * Scrollframes are tranparent. If this is given a scrollframe is will return the
  * frame inside. If there is no scrollframe it does nothing.
  */
-nsIBox*
-nsGrid::GetScrolledBox(nsIBox* aChild)
+nsIFrame*
+nsGrid::GetScrolledBox(nsIFrame* aChild)
 {
   // first see if it is a scrollframe. If so walk down into it and get the scrolled child
       nsIScrollableFrame *scrollFrame = do_QueryFrame(aChild);
       if (scrollFrame) {
          nsIFrame* scrolledFrame = scrollFrame->GetScrolledFrame();
          NS_ASSERTION(scrolledFrame,"Error no scroll frame!!");
          return scrolledFrame;
       }
 
       return aChild;
 }
 
 /*
  * Scrollframes are tranparent. If this is given a child in a scrollframe is will return the
  * scrollframe ourside it. If there is no scrollframe it does nothing.
  */
-nsIBox*
-nsGrid::GetScrollBox(nsIBox* aChild)
+nsIFrame*
+nsGrid::GetScrollBox(nsIFrame* aChild)
 {
   if (!aChild)
     return nullptr;
 
   // get parent
-  nsIBox* parent = aChild->GetParentBox();
+  nsIFrame* parent = aChild->GetParentBox();
 
   // 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.
--- a/layout/xul/base/src/grid/nsGrid.h
+++ b/layout/xul/base/src/grid/nsGrid.h
@@ -50,69 +50,69 @@ public:
 
   nscoord GetPrefRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, bool aIsHorizontal = true);
   nscoord GetMinRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, bool aIsHorizontal = true);
   nscoord GetMaxRowHeight(nsBoxLayoutState& aBoxLayoutState, PRInt32 aRowIndex, bool aIsHorizontal = true);
   void GetRowOffsets(nsBoxLayoutState& aState, PRInt32 aIndex, nscoord& aTop, nscoord& aBottom, bool aIsHorizontal = true);
 
   void RowAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, bool aIsHorizontal = true);
   void CellAddedOrRemoved(nsBoxLayoutState& aBoxLayoutState, PRInt32 aIndex, bool aIsHorizontal = true);
-  void DirtyRows(nsIBox* aRowBox, nsBoxLayoutState& aState);
+  void DirtyRows(nsIFrame* aRowBox, nsBoxLayoutState& aState);
 #ifdef DEBUG_grid
   void PrintCellMap();
 #endif
   PRInt32 GetExtraColumnCount(bool aIsHorizontal = true);
   PRInt32 GetExtraRowCount(bool aIsHorizontal = true);
 
 // accessors
-  void SetBox(nsIBox* aBox) { mBox = aBox; }
-  nsIBox* GetBox() { return mBox; }
-  nsIBox* GetRowsBox() { return mRowsBox; }
-  nsIBox* GetColumnsBox() { return mColumnsBox; }
+  void SetBox(nsIFrame* aBox) { mBox = aBox; }
+  nsIFrame* GetBox() { return mBox; }
+  nsIFrame* GetRowsBox() { return mRowsBox; }
+  nsIFrame* GetColumnsBox() { return mColumnsBox; }
   PRInt32 GetRowCount(PRInt32 aIsHorizontal = true);
   PRInt32 GetColumnCount(PRInt32 aIsHorizontal = true);
 
-  static nsIBox* GetScrolledBox(nsIBox* aChild);
-  static nsIBox* GetScrollBox(nsIBox* aChild);
-  static nsIGridPart* GetPartFromBox(nsIBox* aBox);
+  static nsIFrame* GetScrolledBox(nsIFrame* aChild);
+  static nsIFrame* GetScrollBox(nsIFrame* aChild);
+  static nsIGridPart* GetPartFromBox(nsIFrame* aBox);
   void GetFirstAndLastRow(nsBoxLayoutState& aState, 
                           PRInt32& aFirstIndex, 
                           PRInt32& aLastIndex, 
                           nsGridRow*& aFirstRow,
                           nsGridRow*& aLastRow,
                           bool aIsHorizontal);
 
 private:
 
-  nsMargin GetBoxTotalMargin(nsIBox* aBox, bool aIsHorizontal = true);
+  nsMargin GetBoxTotalMargin(nsIFrame* aBox, bool aIsHorizontal = true);
 
   void FreeMap();
-  void FindRowsAndColumns(nsIBox** aRows, nsIBox** aColumns);
-  void BuildRows(nsIBox* aBox, PRInt32 aSize, nsGridRow** aColumnsRows, bool aIsHorizontal = true);
+  void FindRowsAndColumns(nsIFrame** aRows, nsIFrame** aColumns);
+  void BuildRows(nsIFrame* aBox, PRInt32 aSize, nsGridRow** aColumnsRows, bool aIsHorizontal = true);
   nsGridCell* BuildCellMap(PRInt32 aRows, PRInt32 aColumns);
   void PopulateCellMap(nsGridRow* aRows, nsGridRow* aColumns, PRInt32 aRowCount, PRInt32 aColumnCount, bool aIsHorizontal = true);
-  void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
+  void CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
   void SetLargestSize(nsSize& aSize, nscoord aHeight, bool aIsHorizontal = true);
   void SetSmallestSize(nsSize& aSize, nscoord aHeight, bool aIsHorizontal = true);
-  bool IsGrid(nsIBox* aBox);
+  bool IsGrid(nsIFrame* aBox);
 
   // the box that implement the <grid> tag
-  nsIBox* mBox;
+  nsIFrame* mBox;
 
   // an array of row object
   nsGridRow* mRows;
 
   // an array of columns objects.
   nsGridRow* mColumns;
 
   // the first in the <grid> that implements the <rows> tag.
-  nsIBox* mRowsBox;
+  nsIFrame* mRowsBox;
 
   // the first in the <grid> that implements the <columns> tag.
-  nsIBox* mColumnsBox;
+  nsIFrame* mColumnsBox;
 
   // a flag that is false tells us to rebuild the who grid
   bool mNeedsRebuild;
 
   // number of rows and columns as defined by the XUL
   PRInt32 mRowCount;
   PRInt32 mColumnCount;
 
--- a/layout/xul/base/src/grid/nsGridCell.h
+++ b/layout/xul/base/src/grid/nsGridCell.h
@@ -11,17 +11,16 @@
 **/
 
 #ifndef nsGridCell_h___
 #define nsGridCell_h___
 
 class nsBoxLayoutState;
 struct nsSize;
 class nsIFrame;
-typedef class nsIFrame nsIBox;
 
 /*
  * Grid cell is what makes up the cellmap in the grid. Each GridCell contains
  * 2 pointers. One to the matching box in the columns and one to the matching box
  * in the rows. Remember that you can put content in both rows and columns.
  * When asked for preferred/min/max sizes it works like a stack and takes the 
  * biggest sizes.
  */
@@ -33,20 +32,20 @@ public:
     virtual ~nsGridCell();
 
     nsSize      GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
     nsSize      GetMinSize(nsBoxLayoutState& aBoxLayoutState);
     nsSize      GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
     bool        IsCollapsed();
 
 // accessors
-    nsIBox*     GetBoxInColumn()             { return mBoxInColumn; }
-    nsIBox*     GetBoxInRow()                { return mBoxInRow; }
-    void        SetBoxInRow(nsIBox* aBox)    { mBoxInRow = aBox; }
-    void        SetBoxInColumn(nsIBox* aBox) { mBoxInColumn = aBox; }
+    nsIFrame*   GetBoxInColumn()               { return mBoxInColumn; }
+    nsIFrame*   GetBoxInRow()                  { return mBoxInRow; }
+    void        SetBoxInRow(nsIFrame* aBox)    { mBoxInRow = aBox; }
+    void        SetBoxInColumn(nsIFrame* aBox) { mBoxInColumn = aBox; }
 
 private:
-    nsIBox* mBoxInColumn;
-    nsIBox* mBoxInRow;
+    nsIFrame* mBoxInColumn;
+    nsIFrame* mBoxInRow;
 };
 
 #endif
 
--- a/layout/xul/base/src/grid/nsGridLayout2.cpp
+++ b/layout/xul/base/src/grid/nsGridLayout2.cpp
@@ -29,50 +29,50 @@ NS_NewGridLayout2( nsIPresShell* aPresSh
 } 
 
 nsGridLayout2::nsGridLayout2(nsIPresShell* aPresShell):nsStackLayout()
 {
 }
 
 // static
 void
-nsGridLayout2::AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize)
+nsGridLayout2::AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize)
 {
   nsMargin offset;
   GetOffset(aState, aChild, offset);
   aSize.width += offset.left;
   aSize.height += offset.top;
 }
 
 NS_IMETHODIMP
-nsGridLayout2::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsGridLayout2::Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   // XXX This should be set a better way!
   mGrid.SetBox(aBox);
   NS_ASSERTION(aBox->GetLayoutManager() == this, "setting incorrect box");
 
   nsresult rv = nsStackLayout::Layout(aBox, aBoxLayoutState);
 #ifdef DEBUG_grid
   mGrid.PrintCellMap();
 #endif
   return rv;
 }
 
 void
-nsGridLayout2::IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsGridLayout2::IntrinsicWidthsDirty(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsStackLayout::IntrinsicWidthsDirty(aBox, aBoxLayoutState);
   // XXXldb We really don't need to do all the work that NeedsRebuild
   // does; we just need to mark intrinsic widths dirty on the
   // (row/column)(s/-groups).
   mGrid.NeedsRebuild(aBoxLayoutState);
 }
 
 nsGrid*
-nsGridLayout2::GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
+nsGridLayout2::GetGrid(nsIFrame* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
 {
   // XXX This should be set a better way!
   mGrid.SetBox(aBox);
   NS_ASSERTION(aBox->GetLayoutManager() == this, "setting incorrect box");
   return &mGrid;
 }
 
 void
@@ -84,25 +84,25 @@ nsGridLayout2::AddWidth(nsSize& aSize, n
     if (aSize2 == NS_INTRINSICSIZE)
       size = NS_INTRINSICSIZE;
     else
       size += aSize2;
   }
 }
 
 nsSize
-nsGridLayout2::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridLayout2::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize minSize = nsStackLayout::GetMinSize(aBox, aState); 
 
   // if there are no <rows> tags that will sum up our columns,
   // sum up our columns here.
   nsSize total(0,0);
-  nsIBox* rowsBox = mGrid.GetRowsBox();
-  nsIBox* columnsBox = mGrid.GetColumnsBox();
+  nsIFrame* rowsBox = mGrid.GetRowsBox();
+  nsIFrame* columnsBox = mGrid.GetColumnsBox();
   if (!rowsBox || !columnsBox) {
     if (!rowsBox) {
       // max height is the sum of our rows
       PRInt32 rows = mGrid.GetRowCount();
       for (PRInt32 i=0; i < rows; i++)
       {
         nscoord height = mGrid.GetMinRowHeight(aState, i, true); 
         AddWidth(total, height, false); // AddHeight
@@ -123,25 +123,25 @@ nsGridLayout2::GetMinSize(nsIBox* aBox, 
     AddOffset(aState, aBox, total);
     AddLargestSize(minSize, total);
   }
   
   return minSize;
 }
 
 nsSize
-nsGridLayout2::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridLayout2::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize pref = nsStackLayout::GetPrefSize(aBox, aState); 
 
   // if there are no <rows> tags that will sum up our columns,
   // sum up our columns here.
   nsSize total(0,0);
-  nsIBox* rowsBox = mGrid.GetRowsBox();
-  nsIBox* columnsBox = mGrid.GetColumnsBox();
+  nsIFrame* rowsBox = mGrid.GetRowsBox();
+  nsIFrame* columnsBox = mGrid.GetColumnsBox();
   if (!rowsBox || !columnsBox) {
     if (!rowsBox) {
       // max height is the sum of our rows
       PRInt32 rows = mGrid.GetRowCount();
       for (PRInt32 i=0; i < rows; i++)
       {
         nscoord height = mGrid.GetPrefRowHeight(aState, i, true); 
         AddWidth(total, height, false); // AddHeight
@@ -162,25 +162,25 @@ nsGridLayout2::GetPrefSize(nsIBox* aBox,
     AddOffset(aState, aBox, total);
     AddLargestSize(pref, total);
   }
 
   return pref;
 }
 
 nsSize
-nsGridLayout2::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridLayout2::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize maxSize = nsStackLayout::GetMaxSize(aBox, aState); 
 
   // if there are no <rows> tags that will sum up our columns,
   // sum up our columns here.
   nsSize total(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
-  nsIBox* rowsBox = mGrid.GetRowsBox();
-  nsIBox* columnsBox = mGrid.GetColumnsBox();
+  nsIFrame* rowsBox = mGrid.GetRowsBox();
+  nsIFrame* columnsBox = mGrid.GetColumnsBox();
   if (!rowsBox || !columnsBox) {
     if (!rowsBox) {
       total.height = 0;
       // max height is the sum of our rows
       PRInt32 rows = mGrid.GetRowCount();
       for (PRInt32 i=0; i < rows; i++)
       {
         nscoord height = mGrid.GetMaxRowHeight(aState, i, true); 
@@ -203,57 +203,57 @@ nsGridLayout2::GetMaxSize(nsIBox* aBox, 
     AddOffset(aState, aBox, total);
     AddSmallestSize(maxSize, total);
   }
 
   return maxSize;
 }
 
 PRInt32
-nsGridLayout2::BuildRows(nsIBox* aBox, nsGridRow* aRows)
+nsGridLayout2::BuildRows(nsIFrame* aBox, nsGridRow* aRows)
 {
   if (aBox) {
     aRows[0].Init(aBox, true);
     return 1;
   }
   return 0;
 }
 
 nsMargin
-nsGridLayout2::GetTotalMargin(nsIBox* aBox, bool aIsHorizontal)
+nsGridLayout2::GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)
 {
   nsMargin margin(0,0,0,0);
   return margin;
 }
 
 void
-nsGridLayout2::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
-                                nsIBox* aPrevBox,
+nsGridLayout2::ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
+                                nsIFrame* aPrevBox,
                                 const nsFrameList::Slice& aNewChildren)
 {
   mGrid.NeedsRebuild(aState);
 }
 
 void
-nsGridLayout2::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
+nsGridLayout2::ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
                                 const nsFrameList::Slice& aNewChildren)
 {
   mGrid.NeedsRebuild(aState);
 }
 
 void
-nsGridLayout2::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
-                               nsIBox* aChildList)
+nsGridLayout2::ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
+                               nsIFrame* aChildList)
 {
   mGrid.NeedsRebuild(aState);
 }
 
 void
-nsGridLayout2::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState,
-                           nsIBox* aChildList)
+nsGridLayout2::ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
+                           nsIFrame* aChildList)
 {
   mGrid.NeedsRebuild(aState);
 }
 
 NS_IMPL_ADDREF_INHERITED(nsGridLayout2, nsStackLayout)
 NS_IMPL_RELEASE_INHERITED(nsGridLayout2, nsStackLayout)
 
 NS_INTERFACE_MAP_BEGIN(nsGridLayout2)
--- a/layout/xul/base/src/grid/nsGridLayout2.h
+++ b/layout/xul/base/src/grid/nsGridLayout2.h
@@ -4,19 +4,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsGridLayout2_h___
 #define nsGridLayout2_h___
 
 #include "nsStackLayout.h"
 #include "nsIGridPart.h"
-#include "nsCOMPtr.h"
+#include "nsCoord.h"
 #include "nsGrid.h"
 
+class nsIPresContext;
 class nsGridRowGroupLayout;
 class nsGridRowLayout;
 class nsGridRow;
 class nsBoxLayoutState;
 class nsGridCell;
 
 /**
  * The nsBoxLayout implementation for a grid.
@@ -25,46 +26,46 @@ class nsGridLayout2 : public nsStackLayo
                       public nsIGridPart
 {
 public:
 
   friend nsresult NS_NewGridLayout2(nsIPresShell* aPresShell, nsBoxLayout** aNewLayout);
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void IntrinsicWidthsDirty(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
 
   virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return nullptr; }
   virtual nsGridLayout2* CastToGridLayout() { return this; }
-  virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr);
-  virtual nsIGridPart* GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox) {
+  virtual nsGrid* GetGrid(nsIFrame* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr);
+  virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) {
     NS_NOTREACHED("Should not be called"); return nullptr;
   }
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount) { aRowCount++; }
-  virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState) { }
-  virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
-  virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount) { aRowCount++; }
+  virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState) { }
+  virtual PRInt32 BuildRows(nsIFrame* aBox, nsGridRow* aRows);
+  virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal);
   virtual Type GetType() { return eGrid; }
-  virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
-                                nsIBox* aPrevBox,
+  virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
+                                nsIFrame* aPrevBox,
                                 const nsFrameList::Slice& aNewChildren);
-  virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
+  virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
                                 const nsFrameList::Slice& aNewChildren);
-  virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
-                             nsIBox* aChildList);
-  virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState,
-                         nsIBox* aChildList);
+  virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState,
+                               nsIFrame* aChildList);
+  virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState,
+                           nsIFrame* aChildList);
 
   virtual nsIGridPart* AsGridPart() { return this; }
 
-  static void AddOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsSize& aSize);
+  static void AddOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsSize& aSize);
 
 protected:
 
   nsGridLayout2(nsIPresShell* aShell);
   nsGrid mGrid;
 
 private:
   void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
--- a/layout/xul/base/src/grid/nsGridRow.cpp
+++ b/layout/xul/base/src/grid/nsGridRow.cpp
@@ -25,17 +25,17 @@ nsGridRow::nsGridRow():mIsBogus(false),
                        mTopMargin(0),
                        mBottomMargin(0)
 
 {
     MOZ_COUNT_CTOR(nsGridRow);
 }
 
 void
-nsGridRow::Init(nsIBox* aBox, bool aIsBogus)
+nsGridRow::Init(nsIFrame* aBox, bool aIsBogus)
 {
   mBox = aBox;
   mIsBogus = aIsBogus;
   mFlex = -1;
   mPref = -1;
   mMin = -1;
   mMax = -1;
   mTop = -1;
--- a/layout/xul/base/src/grid/nsGridRow.h
+++ b/layout/xul/base/src/grid/nsGridRow.h
@@ -13,42 +13,41 @@
 #ifndef nsGridRow_h___
 #define nsGridRow_h___
 
 #include "nsCoord.h"
 
 class nsGridLayout2;
 class nsBoxLayoutState;
 class nsIFrame;
-typedef class nsIFrame nsIBox;
 
 /**
  * The row (or column) data structure in the grid cellmap.
  */
 class nsGridRow
 {
 public:
    nsGridRow();
    ~nsGridRow();
-   
-   void Init(nsIBox* aBox, bool aIsBogus);
+
+   void Init(nsIFrame* aBox, bool aIsBogus);
 
 // accessors
-   nsIBox* GetBox()   { return mBox;          }
+   nsIFrame* GetBox()   { return mBox;          }
    bool IsPrefSet() { return (mPref != -1); }
    bool IsMinSet()  { return (mMin  != -1); }
    bool IsMaxSet()  { return (mMax  != -1); } 
    bool IsFlexSet() { return (mFlex != -1); }
    bool IsOffsetSet() { return (mTop != -1 && mBottom != -1); }
    bool IsCollapsed();
 
 public:
 
    bool    mIsBogus;
-   nsIBox* mBox;
+   nsIFrame* mBox;
    nscoord mFlex;
    nscoord mPref;
    nscoord mMin;
    nscoord mMax;
    nscoord mTop;
    nscoord mBottom;
    nscoord mTopMargin;
    nscoord mBottomMargin;
--- a/layout/xul/base/src/grid/nsGridRowGroupFrame.cpp
+++ b/layout/xul/base/src/grid/nsGridRowGroupFrame.cpp
@@ -47,17 +47,17 @@ 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;
-  nsIBox* child = GetChildBox();
+  nsIFrame* child = GetChildBox();
   while (child)
   {
     totalFlex += child->GetFlex(aState);
     child = child->GetNextBox();
   }
 
   mFlex = totalFlex;
 
--- a/layout/xul/base/src/grid/nsGridRowGroupLayout.cpp
+++ b/layout/xul/base/src/grid/nsGridRowGroupLayout.cpp
@@ -34,17 +34,17 @@ nsGridRowGroupLayout::nsGridRowGroupLayo
 {
 }
 
 nsGridRowGroupLayout::~nsGridRowGroupLayout()
 {
 }
 
 void
-nsGridRowGroupLayout::ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowGroupLayout::ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   if (grid)
     grid->RowAddedOrRemoved(aState, index, isHorizontal);
 }
@@ -56,17 +56,17 @@ nsGridRowGroupLayout::AddWidth(nsSize& a
 
   if (size == NS_INTRINSICSIZE || aSize2 == NS_INTRINSICSIZE)
     size = NS_INTRINSICSIZE;
   else
     size += aSize2;
 }
 
 nsSize
-nsGridRowGroupLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowGroupLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 { 
   nsSize vpref = nsGridRowLayout::GetPrefSize(aBox, aState); 
 
 
  /* It is possible that we could have some extra columns. This is when less columns in XUL were 
   * defined that needed. And example might be a grid with 3 defined columns but a row with 4 cells in 
   * it. We would need an extra column to make the grid work. But because that extra column does not 
   * have a box associated with it we must add its size in manually. Remember we could have extra rows
@@ -90,17 +90,17 @@ nsGridRowGroupLayout::GetPrefSize(nsIBox
       AddWidth(vpref, pref, isHorizontal);
     }
   }
 
   return vpref;
 }
 
 nsSize
-nsGridRowGroupLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowGroupLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
  nsSize maxSize = nsGridRowLayout::GetMaxSize(aBox, aState); 
 
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
 
   if (grid) 
   {
@@ -116,17 +116,17 @@ nsGridRowGroupLayout::GetMaxSize(nsIBox*
       AddWidth(maxSize, max, isHorizontal);
     }
   }
 
   return maxSize;
 }
 
 nsSize
-nsGridRowGroupLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowGroupLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize minSize = nsGridRowLayout::GetMinSize(aBox, aState); 
 
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
 
   if (grid) 
   {
@@ -144,54 +144,54 @@ nsGridRowGroupLayout::GetMinSize(nsIBox*
 
   return minSize;
 }
 
 /*
  * Run down through our children dirtying them recursively.
  */
 void
-nsGridRowGroupLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
+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);
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     while(child) {
 
       // walk into scrollframes
-      nsIBox* deepChild = nsGrid::GetScrolledBox(child);
+      nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       // walk into other monuments
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) 
         monument->DirtyRows(deepChild, aState);
 
       child = child->GetNextBox();
     }
   }
 }
 
 
 void
-nsGridRowGroupLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
+nsGridRowGroupLayout::CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
 {
   if (aBox) {
     PRInt32 startCount = aRowCount;
 
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     while(child) {
       
       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
-      nsIBox* deepChild = nsGrid::GetScrolledBox(child);
+      nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) {
         monument->CountRowsColumns(deepChild, aRowCount, aComputedColumnCount);
         child = child->GetNextBox();
         deepChild = child;
         continue;
       }
@@ -206,27 +206,27 @@ nsGridRowGroupLayout::CountRowsColumns(n
   }
 }
 
 
 /**
  * Fill out the given row structure recursively
  */
 PRInt32 
-nsGridRowGroupLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows)
+nsGridRowGroupLayout::BuildRows(nsIFrame* aBox, nsGridRow* aRows)
 { 
   PRInt32 rowCount = 0;
 
   if (aBox) {
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     while(child) {
       
       // first see if it is a scrollframe. If so walk down into it and get the scrolled child
-      nsIBox* deepChild = nsGrid::GetScrolledBox(child);
+      nsIFrame* deepChild = nsGrid::GetScrolledBox(child);
 
       nsIGridPart* monument = nsGrid::GetPartFromBox(deepChild);
       if (monument) {
         rowCount += monument->BuildRows(deepChild, &aRows[rowCount]);
         child = child->GetNextBox();
         deepChild = child;
         continue;
       }
@@ -239,17 +239,17 @@ nsGridRowGroupLayout::BuildRows(nsIBox* 
       rowCount++;
     }
   }
 
   return rowCount;
 }
 
 nsMargin
-nsGridRowGroupLayout::GetTotalMargin(nsIBox* aBox, bool aIsHorizontal)
+nsGridRowGroupLayout::GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)
 {
   // group have border and padding added to the total margin
 
   nsMargin margin = nsGridRowLayout::GetTotalMargin(aBox, aIsHorizontal);
   
   // make sure we have the scrollframe on the outside if it has one.
   // that's where the border is.
   aBox = nsGrid::GetScrollBox(aBox);
--- a/layout/xul/base/src/grid/nsGridRowGroupLayout.h
+++ b/layout/xul/base/src/grid/nsGridRowGroupLayout.h
@@ -20,31 +20,31 @@
  */
 class nsGridRowGroupLayout : public nsGridRowLayout
 {
 public:
 
   friend already_AddRefed<nsBoxLayout> NS_NewGridRowGroupLayout();
 
   virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return this; }
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
-  virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState);
-  virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
-  virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
+  virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState);
+  virtual PRInt32 BuildRows(nsIFrame* aBox, nsGridRow* aRows);
+  virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal);
   virtual PRInt32 GetRowCount() { return mRowCount; }
   virtual Type GetType() { return eRowGroup; }
 
 protected:
   nsGridRowGroupLayout();
   virtual ~nsGridRowGroupLayout();
 
-  virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
+  virtual void ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState);
   static void AddWidth(nsSize& aSize, nscoord aSize2, bool aIsHorizontal);
 
 private:
   nsGridRow* mRowColumn;
   PRInt32 mRowCount;
 };
 
 #endif
--- a/layout/xul/base/src/grid/nsGridRowLayout.cpp
+++ b/layout/xul/base/src/grid/nsGridRowLayout.cpp
@@ -17,44 +17,44 @@
 #include "nsStackLayout.h"
 #include "nsGrid.h"
 
 nsGridRowLayout::nsGridRowLayout():nsSprocketLayout()
 {
 }
 
 void
-nsGridRowLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
-                                  nsIBox* aPrevBox,
+nsGridRowLayout::ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
+                                  nsIFrame* aPrevBox,
                                   const nsFrameList::Slice& aNewChildren)
 {
   ChildAddedOrRemoved(aBox, aState);
 }
 
 void
-nsGridRowLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
+nsGridRowLayout::ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
                                   const nsFrameList::Slice& aNewChildren)
 {
   ChildAddedOrRemoved(aBox, aState);
 }
 
 void
-nsGridRowLayout::ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
+nsGridRowLayout::ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList)
 {
   ChildAddedOrRemoved(aBox, aState);
 }
 
 void
-nsGridRowLayout::ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
+nsGridRowLayout::ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList)
 {
   ChildAddedOrRemoved(aBox, aState);
 }
 
 nsIGridPart*
-nsGridRowLayout::GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox)
+nsGridRowLayout::GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox)
 {
   // go up and find our parent gridRow. Skip and non gridRow
   // parents.
   *aParentBox = nullptr;
   
   // walk up through any scrollboxes
   aBox = nsGrid::GetScrollBox(aBox);
 
@@ -71,35 +71,35 @@ nsGridRowLayout::GetParentGridPart(nsIBo
     }
   }
 
   return nullptr;
 }
 
 
 nsGrid*
-nsGridRowLayout::GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
+nsGridRowLayout::GetGrid(nsIFrame* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor)
 {
 
    if (aRequestor == nullptr)
    {
-      nsIBox* parentBox; // nsIBox is implemented by nsIFrame and is not refcounted.
+      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;
    }
 
    PRInt32 index = -1;
-   nsIBox* child = aBox->GetChildBox();
+   nsIFrame* child = aBox->GetChildBox();
    PRInt32 count = 0;
    while(child)
    {
      // if there is a scrollframe walk inside it to its child
-     nsIBox* childBox = nsGrid::GetScrolledBox(child);
+     nsIFrame* childBox = nsGrid::GetScrolledBox(child);
 
      nsBoxLayout* layout = childBox->GetLayoutManager();
      nsIGridPart* gridRow = nsGrid::GetPartFromBox(childBox);
      if (gridRow) 
      {
        if (layout == aRequestor) {
           index = count;
           break;
@@ -116,42 +116,42 @@ nsGridRowLayout::GetGrid(nsIBox* aBox, P
    // fail.
    if (index == -1) {
      *aIndex = -1;
      return nullptr;
    }
 
    (*aIndex) += index;
 
-   nsIBox* parentBox; // nsIBox is implemented by nsIFrame and is not refcounted.
+   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;
 }
 
 nsMargin
-nsGridRowLayout::GetTotalMargin(nsIBox* aBox, bool aIsHorizontal)
+nsGridRowLayout::GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)
 {
   // get our parents margin
   nsMargin margin(0,0,0,0);
-  nsIBox* parent = nullptr;
+  nsIFrame* parent = nullptr;
   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
-    nsIBox* next = aBox->GetNextBox();
+    nsIFrame* next = aBox->GetNextBox();
 
     // get the parent first child to see if we are first
-    nsIBox* child = parent->GetChildBox();
+    nsIFrame* child = parent->GetChildBox();
 
     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/base/src/grid/nsGridRowLayout.h
+++ b/layout/xul/base/src/grid/nsGridRowLayout.h
@@ -30,29 +30,29 @@ class nsGrid;
 class nsGridRowLayout : public nsSprocketLayout,
                         public nsIGridPart
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual nsGridRowGroupLayout* CastToRowGroupLayout() { return nullptr; }
   virtual nsGridLayout2* CastToGridLayout() { return nullptr; }
-  virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr);
-  virtual nsIGridPart* GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox);
-  virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
-                                nsIBox* aPrevBox,
+  virtual nsGrid* GetGrid(nsIFrame* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr);
+  virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox);
+  virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
+                                nsIFrame* aPrevBox,
                                 const nsFrameList::Slice& aNewChildren);
-  virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
+  virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
                                 const nsFrameList::Slice& aNewChildren);
-  virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);
-  virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);
-  virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal);
+  virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList);
+  virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList);
+  virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal);
 
   virtual nsIGridPart* AsGridPart() { return this; }
 
 protected:
-  virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)=0;
+  virtual void ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState)=0;
 
   nsGridRowLayout();
 };
 
 #endif
 
--- a/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp
+++ b/layout/xul/base/src/grid/nsGridRowLeafLayout.cpp
@@ -30,17 +30,17 @@ nsGridRowLeafLayout::nsGridRowLeafLayout
 {
 }
 
 nsGridRowLeafLayout::~nsGridRowLeafLayout()
 {
 }
 
 nsSize
-nsGridRowLeafLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowLeafLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   // If we are not in a grid. Then we just work like a box. But if we are in a grid
   // ask the grid for our size.
   if (!grid) {
@@ -48,33 +48,33 @@ nsGridRowLeafLayout::GetPrefSize(nsIBox*
   }
   else {
     return grid->GetPrefRowSize(aState, index, isHorizontal);
     //AddBorderAndPadding(aBox, pref);
   }
 }
 
 nsSize
-nsGridRowLeafLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowLeafLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   if (!grid)
     return nsGridRowLayout::GetMinSize(aBox, aState); 
   else {
     nsSize minSize = grid->GetMinRowSize(aState, index, isHorizontal);
     AddBorderAndPadding(aBox, minSize);
     return minSize;
   }
 }
 
 nsSize
-nsGridRowLeafLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowLeafLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   if (!grid)
     return nsGridRowLayout::GetMaxSize(aBox, aState); 
   else {
@@ -83,43 +83,43 @@ nsGridRowLeafLayout::GetMaxSize(nsIBox* 
     AddBorderAndPadding(aBox, maxSize);
     return maxSize;
   }
 }
 
 /** If a child is added or removed or changes size
   */
 void
-nsGridRowLeafLayout::ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowLeafLayout::ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   if (grid)
     grid->CellAddedOrRemoved(aState, index, isHorizontal);
 }
 
 void
-nsGridRowLeafLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes)
+nsGridRowLeafLayout::PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes)
 {
   PRInt32 index = 0;
   nsGrid* grid = GetGrid(aBox, &index);
   bool isHorizontal = IsHorizontal(aBox);
 
   // Our base class SprocketLayout is giving us a chance to change the box sizes before layout
   // 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;
     PRInt32 count = grid->GetColumnCount(isHorizontal); 
     nsBoxSize* start = nullptr;
     nsBoxSize* last = nullptr;
     nsBoxSize* current = nullptr;
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
     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
@@ -127,17 +127,17 @@ nsGridRowLeafLayout::PopulateBoxSizes(ns
         grid->GetMinRowHeight(aState, i, !isHorizontal);  // GetMinColumnWidth
       nscoord max = 
         grid->GetMaxRowHeight(aState, i, !isHorizontal);  // GetMaxColumnWidth
       nscoord flex =
         grid->GetRowFlex(aState, i, !isHorizontal);       // GetColumnFlex
       nscoord left  = 0;
       nscoord right  = 0;
       grid->GetRowOffsets(aState, i, left, right, !isHorizontal); // GetColumnOffsets
-      nsIBox* box = column->GetBox();
+      nsIFrame* box = column->GetBox();
       bool collapsed = false;
       nscoord topMargin = column->mTopMargin;
       nscoord bottomMargin = column->mBottomMargin;
 
       if (box) 
         collapsed = box->IsCollapsed();
 
       pref = pref - (left + right);
@@ -211,33 +211,33 @@ nsGridRowLeafLayout::PopulateBoxSizes(ns
     }
     aBoxSizes = start;
   }
 
   nsSprocketLayout::PopulateBoxSizes(aBox, aState, aBoxSizes, aMinSize, aMaxSize, aFlexes);
 }
 
 void
-nsGridRowLeafLayout::ComputeChildSizes(nsIBox* aBox,
+nsGridRowLeafLayout::ComputeChildSizes(nsIFrame* aBox,
                            nsBoxLayoutState& aState, 
                            nscoord& aGivenSize, 
                            nsBoxSize* aBoxSizes, 
                            nsComputedBoxSize*& aComputedBoxSizes)
 { 
   // see if we are in a scrollable frame. If we are then there could be scrollbars present
   // if so we need to subtract them out to make sure our columns line up.
   if (aBox) {
     bool isHorizontal = aBox->IsHorizontal();
 
     // go up the parent chain looking for scrollframes
     nscoord diff = 0;
-    nsIBox* parentBox;
+    nsIFrame* parentBox;
     (void)GetParentGridPart(aBox, &parentBox);
     while (parentBox) {
-      nsIBox* scrollbox = nsGrid::GetScrollBox(parentBox);
+      nsIFrame* scrollbox = nsGrid::GetScrollBox(parentBox);
       nsIScrollableFrame *scrollable = do_QueryFrame(scrollbox);
       if (scrollable) {
         // Don't call GetActualScrollbarSizes here because it's not safe
         // to call that while we're reflowing the contents of the scrollframe,
         // which we are here.
         nsMargin scrollbarSizes = scrollable->GetDesiredScrollbarSizes(&aState);
         PRUint32 visible = scrollable->GetScrollbarVisibility();
 
@@ -273,38 +273,38 @@ nsGridRowLeafLayout::ComputeChildSizes(n
     }
   }
       
   nsSprocketLayout::ComputeChildSizes(aBox, aState, aGivenSize, aBoxSizes, aComputedBoxSizes);
 
 }
 
 NS_IMETHODIMP
-nsGridRowLeafLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsGridRowLeafLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   return nsGridRowLayout::Layout(aBox, aBoxLayoutState);
 }
 
 void
-nsGridRowLeafLayout::DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)
+nsGridRowLeafLayout::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.
     aState.PresShell()->FrameNeedsReflow(aBox, nsIPresShell::eTreeChange,
                                          NS_FRAME_IS_DIRTY);
   }
 }
 
 void
-nsGridRowLeafLayout::CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
+nsGridRowLeafLayout::CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)
 {
   if (aBox) {
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     // count the children
     PRInt32 columnCount = 0;
     while(child) {
       child = child->GetNextBox();
       columnCount++;
     }
 
@@ -312,18 +312,18 @@ nsGridRowLeafLayout::CountRowsColumns(ns
     if (columnCount > aComputedColumnCount) 
       aComputedColumnCount = columnCount;
 
     aRowCount++;
   }
 }
 
 PRInt32
-nsGridRowLeafLayout::BuildRows(nsIBox* aBox, nsGridRow* aRows)
-{ 
+nsGridRowLeafLayout::BuildRows(nsIFrame* aBox, nsGridRow* aRows)
+{
   if (aBox) {
       aRows[0].Init(aBox, false);
       return 1;
   }
 
   return 0;
 }
 
--- a/layout/xul/base/src/grid/nsGridRowLeafLayout.h
+++ b/layout/xul/base/src/grid/nsGridRowLeafLayout.h
@@ -22,38 +22,40 @@
 // XXXldb This needs a better name that indicates that it's for any grid
 // row.
 class nsGridRowLeafLayout : public nsGridRowLayout
 {
 public:
 
   friend already_AddRefed<nsBoxLayout> NS_NewGridRowLeafLayout();
 
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void ChildAddedOrRemoved(nsIBox* aBox, nsBoxLayoutState& aState);
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
-  virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState);
-  virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void ChildAddedOrRemoved(nsIFrame* aBox, nsBoxLayoutState& aState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount);
+  virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState);
+  virtual PRInt32 BuildRows(nsIFrame* aBox, nsGridRow* aRows);
   virtual Type GetType() { return eRowLeaf; }
 
 protected:
 
-  virtual void PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes);
-  virtual void ComputeChildSizes(nsIBox* aBox, 
-                         nsBoxLayoutState& aState, 
-                         nscoord& aGivenSize, 
-                         nsBoxSize* aBoxSizes, 
-                         nsComputedBoxSize*& aComputedBoxSizes);
+  virtual void PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState,
+                                nsBoxSize*& aBoxSizes, nscoord& aMinSize,
+                                nscoord& aMaxSize, PRInt32& aFlexes);
+  virtual void ComputeChildSizes(nsIFrame* aBox,
+                                 nsBoxLayoutState& aState,
+                                 nscoord& aGivenSize,
+                                 nsBoxSize* aBoxSizes,
+                                 nsComputedBoxSize*& aComputedBoxSizes);
 
 
   nsGridRowLeafLayout();
   virtual ~nsGridRowLeafLayout();
-  //virtual void AddBorderAndPadding(nsIBox* aBox, nsSize& aSize);
+  //virtual void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
 
 private:
 
 }; // class nsGridRowLeafLayout
 
 #endif
 
--- a/layout/xul/base/src/grid/nsIGridPart.h
+++ b/layout/xul/base/src/grid/nsIGridPart.h
@@ -44,38 +44,38 @@ public:
    *                       when aRequestor is non-null.
    * @param aRequestor [IN] Non-null if and only if this is a recursive
    *                   call from the GetGrid method on a child grid part,
    *                   in which case it is a pointer to that grid part.
    *                   (This may only be non-null for row groups and
    *                   grids.)
    * @return The grid of which aBox (a row, row group, or grid) is a part.
    */
-  virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr)=0;
+  virtual nsGrid* GetGrid(nsIFrame* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nullptr)=0;
 
   /**
    * @param aBox [IN] The other half of the |this| parameter, i.e., the box
    *                  whose layout manager is |this|.
    * @param aParentBox [OUT] The box representing the next level up in
    *                   the grid (i.e., row group for a row, grid for a
    *                   row group).
    * @returns The layout manager for aParentBox.
    */
-  virtual nsIGridPart* GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox) = 0;
+  virtual nsIGridPart* GetParentGridPart(nsIFrame* aBox, nsIFrame** aParentBox) = 0;
 
   /**
    * @param aBox [IN] The other half of the |this| parameter, i.e., the box
    *                  whose layout manager is |this|.
    * @param aRowCount [INOUT] Row count
    * @param aComputedColumnCount [INOUT] Column count
    */
-  virtual void CountRowsColumns(nsIBox* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)=0;
-  virtual void DirtyRows(nsIBox* aBox, nsBoxLayoutState& aState)=0;
-  virtual PRInt32 BuildRows(nsIBox* aBox, nsGridRow* aRows)=0;
-  virtual nsMargin GetTotalMargin(nsIBox* aBox, bool aIsHorizontal)=0;
+  virtual void CountRowsColumns(nsIFrame* aBox, PRInt32& aRowCount, PRInt32& aComputedColumnCount)=0;
+  virtual void DirtyRows(nsIFrame* aBox, nsBoxLayoutState& aState)=0;
+  virtual PRInt32 BuildRows(nsIFrame* aBox, nsGridRow* aRows)=0;
+  virtual nsMargin GetTotalMargin(nsIFrame* aBox, bool aIsHorizontal)=0;
   virtual PRInt32 GetRowCount() { return 1; }
   
   /**
    * Return the level of the grid hierarchy this grid part represents.
    */
   enum Type { eGrid, eRowGroup, eRowLeaf };
   virtual Type GetType()=0;
 
--- a/layout/xul/base/src/nsBox.cpp
+++ b/layout/xul/base/src/nsBox.cpp
@@ -198,17 +198,17 @@ nsBox::~nsBox()
 /* static */ void
 nsBox::Shutdown()
 {
   gGotTheme = false;
   NS_IF_RELEASE(gTheme);
 }
 
 NS_IMETHODIMP
-nsBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)
+nsBox::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)
 {
   return NS_OK;
 }
 
 nsresult
 nsIFrame::GetClientRect(nsRect& aClientRect)
 {
   aClientRect = mRect;
@@ -400,17 +400,17 @@ nsBox::GetPrefSize(nsBoxLayoutState& aSt
   nsSize pref(0,0);
   DISPLAY_PREF_SIZE(this, pref);
 
   if (IsCollapsed())
     return pref;
 
   AddBorderAndPadding(pref);
   bool widthSet, heightSet;
-  nsIBox::AddCSSPrefSize(this, pref, widthSet, heightSet);
+  nsIFrame::AddCSSPrefSize(this, pref, widthSet, heightSet);
 
   nsSize minSize = GetMinSize(aState);
   nsSize maxSize = GetMaxSize(aState);
   return BoundsCheck(minSize, pref, maxSize);
 }
 
 nsSize
 nsBox::GetMinSize(nsBoxLayoutState& aState)
@@ -420,17 +420,17 @@ nsBox::GetMinSize(nsBoxLayoutState& aSta
   nsSize min(0,0);
   DISPLAY_MIN_SIZE(this, min);
 
   if (IsCollapsed())
     return min;
 
   AddBorderAndPadding(min);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMinSize(aState, this, min, widthSet, heightSet);
+  nsIFrame::AddCSSMinSize(aState, this, min, widthSet, heightSet);
   return min;
 }
 
 nsSize
 nsBox::GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState)
 {
   return nsSize(0, 0);
 }
@@ -443,26 +443,26 @@ nsBox::GetMaxSize(nsBoxLayoutState& aSta
   nsSize maxSize(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
   DISPLAY_MAX_SIZE(this, maxSize);
 
   if (IsCollapsed())
     return maxSize;
 
   AddBorderAndPadding(maxSize);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMaxSize(this, maxSize, widthSet, heightSet);
+  nsIFrame::AddCSSMaxSize(this, maxSize, widthSet, heightSet);
   return maxSize;
 }
 
 nscoord
 nsBox::GetFlex(nsBoxLayoutState& aState)
 {
   nscoord flex = 0;
 
-  nsIBox::AddCSSFlex(aState, this, flex);
+  nsIFrame::AddCSSFlex(aState, this, flex);
 
   return flex;
 }
 
 PRUint32
 nsIFrame::GetOrdinal(nsBoxLayoutState& aState)
 {
   PRUint32 ordinal = GetStyleXUL()->mBoxOrdinal;
@@ -599,17 +599,17 @@ nsIFrame::Redraw(nsBoxLayoutState& aStat
   // nsStackLayout, at least, expects us to repaint descendants even
   // if a damage rect is provided
   FrameLayerBuilder::InvalidateThebesLayersInSubtree(this);
 
   return NS_OK;
 }
 
 bool
-nsIBox::AddCSSPrefSize(nsIBox* aBox, nsSize& aSize, bool &aWidthSet, bool &aHeightSet)
+nsIFrame::AddCSSPrefSize(nsIFrame* aBox, nsSize& aSize, bool &aWidthSet, bool &aHeightSet)
 {
     aWidthSet = false;
     aHeightSet = false;
 
     // add in the css min, max, pref
     const nsStylePosition* position = aBox->GetStylePosition();
 
     // see if the width or height was specifically set
@@ -672,17 +672,17 @@ nsIBox::AddCSSPrefSize(nsIBox* aBox, nsS
         }
     }
 
     return (aWidthSet && aHeightSet);
 }
 
 
 bool
-nsIBox::AddCSSMinSize(nsBoxLayoutState& aState, nsIBox* aBox, nsSize& aSize,
+nsIFrame::AddCSSMinSize(nsBoxLayoutState& aState, nsIFrame* aBox, nsSize& aSize,
                       bool &aWidthSet, bool &aHeightSet)
 {
     aWidthSet = false;
     aHeightSet = false;
 
     bool canOverride = true;
 
     // See if a native theme wants to supply a minimum size.
@@ -782,17 +782,17 @@ nsIBox::AddCSSMinSize(nsBoxLayoutState& 
             aHeightSet = true;
         }
     }
 
     return (aWidthSet && aHeightSet);
 }
 
 bool
-nsIBox::AddCSSMaxSize(nsIBox* aBox, nsSize& aSize, bool &aWidthSet, bool &aHeightSet)
+nsIFrame::AddCSSMaxSize(nsIFrame* aBox, nsSize& aSize, bool &aWidthSet, bool &aHeightSet)
 {
     aWidthSet = false;
     aHeightSet = false;
 
     // add in the css min, max, pref
     const nsStylePosition* position = aBox->GetStylePosition();
 
     // and max
@@ -841,17 +841,17 @@ nsIBox::AddCSSMaxSize(nsIBox* aBox, nsSi
             aHeightSet = true;
         }
     }
 
     return (aWidthSet || aHeightSet);
 }
 
 bool
-nsIBox::AddCSSFlex(nsBoxLayoutState& aState, nsIBox* aBox, nscoord& aFlex)
+nsIFrame::AddCSSFlex(nsBoxLayoutState& aState, nsIFrame* aBox, nscoord& aFlex)
 {
     bool flexSet = false;
 
     // get the flexibility
     aFlex = aBox->GetStyleXUL()->mBoxFlex;
 
     // attribute value overrides CSS
     nsIContent* content = aBox->GetContent();
@@ -877,25 +877,25 @@ nsIBox::AddCSSFlex(nsBoxLayoutState& aSt
 
 void
 nsBox::AddBorderAndPadding(nsSize& aSize)
 {
   AddBorderAndPadding(this, aSize);
 }
 
 void
-nsBox::AddBorderAndPadding(nsIBox* aBox, nsSize& aSize)
+nsBox::AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize)
 {
   nsMargin borderPadding(0,0,0,0);
   aBox->GetBorderAndPadding(borderPadding);
   AddMargin(aSize, borderPadding);
 }
 
 void
-nsBox::AddMargin(nsIBox* aChild, nsSize& aSize)
+nsBox::AddMargin(nsIFrame* aChild, nsSize& aSize)
 {
   nsMargin margin(0,0,0,0);
   aChild->GetMargin(margin);
   AddMargin(aSize, margin);
 }
 
 void
 nsBox::AddMargin(nsSize& aSize, const nsMargin& aMargin)
@@ -937,24 +937,24 @@ nsBox::BoundsCheck(const nsSize& aMinSiz
 nsresult
 nsBox::SetDebug(nsBoxLayoutState& aState, bool aDebug)
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsBox::GetDebugBoxAt( const nsPoint& aPoint,
-                      nsIBox**     aBox)
+                      nsIFrame**     aBox)
 {
   nsRect thisRect(nsPoint(0,0), GetSize());
   if (!thisRect.Contains(aPoint))
     return NS_ERROR_FAILURE;
 
-  nsIBox* child = GetChildBox();
-  nsIBox* hit = nullptr;
+  nsIFrame* child = GetChildBox();
+  nsIFrame* hit = nullptr;
 
   *aBox = nullptr;
   while (nullptr != child) {
     nsresult rv = child->GetDebugBoxAt(aPoint - child->GetOffsetTo(this), &hit);
 
     if (NS_SUCCEEDED(rv) && hit) {
       *aBox = hit;
     }
--- a/layout/xul/base/src/nsBox.h
+++ b/layout/xul/base/src/nsBox.h
@@ -37,20 +37,20 @@ public:
 
   NS_IMETHOD GetBorder(nsMargin& aBorderAndPadding);
   NS_IMETHOD GetPadding(nsMargin& aBorderAndPadding);
   NS_IMETHOD GetMargin(nsMargin& aMargin);
 
   virtual Valignment GetVAlign() const { return vAlign_Top; }
   virtual Halignment GetHAlign() const { return hAlign_Left; }
 
-  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
+  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild);
 
 #ifdef DEBUG_LAYOUT
-  NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIBox** aBox);
+  NS_IMETHOD GetDebugBoxAt(const nsPoint& aPoint, nsIFrame** aBox);
   NS_IMETHOD GetDebug(bool& aDebug);
   NS_IMETHOD SetDebug(nsBoxLayoutState& aState, bool aDebug);
 
   NS_IMETHOD DumpBox(FILE* out);
   NS_HIDDEN_(void) PropagateDebug(nsBoxLayoutState& aState);
 #endif
 
   nsBox();
@@ -67,18 +67,18 @@ rollbox.
 
   bool DoesNeedRecalc(const nsSize& aSize);
   bool DoesNeedRecalc(nscoord aCoord);
   void SizeNeedsRecalc(nsSize& aSize);
   void CoordNeedsRecalc(nscoord& aCoord);
 
   void AddBorderAndPadding(nsSize& aSize);
 
-  static void AddBorderAndPadding(nsIBox* aBox, nsSize& aSize);
-  static void AddMargin(nsIBox* aChild, nsSize& aSize);
+  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);
 
 protected:
 
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -75,17 +75,17 @@ using namespace mozilla;
 //#define TEST_SANITY
 
 #ifdef DEBUG_rods
 //#define DO_NOISY_REFLOW
 #endif
 
 #ifdef DEBUG_LAYOUT
 bool nsBoxFrame::gDebug = false;
-nsIBox* nsBoxFrame::mDebugChild = nullptr;
+nsIFrame* nsBoxFrame::mDebugChild = nullptr;
 #endif
 
 nsIFrame*
 NS_NewBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, bool aIsRoot, nsBoxLayout* aLayoutManager)
 {
   return new (aPresShell) nsBoxFrame(aPresShell, aContext, aIsRoot, aLayoutManager);
 }
 
@@ -754,17 +754,17 @@ nsBoxFrame::GetPrefSize(nsBoxLayoutState
   PropagateDebug(aBoxLayoutState);
 #endif
 
   if (IsCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
-  if (!nsIBox::AddCSSPrefSize(this, size, widthSet, heightSet))
+  if (!nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
       nsSize layoutSize = mLayoutManager->GetPrefSize(this, aBoxLayoutState);
       if (!widthSet)
         size.width = layoutSize.width;
       if (!heightSet)
         size.height = layoutSize.height;
     }
@@ -817,17 +817,17 @@ nsBoxFrame::GetMinSize(nsBoxLayoutState&
   PropagateDebug(aBoxLayoutState);
 #endif
 
   if (IsCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
-  if (!nsIBox::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet))
+  if (!nsIFrame::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
       nsSize layoutSize = mLayoutManager->GetMinSize(this, aBoxLayoutState);
       if (!widthSet)
         size.width = layoutSize.width;
       if (!heightSet)
         size.height = layoutSize.height;
     }
@@ -857,17 +857,17 @@ nsBoxFrame::GetMaxSize(nsBoxLayoutState&
   PropagateDebug(aBoxLayoutState);
 #endif
 
   if (IsCollapsed())
     return size;
 
   // if the size was not completely redefined in CSS then ask our children
   bool widthSet, heightSet;
-  if (!nsIBox::AddCSSMaxSize(this, size, widthSet, heightSet))
+  if (!nsIFrame::AddCSSMaxSize(this, size, widthSet, heightSet))
   {
     if (mLayoutManager) {
       nsSize layoutSize = mLayoutManager->GetMaxSize(this, aBoxLayoutState);
       if (!widthSet)
         size.width = layoutSize.width;
       if (!heightSet)
         size.height = layoutSize.height;
     }
@@ -1221,17 +1221,17 @@ nsBoxFrame::AttributeChanged(PRInt32 aNa
       UpdateMouseThrough();
     }
 
     PresContext()->PresShell()->
       FrameNeedsReflow(this, nsIPresShell::eStyleChange, NS_FRAME_IS_DIRTY);
   }
   else if (aAttribute == nsGkAtoms::ordinal) {
     nsBoxLayoutState state(PresContext());
-    nsIBox* parent = GetParentBox();
+    nsIFrame* parent = GetParentBox();
     // 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) &&
         GetStyleDisplay()->mDisplay != NS_STYLE_DISPLAY_POPUP) {
       parent->RelayoutChildAtOrdinal(state, this);
@@ -1708,17 +1708,17 @@ nsBoxFrame::GetValue(nsPresContext* aPre
 {
     if (a == NS_INTRINSICSIZE)
       sprintf(ch, "%d[SET]", b);             
     else
       sprintf(ch, "%d", a);             
 }
 
 nsresult
-nsBoxFrame::DisplayDebugInfoFor(nsIBox*  aBox,
+nsBoxFrame::DisplayDebugInfoFor(nsIFrame*  aBox,
                                 nsPoint& aPoint)
 {
     nsBoxLayoutState state(GetPresContext());
 
     nscoord x = aPoint.x;
     nscoord y = aPoint.y;
 
     // get the area inside our border but not our debug margins.
@@ -1731,17 +1731,17 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* 
     bool isHorizontal = IsHorizontal();
 
     if (!insideBorder.Contains(nsPoint(x,y)))
         return NS_ERROR_FAILURE;
 
     //printf("%%%%%% inside box %%%%%%%\n");
 
     int count = 0;
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     nsMargin m;
     nsMargin m2;
     GetDebugBorder(m);
     PixelMarginToTwips(aPresContext, m);
 
     GetDebugMargin(m2);
     PixelMarginToTwips(aPresContext, m2);
@@ -1778,20 +1778,20 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* 
                     mDebugChild = child;
 
                     nsSize prefSizeCSS(NS_INTRINSICSIZE, NS_INTRINSICSIZE);
                     nsSize minSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
                     nsSize maxSizeCSS (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
                     nscoord flexCSS = NS_INTRINSICSIZE;
 
                     bool widthSet, heightSet;
-                    nsIBox::AddCSSPrefSize(child, prefSizeCSS, widthSet, heightSet);
-                    nsIBox::AddCSSMinSize (state, child, minSizeCSS, widthSet, heightSet);
-                    nsIBox::AddCSSMaxSize (child, maxSizeCSS, widthSet, heightSet);
-                    nsIBox::AddCSSFlex    (state, child, flexCSS);
+                    nsIFrame::AddCSSPrefSize(child, prefSizeCSS, widthSet, heightSet);
+                    nsIFrame::AddCSSMinSize (state, child, minSizeCSS, widthSet, heightSet);
+                    nsIFrame::AddCSSMaxSize (child, maxSizeCSS, widthSet, heightSet);
+                    nsIFrame::AddCSSFlex    (state, child, flexCSS);
 
                     nsSize prefSize = child->GetPrefSize(state);
                     nsSize minSize = child->GetMinSize(state);
                     nsSize maxSize = child->GetMaxSize(state);
                     nscoord flexSize = child->GetFlex(state);
                     nscoord ascentSize = child->GetBoxAscent(state);
 
                     char min[100];
@@ -1832,28 +1832,28 @@ nsBoxFrame::DisplayDebugInfoFor(nsIBox* 
     }
 
     mDebugChild = nullptr;
 
     return NS_OK;
 }
 
 void
-nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, bool aDebug)
+nsBoxFrame::SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug)
 {
-    nsIBox* child = GetChildBox();
+    nsIFrame* child = GetChildBox();
      while (child)
      {
         child->SetDebug(aState, aDebug);
         child = child->GetNextBox();
      }
 }
 
 nsresult
-nsBoxFrame::GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize)
+nsBoxFrame::GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize)
 {
   nsRect rect(aBox->GetRect());
   nsMargin margin(0,0,0,0);
   aBox->GetMargin(margin);
   rect.Inflate(margin);
   aSize.width = rect.width;
   aSize.height = rect.height;
   return NS_OK;
@@ -2019,33 +2019,33 @@ nsBoxFrame::CheckBoxOrder(nsBoxLayoutSta
   if (!child)
     return;
 
   nsIFrame* head = MergeSort(aState, mFrames.FirstChild());
   mFrames = nsFrameList(head, nsLayoutUtils::GetLastSibling(head));
 }
 
 nsresult
-nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect)
+nsBoxFrame::LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect)
 {
   // get the current rect
   nsRect oldRect(aBox->GetRect());
   aBox->SetBounds(aState, aRect);
 
   bool layout = NS_SUBTREE_DIRTY(aBox);
   
   if (layout || (oldRect.width != aRect.width || oldRect.height != aRect.height))  {
     return aBox->Layout(aState);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsBoxFrame::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild)
+nsBoxFrame::RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild)
 {
   if (!SupportsOrdinalsInChildren())
     return NS_OK;
 
   PRUint32 ord = aChild->GetOrdinal(aState);
   
   nsIFrame* child = mFrames.FirstChild();
   nsIFrame* newPrevSib = nullptr;
--- a/layout/xul/base/src/nsBoxFrame.h
+++ b/layout/xul/base/src/nsBoxFrame.h
@@ -53,21 +53,20 @@ public:
                                   bool aIsRoot,
                                   nsBoxLayout* aLayoutManager);
   friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
                                   nsStyleContext* aContext);
 
   // gets the rect inside our border and debug border. If you wish to paint inside a box
   // call this method to get the rect so you don't draw on the debug border or outer border.
 
-  // ------ nsIBox -------------
   virtual void SetLayoutManager(nsBoxLayout* aLayout) { mLayoutManager = aLayout; }
   virtual nsBoxLayout* GetLayoutManager() { return mLayoutManager; }
 
-  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIBox* aChild);
+  NS_IMETHOD RelayoutChildAtOrdinal(nsBoxLayoutState& aState, nsIFrame* aChild);
 
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nscoord GetFlex(nsBoxLayoutState& aBoxLayoutState);
   virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
 #ifdef DEBUG_LAYOUT
   NS_IMETHOD SetDebug(nsBoxLayoutState& aBoxLayoutState, bool aDebug);
@@ -157,22 +156,22 @@ public:
                                          const nsRect&           aDirtyRect,
                                          const nsDisplayListSet& aLists);
 
   NS_IMETHOD BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                               const nsRect&           aDirtyRect,
                               const nsDisplayListSet& aLists);
   
 #ifdef DEBUG_LAYOUT
-    virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIBox* aChild, bool aDebug);
-    nsresult DisplayDebugInfoFor(nsIBox*  aBox, 
+    virtual void SetDebugOnChildList(nsBoxLayoutState& aState, nsIFrame* aChild, bool aDebug);
+    nsresult DisplayDebugInfoFor(nsIFrame*  aBox, 
                                  nsPoint& aPoint);
 #endif
 
-  static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIBox* aBox, const nsRect& aRect);
+  static nsresult LayoutChildAt(nsBoxLayoutState& aState, nsIFrame* aBox, const nsRect& aRect);
 
   /**
    * Utility method to redirect events on descendants to this frame.
    * Supports 'allowevents' attribute on descendant elements to allow those
    * elements and their descendants to receive events.
    */
   nsresult WrapListsInRedirector(nsDisplayListBuilder*   aBuilder,
                                  const nsDisplayListSet& aIn,
@@ -228,17 +227,17 @@ private:
     nsresult SetDebug(nsPresContext* aPresContext, bool aDebug);
     bool GetInitialDebug(bool& aDebug);
     void GetDebugPref(nsPresContext* aPresContext);
 
     void GetDebugBorder(nsMargin& aInset);
     void GetDebugPadding(nsMargin& aInset);
     void GetDebugMargin(nsMargin& aInset);
 
-    nsresult GetFrameSizeWithMargin(nsIBox* aBox, nsSize& aSize);
+    nsresult GetFrameSizeWithMargin(nsIFrame* aBox, nsSize& aSize);
 
     void PixelMarginToTwips(nsPresContext* aPresContext, nsMargin& aMarginPixels);
 
     void GetValue(nsPresContext* aPresContext, const nsSize& a, const nsSize& b, char* value);
     void GetValue(nsPresContext* aPresContext, PRInt32 a, PRInt32 b, char* value);
     void DrawSpacer(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, bool aHorizontal, PRInt32 flex, nscoord x, nscoord y, nscoord size, nscoord spacerSize);
     void DrawLine(nsRenderingContext& aRenderingContext,  bool aHorizontal, nscoord x1, nscoord y1, nscoord x2, nscoord y2);
     void FillRect(nsRenderingContext& aRenderingContext,  bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height);
@@ -248,15 +247,15 @@ private:
     void CacheAttributes();
 
     // instance variables.
     Halignment mHalign;
     Valignment mValign;
 
 #ifdef DEBUG_LAYOUT
     static bool gDebug;
-    static nsIBox* mDebugChild;
+    static nsIFrame* mDebugChild;
 #endif
 
 }; // class nsBoxFrame
 
 #endif
 
--- a/layout/xul/base/src/nsBoxLayout.cpp
+++ b/layout/xul/base/src/nsBoxLayout.cpp
@@ -11,67 +11,67 @@
 //
 
 #include "nsBox.h"
 #include "nsCOMPtr.h"
 #include "nsContainerFrame.h"
 #include "nsBoxLayout.h"
 
 void
-nsBoxLayout::AddBorderAndPadding(nsIBox* aBox, nsSize& aSize)
+nsBoxLayout::AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize)
 {
   nsBox::AddBorderAndPadding(aBox, aSize);
 }
 
 void
-nsBoxLayout::AddMargin(nsIBox* aBox, nsSize& aSize)
+nsBoxLayout::AddMargin(nsIFrame* aBox, nsSize& aSize)
 {
   nsBox::AddMargin(aBox, aSize);
 }
 
 void
 nsBoxLayout::AddMargin(nsSize& aSize, const nsMargin& aMargin)
 {
   nsBox::AddMargin(aSize, aMargin);
 }
 
 nsSize
-nsBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsBoxLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsSize pref (0, 0);
   AddBorderAndPadding(aBox, pref);
 
   return pref;
 }
 
 nsSize
-nsBoxLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsBoxLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsSize minSize (0,0);
   AddBorderAndPadding(aBox, minSize);
   return minSize;
 }
 
 nsSize
-nsBoxLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsBoxLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   //AddBorderAndPadding () never changes maxSize (NS_INTRINSICSIZE)
   //AddBorderAndPadding(aBox, maxSize);
   return nsSize (NS_INTRINSICSIZE,NS_INTRINSICSIZE);
 }
 
 
 nscoord
-nsBoxLayout::GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsBoxLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   return 0;
 }
 
 NS_IMETHODIMP
-nsBoxLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsBoxLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   return NS_OK;
 }
 
 void
 nsBoxLayout::AddLargestSize(nsSize& aSize, const nsSize& aSize2)
 {
   if (aSize2.width > aSize.width)
--- a/layout/xul/base/src/nsBoxLayout.h
+++ b/layout/xul/base/src/nsBoxLayout.h
@@ -2,17 +2,23 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsBoxLayout_h___
 #define nsBoxLayout_h___
 
 #include "nsISupports.h"
-#include "nsIFrame.h"
+#include "nsCoord.h"
+#include "nsFrameList.h"
+
+class nsIFrame;
+class nsBoxLayoutState;
+struct nsSize;
+struct nsMargin;
 
 #define NS_BOX_LAYOUT_IID \
 { 0x09d522a7, 0x304c, 0x4137, \
  { 0xaf, 0xc9, 0xe0, 0x80, 0x2e, 0x89, 0xb7, 0xe8 } }
 
 class nsIGridPart;
 
 class nsBoxLayout : public nsISupports {
@@ -21,33 +27,33 @@ public:
 
   nsBoxLayout() {}
   virtual ~nsBoxLayout() {}
 
   NS_DECL_ISUPPORTS
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_BOX_LAYOUT_IID)
 
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState);
 
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nscoord GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
-                                nsIBox* aPrevBox,
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nscoord GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual void ChildrenInserted(nsIFrame* aBox, nsBoxLayoutState& aState,
+                                nsIFrame* aPrevBox,
                                 const nsFrameList::Slice& aNewChildren) {}
-  virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
+  virtual void ChildrenAppended(nsIFrame* aBox, nsBoxLayoutState& aState,
                                 const nsFrameList::Slice& aNewChildren) {}
-  virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) {}
-  virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList) {}
-  virtual void IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aState) {}
+  virtual void ChildrenRemoved(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList) {}
+  virtual void ChildrenSet(nsIFrame* aBox, nsBoxLayoutState& aState, nsIFrame* aChildList) {}
+  virtual void IntrinsicWidthsDirty(nsIFrame* aBox, nsBoxLayoutState& aState) {}
 
-  virtual void AddBorderAndPadding(nsIBox* aBox, nsSize& aSize);
-  virtual void AddMargin(nsIBox* aChild, nsSize& aSize);
+  virtual void AddBorderAndPadding(nsIFrame* aBox, nsSize& aSize);
+  virtual void AddMargin(nsIFrame* aChild, nsSize& aSize);
   virtual void AddMargin(nsSize& aSize, const nsMargin& aMargin);
 
   virtual nsIGridPart* AsGridPart() { return nullptr; }
 
   static void AddLargestSize(nsSize& aSize, const nsSize& aToAdd);
   static void AddSmallestSize(nsSize& aSize, const nsSize& aToAdd);
 };
 
--- a/layout/xul/base/src/nsDeckFrame.cpp
+++ b/layout/xul/base/src/nsDeckFrame.cpp
@@ -78,34 +78,34 @@ nsDeckFrame::Init(nsIContent*     aConte
   nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
 
   mIndex = GetSelectedIndex();
 
   return rv;
 }
 
 void
-nsDeckFrame::HideBox(nsIBox* aBox)
+nsDeckFrame::HideBox(nsIFrame* aBox)
 {
   nsIPresShell::ClearMouseCapture(aBox);
 }
 
 void
 nsDeckFrame::IndexChanged()
 {
   //did the index change?
   PRInt32 index = GetSelectedIndex();
   if (index == mIndex)
     return;
 
   // redraw
   InvalidateOverflowRect();
 
   // hide the currently showing box
-  nsIBox* currentBox = GetSelectedBox();
+  nsIFrame* currentBox = GetSelectedBox();
   if (currentBox) // only hide if it exists
     HideBox(currentBox);
 
   mIndex = index;
 }
 
 PRInt32
 nsDeckFrame::GetSelectedIndex()
@@ -147,17 +147,17 @@ nsDeckFrame::BuildDisplayList(nsDisplayL
 }
 
 NS_IMETHODIMP
 nsDeckFrame::BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                          const nsRect&           aDirtyRect,
                                          const nsDisplayListSet& aLists)
 {
   // only paint the selected box
-  nsIBox* box = GetSelectedBox();
+  nsIFrame* box = GetSelectedBox();
   if (!box)
     return NS_OK;
 
   // Putting the child in the background list. This is a little weird but
   // it matches what we were doing before.
   nsDisplayListSet set(aLists, aLists.BlockBorderBackgrounds());
   return BuildDisplayListForChild(aBuilder, box, aDirtyRect, set);
 }
@@ -169,17 +169,17 @@ nsDeckFrame::DoLayout(nsBoxLayoutState& 
   // We will do that.
   PRUint32 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
-  nsIBox* box = GetChildBox();
+  nsIFrame* box = GetChildBox();
 
   nscoord count = 0;
   while (box) 
   {
     // make collapsed children not show up
     if (count != mIndex) 
       HideBox(box);
 
--- a/layout/xul/base/src/nsDeckFrame.h
+++ b/layout/xul/base/src/nsDeckFrame.h
@@ -56,17 +56,17 @@ public:
   nsDeckFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 
   nsIFrame* GetSelectedBox();
 
 protected:
 
   void IndexChanged();
   PRInt32 GetSelectedIndex();
-  void HideBox(nsIBox* aBox);
+  void HideBox(nsIFrame* aBox);
 
 private:
 
   PRInt32 mIndex;
 
 }; // class nsDeckFrame
 
 #endif
--- a/layout/xul/base/src/nsGroupBoxFrame.cpp
+++ b/layout/xul/base/src/nsGroupBoxFrame.cpp
@@ -38,17 +38,17 @@ public:
   // make sure we our kids get our orient and align instead of us.
   // our child box has no content node so it will search for a parent with one.
   // that will be us.
   virtual void GetInitialOrientation(bool& aHorizontal) { aHorizontal = false; }
   virtual bool GetInitialHAlignment(Halignment& aHalign)  { aHalign = hAlign_Left; return true; } 
   virtual bool GetInitialVAlignment(Valignment& aValign)  { aValign = vAlign_Top; return true; } 
   virtual bool GetInitialAutoStretch(bool& aStretch)    { aStretch = true; return true; } 
 
-  nsIBox* GetCaptionBox(nsPresContext* aPresContext, nsRect& aCaptionRect);
+  nsIFrame* GetCaptionBox(nsPresContext* aPresContext, nsRect& aCaptionRect);
 };
 
 /*
 class nsGroupBoxInnerFrame : public nsBoxFrame {
 public:
 
     nsGroupBoxInnerFrame(nsIPresShell* aShell, nsStyleContext* aContext):
       nsBoxFrame(aShell, aContext) {}
@@ -128,17 +128,17 @@ nsGroupBoxFrame::PaintBorderBackground(n
     nsPoint aPt, const nsRect& aDirtyRect) {
   PRIntn skipSides = 0;
   const nsStyleBorder* borderStyleData = GetStyleBorder();
   const nsMargin& border = borderStyleData->GetComputedBorder();
   nscoord yoff = 0;
   nsPresContext* presContext = PresContext();
 
   nsRect groupRect;
-  nsIBox* groupBox = GetCaptionBox(presContext, groupRect);
+  nsIFrame* groupBox = GetCaptionBox(presContext, groupRect);
 
   if (groupBox) {        
     // if the border is smaller than the legend. Move the border down
     // to be centered on the legend. 
     nsMargin groupMargin;
     groupBox->GetStyleMargin()->GetMargin(groupMargin);
     groupRect.Inflate(groupMargin);
  
@@ -202,35 +202,35 @@ nsGroupBoxFrame::PaintBorderBackground(n
     
   } else {
     nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
                                 aDirtyRect, nsRect(aPt, GetSize()),
                                 mStyleContext, skipSides);
   }
 }
 
-nsIBox*
+nsIFrame*
 nsGroupBoxFrame::GetCaptionBox(nsPresContext* aPresContext, nsRect& aCaptionRect)
 {
     // first child is our grouped area
-    nsIBox* box = GetChildBox();
+    nsIFrame* box = GetChildBox();
 
     // no area fail.
     if (!box)
       return nullptr;
 
     // get the first child in the grouped area, that is the caption
     box = box->GetChildBox();
 
     // nothing in the area? fail
     if (!box)
       return nullptr;
 
     // now get the caption itself. It is in the caption frame.
-    nsIBox* child = box->GetChildBox();
+    nsIFrame* child = box->GetChildBox();
 
     if (child) {
        // convert to our coordinates.
        nsRect parentRect(box->GetRect());
        aCaptionRect = child->GetRect();
        aCaptionRect.x += parentRect.x;
        aCaptionRect.y += parentRect.y;
     }
--- a/layout/xul/base/src/nsImageBoxFrame.cpp
+++ b/layout/xul/base/src/nsImageBoxFrame.cpp
@@ -434,17 +434,17 @@ nsImageBoxFrame::GetPrefSize(nsBoxLayout
   nsSize intrinsicSize = size;
 
   nsMargin borderPadding(0,0,0,0);
   GetBorderAndPadding(borderPadding);
   size.width += borderPadding.LeftRight();
   size.height += borderPadding.TopBottom();
 
   bool widthSet, heightSet;
-  nsIBox::AddCSSPrefSize(this, size, widthSet, heightSet);
+  nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet);
   NS_ASSERTION(size.width != NS_INTRINSICSIZE && size.height != NS_INTRINSICSIZE,
                "non-intrinsic size expected");
 
   nsSize minSize = GetMinSize(aState);
   nsSize maxSize = GetMaxSize(aState);
 
   if (!widthSet && !heightSet) {
     if (minSize.width != NS_INTRINSICSIZE)
@@ -499,17 +499,17 @@ nsImageBoxFrame::GetPrefSize(nsBoxLayout
 nsSize
 nsImageBoxFrame::GetMinSize(nsBoxLayoutState& aState)
 {
   // An image can always scale down to (0,0).
   nsSize size(0,0);
   DISPLAY_MIN_SIZE(this, size);
   AddBorderAndPadding(size);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMinSize(aState, this, size, widthSet, heightSet);
+  nsIFrame::AddCSSMinSize(aState, this, size, widthSet, heightSet);
   return size;
 }
 
 nscoord
 nsImageBoxFrame::GetBoxAscent(nsBoxLayoutState& aState)
 {
   return GetPrefSize(aState).height;
 }
--- a/layout/xul/base/src/nsImageBoxFrame.h
+++ b/layout/xul/base/src/nsImageBoxFrame.h
@@ -39,26 +39,23 @@ private:
   nsImageBoxFrame *mFrame;
 };
 
 class nsImageBoxFrame : public nsLeafBoxFrame
 {
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
-  // nsIBox
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
   virtual void MarkIntrinsicWidthsDirty();
 
   friend nsIFrame* NS_NewImageBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
 
-  // nsIBox frame interface
-
   NS_IMETHOD  Init(nsIContent*      aContent,
                    nsIFrame*        aParent,
                    nsIFrame*        asPrevInFlow);
 
   NS_IMETHOD AttributeChanged(PRInt32 aNameSpaceID,
                               nsIAtom* aAttribute,
                               PRInt32 aModType);
 
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -179,17 +179,17 @@ NS_IMETHODIMP
 nsListBoxBodyFrame::Init(nsIContent*     aContent,
                          nsIFrame*       aParent, 
                          nsIFrame*       aPrevInFlow)
 {
   nsresult rv = nsBoxFrame::Init(aContent, aParent, aPrevInFlow);
   NS_ENSURE_SUCCESS(rv, rv);
   nsIScrollableFrame* scrollFrame = nsLayoutUtils::GetScrollableFrameFor(this);
   if (scrollFrame) {
-    nsIBox* verticalScrollbar = scrollFrame->GetScrollbarBox(true);
+    nsIFrame* verticalScrollbar = scrollFrame->GetScrollbarBox(true);
     nsScrollbarFrame* scrollbarFrame = do_QueryFrame(verticalScrollbar);
     if (scrollbarFrame) {
       scrollbarFrame->SetScrollbarMediatorContent(GetContent());
     }
   }
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
   mRowHeight = fm->MaxHeight();
@@ -230,18 +230,16 @@ nsListBoxBodyFrame::AttributeChanged(PRI
   }
   else
     rv = nsBoxFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
 
   return rv;
  
 }
 
-/////////// nsIBox ///////////////
-
 /* virtual */ void
 nsListBoxBodyFrame::MarkIntrinsicWidthsDirty()
 {
   mStringWidth = -1;
   nsBoxFrame::MarkIntrinsicWidthsDirty();
 }
 
 /////////// nsBox ///////////////
@@ -990,17 +988,17 @@ nsListBoxBodyFrame::CreateRows()
     if (fixed)
       availableHeight = 10;
     else
       return;
   }
   
   // get the first tree box. If there isn't one create one.
   bool created = false;
-  nsIBox* box = GetFirstItemBox(0, &created);
+  nsIFrame* box = GetFirstItemBox(0, &created);
   nscoord rowHeight = GetRowHeightAppUnits();
   while (box) {  
     if (created && mRowsToPrepend > 0)
       --mRowsToPrepend;
 
     // if the row height is 0 then fail. Wait until someone 
     // laid out and sets the row height.
     if (rowHeight == 0)
@@ -1083,38 +1081,38 @@ IsListItemChild(nsListBoxBodyFrame* aPar
   if (existingFrame && existingFrame->GetParent() != aParent) {
     return false;
   }
   *aChildFrame = existingFrame;
   return true;
 }
 
 //
-// Get the nsIBox for the first visible listitem, and if none exists,
+// Get the nsIFrame for the first visible listitem, and if none exists,
 // create one.
 //
-nsIBox* 
+nsIFrame*
 nsListBoxBodyFrame::GetFirstItemBox(PRInt32 aOffset, bool* aCreated)
 {
   if (aCreated)
    *aCreated = false;
 
   // Clear ourselves out.
   mBottomFrame = mTopFrame;
 
   if (mTopFrame) {
-    return mTopFrame->IsBoxFrame() ? static_cast<nsIBox*>(mTopFrame) : nullptr;
+    return mTopFrame->IsBoxFrame() ? mTopFrame : nullptr;
   }
 
   // top frame was cleared out
   mTopFrame = GetFirstFrame();
   mBottomFrame = mTopFrame;
 
   if (mTopFrame && mRowsToPrepend <= 0) {
-    return mTopFrame->IsBoxFrame() ? static_cast<nsIBox*>(mTopFrame) : nullptr;
+    return mTopFrame->IsBoxFrame() ? mTopFrame : nullptr;
   }
 
   // At this point, we either have no frames at all, 
   // or the user has scrolled upwards, leaving frames
   // to be created at the top.  Let's determine which
   // content needs a new frame first.
 
   nsCOMPtr<nsIContent> startContent;
@@ -1154,30 +1152,30 @@ nsListBoxBodyFrame::GetFirstItemBox(PRIn
                              &topFrame, isAppend, false, nullptr);
     mTopFrame = topFrame;
     if (mTopFrame) {
       if (aCreated)
         *aCreated = true;
 
       mBottomFrame = mTopFrame;
 
-      return mTopFrame->IsBoxFrame() ? static_cast<nsIBox*>(mTopFrame) : nullptr;
+      return mTopFrame->IsBoxFrame() ? mTopFrame : nullptr;
     } else
       return GetFirstItemBox(++aOffset, 0);
   }
 
   return nullptr;
 }
 
 //
-// Get the nsIBox for the next visible listitem after aBox, and if none
+// Get the nsIFrame for the next visible listitem after aBox, and if none
 // exists, create one.
 //
-nsIBox* 
-nsListBoxBodyFrame::GetNextItemBox(nsIBox* aBox, PRInt32 aOffset,
+nsIFrame*
+nsListBoxBodyFrame::GetNextItemBox(nsIFrame* aBox, PRInt32 aOffset,
                                    bool* aCreated)
 {
   if (aCreated)
     *aCreated = false;
 
   nsIFrame* result = aBox->GetNextSibling();
 
   if (!result || result == mLinkupFrame || mRowsToPrepend > 0) {
--- a/layout/xul/base/src/nsListBoxBodyFrame.h
+++ b/layout/xul/base/src/nsListBoxBodyFrame.h
@@ -58,17 +58,16 @@ public:
   NS_IMETHOD PositionChanged(nsScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32& aNewIndex);
   NS_IMETHOD ScrollbarButtonPressed(nsScrollbarFrame* aScrollbar, PRInt32 aOldIndex, PRInt32 aNewIndex);
   NS_IMETHOD VisibilityChanged(bool aVisible);
 
   // nsIReflowCallback
   virtual bool ReflowFinished();
   virtual void ReflowCallbackCanceled();
 
-  // nsIBox
   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
   virtual void MarkIntrinsicWidthsDirty();
 
   virtual nsSize GetMinSizeForScrollArea(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
 
   // size calculation 
   PRInt32 GetRowCount();
@@ -93,18 +92,18 @@ public:
   // frames
   nsIFrame* GetFirstFrame();
   nsIFrame* GetLastFrame();
 
   // lazy row creation and destruction
   void CreateRows();
   void DestroyRows(PRInt32& aRowsToLose);
   void ReverseDestroyRows(PRInt32& aRowsToLose);
-  nsIBox* GetFirstItemBox(PRInt32 aOffset, bool* aCreated);
-  nsIBox* GetNextItemBox(nsIBox* aBox, PRInt32 aOffset, bool* aCreated);
+  nsIFrame* GetFirstItemBox(PRInt32 aOffset, bool* aCreated);
+  nsIFrame* GetNextItemBox(nsIFrame* aBox, PRInt32 aOffset, bool* aCreated);
   bool ContinueReflow(nscoord height);
   NS_IMETHOD ListBoxAppendFrames(nsFrameList& aFrameList);
   NS_IMETHOD ListBoxInsertFrames(nsIFrame* aPrevFrame, nsFrameList& aFrameList);
   void OnContentInserted(nsPresContext* aPresContext, nsIContent* aContent);
   void OnContentRemoved(nsPresContext* aPresContext,  nsIContent* aContainer,
                         nsIFrame* aChildFrame, nsIContent* aOldNextSibling);
 
   void GetListItemContentAt(PRInt32 aIndex, nsIContent** aContent);
--- a/layout/xul/base/src/nsListBoxLayout.cpp
+++ b/layout/xul/base/src/nsListBoxLayout.cpp
@@ -16,17 +16,17 @@
 
 nsListBoxLayout::nsListBoxLayout() : nsGridRowGroupLayout()
 {
 }
 
 ////////// nsBoxLayout //////////////
 
 nsSize
-nsListBoxLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsListBoxLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsSize pref = nsGridRowGroupLayout::GetPrefSize(aBox, aBoxLayoutState);
 
   nsListBoxBodyFrame* frame = static_cast<nsListBoxBodyFrame*>(aBox);
   if (frame) {
     nscoord rowheight = frame->GetRowHeightAppUnits();
     pref.height = frame->GetRowCount() * rowheight;
     // Pad the height.
@@ -42,17 +42,17 @@ nsListBoxLayout::GetPrefSize(nsIBox* aBo
       if (width > pref.width)
         pref.width = width;
     }
   }
   return pref;
 }
 
 nsSize
-nsListBoxLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsListBoxLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsSize minSize = nsGridRowGroupLayout::GetMinSize(aBox, aBoxLayoutState);
 
   nsListBoxBodyFrame* frame = static_cast<nsListBoxBodyFrame*>(aBox);
   if (frame) {
     nscoord rowheight = frame->GetRowHeightAppUnits();
     minSize.height = frame->GetRowCount() * rowheight;
     // Pad the height.
@@ -68,17 +68,17 @@ nsListBoxLayout::GetMinSize(nsIBox* aBox
       if (width > minSize.width)
         minSize.width = width;
     }
   }
   return minSize;
 }
 
 nsSize
-nsListBoxLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)
+nsListBoxLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState)
 {
   nsSize maxSize = nsGridRowGroupLayout::GetMaxSize(aBox, aBoxLayoutState);
 
   nsListBoxBodyFrame* frame = static_cast<nsListBoxBodyFrame*>(aBox);
   if (frame) {
     nscoord rowheight = frame->GetRowHeightAppUnits();
     maxSize.height = frame->GetRowCount() * rowheight;
     // Pad the height.
@@ -88,29 +88,29 @@ nsListBoxLayout::GetMaxSize(nsIBox* aBox
       nscoord remainder = m == 0 ? 0 : rowheight - m;
       maxSize.height += remainder;
     }
   }
   return maxSize;
 }
 
 NS_IMETHODIMP
-nsListBoxLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
+nsListBoxLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   return LayoutInternal(aBox, aState);
 }
 
 
 /////////// nsListBoxLayout /////////////////////////
 
 /**
  * Called to layout our our children. Does no frame construction
  */
 NS_IMETHODIMP
-nsListBoxLayout::LayoutInternal(nsIBox* aBox, nsBoxLayoutState& aState)
+nsListBoxLayout::LayoutInternal(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   PRInt32 redrawStart = -1;
 
   // Get the start y position.
   nsListBoxBodyFrame* body = static_cast<nsListBoxBodyFrame*>(aBox);
   if (!body) {
     NS_ERROR("Frame encountered that isn't a listboxbody!");
     return NS_ERROR_FAILURE;
@@ -131,17 +131,17 @@ nsListBoxLayout::LayoutInternal(nsIBox* 
     bool fixed = (body->GetFixedRowSize() != -1);
     if (fixed)
       availableHeight = 10;
     else
       return NS_OK;
   }
 
   // run through all our currently created children
-  nsIBox* box = body->GetChildBox();
+  nsIFrame* box = body->GetChildBox();
 
   // 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());
--- a/layout/xul/base/src/nsListBoxLayout.h
+++ b/layout/xul/base/src/nsListBoxLayout.h
@@ -4,28 +4,28 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsListBoxLayout_h___
 #define nsListBoxLayout_h___
 
 #include "nsGridRowGroupLayout.h"
 
 class nsIFrame;
-typedef class nsIFrame nsIBox;
+typedef class nsIFrame nsIFrame;
 class nsBoxLayoutState;
 
 class nsListBoxLayout : public nsGridRowGroupLayout
 {
 public:
   nsListBoxLayout();
 
   // nsBoxLayout
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
 
 protected:
-  NS_IMETHOD LayoutInternal(nsIBox* aBox, nsBoxLayoutState& aState);
+  NS_IMETHOD LayoutInternal(nsIFrame* aBox, nsBoxLayoutState& aState);
 };
 
 #endif
 
--- a/layout/xul/base/src/nsListItemFrame.h
+++ b/layout/xul/base/src/nsListItemFrame.h
@@ -1,14 +1,13 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsBoxFrame.h"
 #include "nsGridRowLeafFrame.h"
 
 nsIFrame* NS_NewListItemFrame(nsIPresShell* aPresShell,
                               nsStyleContext *aContext);
 
 class nsListItemFrame : public nsGridRowLeafFrame
 {
 public:
@@ -18,19 +17,18 @@ public:
                                        nsStyleContext *aContext);
 
   // overridden so that children of listitems don't handle mouse events,
   // unless allowevents="true" is specified on the listitem
   NS_IMETHOD BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                          const nsRect&           aDirtyRect,
                                          const nsDisplayListSet& aLists);
 
-  // nsIBox
   virtual nsSize GetPrefSize(nsBoxLayoutState& aState);
-  
+
 protected:
   nsListItemFrame(nsIPresShell* aPresShell,
                   nsStyleContext *aContext,
                   bool aIsRoot = nullptr,
                   nsBoxLayout* aLayoutManager = nullptr);
   virtual ~nsListItemFrame();
 
 }; // class nsListItemFrame
--- a/layout/xul/base/src/nsMenuFrame.cpp
+++ b/layout/xul/base/src/nsMenuFrame.cpp
@@ -1333,17 +1333,17 @@ nsMenuFrame::AppendFrames(ChildListID   
 }
 
 bool
 nsMenuFrame::SizeToPopup(nsBoxLayoutState& aState, nsSize& aSize)
 {
   if (!IsCollapsed()) {
     bool widthSet, heightSet;
     nsSize tmpSize(-1, 0);
-    nsIBox::AddCSSPrefSize(this, tmpSize, widthSet, heightSet);
+    nsIFrame::AddCSSPrefSize(this, tmpSize, widthSet, heightSet);
     if (!widthSet && GetFlex(aState) == 0) {
       nsMenuPopupFrame* popupFrame = GetPopup();
       if (!popupFrame)
         return false;
       tmpSize = popupFrame->GetPrefSize(aState);
 
       // Produce a size such that:
       //  (1) the menu and its popup can be the same width
--- a/layout/xul/base/src/nsMenuFrame.h
+++ b/layout/xul/base/src/nsMenuFrame.h
@@ -77,17 +77,16 @@ class nsMenuFrame : public nsBoxFrame
 {
 public:
   nsMenuFrame(nsIPresShell* aShell, nsStyleContext* aContext);
 
   NS_DECL_QUERYFRAME_TARGET(nsMenuFrame)
   NS_DECL_QUERYFRAME
   NS_DECL_FRAMEARENA_HELPERS
 
-  // nsIBox
   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
 
   NS_IMETHOD Init(nsIContent*      aContent,
                   nsIFrame*        aParent,
                   nsIFrame*        aPrevInFlow);
 
--- a/layout/xul/base/src/nsPopupSetFrame.h
+++ b/layout/xul/base/src/nsPopupSetFrame.h
@@ -30,17 +30,16 @@ public:
   NS_IMETHOD RemoveFrame(ChildListID     aListID,
                          nsIFrame*       aOldFrame);
   NS_IMETHOD InsertFrames(ChildListID     aListID,
                           nsIFrame*       aPrevFrame,
                           nsFrameList&    aFrameList);
   NS_IMETHOD  SetInitialChildList(ChildListID     aListID,
                                   nsFrameList&    aChildList);
 
-  // nsIBox
   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
 
   // Used to destroy our popup frames.
   virtual void DestroyFrom(nsIFrame* aDestructRoot);
 
   virtual nsIAtom* GetType() const;
 
 #ifdef DEBUG
--- a/layout/xul/base/src/nsSliderFrame.cpp
+++ b/layout/xul/base/src/nsSliderFrame.cpp
@@ -43,17 +43,17 @@ using namespace mozilla;
 
 bool nsSliderFrame::gMiddlePref = false;
 PRInt32 nsSliderFrame::gSnapMultiplier;
 
 // Turn this on if you want to debug slider frames.
 #undef DEBUG_SLIDER
 
 static already_AddRefed<nsIContent>
-GetContentOfBox(nsIBox *aBox)
+GetContentOfBox(nsIFrame *aBox)
 {
   nsIContent* content = aBox->GetContent();
   NS_IF_ADDREF(content);
   return content;
 }
 
 nsIFrame*
 NS_NewSliderFrame (nsIPresShell* aPresShell, nsStyleContext* aContext)
@@ -233,17 +233,17 @@ nsSliderFrame::AttributeChanged(PRInt32 
      rv = CurrentPositionChanged(PresContext(), false);
      NS_ASSERTION(NS_SUCCEEDED(rv), "failed to change position");
      if (NS_FAILED(rv))
         return rv;
   } else if (aAttribute == nsGkAtoms::minpos ||
              aAttribute == nsGkAtoms::maxpos) {
       // bounds check it.
 
-      nsIBox* scrollbarBox = GetScrollbar();
+      nsIFrame* scrollbarBox = GetScrollbar();
       nsCOMPtr<nsIContent> scrollbar;
       scrollbar = GetContentOfBox(scrollbarBox);
       PRInt32 current = GetCurrentPosition(scrollbar);
       PRInt32 min = GetMinPosition(scrollbar);
       PRInt32 max = GetMaxPosition(scrollbar);
 
       // inform the parent <scale> that the minimum or maximum changed
       nsIFrame* parent = GetParent();
@@ -305,17 +305,17 @@ nsSliderFrame::BuildDisplayList(nsDispla
 }
 
 NS_IMETHODIMP
 nsSliderFrame::BuildDisplayListForChildren(nsDisplayListBuilder*   aBuilder,
                                            const nsRect&           aDirtyRect,
                                            const nsDisplayListSet& aLists)
 {
   // if we are too small to have a thumb don't paint it.
-  nsIBox* thumb = GetChildBox();
+  nsIFrame* thumb = GetChildBox();
 
   if (thumb) {
     nsRect thumbRect(thumb->GetRect());
     nsMargin m;
     thumb->GetMargin(m);
     thumbRect.Inflate(m);
 
     nsRect crect;
@@ -327,17 +327,17 @@ nsSliderFrame::BuildDisplayListForChildr
   
   return nsBoxFrame::BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists);
 }
 
 NS_IMETHODIMP
 nsSliderFrame::DoLayout(nsBoxLayoutState& aState)
 {
   // get the thumb should be our only child
-  nsIBox* thumbBox = GetChildBox();
+  nsIFrame* thumbBox = GetChildBox();
 
   if (!thumbBox) {
     SyncLayout(aState);
     return NS_OK;
   }
 
   EnsureOrient();
 
@@ -350,17 +350,17 @@ nsSliderFrame::DoLayout(nsBoxLayoutState
   }
 #endif
 
   // get the content area inside our borders
   nsRect clientRect;
   GetClientRect(clientRect);
 
   // get the scrollbar
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
   nsCOMPtr<nsIContent> scrollbar;
   scrollbar = GetContentOfBox(scrollbarBox);
 
   // get the thumb's pref size
   nsSize thumbSize = thumbBox->GetPrefSize(aState);
 
   if (IsHorizontal())
     thumbSize.height = clientRect.height;
@@ -425,17 +425,17 @@ nsSliderFrame::HandleEvent(nsPresContext
 
   // If a web page calls event.preventDefault() we still want to
   // scroll when scroll arrow is clicked. See bug 511075.
   if (!mContent->IsInNativeAnonymousSubtree() &&
       nsEventStatus_eConsumeNoDefault == *aEventStatus) {
     return NS_OK;
   }
 
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
   nsCOMPtr<nsIContent> scrollbar;
   scrollbar = GetContentOfBox(scrollbarBox);
   bool isHorizontal = IsHorizontal();
 
   if (isDraggingThumb())
   {
     switch (aEvent->message) {
     case NS_TOUCH_MOVE:
@@ -599,17 +599,17 @@ nsSliderFrame::GetScrollToClick()
 
 #else
     return mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::movetoclick,
                                   nsGkAtoms::_true, eCaseMatters);
   return false;
 #endif
 }
 
-nsIBox*
+nsIFrame*
 nsSliderFrame::GetScrollbar()
 {
   // if we are in a scrollbar then return the scrollbar's content node
   // if we are not then return ours.
    nsIFrame* scrollbar;
    nsScrollbarButtonFrame::GetParentWithTag(nsGkAtoms::scrollbar, this, scrollbar);
 
    if (scrollbar == nullptr)
@@ -619,17 +619,17 @@ nsSliderFrame::GetScrollbar()
 }
 
 void
 nsSliderFrame::PageUpDown(nscoord change)
 {
   // on a page up or down get our page increment. We get this by getting the scrollbar we are in and
   // asking it for the current position and the page increment. If we are not in a scrollbar we will
   // get the values from our own node.
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
   nsCOMPtr<nsIContent> scrollbar;
   scrollbar = GetContentOfBox(scrollbarBox);
 
   if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir,
                             nsGkAtoms::reverse, eCaseMatters))
     change = -change;
 
   nscoord pageIncrement = GetPageIncrement(scrollbar);
@@ -647,17 +647,17 @@ nsSliderFrame::PageUpDown(nscoord change
   SetCurrentPositionInternal(scrollbar, newpos, true, false);
 }
 
 // called when the current position changed and we need to update the thumb's location
 nsresult
 nsSliderFrame::CurrentPositionChanged(nsPresContext* aPresContext,
                                       bool aImmediateRedraw)
 {
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
   nsCOMPtr<nsIContent> scrollbar;
   scrollbar = GetContentOfBox(scrollbarBox);
 
   // get the current position
   PRInt32 curPos = GetCurrentPosition(scrollbar);
 
   // do nothing if the position did not change
   if (mCurPos == curPos)
@@ -779,17 +779,17 @@ nsSliderFrame::SetCurrentPosition(nsICon
 }
 
 void
 nsSliderFrame::SetCurrentPositionInternal(nsIContent* aScrollbar, PRInt32 aNewPos,
                                           bool aIsSmooth,
                                           bool aImmediateRedraw)
 {
   nsCOMPtr<nsIContent> scrollbar = aScrollbar;
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
 
   mUserChanged = true;
 
   nsScrollbarFrame* scrollbarFrame = do_QueryFrame(scrollbarBox);
   if (scrollbarFrame) {
     // See if we have a mediator.
     nsIScrollbarMediator* mediator = scrollbarFrame->GetScrollbarMediator();
     if (mediator) {
@@ -892,17 +892,17 @@ nsSliderFrame::StartDrag(nsIDOMEvent* aE
     if (!thumbFrame) {
       return NS_OK;
     }
     nsSize thumbSize = thumbFrame->GetSize();
     nscoord thumbLength = isHorizontal ? thumbSize.width : thumbSize.height;
 
     newpos -= (thumbLength/2);
 
-    nsIBox* scrollbarBox = GetScrollbar();
+    nsIFrame* scrollbarBox = GetScrollbar();
     scrollbar = GetContentOfBox(scrollbarBox);
   }
 
   DragThumb(true);
 
   if (scrollToClick) {
     // should aMaySnap be true here?
     SetCurrentThumbPosition(scrollbar, newpos, false, false, false);
@@ -1075,17 +1075,17 @@ nsSliderFrame::GetMaxSize(nsBoxLayoutSta
 {
   EnsureOrient();
   return nsBoxFrame::GetMaxSize(aState);
 }
 
 void
 nsSliderFrame::EnsureOrient()
 {
-  nsIBox* scrollbarBox = GetScrollbar();
+  nsIFrame* scrollbarBox = GetScrollbar();
 
   bool isHorizontal = (scrollbarBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
   if (isHorizontal)
       mState |= NS_STATE_IS_HORIZONTAL;
   else
       mState &= ~NS_STATE_IS_HORIZONTAL;
 }
 
--- a/layout/xul/base/src/nsSliderFrame.h
+++ b/layout/xul/base/src/nsSliderFrame.h
@@ -47,17 +47,16 @@ public:
   virtual ~nsSliderFrame();
 
 #ifdef DEBUG
   NS_IMETHOD GetFrameName(nsAString& aResult) const {
     return MakeFrameName(NS_LITERAL_STRING("SliderFrame"), aResult);
   }
 #endif
 
-  // nsIBox
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMaxSize(nsBoxLayoutState& aBoxLayoutState);
   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
 
   // nsIFrame overrides
   NS_IMETHOD  AppendFrames(ChildListID     aListID,
                            nsFrameList&    aFrameList);
@@ -122,17 +121,17 @@ public:
 
   NS_IMETHOD HandleRelease(nsPresContext* aPresContext,
                            nsGUIEvent *    aEvent,
                            nsEventStatus*  aEventStatus);
 
 private:
 
   bool GetScrollToClick();
-  nsIBox* GetScrollbar();
+  nsIFrame* GetScrollbar();
 
   void PageUpDown(nscoord change);
   void SetCurrentThumbPosition(nsIContent* aScrollbar, nscoord aNewPos, bool aIsSmooth,
                                bool aImmediateRedraw, bool aMaySnap);
   void SetCurrentPosition(nsIContent* aScrollbar, PRInt32 aNewPos, bool aIsSmooth,
                           bool aImmediateRedraw);
   void SetCurrentPositionInternal(nsIContent* aScrollbar, PRInt32 pos,
                                   bool aIsSmooth, bool aImmediateRedraw);
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -100,23 +100,23 @@ public:
   ResizeType GetResizeBefore();
   ResizeType GetResizeAfter();
   State GetState();
 
   void Reverse(nsSplitterInfo*& aIndexes, PRInt32 aCount);
   bool SupportsCollapseDirection(CollapseDirection aDirection);
 
   void EnsureOrient();
-  void SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize);
+  void SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize);
 
   nsSplitterFrame* mOuter;
   bool mDidDrag;
   nscoord mDragStart;
   nscoord mCurrentPos;
-  nsIBox* mParentBox;
+  nsIFrame* mParentBox;
   bool mPressed;
   nsSplitterInfo* mChildInfosBefore;
   nsSplitterInfo* mChildInfosAfter;
   PRInt32 mChildInfosBeforeCount;
   PRInt32 mChildInfosAfterCount;
   State mState;
   nscoord mSplitterPos;
   bool mDragging;
@@ -314,17 +314,17 @@ nsSplitterFrame::DoLayout(nsBoxLayoutSta
 
   return nsBoxFrame::DoLayout(aState);
 }
 
 
 void
 nsSplitterFrame::GetInitialOrientation(bool& aIsHorizontal)
 {
-  nsIBox* box = GetParentBox();
+  nsIFrame* box = GetParentBox();
   if (box) {
     aIsHorizontal = !box->IsHorizontal();
   }
   else
     nsBoxFrame::GetInitialOrientation(aIsHorizontal);
 }
 
 NS_IMETHODIMP
@@ -657,17 +657,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.
   PRInt32 count = 0;
   mChildInfosBeforeCount = 0;
   mChildInfosAfterCount = 0;
 
-  nsIBox* childBox = mParentBox->GetChildBox();
+  nsIFrame* childBox = mParentBox->GetChildBox();
 
   while (nullptr != childBox) 
   { 
     nsIContent* content = childBox->GetContent();
     nsIDocument* doc = content->OwnerDoc();
     PRInt32 dummy;
     nsIAtom* atom = doc->BindingManager()->ResolveTag(content, &dummy);
 
@@ -902,19 +902,19 @@ nsSplitterFrameInner::AdjustChildren(nsP
   AdjustChildren(aPresContext, mChildInfosBefore, mChildInfosBeforeCount, isHorizontal);
   AdjustChildren(aPresContext, mChildInfosAfter, mChildInfosAfterCount, isHorizontal);
    
    // printf("----- Posting Dirty -----\n");
 
   aPresContext->PresShell()->FlushPendingNotifications(Flush_Display);
 }
 
-static nsIBox* GetChildBoxForContent(nsIBox* aParentBox, nsIContent* aContent)
+static nsIFrame* GetChildBoxForContent(nsIFrame* aParentBox, nsIContent* aContent)
 {
-  nsIBox* childBox = aParentBox->GetChildBox();
+  nsIFrame* childBox = aParentBox->GetChildBox();
 
   while (nullptr != childBox) {
     if (childBox->GetContent() == aContent) {
       return childBox;
     }
     childBox = childBox->GetNextBox();
   }
   return nullptr;
@@ -925,37 +925,37 @@ nsSplitterFrameInner::AdjustChildren(nsP
 {
   ///printf("------- AdjustChildren------\n");
 
   nsBoxLayoutState state(aPresContext);
 
   nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
 
   // first set all the widths.
-  nsIBox* child =  mOuter->GetChildBox();
+  nsIFrame* child =  mOuter->GetChildBox();
   while(child)
   {
     SetPreferredSize(state, child, onePixel, aIsHorizontal, nullptr);
     child = child->GetNextBox();
   }
 
   // now set our changed widths.
   for (int i=0; i < aCount; i++) 
   {
     nscoord   pref       = aChildInfos[i].changed;
-    nsIBox* childBox     = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
+    nsIFrame* childBox     = GetChildBoxForContent(mParentBox, aChildInfos[i].childElem);
 
     if (childBox) {
       SetPreferredSize(state, childBox, onePixel, aIsHorizontal, &pref);
     }
   }
 }
 
 void
-nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIBox* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize)
+nsSplitterFrameInner::SetPreferredSize(nsBoxLayoutState& aState, nsIFrame* aChildBox, nscoord aOnePixel, bool aIsHorizontal, nscoord* aSize)
 {
   nsRect rect(aChildBox->GetRect());
   nscoord pref = 0;
 
   if (!aSize)
   {
     if (aIsHorizontal) 
       pref = rect.width;
--- a/layout/xul/base/src/nsSprocketLayout.cpp
+++ b/layout/xul/base/src/nsSprocketLayout.cpp
@@ -47,35 +47,35 @@ nsSprocketLayout::Shutdown()
   NS_IF_RELEASE(gInstance);
 }
 
 nsSprocketLayout::nsSprocketLayout()
 {
 }
 
 bool 
-nsSprocketLayout::IsHorizontal(nsIBox* aBox)
+nsSprocketLayout::IsHorizontal(nsIFrame* aBox)
 {
    return (aBox->GetStateBits() & NS_STATE_IS_HORIZONTAL) != 0;
 }
 
 void
-nsSprocketLayout::GetFrameState(nsIBox* aBox, nsFrameState& aState)
+nsSprocketLayout::GetFrameState(nsIFrame* aBox, nsFrameState& aState)
 {
    aState = aBox->GetStateBits();
 }
 
 static PRUint8
-GetFrameDirection(nsIBox* aBox)
+GetFrameDirection(nsIFrame* aBox)
 {
    return aBox->GetStyleVisibility()->mDirection;
 }
 
 static void
-HandleBoxPack(nsIBox* aBox, const nsFrameState& aFrameState, nscoord& aX, nscoord& aY, 
+HandleBoxPack(nsIFrame* aBox, const nsFrameState& aFrameState, nscoord& aX, nscoord& aY, 
               const nsRect& aOriginalRect, const nsRect& aClientRect)
 {
   // In the normal direction we lay out our kids in the positive direction (e.g., |x| will get
   // bigger for a horizontal box, and |y| will get bigger for a vertical box).  In the reverse
   // direction, the opposite is true.  We'll be laying out each child at a smaller |x| or
   // |y|.
   PRUint8 frameDirection = GetFrameDirection(aBox);
 
@@ -107,18 +107,18 @@ HandleBoxPack(nsIBox* aBox, const nsFram
     }
     else {
       // The reverse direction. |y| decreases as we move through our children.
       aY = aClientRect.y + aOriginalRect.height;
     }
   }
 
   // Get our pack/alignment information.
-  nsIBox::Halignment halign = aBox->GetHAlign();
-  nsIBox::Valignment valign = aBox->GetVAlign();
+  nsIFrame::Halignment halign = aBox->GetHAlign();
+  nsIFrame::Valignment valign = aBox->GetVAlign();
 
   // The following code handles box PACKING.  Packing comes into play in the case where the computed size for 
   // all of our children (now stored in our client rect) is smaller than the size available for
   // the box (stored in |aOriginalRect|).  
   // 
   // Here we adjust our |x| and |y| variables accordingly so that we start at the beginning,
   // middle, or end of the box.
   //
@@ -161,22 +161,22 @@ HandleBoxPack(nsIBox* aBox, const nsFram
         else
           aY -= (aOriginalRect.height - aClientRect.height);
         break;
     }
   }
 }
 
 NS_IMETHODIMP
-nsSprocketLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
+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()) {
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
     while(child) 
     {
       nsBoxFrame::LayoutChildAt(aState, child, nsRect(0,0,0,0));  
       child = child->GetNextBox();
     }
     return NS_OK;
   }
 
@@ -296,17 +296,17 @@ nsSprocketLayout::Layout(nsIBox* aBox, n
     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;
 
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     PRInt32 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.");
@@ -612,17 +612,17 @@ nsSprocketLayout::Layout(nsIBox* aBox, n
   // 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) {
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
 
     // reposition all our children
     while (child) 
     {
       nsRect childRect(child->GetRect());
       childRect.x += (x - origX);
       childRect.y += (y - origY);
       child->SetBounds(aState, childRect);
@@ -640,17 +640,17 @@ nsSprocketLayout::Layout(nsIBox* aBox, n
     aBox->Redraw(aState);
 
   // That's it!  If you made it this far without having a nervous breakdown, 
   // congratulations!  Go get yourself a beer.
   return NS_OK;
 }
 
 void
-nsSprocketLayout::PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes)
+nsSprocketLayout::PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes)
 {
   // used for the equal size flag
   nscoord biggestPrefWidth = 0;
   nscoord biggestMinWidth = 0;
   nscoord smallestMaxWidth = NS_INTRINSICSIZE;
 
   nsFrameState frameState = 0;
   GetFrameState(aBox, frameState);
@@ -673,17 +673,17 @@ nsSprocketLayout::PopulateBoxSizes(nsIBo
   // 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
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
 
   aFlexes = 0;
   nsBoxSize* currentBox = nullptr;
 
 #if 0
   nsBoxSize* start = aBoxSizes;
   
   while(child)
@@ -884,17 +884,17 @@ nsSprocketLayout::PopulateBoxSizes(nsIBo
       }
       currentBox = currentBox->next;
     }
   }
 
 }
 
 void
-nsSprocketLayout::ComputeChildsNextPosition(nsIBox* aBox, 
+nsSprocketLayout::ComputeChildsNextPosition(nsIFrame* aBox, 
                                       const nscoord& aCurX, 
                                       const nscoord& aCurY, 
                                       nscoord& aNextX, 
                                       nscoord& aNextY, 
                                       const nsRect& aCurrentChildSize)
 {
   // Get the position along the box axis for the child.
   // The out-of-axis position is not set.
@@ -913,46 +913,46 @@ nsSprocketLayout::ComputeChildsNextPosit
     if (frameState & NS_STATE_IS_DIRECTION_NORMAL)
       aNextY = aCurY + aCurrentChildSize.height;
     else
       aNextY = aCurY - aCurrentChildSize.height;
   }
 }
 
 void
-nsSprocketLayout::AlignChildren(nsIBox* aBox,
+nsSprocketLayout::AlignChildren(nsIFrame* aBox,
                                 nsBoxLayoutState& aState,
                                 bool* aNeedsRedraw)
 {
   nsFrameState frameState = 0;
   GetFrameState(aBox, frameState);
   bool isHorizontal = (frameState & NS_STATE_IS_HORIZONTAL) != 0;
   nsRect clientRect;
   aBox->GetClientRect(clientRect);
 
   NS_PRECONDITION(!(frameState & NS_STATE_AUTO_STRETCH),
                   "Only AlignChildren() with non-stretch alignment");
 
   // These are only calculated if needed
-  nsIBox::Halignment halign;
-  nsIBox::Valignment valign;
+  nsIFrame::Halignment halign;
+  nsIFrame::Valignment valign;
   nscoord maxAscent;
   bool isLTR;
 
   if (isHorizontal) {
     valign = aBox->GetVAlign();
     if (valign == nsBoxFrame::vAlign_BaseLine) {
       maxAscent = aBox->GetBoxAscent(aState);
     }
   } else {
     isLTR = GetFrameDirection(aBox) == NS_STYLE_DIRECTION_LTR;
     halign = aBox->GetHAlign();
   }
 
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
   while (child) {
 
     nsMargin margin;
     child->GetMargin(margin);
     nsRect childRect = child->GetRect();
 
     if (isHorizontal) {
       const nscoord startAlign = clientRect.y + margin.top;
@@ -1009,19 +1009,19 @@ nsSprocketLayout::AlignChildren(nsIBox* 
       child->SetBounds(aState, childRect);
     }
 
     child = child->GetNextBox();
   }
 }
 
 void
-nsSprocketLayout::ChildResized(nsIBox* aBox,
+nsSprocketLayout::ChildResized(nsIFrame* aBox,
                          nsBoxLayoutState& aState, 
-                         nsIBox* aChild,
+                         nsIFrame* aChild,
                          nsBoxSize* aChildBoxSize,
                          nsComputedBoxSize* aChildComputedSize,
                          nsBoxSize* aBoxSizes, 
                          nsComputedBoxSize* aComputedBoxSizes, 
                          const nsRect& aChildLayoutRect, 
                          nsRect& aChildActualRect, 
                          nsRect& aContainingRect,
                          PRInt32 aFlexes, 
@@ -1149,17 +1149,17 @@ nsSprocketLayout::InvalidateComputedSize
 {
   while(aComputedBoxSizes) {
       aComputedBoxSizes->valid = false;
       aComputedBoxSizes = aComputedBoxSizes->next;
   }
 }
 
 void
-nsSprocketLayout::ComputeChildSizes(nsIBox* aBox,
+nsSprocketLayout::ComputeChildSizes(nsIFrame* aBox,
                            nsBoxLayoutState& aState, 
                            nscoord& aGivenSize, 
                            nsBoxSize* aBoxSizes, 
                            nsComputedBoxSize*& aComputedBoxSizes)
 {  
 
   //nscoord onePixel = aState.PresContext()->IntScaledPixelsToTwips(1);
 
@@ -1302,27 +1302,27 @@ nsSprocketLayout::ComputeChildSizes(nsIB
 
     boxSizes         = boxSizes->next;
     computedBoxSizes = computedBoxSizes->next;
   }
 }
 
 
 nsSize
-nsSprocketLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsSprocketLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
    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
 
-   nsIBox* child = aBox->GetChildBox();
+   nsIFrame* child = aBox->GetChildBox();
    nsFrameState frameState = 0;
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    PRInt32 count = 0;
    
    while (child) 
    {  
       // ignore collapsed children
@@ -1358,28 +1358,28 @@ nsSprocketLayout::GetPrefSize(nsIBox* aB
     
    // now add our border and padding
    AddBorderAndPadding(aBox, vpref);
 
   return vpref;
 }
 
 nsSize
-nsSprocketLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsSprocketLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
    nsSize minSize (0, 0);
    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
 
-   nsIBox* child = aBox->GetChildBox();
+   nsIFrame* child = aBox->GetChildBox();
    nsFrameState frameState = 0;
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    PRInt32 count = 0;
 
    while (child) 
    {  
        // ignore collapsed children
@@ -1427,28 +1427,28 @@ nsSprocketLayout::GetMinSize(nsIBox* aBo
 
   // now add our border and padding
   AddBorderAndPadding(aBox, minSize);
 
   return minSize;
 }
 
 nsSize
-nsSprocketLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsSprocketLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
 
   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
 
-   nsIBox* child = aBox->GetChildBox();
+   nsIFrame* child = aBox->GetChildBox();
    nsFrameState frameState = 0;
    GetFrameState(aBox, frameState);
    bool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
    PRInt32 count = 0;
 
    while (child) 
    {  
       // ignore collapsed children
@@ -1494,26 +1494,26 @@ nsSprocketLayout::GetMaxSize(nsIBox* aBo
   // now add our border and padding
   AddBorderAndPadding(aBox, maxSize);
 
   return maxSize;
 }
 
 
 nscoord
-nsSprocketLayout::GetAscent(nsIBox* aBox, nsBoxLayoutState& aState)
+nsSprocketLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
    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
    
-   nsIBox* child = aBox->GetChildBox();
+   nsIFrame* child = aBox->GetChildBox();
    
    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);
--- a/layout/xul/base/src/nsSprocketLayout.h
+++ b/layout/xul/base/src/nsSprocketLayout.h
@@ -3,16 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsSprocketLayout_h___
 #define nsSprocketLayout_h___
 
 #include "nsBoxLayout.h"
 #include "nsCOMPtr.h"
+#include "nsIFrame.h"
 
 class nsBoxSize
 {
 public:
 
   nsBoxSize();
 
   nscoord pref;
@@ -61,75 +62,77 @@ nsresult NS_NewSprocketLayout(nsIPresShe
 
 class nsSprocketLayout : public nsBoxLayout {
 
 public:
 
   friend nsresult NS_NewSprocketLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout);
   static void Shutdown();
 
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState);
 
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nscoord GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nscoord GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
 
   nsSprocketLayout();
 
-  static bool IsHorizontal(nsIBox* aBox);
+  static bool IsHorizontal(nsIFrame* aBox);
 
   static void SetLargestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal);
   static void SetSmallestSize(nsSize& aSize1, const nsSize& aSize2, bool aIsHorizontal);
 
   static void AddLargestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal);
   static void AddSmallestSize(nsSize& aSize, const nsSize& aSizeToAdd, bool aIsHorizontal);
   static void AddCoord(nscoord& aCoord, nscoord aCoordToAdd);
 
 protected:
 
 
-  void ComputeChildsNextPosition(nsIBox* aBox,
+  void ComputeChildsNextPosition(nsIFrame* aBox,
                                  const nscoord& aCurX, 
                                  const nscoord& aCurY, 
                                  nscoord& aNextX, 
                                  nscoord& aNextY, 
                                  const nsRect& aChildSize);
 
-  void ChildResized(nsIBox* aBox,
+  void ChildResized(nsIFrame* aBox,
                     nsBoxLayoutState& aState, 
-                    nsIBox* aChild,
+                    nsIFrame* aChild,
                     nsBoxSize* aChildBoxSize, 
                     nsComputedBoxSize* aChildComputedBoxSize, 
                     nsBoxSize* aBoxSizes, 
                     nsComputedBoxSize* aComputedBoxSizes, 
                     const nsRect& aChildLayoutRect, 
                     nsRect& aChildActualRect, 
                     nsRect& aContainingRect, 
                     PRInt32 aFlexes, 
                     bool& aFinished);
 
-  void AlignChildren(nsIBox* aBox,
+  void AlignChildren(nsIFrame* aBox,
                      nsBoxLayoutState& aState,
                      bool* aNeedsRedraw);
 
-  virtual void ComputeChildSizes(nsIBox* aBox, 
+  virtual void ComputeChildSizes(nsIFrame* aBox, 
                          nsBoxLayoutState& aState, 
                          nscoord& aGivenSize, 
                          nsBoxSize* aBoxSizes, 
                          nsComputedBoxSize*& aComputedBoxSizes);
 
 
-  virtual void PopulateBoxSizes(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState, nsBoxSize*& aBoxSizes, nscoord& aMinSize, nscoord& aMaxSize, PRInt32& aFlexes);
+  virtual void PopulateBoxSizes(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState,
+                                nsBoxSize*& aBoxSizes, nscoord& aMinSize,
+                                nscoord& aMaxSize, PRInt32& aFlexes);
 
   virtual void InvalidateComputedSizes(nsComputedBoxSize* aComputedBoxSizes);
 
   virtual bool GetDefaultFlex(PRInt32& aFlex);
 
-  virtual void GetFrameState(nsIBox* aBox, nsFrameState& aState);
+  virtual void GetFrameState(nsIFrame* aBox, nsFrameState& aState);
 
 private:
 
 
   // because the sprocket layout manager has no instance variables. We 
   // can make a static one and reuse it everywhere.
   static nsBoxLayout* gInstance;
 
--- a/layout/xul/base/src/nsStackLayout.cpp
+++ b/layout/xul/base/src/nsStackLayout.cpp
@@ -54,21 +54,21 @@ nsStackLayout::nsStackLayout()
  * Sizing: we are as wide as the widest child plus its left offset
  * we are tall as the tallest child plus its top offset.
  *
  * Only children which have -moz-stack-sizing set to stretch-to-fit
  * (the default) will be included in the size computations.
  */
 
 nsSize
-nsStackLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsStackLayout::GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize prefSize (0, 0);
 
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
   while (child) {
     if (child->GetStyleXUL()->mStretchStack) {
       nsSize pref = child->GetPrefSize(aState);
 
       AddMargin(child, pref);
       nsMargin offset;
       GetOffset(aState, child, offset);
       pref.width += offset.LeftRight();
@@ -80,21 +80,21 @@ nsStackLayout::GetPrefSize(nsIBox* aBox,
   }
 
   AddBorderAndPadding(aBox, prefSize);
 
   return prefSize;
 }
 
 nsSize
-nsStackLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsStackLayout::GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize minSize (0, 0);
 
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
   while (child) {
     if (child->GetStyleXUL()->mStretchStack) {
       nsSize min = child->GetMinSize(aState);
 
       AddMargin(child, min);
       nsMargin offset;
       GetOffset(aState, child, offset);
       min.width += offset.LeftRight();
@@ -106,21 +106,21 @@ nsStackLayout::GetMinSize(nsIBox* aBox, 
   }
 
   AddBorderAndPadding(aBox, minSize);
 
   return minSize;
 }
 
 nsSize
-nsStackLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState)
+nsStackLayout::GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsSize maxSize (NS_INTRINSICSIZE, NS_INTRINSICSIZE);
 
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
   while (child) {
     if (child->GetStyleXUL()->mStretchStack) {
       nsSize min = child->GetMinSize(aState);
       nsSize max = child->GetMaxSize(aState);
 
       max = nsBox::BoundsCheckMinMax(min, max);
 
       AddMargin(child, max);
@@ -136,37 +136,37 @@ nsStackLayout::GetMaxSize(nsIBox* aBox, 
 
   AddBorderAndPadding(aBox, maxSize);
 
   return maxSize;
 }
 
 
 nscoord
-nsStackLayout::GetAscent(nsIBox* aBox, nsBoxLayoutState& aState)
+nsStackLayout::GetAscent(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nscoord vAscent = 0;
 
-  nsIBox* child = aBox->GetChildBox();
+  nsIFrame* child = aBox->GetChildBox();
   while (child) {  
     nscoord ascent = child->GetBoxAscent(aState);
     nsMargin margin;
     child->GetMargin(margin);
     ascent += margin.top;
     if (ascent > vAscent)
       vAscent = ascent;
 
     child = child->GetNextBox();
   }
 
   return vAscent;
 }
 
 PRUint8
-nsStackLayout::GetOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsMargin& aOffset)
+nsStackLayout::GetOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsMargin& aOffset)
 {
   aOffset = nsMargin(0, 0, 0, 0);
 
   // get the left, right, top and bottom offsets
 
   // As an optimization, we cache the fact that we are not positioned to avoid
   // wasting time fetching attributes.
   if (aChild->IsBoxFrame() &&
@@ -247,25 +247,25 @@ nsStackLayout::GetOffset(nsBoxLayoutStat
     aChild->AddStateBits(NS_STATE_STACK_NOT_POSITIONED);
   }
 
   return offsetSpecified;
 }
 
 
 NS_IMETHODIMP
-nsStackLayout::Layout(nsIBox* aBox, nsBoxLayoutState& aState)
+nsStackLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
 {
   nsRect clientRect;
   aBox->GetClientRect(clientRect);
 
   bool grow;
 
   do {
-    nsIBox* child = aBox->GetChildBox();
+    nsIFrame* child = aBox->GetChildBox();
     grow = false;
 
     while (child) 
     {  
       nsMargin margin;
       child->GetMargin(margin);
       nsRect childRect(clientRect);
       childRect.Deflate(margin);
--- a/layout/xul/base/src/nsStackLayout.h
+++ b/layout/xul/base/src/nsStackLayout.h
@@ -11,40 +11,43 @@
  
 **/
 
 #ifndef nsStackLayout_h___
 #define nsStackLayout_h___
 
 #include "nsBoxLayout.h"
 #include "nsCOMPtr.h"
+#include "nsCoord.h"
+
+class nsIPresShell;
 
 nsresult NS_NewStackLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout);
 
 class nsStackLayout : public nsBoxLayout
 {
 public:
 
   friend nsresult NS_NewStackLayout(nsIPresShell* aPresShell, nsCOMPtr<nsBoxLayout>& aNewLayout);
   static void Shutdown();
 
   nsStackLayout();
 
-  NS_IMETHOD Layout(nsIBox* aBox, nsBoxLayoutState& aState);
+  NS_IMETHOD Layout(nsIFrame* aBox, nsBoxLayoutState& aState);
 
-  virtual nsSize GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMinSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
-  virtual nscoord GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetPrefSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMinSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nsSize GetMaxSize(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
+  virtual nscoord GetAscent(nsIFrame* aBox, nsBoxLayoutState& aBoxLayoutState);
 
   // get the child offsets for aChild and set them in aMargin. Returns a
   // bitfield mask of the SPECIFIED_LEFT, SPECIFIED_RIGHT, SPECIFIED_TOP and
   // SPECIFIED_BOTTOM offsets indicating which sides have been specified by
-  // attributes. 
-  static PRUint8 GetOffset(nsBoxLayoutState& aState, nsIBox* aChild, nsMargin& aMargin);
+  // attributes.
+  static PRUint8 GetOffset(nsBoxLayoutState& aState, nsIFrame* aChild, nsMargin& aMargin);
 
 private:
   static nsBoxLayout* gInstance;
 
 }; // class nsStackLayout
 
 
 
--- a/layout/xul/base/src/nsTextBoxFrame.cpp
+++ b/layout/xul/base/src/nsTextBoxFrame.cpp
@@ -1026,17 +1026,17 @@ nsTextBoxFrame::GetPrefSize(nsBoxLayoutS
 {
     CalcTextSize(aBoxLayoutState);
 
     nsSize size = mTextSize;
     DISPLAY_PREF_SIZE(this, size);
 
     AddBorderAndPadding(size);
     bool widthSet, heightSet;
-    nsIBox::AddCSSPrefSize(this, size, widthSet, heightSet);
+    nsIFrame::AddCSSPrefSize(this, size, widthSet, heightSet);
 
     return size;
 }
 
 /**
  * Ok return our dimensions
  */
 nsSize
@@ -1048,17 +1048,17 @@ nsTextBoxFrame::GetMinSize(nsBoxLayoutSt
     DISPLAY_MIN_SIZE(this, size);
 
     // if there is cropping our min width becomes our border and padding
     if (mCropType != CropNone)
         size.width = 0;
 
     AddBorderAndPadding(size);
     bool widthSet, heightSet;
-    nsIBox::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet);
+    nsIFrame::AddCSSMinSize(aBoxLayoutState, this, size, widthSet, heightSet);
 
     return size;
 }
 
 nscoord
 nsTextBoxFrame::GetBoxAscent(nsBoxLayoutState& aBoxLayoutState)
 {
     CalcTextSize(aBoxLayoutState);
--- a/layout/xul/base/src/nsTextBoxFrame.h
+++ b/layout/xul/base/src/nsTextBoxFrame.h
@@ -11,17 +11,16 @@ class nsAccessKeyInfo;
 class nsAsyncAccesskeyUpdate;
 
 typedef nsLeafBoxFrame nsTextBoxFrameSuper;
 class nsTextBoxFrame : public nsTextBoxFrameSuper
 {
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
-  // nsIBox
   virtual nsSize GetPrefSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual nscoord GetBoxAscent(nsBoxLayoutState& aBoxLayoutState);
   NS_IMETHOD DoLayout(nsBoxLayoutState& aBoxLayoutState);
   virtual void MarkIntrinsicWidthsDirty();
 
   enum CroppingStyle { CropNone, CropLeft, CropRight, CropCenter };
 
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -212,17 +212,17 @@ nsTreeBodyFrame::GetMinSize(nsBoxLayoutS
       desiredRows = 0;
     }
   }
 
   min.height = mRowHeight * desiredRows;
 
   AddBorderAndPadding(min);
   bool widthSet, heightSet;
-  nsIBox::AddCSSMinSize(aBoxLayoutState, this, min, widthSet, heightSet);
+  nsIFrame::AddCSSMinSize(aBoxLayoutState, this, min, widthSet, heightSet);
 
   return min;
 }
 
 nscoord
 nsTreeBodyFrame::CalcMaxRowWidth()
 {
   if (mStringWidth != -1)
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.h
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.h
@@ -96,17 +96,16 @@ public:
                                 PRInt32 *aX, PRInt32 *aY,
                                 PRInt32 *aWidth, PRInt32 *aHeight);
   nsresult IsCellCropped(PRInt32 aRow, nsITreeColumn *aCol, bool *aResult);
   nsresult RowCountChanged(PRInt32 aIndex, PRInt32 aCount);
   nsresult BeginUpdateBatch();
   nsresult EndUpdateBatch();
   nsresult ClearStyleAndImageCaches();
 
-  // nsIBox
   virtual nsSize GetMinSize(nsBoxLayoutState& aBoxLayoutState);
   virtual void SetBounds(nsBoxLayoutState& aBoxLayoutState, const nsRect& aRect,
                          bool aRemoveOverflowArea = false);
 
   // nsIReflowCallback
   virtual bool ReflowFinished();
   virtual void ReflowCallbackCanceled();