Bug 233463, patch 5 - Remove nsFrameList(nsIFrame*) ctor. r=bzbarsky

This commit is contained in:
Mats Palmgren 2009-09-18 13:09:36 +02:00
parent eb7a0b3a40
commit 2c137c2022
19 changed files with 69 additions and 83 deletions

View File

@ -207,7 +207,7 @@ CreateBidiContinuation(nsIFrame* aFrame,
// 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;
@ -229,7 +229,12 @@ IsFrameInCurrentLine(nsBlockInFlowLineIterator* aLineIter,
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

View File

@ -614,7 +614,7 @@ 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);
}
@ -1500,15 +1500,14 @@ GetChildListNameFor(nsIFrame* aChildFrame)
// 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.
@ -2944,10 +2943,10 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement)
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);
}
@ -4399,7 +4398,7 @@ 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
@ -5692,9 +5691,8 @@ 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);
@ -10346,7 +10344,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
// 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);
@ -10367,7 +10365,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
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;
@ -10413,7 +10411,7 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
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;

View File

@ -494,11 +494,7 @@ nsFrameIterator::GetFirstChildInner(nsIFrame* aFrame) {
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*
@ -511,8 +507,7 @@ 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);
}
@ -545,20 +540,12 @@ nsFrameIterator::IsPopupFrame(nsIFrame* aFrame)
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*
@ -566,8 +553,7 @@ 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*
@ -575,6 +561,5 @@ 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);
}

View File

@ -1197,7 +1197,7 @@ nsComboboxControlFrame::CreateFrameFor(nsIContent* aContent)
return nsnull;
}
nsFrameList textList(mTextFrame);
nsFrameList textList(mTextFrame, mTextFrame);
mDisplayFrame->SetInitialChildList(nsnull, textList);
return mDisplayFrame;
}

View File

@ -529,7 +529,9 @@ nsBlockFrame::GetChildList(nsIAtom* aListName) const
}
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();
@ -538,7 +540,8 @@ nsBlockFrame::GetChildList(nsIAtom* aListName) const
return mFloats;
}
else if (aListName == nsGkAtoms::bulletList) {
return (HaveOutsideBullet()) ? mBullet : nsnull;
return HaveOutsideBullet() ? nsFrameList(mBullet, mBullet)
: nsFrameList::EmptyList();
}
return nsContainerFrame::GetChildList(aListName);
}
@ -3950,7 +3953,8 @@ nsBlockFrame::SplitLine(nsBlockReflowState& aState,
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
@ -4527,7 +4531,7 @@ nsBlockFrame::GetOverflowOutOfFlows() const
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
@ -6331,7 +6335,7 @@ nsBlockFrame::SetInitialChildList(nsIAtom* aListName,
// 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 {

View File

@ -1330,7 +1330,7 @@ nsContainerFrame::PushChildren(nsPresContext* aPresContext,
}
else {
// Add the frames to our overflow list
SetOverflowFrames(aPresContext, aFromChild);
SetOverflowFrames(aPresContext, tail);
}
}

View File

@ -274,16 +274,9 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
}
// 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);
}
}

View File

@ -4769,7 +4769,7 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsDirection aDirection)
// 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);
@ -4806,7 +4806,7 @@ nsIFrame::PeekOffsetParagraph(nsPeekOffsetStruct *aPos)
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);

View File

@ -49,13 +49,6 @@
const nsFrameList* nsFrameList::sEmptyList;
nsFrameList::nsFrameList(nsIFrame* aFirstFrame)
: mFirstChild(aFirstFrame)
, mLastChild(nsLayoutUtils::GetLastSibling(aFirstFrame))
{
MOZ_COUNT_CTOR(nsFrameList);
}
/* static */
nsresult
nsFrameList::Init()
@ -100,6 +93,13 @@ nsFrameList::SetFrames(nsIFrame* 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)
{
@ -187,6 +187,15 @@ nsFrameList::DestroyFrameIfPresent(nsIFrame* aFrame)
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)

View File

@ -56,9 +56,6 @@ public:
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)
{
@ -109,10 +106,7 @@ public:
* 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,
@ -197,10 +191,7 @@ public:
*/
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

View File

@ -676,7 +676,7 @@ CanvasFrame::Reflow(nsPresContext* aPresContext,
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

View File

@ -256,7 +256,7 @@ nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer,
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) {

View File

@ -1342,7 +1342,7 @@ 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();

View File

@ -353,7 +353,7 @@ nsMathMLmoFrame::ProcessOperatorData()
// 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);

View File

@ -2050,7 +2050,8 @@ nsBoxFrame::CheckBoxOrder(nsBoxLayoutState& aState)
if (!child)
return;
mFrames = nsFrameList(MergeSort(aState, mFrames.FirstChild()));
nsIFrame* head = MergeSort(aState, mFrames.FirstChild());
mFrames = nsFrameList(head, nsLayoutUtils::GetLastSibling(head));
}
NS_IMETHODIMP

View File

@ -331,7 +331,7 @@ nsFrameList
nsMenuFrame::GetChildList(nsIAtom* aListName) const
{
if (nsGkAtoms::popupList == aListName) {
return mPopupFrame;
return nsFrameList(mPopupFrame, mPopupFrame);
}
return nsBoxFrame::GetChildList(aListName);
}

View File

@ -641,7 +641,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
// 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.
@ -875,7 +875,7 @@ nsSplitterFrameInner::UpdateState()
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();
}

View File

@ -1805,7 +1805,7 @@ nsXULPopupManager::GetPreviousMenuItem(nsIFrame* aParent,
if (!immediateParent)
immediateParent = aParent;
nsFrameList frames(immediateParent->GetFirstChild(nsnull));
const nsFrameList& frames(immediateParent->GetChildList(nsnull));
nsIFrame* currFrame = nsnull;
if (aStart)

View File

@ -127,7 +127,7 @@ nsDisplayXULTreeColSplitterTarget::HitTest(nsDisplayListBuilder* aBuilder,
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);