Bug 233463, patch 5 - Remove nsFrameList(nsIFrame*) ctor. r=bzbarsky
authorMats Palmgren <matspal@gmail.com>
Fri, 18 Sep 2009 13:09:36 +0200
changeset 32846 4b8efcb179b8d66e91fd0ca10c2c8b0b0c20c250
parent 32845 17874c9d2249bf0b2745f01a2606541890f1f3a6
child 32847 628f4b819a3da92cd5f6c26924bab02b4e759405
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs233463
milestone1.9.3a1pre
Bug 233463, patch 5 - Remove nsFrameList(nsIFrame*) ctor. r=bzbarsky
layout/base/nsBidiPresUtils.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsFrameTraversal.cpp
layout/forms/nsComboboxControlFrame.cpp
layout/generic/nsBlockFrame.cpp
layout/generic/nsContainerFrame.cpp
layout/generic/nsFirstLetterFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsFrameList.cpp
layout/generic/nsFrameList.h
layout/generic/nsHTMLFrame.cpp
layout/generic/nsInlineFrame.cpp
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLmoFrame.cpp
layout/xul/base/src/nsBoxFrame.cpp
layout/xul/base/src/nsMenuFrame.cpp
layout/xul/base/src/nsSplitterFrame.cpp
layout/xul/base/src/nsXULPopupManager.cpp
layout/xul/base/src/tree/src/nsTreeColFrame.cpp
--- a/layout/base/nsBidiPresUtils.cpp
+++ b/layout/base/nsBidiPresUtils.cpp
@@ -202,17 +202,17 @@ CreateBidiContinuation(nsIFrame*       a
   nsresult rv = presShell->FrameConstructor()->
     CreateContinuingFrame(presContext, aFrame, parent, aNewFrame, PR_FALSE);
   if (NS_FAILED(rv)) {
     return rv;
   }
   
   // The list name nsGkAtoms::nextBidi would indicate we don't want reflow
   // XXXbz this needs higher-level framelist love
-  nsFrameList temp(*aNewFrame);
+  nsFrameList temp(*aNewFrame, *aNewFrame);
   rv = parent->InsertFrames(nsGkAtoms::nextBidi, aFrame, temp);
   if (NS_FAILED(rv)) {
     return rv;
   }
   
   // Split inline ancestor frames
   rv = SplitInlineAncestors(aFrame);
   if (NS_FAILED(rv)) {
@@ -224,17 +224,22 @@ CreateBidiContinuation(nsIFrame*       a
 
 static PRBool
 IsFrameInCurrentLine(nsBlockInFlowLineIterator* aLineIter,
                      nsIFrame* aPrevFrame, nsIFrame* aFrame)
 {
   nsIFrame* endFrame = aLineIter->IsLastLineInList() ? nsnull :
     aLineIter->GetLine().next()->mFirstChild;
   nsIFrame* startFrame = aPrevFrame ? aPrevFrame : aLineIter->GetLine()->mFirstChild;
-  return nsFrameList(startFrame).ContainsFrameBefore(aFrame, endFrame);
+  for (nsIFrame* frame = startFrame; frame && frame != endFrame;
+       frame = frame->GetNextSibling()) {
+    if (frame == aFrame)
+      return PR_TRUE;
+  }
+  return PR_FALSE;
 }
 
 static void
 AdvanceLineIteratorToFrame(nsIFrame* aFrame,
                            nsBlockInFlowLineIterator* aLineIter,
                            nsIFrame*& aPrevFrame)
 {
   // Advance aLine to the line containing aFrame
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -609,17 +609,17 @@ MarkIBSpecialPrevSibling(nsIFrame *aAnon
   aAnonymousFrame->SetProperty(nsGkAtoms::IBSplitSpecialPrevSibling,
                                aSpecialParent, nsnull, nsnull);
 }
 
 inline void
 SetInitialSingleChild(nsIFrame* aParent, nsIFrame* aFrame)
 {
   NS_PRECONDITION(!aFrame->GetNextSibling(), "Should be using a frame list");
-  nsFrameList temp(aFrame);
+  nsFrameList temp(aFrame, aFrame);
   aParent->SetInitialChildList(nsnull, temp);
 }
 
 // -----------------------------------------------------------
 
 static PRBool
 IsOutOfFlowList(nsIAtom* aListName)
 {
@@ -1495,25 +1495,24 @@ GetChildListNameFor(nsIFrame*       aChi
   } else {
     listName = nsnull;
   }
 
 #ifdef NS_DEBUG
   // Verify that the frame is actually in that child list or in the
   // corresponding overflow list.
   nsIFrame* parent = aChildFrame->GetParent();
-  PRBool found = nsFrameList(parent->GetFirstChild(listName))
-                   .ContainsFrame(aChildFrame);
+  PRBool found = parent->GetChildList(listName).ContainsFrame(aChildFrame);
   if (!found) {
     if (!(aChildFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
-      found = nsFrameList(parent->GetFirstChild(nsGkAtoms::overflowList))
+      found = parent->GetChildList(nsGkAtoms::overflowList)
                 .ContainsFrame(aChildFrame);
     }
     else if (aChildFrame->GetStyleDisplay()->IsFloating()) {
-      found = nsFrameList(parent->GetFirstChild(nsGkAtoms::overflowOutOfFlowList))
+      found = parent->GetChildList(nsGkAtoms::overflowOutOfFlowList)
                 .ContainsFrame(aChildFrame);
     }
     // else it's positioned and should have been on the 'listName' child list.
     NS_POSTCONDITION(found, "not in child list");
   }
 #endif
 
   return listName;
@@ -2939,20 +2938,20 @@ nsCSSFrameConstructor::SetUpDocElementCo
     SetInitialSingleChild(rootFrame, pageFrame);
 
     // The eventual parent of the document element frame.
     // XXX should this be set for every new page (in ConstructPageFrame)?
     mDocElementContainingBlock = canvasFrame;
     mHasRootAbsPosContainingBlock = PR_TRUE;
   }
 
-  nsFrameList newFrameList(newFrame);
   if (viewportFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
-    viewportFrame->SetInitialChildList(nsnull, newFrameList);
+    SetInitialSingleChild(viewportFrame, newFrame);
   } else {
+    nsFrameList newFrameList(newFrame, newFrame);
     viewportFrame->AppendFrames(nsnull, newFrameList);
   }
 
   return NS_OK;
 }
 
 nsresult
 nsCSSFrameConstructor::ConstructPageFrame(nsIPresShell*  aPresShell,
@@ -4394,17 +4393,17 @@ nsCSSFrameConstructor::BeginBuildingScro
 
   return aScrolledChildStyle;
 }
 
 void
 nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIFrame* aScrollFrame,
                                                  nsIFrame* aScrolledFrame)
 {
-  nsFrameList scrolled(aScrolledFrame);
+  nsFrameList scrolled(aScrolledFrame, aScrolledFrame);
   aScrollFrame->AppendFrames(nsnull, scrolled);
 
   // force the scrolled frame to have a view. The view will be parented to
   // the correct anonymous inner view because the scrollframes override
   // nsIFrame::GetParentViewForChildFrame.
   nsHTMLContainerFrame::CreateViewForFrame(aScrolledFrame, PR_TRUE);
 
   // XXXbz what's the point of the code after this in this method?
@@ -5687,19 +5686,18 @@ AdjustAppendParentForAfterContent(nsPres
  * This function will get the previous sibling to use for an append operation.
  * it takes a parent frame (must not be null) and its :after frame (may be
  * null).
  */
 static nsIFrame*
 FindAppendPrevSibling(nsIFrame* aParentFrame, nsIFrame* aAfterFrame)
 {
   if (aAfterFrame) {
-    nsFrameList childList(aParentFrame->GetFirstChild(nsnull));
     NS_ASSERTION(aAfterFrame->GetParent() == aParentFrame, "Wrong parent");
-    return childList.GetPrevSiblingFor(aAfterFrame);
+    return aParentFrame->GetChildList(nsnull).GetPrevSiblingFor(aAfterFrame);
   }
 
   return aParentFrame->GetLastChild(nsnull);
 }
 
 /**
  * This function will get the next sibling for a frame insert operation given
  * the parent and previous sibling.  aPrevSibling may be null.
@@ -10341,17 +10339,17 @@ nsCSSFrameConstructor::RemoveFloatingFir
   // First find out where (in the content) the placeholder frames
   // text is and its previous sibling frame, if any.  Note that:
   // 1)  The placeholder had better be in the principal child list of
   //     parentFrame.
   // 2)  It's probably near the beginning (since we're a first-letter frame),
   //     so just doing a linear search for the prevSibling is ok.
   // 3)  Trying to use FindPreviousSibling will fail if the first-letter is in
   //     anonymous content (eg generated content).
-  nsFrameList siblingList(parentFrame->GetFirstChild(nsnull));
+  const nsFrameList& siblingList(parentFrame->GetChildList(nsnull));
   NS_ASSERTION(siblingList.ContainsFrame(placeholderFrame),
                "Placeholder not in parent's principal child list?");
   nsIFrame* prevSibling = siblingList.GetPrevSiblingFor(placeholderFrame);
 
   // Now that everything is set...
 #ifdef NOISY_FIRST_LETTER
   printf("RemoveFloatingFirstLetterFrames: textContent=%p oldTextFrame=%p newTextFrame=%p\n",
          textContent.get(), textFrame, newTextFrame);
@@ -10362,17 +10360,17 @@ nsCSSFrameConstructor::RemoveFloatingFir
   aFrameManager->RemoveFrame(aBlockFrame, nsGkAtoms::floatList,
                              floatFrame);
 
   // Remove placeholder frame
   ::DeletingFrameSubtree(aFrameManager, placeholderFrame);
   aFrameManager->RemoveFrame(parentFrame, nsnull, placeholderFrame);
 
   // Insert text frame in its place
-  nsFrameList textList(newTextFrame);
+  nsFrameList textList(newTextFrame, newTextFrame);
   aFrameManager->InsertFrames(parentFrame, nsnull, prevSibling, textList);
 
   return NS_OK;
 }
 
 nsresult
 nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
                                                nsIPresShell* aPresShell,
@@ -10408,17 +10406,17 @@ nsCSSFrameConstructor::RemoveFirstLetter
       textFrame = NS_NewTextFrame(aPresShell, newSC);
       textFrame->Init(textContent, aFrame, nsnull);
 
       // Next rip out the kid and replace it with the text frame
       ::DeletingFrameSubtree(aFrameManager, kid);
       aFrameManager->RemoveFrame(aFrame, nsnull, kid);
 
       // Insert text frame in its place
-      nsFrameList textList(textFrame);
+      nsFrameList textList(textFrame, textFrame);
       aFrameManager->InsertFrames(aFrame, nsnull, prevSibling, textList);
 
       *aStopLooking = PR_TRUE;
       aFrame->RemoveStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
       break;
     }
     else if (IsInlineFrame(kid)) {
       // Look inside child inline frame for the letter frame
--- a/layout/base/nsFrameTraversal.cpp
+++ b/layout/base/nsFrameTraversal.cpp
@@ -489,35 +489,30 @@ nsFrameIterator::GetPrevSibling(nsIFrame
 
 nsIFrame*
 nsFrameIterator::GetFirstChildInner(nsIFrame* aFrame) {
   return aFrame->GetFirstChild(nsnull);
 }
 
 nsIFrame*
 nsFrameIterator::GetLastChildInner(nsIFrame* aFrame) {
-  nsIFrame* child = aFrame->GetFirstChild(nsnull);
-  if (!child)
-    return nsnull;
-  nsFrameList list(child);
-  return list.LastChild();
+  return aFrame->GetChildList(nsnull).LastChild();
 }
 
 nsIFrame*
 nsFrameIterator::GetNextSiblingInner(nsIFrame* aFrame) {
   return aFrame->GetNextSibling();
 }
 
 nsIFrame*
 nsFrameIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
   nsIFrame* parent = GetParentFrame(aFrame);
   if (!parent)
     return nsnull;
-  nsFrameList list(parent->GetFirstChild(nsnull));
-  return list.GetPrevSiblingFor(aFrame);
+  return parent->GetChildList(nsnull).GetPrevSiblingFor(aFrame);
 }
 
 
 nsIFrame*
 nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
 {
   nsIFrame* result = aFrame;
   nsIPresShell *presShell = mPresContext->GetPresShell();
@@ -540,41 +535,31 @@ nsFrameIterator::IsPopupFrame(nsIFrame* 
   return (aFrame &&
           aFrame->GetStyleDisplay()->mDisplay == NS_STYLE_DISPLAY_POPUP);
 }
 
 // nsVisualIterator implementation
 
 nsIFrame*
 nsVisualIterator::GetFirstChildInner(nsIFrame* aFrame) {
-  nsIFrame* child = aFrame->GetFirstChild(nsnull);
-  if (!child)
-    return nsnull;
-  nsFrameList list(child);
-  return list.GetNextVisualFor(nsnull);
+  return aFrame->GetChildList(nsnull).GetNextVisualFor(nsnull);
 }
 
 nsIFrame*
 nsVisualIterator::GetLastChildInner(nsIFrame* aFrame) {
-  nsIFrame* child = aFrame->GetFirstChild(nsnull);
-  if (!child)
-    return nsnull;
-  nsFrameList list(child);
-  return list.GetPrevVisualFor(nsnull);
+  return aFrame->GetChildList(nsnull).GetPrevVisualFor(nsnull);
 }
 
 nsIFrame*
 nsVisualIterator::GetNextSiblingInner(nsIFrame* aFrame) {
   nsIFrame* parent = GetParentFrame(aFrame);
   if (!parent)
     return nsnull;
-  nsFrameList list(parent->GetFirstChild(nsnull));
-  return list.GetNextVisualFor(aFrame);
+  return parent->GetChildList(nsnull).GetNextVisualFor(aFrame);
 }
 
 nsIFrame*
 nsVisualIterator::GetPrevSiblingInner(nsIFrame* aFrame) {
   nsIFrame* parent = GetParentFrame(aFrame);
   if (!parent)
     return nsnull;
-  nsFrameList list(parent->GetFirstChild(nsnull));
-  return list.GetPrevVisualFor(aFrame);
+  return parent->GetChildList(nsnull).GetPrevVisualFor(aFrame);
 }
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1192,17 +1192,17 @@ nsComboboxControlFrame::CreateFrameFor(n
   if (NS_FAILED(rv)) {
     mDisplayFrame->Destroy();
     mDisplayFrame = nsnull;
     mTextFrame->Destroy();
     mTextFrame = nsnull;
     return nsnull;
   }
 
-  nsFrameList textList(mTextFrame);
+  nsFrameList textList(mTextFrame, mTextFrame);
   mDisplayFrame->SetInitialChildList(nsnull, textList);
   return mDisplayFrame;
 }
 
 void
 nsComboboxControlFrame::Destroy()
 {
   // Revoke any pending RedisplayTextEvent
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -524,26 +524,29 @@ nsBlockFrame::GetChildList(nsIAtom* aLis
     // in-flow kids, we could switch GetChildList to returning a |const
     // nsFrameList&|.
     return mLines.empty() ? nsFrameList::EmptyList()
                           : nsFrameList(mLines.front()->mFirstChild,
                                         mLines.back()->LastChild());
   }
   else if (aListName == nsGkAtoms::overflowList) {
     nsLineList* overflowLines = GetOverflowLines();
-    return overflowLines ? overflowLines->front()->mFirstChild : nsnull;
+    return overflowLines ? nsFrameList(overflowLines->front()->mFirstChild,
+                                       overflowLines->back()->LastChild())
+                         : nsFrameList::EmptyList();
   }
   else if (aListName == nsGkAtoms::overflowOutOfFlowList) {
     return GetOverflowOutOfFlows();
   }
   else if (aListName == nsGkAtoms::floatList) {
     return mFloats;
   }
   else if (aListName == nsGkAtoms::bulletList) {
-    return (HaveOutsideBullet()) ? mBullet : nsnull;
+    return HaveOutsideBullet() ? nsFrameList(mBullet, mBullet)
+                               : nsFrameList::EmptyList();
   }
   return nsContainerFrame::GetChildList(aListName);
 }
 
 #define NS_BLOCK_FRAME_OVERFLOW_OOF_LIST_INDEX  (NS_CONTAINER_LIST_COUNT_INCL_OC + 0)
 #define NS_BLOCK_FRAME_FLOAT_LIST_INDEX         (NS_CONTAINER_LIST_COUNT_INCL_OC + 1)
 #define NS_BLOCK_FRAME_BULLET_LIST_INDEX        (NS_CONTAINER_LIST_COUNT_INCL_OC + 2)
 #define NS_BLOCK_FRAME_ABSOLUTE_LIST_INDEX      (NS_CONTAINER_LIST_COUNT_INCL_OC + 3)
@@ -3945,17 +3948,18 @@ nsBlockFrame::SplitLine(nsBlockReflowSta
       aLine->List(stdout, gNoiseIndent+1);
     }
   }
 #endif
 
   if (0 != pushCount) {
     NS_ABORT_IF_FALSE(aLine->GetChildCount() > pushCount, "bad push");
     NS_ABORT_IF_FALSE(nsnull != aFrame, "whoops");
-    NS_ASSERTION(nsFrameList(aFrame).GetLength() >= pushCount,
+    NS_ASSERTION(nsFrameList(aFrame, nsLayoutUtils::GetLastSibling(aFrame))
+                   .GetLength() >= pushCount,
                  "Not enough frames to push");
 
     // Put frames being split out into their own line
     nsLineBox* newLine = aState.NewLineBox(aFrame, pushCount, PR_FALSE);
     if (!newLine) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
     mLines.after_insert(aLine, newLine);
@@ -4522,17 +4526,17 @@ nsFrameList
 nsBlockFrame::GetOverflowOutOfFlows() const
 {
   if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
     return nsFrameList();
   }
   nsIFrame* result = static_cast<nsIFrame*>
                                 (GetProperty(nsGkAtoms::overflowOutOfFlowsProperty));
   NS_ASSERTION(result, "value should always be non-empty when state set");
-  return nsFrameList(result);
+  return nsFrameList(result, nsLayoutUtils::GetLastSibling(result));
 }
 
 // This takes ownership of the frames
 void
 nsBlockFrame::SetOverflowOutOfFlows(const nsFrameList& aList)
 {
   if (aList.IsEmpty()) {
     if (!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS)) {
@@ -6326,17 +6330,17 @@ nsBlockFrame::SetInitialChildList(nsIAto
         return NS_ERROR_OUT_OF_MEMORY;
       }
       bullet->Init(mContent, this, nsnull);
 
       // If the list bullet frame should be positioned inside then add
       // it to the flow now.
       if (NS_STYLE_LIST_STYLE_POSITION_INSIDE ==
           styleList->mListStylePosition) {
-        AddFrames(bullet, nsnull);
+        AddFrames(nsFrameList(bullet, bullet), nsnull);
         mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET;
       }
       else {
         mState |= NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET;
       }
 
       mBullet = bullet;
     }
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -1325,17 +1325,17 @@ nsContainerFrame::PushChildren(nsPresCon
     // views need to be reparented.
     for (nsIFrame* f = aFromChild; f; f = f->GetNextSibling()) {
       nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, this, nextInFlow);
     }
     nextInFlow->mFrames.InsertFrames(nextInFlow, nsnull, tail);
   }
   else {
     // Add the frames to our overflow list
-    SetOverflowFrames(aPresContext, aFromChild);
+    SetOverflowFrames(aPresContext, tail);
   }
 }
 
 /**
  * Moves any frames on the overflow lists (the prev-in-flow's overflow list and
  * the receiver's overflow list) to the child list.
  *
  * Updates this frame's child count and content mapping.
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -269,26 +269,19 @@ nsFirstLetterFrame::Reflow(nsPresContext
     // have one.
     nsIFrame* nextInFlow;
     rv = CreateNextInFlow(aPresContext, kid, nextInFlow);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     // And then push it to our overflow list
-    if (nextInFlow) {
-      mFrames.RemoveFramesAfter(kid);
-      SetOverflowFrames(aPresContext, nextInFlow);
-    }
-    else {
-      nsIFrame* nextSib = kid->GetNextSibling();
-      if (nextSib) {
-        mFrames.RemoveFramesAfter(kid);
-        SetOverflowFrames(aPresContext, nextSib);
-      }
+    const nsFrameList& overflow = mFrames.RemoveFramesAfter(kid);
+    if (overflow.NotEmpty()) {
+      SetOverflowFrames(aPresContext, overflow);
     }
   }
 
   FinishAndStoreOverflow(&aMetrics);
 
   NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
   return rv;
 }
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4764,17 +4764,17 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsD
     aFrame->GetOffsets(startOffset, endOffset);
     result.mContent = aFrame->GetContent();
     result.mOffset = endOffset - (aDirection == eDirPrevious ? 0 : 1);
     return result;
   }
 
   // Iterate over children and call ourselves recursively
   if (aDirection == eDirPrevious) {
-    nsFrameList children(aFrame->GetFirstChild(nsnull));
+    const nsFrameList& children(aFrame->GetChildList(nsnull));
     nsIFrame* child = children.LastChild();
     while(child && !result.mContent) {
       result = FindBlockFrameOrBR(child, aDirection);
       child = children.GetPrevSiblingFor(child);
     }
   } else { // eDirNext
     nsIFrame* child = aFrame->GetFirstChild(nsnull);
     while(child && !result.mContent) {
@@ -4801,17 +4801,17 @@ nsIFrame::PeekOffsetParagraph(nsPeekOffs
   if (aPos->mDirection == eDirPrevious) {
     while (!reachedBlockAncestor) {
       nsIFrame* parent = frame->GetParent();
       // Treat a frame associated with the root content as if it were a block frame.
       if (!frame->mContent || !frame->mContent->GetParent()) {
         reachedBlockAncestor = PR_TRUE;
         break;
       }
-      nsFrameList siblings(parent->GetFirstChild(nsnull));
+      const nsFrameList& siblings(parent->GetChildList(nsnull));
       nsIFrame* sibling = siblings.GetPrevSiblingFor(frame);
       while (sibling && !blockFrameOrBR.mContent) {
         blockFrameOrBR = FindBlockFrameOrBR(sibling, eDirPrevious);
         sibling = siblings.GetPrevSiblingFor(sibling);
       }
       if (blockFrameOrBR.mContent) {
         aPos->mResultContent = blockFrameOrBR.mContent;
         aPos->mContentOffset = blockFrameOrBR.mOffset;
--- a/layout/generic/nsFrameList.cpp
+++ b/layout/generic/nsFrameList.cpp
@@ -44,23 +44,16 @@
 #include "nsCOMPtr.h"
 #include "nsGkAtoms.h"
 #include "nsILineIterator.h"
 #include "nsBidiPresUtils.h"
 #endif // IBMBIDI
 
 const nsFrameList* nsFrameList::sEmptyList;
 
-nsFrameList::nsFrameList(nsIFrame* aFirstFrame)
-  : mFirstChild(aFirstFrame)
-  , mLastChild(nsLayoutUtils::GetLastSibling(aFirstFrame))
-{
-  MOZ_COUNT_CTOR(nsFrameList);
-}
-
 /* static */
 nsresult
 nsFrameList::Init()
 {
   NS_PRECONDITION(!sEmptyList, "Shouldn't be allocated");
 
   sEmptyList = new nsFrameList();
   if (!sEmptyList)
@@ -96,16 +89,23 @@ nsFrameList::SetFrames(nsIFrame* aFrameL
 {
   NS_PRECONDITION(!mFirstChild, "Losing frames");
 
   mFirstChild = aFrameList;
   mLastChild = nsLayoutUtils::GetLastSibling(mFirstChild);
 }
 
 void
+nsFrameList::AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList)
+{
+  nsFrameList temp(aFrameList, nsLayoutUtils::GetLastSibling(aFrameList));
+  AppendFrames(aParent, temp);
+}
+
+void
 nsFrameList::RemoveFrame(nsIFrame* aFrame, nsIFrame* aPrevSiblingHint)
 {
   NS_PRECONDITION(aFrame, "null ptr");
   NS_PRECONDITION(ContainsFrame(aFrame), "wrong list");
 
   nsIFrame* nextFrame = aFrame->GetNextSibling();
   if (aFrame == mFirstChild) {
     mFirstChild = nextFrame;
@@ -182,16 +182,25 @@ nsFrameList::DestroyFrameIfPresent(nsIFr
 
   if (RemoveFrameIfPresent(aFrame)) {
     aFrame->Destroy();
     return PR_TRUE;
   }
   return PR_FALSE;
 }
 
+void
+nsFrameList::InsertFrames(nsIFrame* aParent,
+                          nsIFrame* aPrevSibling,
+                          nsIFrame* aFrameList)
+{
+  nsFrameList temp(aFrameList, nsLayoutUtils::GetLastSibling(aFrameList));
+  InsertFrames(aParent, aPrevSibling, temp);
+}
+
 nsFrameList::Slice
 nsFrameList::InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling,
                           nsFrameList& aFrameList)
 {
   NS_PRECONDITION(aFrameList.NotEmpty(), "Unexpected empty list");
 
   if (aParent) {
     aFrameList.ApplySetParent(aParent);
--- a/layout/generic/nsFrameList.h
+++ b/layout/generic/nsFrameList.h
@@ -51,19 +51,16 @@ class nsIFrame;
 class nsFrameList {
 public:
   nsFrameList() :
     mFirstChild(nsnull), mLastChild(nsnull)
   {
     MOZ_COUNT_CTOR(nsFrameList);
   }
 
-  // XXX We should make this explicit when we can!
-  nsFrameList(nsIFrame* aFirstFrame);
-
   nsFrameList(nsIFrame* aFirstFrame, nsIFrame* aLastFrame) :
     mFirstChild(aFirstFrame), mLastChild(aLastFrame)
   {
     MOZ_COUNT_CTOR(nsFrameList);
 #ifdef DEBUG
     VerifyList();
 #endif
   }
@@ -104,20 +101,17 @@ public:
   }
 
   class Slice;
 
   /**
    * Append frames from aFrameList to this list. If aParent
    * is not null, reparents the newly-added frames.
    */
-  void AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList) {
-    nsFrameList temp(aFrameList);
-    AppendFrames(aParent, temp);
-  }
+  void AppendFrames(nsIFrame* aParent, nsIFrame* aFrameList);
 
   /**
    * Append aFrameList to this list.  If aParent is not null,
    * reparents the newly added frames.  Clears out aFrameList and
    * returns a list slice represening the newly-appended frames.
    */
   Slice AppendFrames(nsIFrame* aParent, nsFrameList& aFrameList) {
     return InsertFrames(aParent, LastChild(), aFrameList);
@@ -192,20 +186,17 @@ public:
 
   /**
    * Insert aFrameList right after aPrevSibling, or prepend it to this
    * list if aPrevSibling is null. If aParent is not null, also
    * reparents newly-added frames.
    */
   void InsertFrames(nsIFrame* aParent,
                     nsIFrame* aPrevSibling,
-                    nsIFrame* aFrameList) {
-    nsFrameList temp(aFrameList);
-    InsertFrames(aParent, aPrevSibling, temp);
-  }
+                    nsIFrame* aFrameList);
 
   /**
    * Inserts aFrameList into this list after aPrevSibling (at the beginning if
    * aPrevSibling is null).  If aParent is not null, reparents the newly added
    * frames.  Clears out aFrameList and returns a list slice representing the
    * newly-inserted frames.
    */
   Slice InsertFrames(nsIFrame* aParent, nsIFrame* aPrevSibling,
--- a/layout/generic/nsHTMLFrame.cpp
+++ b/layout/generic/nsHTMLFrame.cpp
@@ -671,17 +671,17 @@ CanvasFrame::Reflow(nsPresContext*      
     if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
       nsIFrame* nextFrame = kidFrame->GetNextInFlow();
       NS_ASSERTION(nextFrame || aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
         "If it's incomplete and has no nif yet, it must flag a nif reflow.");
       if (!nextFrame) {
         nsresult rv = aPresContext->PresShell()->FrameConstructor()->
           CreateContinuingFrame(aPresContext, kidFrame, this, &nextFrame);
         NS_ENSURE_SUCCESS(rv, rv);
-        SetOverflowFrames(aPresContext, nextFrame);
+        SetOverflowFrames(aPresContext, nsFrameList(nextFrame, nextFrame));
         // Root overflow containers will be normal children of
         // the canvas frame, but that's ok because there
         // aren't any other frames we need to isolate them from
         // during reflow.
       }
       if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
         nextFrame->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
       }
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -251,17 +251,17 @@ nsInlineFrame::ReparentFloatsForInlineCh
   if (ancestor == aOurLineContainer)
     return;
 
   nsBlockFrame* ourBlock = nsLayoutUtils::GetAsBlock(aOurLineContainer);
   NS_ASSERTION(ourBlock, "Not a block, but broke vertically?");
   nsBlockFrame* frameBlock = nsLayoutUtils::GetAsBlock(ancestor);
   NS_ASSERTION(frameBlock, "ancestor not a block");
 
-  nsFrameList blockChildren(ancestor->GetFirstChild(nsnull));
+  const nsFrameList& blockChildren(ancestor->GetChildList(nsnull));
   PRBool isOverflow = !blockChildren.ContainsFrame(ancestorBlockChild);
 
   while (PR_TRUE) {
     ourBlock->ReparentFloats(aFrame, frameBlock, isOverflow, PR_FALSE);
 
     if (!aReparentSiblings)
       return;
     nsIFrame* next = aFrame->GetNextSibling();
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -1337,17 +1337,17 @@ public:
 
 // We only need one of these so we just make it a static global, no need
 // to dynamically allocate/destroy it.
 static ForceReflow gForceReflow;
 
 void
 nsMathMLContainerFrame::SetIncrementScriptLevel(PRInt32 aChildIndex, PRBool aIncrement)
 {
-  nsIFrame* child = nsFrameList(GetFirstChild(nsnull)).FrameAt(aChildIndex);
+  nsIFrame* child = GetChildList(nsnull).FrameAt(aChildIndex);
   if (!child)
     return;
   nsIContent* content = child->GetContent();
   if (!content->IsNodeOfType(nsINode::eMATHML))
     return;
   nsMathMLElement* element = static_cast<nsMathMLElement*>(content);
 
   if (element->GetIncrementScriptLevel() == aIncrement)
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -348,17 +348,17 @@ nsMathMLmoFrame::ProcessOperatorData()
     // flag if we have an embellished ancestor
     if (embellishAncestor != this)
       mFlags |= NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR;
     else
       mFlags &= ~NS_MATHML_OPERATOR_EMBELLISH_ANCESTOR;
 
     // find the position of our outermost embellished container w.r.t
     // its siblings (frames are singly-linked together).
-    nsFrameList frameList(parentAncestor->GetFirstChild(nsnull));
+    const nsFrameList& frameList(parentAncestor->GetChildList(nsnull));
 
     nsIFrame* nextSibling = embellishAncestor->GetNextSibling();
     nsIFrame* prevSibling = frameList.GetPrevSiblingFor(embellishAncestor);
 
     // flag to distinguish from a real infix
     if (!prevSibling && !nextSibling)
       mFlags |= NS_MATHML_OPERATOR_EMBELLISH_ISOLATED;
     else
--- a/layout/xul/base/src/nsBoxFrame.cpp
+++ b/layout/xul/base/src/nsBoxFrame.cpp
@@ -2045,17 +2045,18 @@ nsBoxFrame::CheckBoxOrder(nsBoxLayoutSta
     if (ordinal < maxOrdinal)
       break;
     maxOrdinal = ordinal;
   }
 
   if (!child)
     return;
 
-  mFrames = nsFrameList(MergeSort(aState, mFrames.FirstChild()));
+  nsIFrame* head = MergeSort(aState, mFrames.FirstChild());
+  mFrames = nsFrameList(head, nsLayoutUtils::GetLastSibling(head));
 }
 
 NS_IMETHODIMP
 nsBoxFrame::SetLayoutManager(nsIBoxLayout* aLayout)
 {
   mLayoutManager = aLayout;
   return NS_OK;
 }
--- a/layout/xul/base/src/nsMenuFrame.cpp
+++ b/layout/xul/base/src/nsMenuFrame.cpp
@@ -326,17 +326,17 @@ nsMenuFrame::~nsMenuFrame()
 }
 
 // The following methods are all overridden to ensure that the menupopup frame
 // is placed in the appropriate list.
 nsFrameList
 nsMenuFrame::GetChildList(nsIAtom* aListName) const
 {
   if (nsGkAtoms::popupList == aListName) {
-    return mPopupFrame;
+    return nsFrameList(mPopupFrame, mPopupFrame);
   }
   return nsBoxFrame::GetChildList(aListName);
 }
 
 void
 nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList)
 {
   for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
--- a/layout/xul/base/src/nsSplitterFrame.cpp
+++ b/layout/xul/base/src/nsSplitterFrame.cpp
@@ -636,17 +636,17 @@ nsSplitterFrameInner::MouseDown(nsIDOMEv
     return NS_OK;
 
   mParentBox = mOuter->GetParentBox();
   if (!mParentBox)
     return NS_OK;
 
   // get our index
   nsPresContext* outerPresContext = mOuter->PresContext();
-  nsFrameList siblingList(mParentBox->GetFirstChild(nsnull));
+  const nsFrameList& siblingList(mParentBox->GetChildList(nsnull));
   PRInt32 childIndex = siblingList.IndexOf(mOuter);
   // if it's 0 (or not found) then stop right here.
   // It might be not found if we're not in the parent's primary frame list.
   if (childIndex <= 0)
     return NS_OK;
 
   PRInt32 childCount = siblingList.GetLength();
   // if it's the last index then we need to allow for resizeafter="grow"
@@ -870,17 +870,17 @@ nsSplitterFrameInner::UpdateState()
   }
 
   if ((SupportsCollapseDirection(Before) || SupportsCollapseDirection(After)) &&
       mOuter->GetParent()->IsBoxFrame()) {
     // Find the splitter's immediate sibling.
     nsIFrame* splitterSibling;
     if (newState == CollapsedBefore || mState == CollapsedBefore) {
       splitterSibling =
-        nsFrameList(mOuter->GetParent()->GetFirstChild(nsnull)).GetPrevSiblingFor(mOuter);
+        mOuter->GetParent()->GetChildList(nsnull).GetPrevSiblingFor(mOuter);
     } else {
       splitterSibling = mOuter->GetNextSibling();
     }
 
     if (splitterSibling) {
       nsCOMPtr<nsIContent> sibling = splitterSibling->GetContent();
       if (sibling) {
         if (mState == CollapsedBefore || mState == CollapsedAfter) {
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -1800,17 +1800,17 @@ nsXULPopupManager::GetPreviousMenuItem(n
 {
   nsIFrame* immediateParent = nsnull;
   nsPresContext* presContext = aParent->PresContext();
   presContext->PresShell()->
     FrameConstructor()->GetInsertionPoint(aParent, nsnull, &immediateParent);
   if (!immediateParent)
     immediateParent = aParent;
 
-  nsFrameList frames(immediateParent->GetFirstChild(nsnull));
+  const nsFrameList& frames(immediateParent->GetChildList(nsnull));
 
   nsIFrame* currFrame = nsnull;
   if (aStart)
     currFrame = frames.GetPrevSiblingFor(aStart);
   else
     currFrame = frames.LastChild();
 
   while (currFrame) {
--- a/layout/xul/base/src/tree/src/nsTreeColFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeColFrame.cpp
@@ -122,17 +122,17 @@ nsDisplayXULTreeColSplitterTarget::HitTe
   if (mFrame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) {
     PRBool tmp = left;
     left = right;
     right = tmp;
   }
 
   if (left || right) {
     // We are a header. Look for the correct splitter.
-    nsFrameList frames(mFrame->GetParent()->GetFirstChild(nsnull));
+    const nsFrameList& frames(mFrame->GetParent()->GetChildList(nsnull));
     nsIFrame* child;
     if (left)
       child = frames.GetPrevSiblingFor(mFrame);
     else
       child = mFrame->GetNextSibling();
 
     if (child && child->GetContent()->NodeInfo()->Equals(nsGkAtoms::splitter,
                                                          kNameSpaceID_XUL)) {