Bug 281387. Make nsIFrame::Append/InsertFrames use nsFrameList. r=bernd,roc, sr=dbaron

This commit is contained in:
Boris Zbarsky 2009-07-30 13:23:32 -04:00
Родитель 3b05f91f31
Коммит 811394b5da
63 изменённых файлов: 479 добавлений и 518 удалений

Просмотреть файл

@ -132,19 +132,23 @@ SplitInlineAncestors(nsIFrame* aFrame)
// The new parent adopts the new frame
frame->SetNextSibling(nsnull);
rv = newParent->InsertFrames(nsGkAtoms::nextBidi, nsnull, newFrame);
if (NS_FAILED(rv)) {
return rv;
}
// XXXbz this thing should be rewritten on top of nsFrameList on a
// much higher level...
nsFrameList temp(newFrame);
// Reparent views as necessary
rv = nsHTMLContainerFrame::ReparentFrameViewList(presContext, newFrame, parent, newParent);
rv = nsHTMLContainerFrame::ReparentFrameViewList(presContext, temp, parent, newParent);
if (NS_FAILED(rv)) {
return rv;
}
rv = newParent->InsertFrames(nsGkAtoms::nextBidi, nsnull, temp);
if (NS_FAILED(rv)) {
return rv;
}
// The list name nsGkAtoms::nextBidi would indicate we don't want reflow
rv = grandparent->InsertFrames(nsGkAtoms::nextBidi, parent, newParent);
nsFrameList temp2(newParent);
rv = grandparent->InsertFrames(nsGkAtoms::nextBidi, parent, temp2);
if (NS_FAILED(rv)) {
return rv;
}
@ -204,7 +208,9 @@ CreateBidiContinuation(nsIFrame* aFrame,
}
// The list name nsGkAtoms::nextBidi would indicate we don't want reflow
rv = parent->InsertFrames(nsGkAtoms::nextBidi, aFrame, *aNewFrame);
// XXXbz this needs higher-level framelist love
nsFrameList temp(*aNewFrame);
rv = parent->InsertFrames(nsGkAtoms::nextBidi, aFrame, temp);
if (NS_FAILED(rv)) {
return rv;
}

Просмотреть файл

@ -1256,8 +1256,7 @@ nsFrameConstructorState::ProcessFrameInsertions(nsAbsoluteItems& aFrameItems,
}
rv = containingBlock->InsertFrames(aChildListName, insertionPoint,
firstNewFrame);
aFrameItems.Clear();
aFrameItems);
}
NS_POSTCONDITION(aFrameItems.IsEmpty(), "How did that happen?");
@ -2432,6 +2431,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIContent* aDocEle
"No viewport? Someone forgot to call ConstructRootFrame!");
NS_PRECONDITION(mFixedContainingBlock == mPresShell->FrameManager()->GetRootFrame(),
"Unexpected mFixedContainingBlock");
NS_PRECONDITION(!mDocElementContainingBlock,
"Shouldn't have a doc element containing block here");
*aNewFrame = nsnull;
@ -2645,7 +2646,7 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIContent* aDocEle
contentFrame->SetInitialChildList(nsnull, childItems);
}
mDocElementContainingBlock->AppendFrames(nsnull, *aNewFrame);
SetInitialSingleChild(mDocElementContainingBlock, *aNewFrame);
return NS_OK;
}
@ -2933,10 +2934,11 @@ nsCSSFrameConstructor::SetUpDocElementContainingBlock(nsIContent* aDocElement)
mHasRootAbsPosContainingBlock = PR_TRUE;
}
nsFrameList newFrameList(newFrame);
if (viewportFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) {
SetInitialSingleChild(viewportFrame, newFrame);
viewportFrame->SetInitialChildList(nsnull, newFrameList);
} else {
viewportFrame->AppendFrames(nsnull, newFrame);
viewportFrame->AppendFrames(nsnull, newFrameList);
}
return NS_OK;
@ -3149,7 +3151,7 @@ nsCSSFrameConstructor::ConstructButtonFrame(nsFrameConstructorState& aState,
if (anonymousChildItems.NotEmpty()) {
// the anonymous content is already parented to the area frame
aState.mFrameManager->AppendFrames(blockFrame, nsnull,
anonymousChildItems.FirstChild());
anonymousChildItems);
}
}
@ -4383,7 +4385,8 @@ void
nsCSSFrameConstructor::FinishBuildingScrollFrame(nsIFrame* aScrollFrame,
nsIFrame* aScrolledFrame)
{
aScrollFrame->AppendFrames(nsnull, aScrolledFrame);
nsFrameList scrolled(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
@ -5755,7 +5758,7 @@ nsCSSFrameConstructor::AppendFrames(nsFrameConstructorState& aState,
// Insert the frames after out aPrevSibling
return aState.mFrameManager->InsertFrames(aParentFrame, nsnull, aPrevSibling,
aFrameList.FirstChild());
aFrameList);
}
#define UNSET_DISPLAY 255
@ -6417,9 +6420,8 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
NS_ASSERTION(nsGkAtoms::tableFrame == frameType, "how did that happen?");
nsIFrame* outerTable = parentFrame->GetParent();
if (outerTable) {
state.mFrameManager->AppendFrames(outerTable,
nsGkAtoms::captionList,
captionItems.FirstChild());
state.mFrameManager->AppendFrames(outerTable, nsGkAtoms::captionList,
captionItems);
}
}
@ -6817,15 +6819,15 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
AppendFrames(state, parentFrame, frameItems, prevSibling);
} else {
state.mFrameManager->InsertFrames(parentFrame, nsnull, prevSibling,
frameItems.FirstChild());
frameItems);
}
}
else {
// we might have a caption treat it here
if (NS_SUCCEEDED(rv) && captionItems.NotEmpty()) {
nsIFrame* newCaptionFrame = captionItems.FirstChild();
nsIFrame* outerTableFrame;
if (GetCaptionAdjustedParent(parentFrame, newCaptionFrame, &outerTableFrame)) {
if (GetCaptionAdjustedParent(parentFrame, captionItems.FirstChild(),
&outerTableFrame)) {
// If the parent of our current prevSibling is different from the frame
// we'll actually use as the parent, then the calculated insertion
// point is now invalid (bug 341382).
@ -6841,12 +6843,12 @@ nsCSSFrameConstructor::ContentInserted(nsIContent* aContainer,
if (isAppend) {
state.mFrameManager->AppendFrames(outerTableFrame,
nsGkAtoms::captionList,
newCaptionFrame);
captionItems);
}
else {
state.mFrameManager->InsertFrames(outerTableFrame,
nsGkAtoms::captionList,
prevSibling, newCaptionFrame);
prevSibling, captionItems);
}
}
}
@ -9705,8 +9707,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLineFrame(
(aLineFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
aLineFrame->SetInitialChildList(nsnull, firstLineChildren);
} else {
aState.mFrameManager->AppendFrames(aLineFrame, nsnull,
firstLineChildren.FirstChild());
aState.mFrameManager->AppendFrames(aLineFrame, nsnull, firstLineChildren);
}
}
else {
@ -9762,9 +9763,10 @@ nsCSSFrameConstructor::InsertFirstLineFrames(
nsFrameItems& aFrameItems)
{
nsresult rv = NS_OK;
// XXXbz If you make this method actually do something, check to make sure
// that the caller is passing what you expect. In particular, which content
// is aContent?
// XXXbz If you make this method actually do something, check to
// make sure that the caller is passing what you expect. In
// particular, which content is aContent? And audit the rest of
// this code too; it makes bogus assumptions and may not build.
#if 0
nsIFrame* parentFrame = *aParentFrame;
nsIFrame* newFrame = aFrameItems.childList;
@ -10156,12 +10158,12 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
aBlockFrames.InsertFrames(nsnull, prevFrame, letterFrames);
}
else {
// Take the old textFrame out of the inline parents child list
// Take the old textFrame out of the inline parent's child list
::DeletingFrameSubtree(mPresShell->FrameManager(), textFrame);
parentFrame->RemoveFrame(nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(nsnull, prevFrame, letterFrames.FirstChild());
parentFrame->InsertFrames(nsnull, prevFrame, letterFrames);
}
}
@ -10342,8 +10344,8 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
aFrameManager->RemoveFrame(parentFrame, nsnull, placeholderFrame);
// Insert text frame in its place
aFrameManager->InsertFrames(parentFrame, nsnull,
prevSibling, newTextFrame);
nsFrameList textList(newTextFrame);
aFrameManager->InsertFrames(parentFrame, nsnull, prevSibling, textList);
return NS_OK;
}
@ -10388,7 +10390,8 @@ nsCSSFrameConstructor::RemoveFirstLetterFrames(nsPresContext* aPresContext,
aFrameManager->RemoveFrame(aFrame, nsnull, kid);
// Insert text frame in its place
aFrameManager->InsertFrames(aFrame, nsnull, prevSibling, textFrame);
nsFrameList textList(textFrame);
aFrameManager->InsertFrames(aFrame, nsnull, prevSibling, textList);
*aStopLooking = PR_TRUE;
aFrame->RemoveStateBits(NS_BLOCK_HAS_FIRST_LETTER_CHILD);
@ -10469,7 +10472,7 @@ nsCSSFrameConstructor::RecoverLetterFrames(nsIFrame* aBlockFrame)
parentFrame->RemoveFrame(nsnull, textFrame);
// Insert in the letter frame(s)
parentFrame->InsertFrames(nsnull, prevFrame, letterFrames.FirstChild());
parentFrame->InsertFrames(nsnull, prevFrame, letterFrames);
}
return rv;
}
@ -10526,9 +10529,9 @@ nsCSSFrameConstructor::CreateListBoxContent(nsPresContext* aPresContext,
if (NS_SUCCEEDED(rv) && (nsnull != newFrame)) {
// Notify the parent frame
if (aIsAppend)
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(newFrame);
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(frameItems);
else
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, newFrame);
rv = ((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, frameItems);
}
EndUpdate();
@ -10842,7 +10845,7 @@ nsCSSFrameConstructor::MoveFramesToEndOfIBSplit(nsFrameConstructorState& aState,
(aExistingEndFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
aExistingEndFrame->SetInitialChildList(nsnull, aFramesToMove);
} else {
aExistingEndFrame->InsertFrames(nsnull, nsnull, aFramesToMove.FirstChild());
aExistingEndFrame->InsertFrames(nsnull, nsnull, aFramesToMove);
}
nsFrameConstructorState* startState = aTargetState ? &aState : nsnull;
MoveChildrenTo(aState.mFrameManager, aExistingEndFrame, newFirstChild,

Просмотреть файл

@ -688,7 +688,7 @@ nsresult
nsFrameManager::InsertFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(!aPrevFrame || (!aPrevFrame->GetNextContinuation()
|| IS_TRUE_OVERFLOW_CONTAINER(aPrevFrame->GetNextContinuation()))

Просмотреть файл

@ -150,7 +150,7 @@ public:
// Functions for manipulating the frame model
NS_HIDDEN_(nsresult) AppendFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
return aParentFrame->AppendFrames(aListName, aFrameList);
}
@ -158,7 +158,7 @@ public:
NS_HIDDEN_(nsresult) InsertFrames(nsIFrame* aParentFrame,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_HIDDEN_(nsresult) RemoveFrame(nsIFrame* aParentFrame,
nsIAtom* aListName,

Просмотреть файл

@ -95,10 +95,10 @@ public:
nsPoint aPt, const nsRect& aDirtyRect);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -118,7 +118,7 @@ public:
protected:
virtual PRIntn GetSkipSides() const;
void ReParentFrameList(nsIFrame* aFrameList);
void ReParentFrameList(const nsFrameList& aFrameList);
nsIFrame* mLegendFrame;
nsIFrame* mContentFrame;
@ -613,34 +613,28 @@ nsFieldSetFrame::GetSkipSides() const
NS_IMETHODIMP
nsFieldSetFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (aFrameList) {
// aFrameList is not allowed to contain "the legend" for this fieldset
ReParentFrameList(aFrameList);
return mContentFrame->AppendFrames(aListName, aFrameList);
}
return NS_OK;
// aFrameList is not allowed to contain "the legend" for this fieldset
ReParentFrameList(aFrameList);
return mContentFrame->AppendFrames(aListName, aFrameList);
}
NS_IMETHODIMP
nsFieldSetFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this ||
aPrevFrame->GetParent() == mContentFrame,
"inserting after sibling frame with different parent");
if (aFrameList) {
// aFrameList is not allowed to contain "the legend" for this fieldset
ReParentFrameList(aFrameList);
if (NS_UNLIKELY(aPrevFrame == mLegendFrame)) {
aPrevFrame = nsnull;
}
return mContentFrame->InsertFrames(aListName, aPrevFrame, aFrameList);
// aFrameList is not allowed to contain "the legend" for this fieldset
ReParentFrameList(aFrameList);
if (NS_UNLIKELY(aPrevFrame == mLegendFrame)) {
aPrevFrame = nsnull;
}
return NS_OK;
return mContentFrame->InsertFrames(aListName, aPrevFrame, aFrameList);
}
NS_IMETHODIMP
@ -666,14 +660,14 @@ NS_IMETHODIMP nsFieldSetFrame::GetAccessible(nsIAccessible** aAccessible)
#endif
void
nsFieldSetFrame::ReParentFrameList(nsIFrame* aFrameList)
nsFieldSetFrame::ReParentFrameList(const nsFrameList& aFrameList)
{
nsFrameManager* frameManager = PresContext()->FrameManager();
for (nsIFrame* frame = aFrameList; frame; frame = frame->GetNextSibling()) {
NS_ASSERTION(mLegendFrame || frame->GetType() != nsGkAtoms::legendFrame,
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
NS_ASSERTION(mLegendFrame || e.get()->GetType() != nsGkAtoms::legendFrame,
"The fieldset's legend is not allowed in this list");
frame->SetParent(mContentFrame);
frameManager->ReParentStyleContext(frame);
e.get()->SetParent(mContentFrame);
frameManager->ReParentStyleContext(e.get());
}
mContentFrame->AddStateBits(GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW);
}

Просмотреть файл

@ -406,7 +406,7 @@ nsHTMLButtonControlFrame::SetAdditionalStyleContext(PRInt32 aIndex,
NS_IMETHODIMP
nsHTMLButtonControlFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("unsupported operation");
return NS_ERROR_UNEXPECTED;
@ -415,7 +415,7 @@ nsHTMLButtonControlFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsHTMLButtonControlFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("unsupported operation");
return NS_ERROR_UNEXPECTED;

Просмотреть файл

@ -95,11 +95,11 @@ public:
nsStyleContext* aStyleContext);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -68,7 +68,7 @@ nsAbsoluteContainingBlock::SetInitialChildList(nsIFrame* aDelegatingFrame,
nsresult
nsAbsoluteContainingBlock::AppendFrames(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(GetChildListName() == aListName, "unexpected child list");
@ -89,7 +89,7 @@ nsresult
nsAbsoluteContainingBlock::InsertFrames(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(GetChildListName() == aListName, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == aDelegatingFrame,

Просмотреть файл

@ -91,11 +91,11 @@ public:
nsFrameList& aChildList);
nsresult AppendFrames(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
nsresult InsertFrames(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
nsresult RemoveFrame(nsIFrame* aDelegatingFrame,
nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -4416,6 +4416,8 @@ nsBlockFrame::HandleOverflowPlaceholdersForPulledFrame(
}
ReparentFrame(outOfFlow, parent, this);
// XXXbz should this be InsertFrame? Or can |frame| really have
// following siblings here?
aState.mOverflowPlaceholders.InsertFrames(nsnull, lastOverflowPlace, frame);
// outOfFlow isn't inserted anywhere yet. Eventually the overflow
// placeholders get put into the overflow lines, and at the same time we
@ -4499,8 +4501,7 @@ nsBlockFrame::DrainOverflowLines(nsBlockReflowState& aState)
for (nsIFrame* f = oofs.mList.FirstChild(); f; f = f->GetNextSibling()) {
ReparentFrame(f, prevBlock, this);
}
mFloats.InsertFrames(nsnull, nsnull, oofs.mList.FirstChild());
oofs.mList.Clear();
mFloats.InsertFrames(nsnull, nsnull, oofs.mList);
}
}
@ -4662,7 +4663,7 @@ nsBlockFrame::DrainOverflowLines(nsBlockReflowState& aState)
// Put the placeholders' out of flows into the float list
keepOutOfFlows.SortByContentOrder();
mFloats.InsertFrames(nsnull, nsnull, keepOutOfFlows.FirstChild());
mFloats.InsertFrames(nsnull, nsnull, keepOutOfFlows);
}
return PR_TRUE;
@ -4789,9 +4790,9 @@ nsBlockFrame::LastChild()
NS_IMETHODIMP
nsBlockFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (nsnull == aFrameList) {
if (aFrameList.IsEmpty()) {
return NS_OK;
}
if (aListName) {
@ -4827,18 +4828,21 @@ nsBlockFrame::AppendFrames(nsIAtom* aListName,
printf("\n");
#endif
nsresult rv = AddFrames(aFrameList, lastKid);
if (NS_SUCCEEDED(rv)) {
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
if (NS_FAILED(rv)) {
return rv;
}
return rv;
aFrameList.Clear();
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
return NS_OK;
}
NS_IMETHODIMP
nsBlockFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
@ -4872,15 +4876,17 @@ nsBlockFrame::InsertFrames(nsIAtom* aListName,
printf("\n");
#endif
nsresult rv = AddFrames(aFrameList, aPrevFrame);
if (NS_FAILED(rv)) {
return rv;
}
aFrameList.Clear();
#ifdef IBMBIDI
if (aListName != nsGkAtoms::nextBidi)
#endif // IBMBIDI
if (NS_SUCCEEDED(rv)) {
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN); // XXX sufficient?
}
return rv;
return NS_OK;
}
static PRBool

Просмотреть файл

@ -170,10 +170,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual nsFrameList GetChildList(nsIAtom* aListName) const;

Просмотреть файл

@ -65,10 +65,10 @@ public:
nsReflowStatus& aStatus);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -1106,7 +1106,7 @@ nsColumnSetFrame::GetSkipSides() const
NS_IMETHODIMP
nsColumnSetFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("AppendFrames not supported");
return NS_ERROR_NOT_IMPLEMENTED;
@ -1115,7 +1115,7 @@ nsColumnSetFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsColumnSetFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("InsertFrames not supported");
return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -126,7 +126,7 @@ nsContainerFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsContainerFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (nsnull != aListName) {
#ifdef IBMBIDI
@ -137,7 +137,7 @@ nsContainerFrame::AppendFrames(nsIAtom* aListName,
return NS_ERROR_INVALID_ARG;
}
}
if (aFrameList) {
if (aFrameList.NotEmpty()) {
mFrames.AppendFrames(this, aFrameList);
// Ask the parent frame to reflow me.
@ -156,7 +156,7 @@ nsContainerFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsContainerFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
@ -170,7 +170,7 @@ nsContainerFrame::InsertFrames(nsIAtom* aListName,
return NS_ERROR_INVALID_ARG;
}
}
if (aFrameList) {
if (aFrameList.NotEmpty()) {
// Insert frames after aPrevFrame
mFrames.InsertFrames(this, aPrevFrame, aFrameList);

Просмотреть файл

@ -80,10 +80,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -415,7 +415,7 @@ NS_IMETHODIMP nsFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(PR_FALSE, "not a container");
return NS_ERROR_UNEXPECTED;
@ -424,7 +424,7 @@ nsFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(PR_FALSE, "not a container");
return NS_ERROR_UNEXPECTED;

Просмотреть файл

@ -166,10 +166,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
virtual void Destroy();

Просмотреть файл

@ -325,20 +325,48 @@ public:
mEnd(aOther.mEnd)
{}
PRBool AtEnd() const { return mFrame == mEnd; }
PRBool AtEnd() const {
// Can't just check mEnd, because some table code goes and destroys the
// tail of the frame list (including mEnd!) while iterating over the
// frame list.
return !mFrame || mFrame == mEnd;
}
/* Next() needs to know about nsIFrame, and nsIFrame will need to
know about nsFrameList methods, so in order to inline this put
the implementation in nsIFrame.h */
inline void Next();
nsIFrame* get() const { return mFrame; }
/**
* Get the current frame we're pointing to. Do not call this on an
* iterator that is at end!
*/
nsIFrame* get() const {
NS_PRECONDITION(!AtEnd(), "Enumerator is at end");
return mFrame;
}
/**
* Get an enumerator that is just like this one, but not limited in terms of
* the part of the list it will traverse.
*/
Enumerator GetUnlimitedEnumerator() const {
return Enumerator(*this, nsnull);
}
#ifdef DEBUG
const nsFrameList& List() const { return mSlice.mList; }
#endif
protected:
Enumerator(const Enumerator& aOther, const nsIFrame* const aNewEnd):
#ifdef DEBUG
mSlice(aOther.mSlice),
#endif
mFrame(aOther.mFrame),
mEnd(aNewEnd)
{}
#ifdef DEBUG
/* Has to be an object, not a reference, since the slice could
well be a temporary constructed from an nsFrameList */

Просмотреть файл

@ -174,7 +174,7 @@ nsHTMLScrollFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsHTMLScrollFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "Only main list supported");
mFrames.AppendFrames(nsnull, aFrameList);
@ -185,7 +185,7 @@ nsHTMLScrollFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsHTMLScrollFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "Only main list supported");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
@ -1061,7 +1061,7 @@ nsXULScrollFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsXULScrollFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsBoxFrame::AppendFrames(aListName, aFrameList);
mInner.ReloadChildFrames();
@ -1071,7 +1071,7 @@ nsXULScrollFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsXULScrollFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
mInner.ReloadChildFrames();

Просмотреть файл

@ -291,10 +291,10 @@ public:
// Because there can be only one child frame, these two function return
// NS_ERROR_FAILURE
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
virtual void Destroy();
@ -458,10 +458,10 @@ public:
// Because there can be only one child frame, these two function return
// NS_ERROR_FAILURE
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
virtual void Destroy();

Просмотреть файл

@ -99,10 +99,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -286,7 +286,7 @@ CanvasFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
CanvasFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;
@ -305,10 +305,12 @@ CanvasFrame::AppendFrames(nsIAtom* aListName,
} else {
// Insert the new frames
NS_ASSERTION(aFrameList.FirstChild() == aFrameList.LastChild(),
"Only one principal child frame allowed");
#ifdef NS_DEBUG
nsFrame::VerifyDirtyBitSet(aFrameList);
#endif
mFrames.AppendFrame(nsnull, aFrameList);
mFrames.AppendFrames(nsnull, aFrameList);
rv = PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
@ -321,7 +323,7 @@ CanvasFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
CanvasFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;

Просмотреть файл

@ -107,10 +107,10 @@ struct nsMargin;
typedef class nsIFrame nsIBox;
// IID for the nsIFrame interface
// 7b437d20-a34e-11dd-ad8b-0800200c9a66
// 2871104e-2738-4ad7-b86a-ede63c71f1c2
#define NS_IFRAME_IID \
{ 0x7b437d20, 0xa34e, 0x11dd, \
{ 0xad, 0x8b, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66 } }
{ 0x2871104e, 0x2738, 0x4ad7, \
{ 0xb8, 0x6a, 0xed, 0xe6, 0x3c, 0x71, 0xf1, 0xc2 } }
/**
* Indication of how the frame can be split. This is used when doing runaround
@ -538,7 +538,7 @@ public:
* @param aListName the name of the child list. A NULL pointer for the atom
* name means the unnamed principal child list
* @param aChildList list of child frames. Each of the frames has its
* NS_FRAME_IS_DIRTY bit set
* NS_FRAME_IS_DIRTY bit set. Must not be empty.
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
* name,
* NS_ERROR_UNEXPECTED if the frame is an atomic frame or if the
@ -559,14 +559,16 @@ public:
* @param aListName the name of the child list. A NULL pointer for the atom
* name means the unnamed principal child list
* @param aFrameList list of child frames to append. Each of the frames has
* its NS_FRAME_IS_DIRTY bit set
* its NS_FRAME_IS_DIRTY bit set. Must not be empty.
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
* name,
* NS_ERROR_UNEXPECTED if the frame is an atomic frame,
* NS_OK otherwise
* NS_OK otherwise. In this case, AppendFrames empties out
* aChildList in the process of moving the frames over to its own
* child list.
*/
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList) = 0;
nsFrameList& aFrameList) = 0;
/**
* This method is responsible for inserting frames into the frame
@ -581,11 +583,13 @@ public:
* @return NS_ERROR_INVALID_ARG if there is no child list with the specified
* name,
* NS_ERROR_UNEXPECTED if the frame is an atomic frame,
* NS_OK otherwise
* NS_OK otherwise. In this case, InsertFrames empties out
* aChildList in the process of moving the frames over to its own
* child list.
*/
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList) = 0;
nsFrameList& aFrameList) = 0;
/**
* This method is responsible for removing a frame in the frame

Просмотреть файл

@ -1098,7 +1098,7 @@ nsPositionedInlineFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsPositionedInlineFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;
@ -1114,7 +1114,7 @@ nsPositionedInlineFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsPositionedInlineFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;

Просмотреть файл

@ -259,10 +259,10 @@ public:
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -112,7 +112,7 @@ ViewportFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
NS_IMETHODIMP
ViewportFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = NS_OK;
@ -131,7 +131,7 @@ ViewportFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
ViewportFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = NS_OK;

Просмотреть файл

@ -75,11 +75,11 @@ public:
nsFrameList& aChildList);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -795,32 +795,26 @@ nsMathMLContainerFrame::ChildListChanged(PRInt32 aModType)
NS_IMETHODIMP
nsMathMLContainerFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (aListName) {
return NS_ERROR_INVALID_ARG;
}
if (aFrameList) {
mFrames.AppendFrames(this, aFrameList);
return ChildListChanged(nsIDOMMutationEvent::ADDITION);
}
return NS_OK;
mFrames.AppendFrames(this, aFrameList);
return ChildListChanged(nsIDOMMutationEvent::ADDITION);
}
NS_IMETHODIMP
nsMathMLContainerFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (aListName) {
return NS_ERROR_INVALID_ARG;
}
if (aFrameList) {
// Insert frames after aPrevFrame
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
return ChildListChanged(nsIDOMMutationEvent::ADDITION);
}
return NS_OK;
// Insert frames after aPrevFrame
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
return ChildListChanged(nsIDOMMutationEvent::ADDITION);
}
NS_IMETHODIMP

Просмотреть файл

@ -119,12 +119,12 @@ public:
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD
RemoveFrame(nsIAtom* aListName,
@ -409,7 +409,7 @@ public:
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName || nsGkAtoms::nextBidi == aListName,
"unexpected frame list");
@ -422,7 +422,7 @@ public:
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName || nsGkAtoms::nextBidi == aListName,
"unexpected frame list");
@ -477,7 +477,7 @@ public:
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName || nsGkAtoms::nextBidi == aListName,
"unexpected frame list");
@ -490,7 +490,7 @@ public:
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName || nsGkAtoms::nextBidi == aListName,
"unexpected frame list");

Просмотреть файл

@ -89,7 +89,7 @@ public:
// we are just a wrapper and these methods shouldn't be called
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("unsupported operation");
return NS_ERROR_NOT_IMPLEMENTED;
@ -98,7 +98,7 @@ public:
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_NOTREACHED("unsupported operation");
return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -114,7 +114,7 @@ public:
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsTableFrame::AppendFrames(aListName, aFrameList);
RestyleTable();
@ -124,7 +124,7 @@ public:
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsTableFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
RestyleTable();
@ -171,7 +171,7 @@ public:
NS_IMETHOD
AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsTableRowFrame::AppendFrames(aListName, aFrameList);
RestyleTable();
@ -181,7 +181,7 @@ public:
NS_IMETHOD
InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsTableRowFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
RestyleTable();

Просмотреть файл

@ -56,7 +56,7 @@ NS_NewSVGContainerFrame(nsIPresShell* aPresShell,
NS_IMETHODIMP
nsSVGContainerFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
return InsertFrames(aListName, mFrames.LastChild(), aFrameList);
}
@ -64,7 +64,7 @@ nsSVGContainerFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsSVGContainerFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
@ -110,14 +110,14 @@ nsSVGDisplayContainerFrame::Init(nsIContent* aContent,
NS_IMETHODIMP
nsSVGDisplayContainerFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
// memorize last new frame
nsIFrame* lastNewFrame = nsnull;
{
nsFrameList tmpList(aFrameList);
lastNewFrame = tmpList.LastChild();
}
// memorize first old frame after insertion point
// XXXbz once again, this would work a lot better if the nsIFrame
// methods returned framelist iterators....
nsIFrame* firstOldFrame = aPrevFrame ?
aPrevFrame->GetNextSibling() : GetChildList(aListName).FirstChild();
nsIFrame* firstNewFrame = aFrameList.FirstChild();
// Insert the new frames
nsSVGContainerFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
@ -125,11 +125,7 @@ nsSVGDisplayContainerFrame::InsertFrames(nsIAtom* aListName,
// Call InitialUpdate on the new frames ONLY if our nsSVGOuterSVGFrame has had
// its initial reflow (our NS_FRAME_FIRST_REFLOW bit is clear) - bug 399863.
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
nsIFrame* end = nsnull;
if (lastNewFrame)
end = lastNewFrame->GetNextSibling();
for (nsIFrame* kid = aFrameList; kid != end;
for (nsIFrame* kid = firstNewFrame; kid != firstOldFrame;
kid = kid->GetNextSibling()) {
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
if (SVGFrame) {

Просмотреть файл

@ -63,10 +63,10 @@ public:
// nsIFrame:
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD Init(nsIContent* aContent,
@ -95,7 +95,7 @@ public:
// nsIFrame:
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD Init(nsIContent* aContent,

Просмотреть файл

@ -134,7 +134,7 @@ nsSVGTextContainerFrame::GetDy()
NS_IMETHODIMP
nsSVGTextContainerFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv = nsSVGDisplayContainerFrame::InsertFrames(aListName,
aPrevFrame,

Просмотреть файл

@ -64,7 +64,7 @@ public:
// nsIFrame
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom *aListName, nsIFrame *aOldFrame);
NS_IMETHOD GetStartPositionOfChar(PRUint32 charnum, nsIDOMSVGPoint **_retval);

Просмотреть файл

@ -259,7 +259,7 @@ nsTableCellFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
NS_IMETHODIMP
nsTableCellFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(PR_FALSE, "unsupported operation");
return NS_ERROR_NOT_IMPLEMENTED;
@ -268,7 +268,7 @@ nsTableCellFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsTableCellFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(PR_FALSE, "unsupported operation");
return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -100,10 +100,10 @@ public:
// so these functions should never be called. They assert and return
// NS_ERROR_NOT_IMPLEMENTED
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -97,34 +97,32 @@ void nsTableColGroupFrame::ResetColIndices(nsIFrame* aFirstColGroup,
nsresult
nsTableColGroupFrame::AddColsToTable(PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame)
nsTableColGroupFrame::AddColsToTable(PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
const nsFrameList::Slice& aCols)
{
nsresult rv = NS_OK;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
if (!tableFrame || !aFirstFrame)
if (!tableFrame)
return NS_ERROR_NULL_POINTER;
// set the col indices of the col frames and and add col info to the table
PRInt32 colIndex = aFirstColIndex;
nsIFrame* kidFrame = aFirstFrame;
PRBool foundLastFrame = PR_FALSE;
while (kidFrame) {
if (nsGkAtoms::tableColFrame == kidFrame->GetType()) {
((nsTableColFrame*)kidFrame)->SetColIndex(colIndex);
if (!foundLastFrame) {
mColCount++;
tableFrame->InsertCol((nsTableColFrame &)*kidFrame, colIndex);
}
colIndex++;
}
if (kidFrame == aLastFrame) {
foundLastFrame = PR_TRUE;
}
kidFrame = kidFrame->GetNextSibling();
nsFrameList::Enumerator e(aCols);
for (; !e.AtEnd(); e.Next()) {
((nsTableColFrame*)e.get())->SetColIndex(colIndex);
mColCount++;
tableFrame->InsertCol((nsTableColFrame &)*e.get(), colIndex);
colIndex++;
}
for (nsFrameList::Enumerator eTail = e.GetUnlimitedEnumerator();
!eTail.AtEnd();
eTail.Next()) {
((nsTableColFrame*)eTail.get())->SetColIndex(colIndex);
colIndex++;
}
// We have already set the colindex for all the colframes in this
// colgroup that come after the first inserted colframe, but there could
// be other colgroups following this one and their colframes need
@ -137,38 +135,28 @@ nsTableColGroupFrame::AddColsToTable(PRInt32 aFirstColIndex,
}
PRBool
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame,
nsIFrame** aLastColGroup)
nsTableColGroupFrame*
nsTableColGroupFrame::GetLastRealColGroup(nsTableFrame* aTableFrame)
{
*aLastColGroup = nsnull;
nsFrameList colGroups = aTableFrame->GetColGroups();
nsIFrame* nextToLastColGroup = nsnull;
nsIFrame* lastColGroup = colGroups.FirstChild();
while(lastColGroup) {
nsIFrame* next = lastColGroup->GetNextSibling();
if (next) {
nextToLastColGroup = lastColGroup;
lastColGroup = next;
}
else {
break;
}
nsFrameList::FrameLinkEnumerator link(colGroups);
for ( ; !link.AtEnd(); link.Next()) {
nextToLastColGroup = link.PrevFrame();
}
if (!lastColGroup) return PR_TRUE; // there are no col group frames
if (!link.PrevFrame()) {
return nsnull; // there are no col group frames
}
nsTableColGroupType lastColGroupType =
((nsTableColGroupFrame *)lastColGroup)->GetColType();
static_cast<nsTableColGroupFrame*>(link.PrevFrame())->GetColType();
if (eColGroupAnonymousCell == lastColGroupType) {
*aLastColGroup = nextToLastColGroup;
return PR_FALSE;
}
else {
*aLastColGroup = lastColGroup;
return PR_TRUE;
return static_cast<nsTableColGroupFrame*>(nextToLastColGroup);
}
return static_cast<nsTableColGroupFrame*>(link.PrevFrame());
}
// don't set mColCount here, it is done in AddColsToTable
@ -223,7 +211,7 @@ nsTableColGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
NS_IMETHODIMP
nsTableColGroupFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
@ -239,23 +227,21 @@ nsTableColGroupFrame::AppendFrames(nsIAtom* aListName,
col = nextCol;
}
mFrames.AppendFrames(this, aFrameList);
InsertColsReflow(GetStartColumnIndex() + mColCount, aFrameList);
const nsFrameList::Slice& newFrames =
mFrames.AppendFrames(this, aFrameList);
InsertColsReflow(GetStartColumnIndex() + mColCount, newFrames);
return NS_OK;
}
NS_IMETHODIMP
nsTableColGroupFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
nsFrameList frames(aFrameList); // convience for getting last frame
nsIFrame* lastFrame = frames.LastChild();
nsTableColFrame* col = GetFirstColumn();
nsTableColFrame* nextCol;
while (col && col->GetColType() == eColAnonymousColGroup) {
@ -281,22 +267,22 @@ nsTableColGroupFrame::InsertFrames(nsIAtom* aListName,
GetNextColumn(aPrevFrame)->GetColType() != eColAnonymousCol,
"Shouldn't be inserting before a spanned colframe");
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
const nsFrameList::Slice& newFrames =
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
nsIFrame* prevFrame = nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame,
nsGkAtoms::tableColFrame);
PRInt32 colIndex = (prevFrame) ? ((nsTableColFrame*)prevFrame)->GetColIndex() + 1 : GetStartColumnIndex();
InsertColsReflow(colIndex, aFrameList, lastFrame);
InsertColsReflow(colIndex, newFrames);
return NS_OK;
}
void
nsTableColGroupFrame::InsertColsReflow(PRInt32 aColIndex,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame)
nsTableColGroupFrame::InsertColsReflow(PRInt32 aColIndex,
const nsFrameList::Slice& aCols)
{
AddColsToTable(aColIndex, PR_TRUE, aFirstFrame, aLastFrame);
AddColsToTable(aColIndex, PR_TRUE, aCols);
PresContext()->PresShell()->FrameNeedsReflow(this,
nsIPresShell::eTreeChange,

Просмотреть файл

@ -103,11 +103,9 @@ public:
* that are the result of wrapping cells in an anonymous
* column and colgroup are not considered real here.
* @param aTableFrame - the table parent of the colgroups
* @param aLastColgroup - the last real colgroup
* @return is false if there is a non real colgroup at the end
* @return the last real colgroup
*/
static PRBool GetLastRealColGroup(nsTableFrame* aTableFrame,
nsIFrame** aLastColGroup);
static nsTableColGroupFrame* GetLastRealColGroup(nsTableFrame* aTableFrame);
/** @see nsIFrame::DidSetStyleContext */
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
@ -115,10 +113,10 @@ public:
/** @see nsIFrame::AppendFrames, InsertFrames, RemoveFrame
*/
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -161,18 +159,16 @@ public:
* @param aResetSubsequentColIndices - the indices of the col frames
* after the insertion might need
* an update
* @param aFirstFrame - first frame that needs to be added to the table,
* the frame should have a correctly set sibling
* @param aLastFrame - last frame that needs to be added. It can be either
* null or should be in the sibling chain of
* aFirstFrame
* @param aCols - an iterator that can be used to iterate over the col
* frames to be added. Once this is done, the frames on the
* sbling chain of its .get() at that point will still need
* their col indices updated.
* @result - if there is no table frame or the table frame is not
* the first in flow it will return an error
*/
nsresult AddColsToTable(PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
nsresult AddColsToTable(PRInt32 aFirstColIndex,
PRBool aResetSubsequentColIndices,
const nsFrameList::Slice& aCols);
#ifdef DEBUG
NS_IMETHOD GetFrameName(nsAString& aResult) const;
@ -237,9 +233,8 @@ public:
protected:
nsTableColGroupFrame(nsStyleContext* aContext);
void InsertColsReflow(PRInt32 aColIndex,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
void InsertColsReflow(PRInt32 aColIndex,
const nsFrameList::Slice& aCols);
/** implement abstract method on nsHTMLContainerFrame */
virtual PRIntn GetSkipSides() const;

Просмотреть файл

@ -354,8 +354,8 @@ nsTableFrame::SetInitialChildList(nsIAtom* aListName,
if (!GetPrevInFlow()) {
// process col groups first so that real cols get constructed before
// anonymous ones due to cells in rows.
InsertColGroups(0, mColGroups.FirstChild());
AppendRowGroups(mFrames.FirstChild());
InsertColGroups(0, mColGroups);
InsertRowGroups(mFrames);
// calc collapsing borders
if (IsBorderCollapse()) {
nsRect damageArea(0, 0, GetColCount(), GetRowCount());
@ -527,78 +527,72 @@ void nsTableFrame::AdjustRowIndices(PRInt32 aRowIndex,
}
void nsTableFrame::ResetRowIndices(nsIFrame* aFirstRowGroupFrame,
nsIFrame* aLastRowGroupFrame)
void nsTableFrame::ResetRowIndices(const nsFrameList::Slice& aRowGroupsToExclude)
{
// Iterate over the row groups and adjust the row indices of all rows
// omit the rowgroups that will be inserted later
// XXXbz this code seems to assume that the row groups handed out by
// aRowGroupsToExclude are already in OrderRowGroups() order.
// There's no reason that would be true!
RowGroupArray rowGroups;
OrderRowGroups(rowGroups);
PRInt32 rowIndex = 0;
nsTableRowGroupFrame* newRgFrame = nsnull;
nsIFrame* omitRgFrame = aFirstRowGroupFrame;
if (omitRgFrame) {
newRgFrame = GetRowGroupFrame(omitRgFrame);
if (omitRgFrame == aLastRowGroupFrame)
omitRgFrame = nsnull;
nsFrameList::Enumerator excludeRowGroupsEnumerator(aRowGroupsToExclude);
if (!excludeRowGroupsEnumerator.AtEnd()) {
newRgFrame = GetRowGroupFrame(excludeRowGroupsEnumerator.get());
excludeRowGroupsEnumerator.Next();
}
for (PRUint32 rgX = 0; rgX < rowGroups.Length(); rgX++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
if (rgFrame == newRgFrame) {
// omit the new rowgroup
if (omitRgFrame) {
omitRgFrame = omitRgFrame->GetNextSibling();
if (omitRgFrame) {
newRgFrame = GetRowGroupFrame(omitRgFrame);
if (omitRgFrame == aLastRowGroupFrame)
omitRgFrame = nsnull;
}
// omit the new rowgroup and move our iterator along
if (!excludeRowGroupsEnumerator.AtEnd()) {
newRgFrame = GetRowGroupFrame(excludeRowGroupsEnumerator.get());
excludeRowGroupsEnumerator.Next();
}
}
else {
nsIFrame* rowFrame = rgFrame->GetFirstChild(nsnull);
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
if (NS_STYLE_DISPLAY_TABLE_ROW==rowFrame->GetStyleDisplay()->mDisplay) {
((nsTableRowFrame *)rowFrame)->SetRowIndex(rowIndex);
const nsFrameList& rowFrames = rgFrame->GetChildList(nsnull);
for (nsFrameList::Enumerator rows(rowFrames); !rows.AtEnd(); rows.Next()) {
if (NS_STYLE_DISPLAY_TABLE_ROW==rows.get()->GetStyleDisplay()->mDisplay) {
((nsTableRowFrame *)rows.get())->SetRowIndex(rowIndex);
rowIndex++;
}
}
}
}
}
void nsTableFrame::InsertColGroups(PRInt32 aStartColIndex,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame)
void nsTableFrame::InsertColGroups(PRInt32 aStartColIndex,
const nsFrameList::Slice& aColGroups)
{
PRInt32 colIndex = aStartColIndex;
nsTableColGroupFrame* firstColGroupToReset = nsnull;
nsIFrame* kidFrame = aFirstFrame;
PRBool didLastFrame = PR_FALSE;
while (kidFrame) {
if (nsGkAtoms::tableColGroupFrame == kidFrame->GetType()) {
if (didLastFrame) {
firstColGroupToReset = (nsTableColGroupFrame*)kidFrame;
break;
}
else {
nsTableColGroupFrame* cgFrame = (nsTableColGroupFrame*)kidFrame;
cgFrame->SetStartColumnIndex(colIndex);
nsIFrame* firstCol = kidFrame->GetFirstChild(nsnull);
cgFrame->AddColsToTable(colIndex, PR_FALSE, firstCol);
PRInt32 numCols = cgFrame->GetColCount();
colIndex += numCols;
}
}
if (kidFrame == aLastFrame) {
didLastFrame = PR_TRUE;
}
kidFrame = kidFrame->GetNextSibling();
nsFrameList::Enumerator colGroups(aColGroups);
for (; !colGroups.AtEnd(); colGroups.Next()) {
nsTableColGroupFrame* cgFrame =
static_cast<nsTableColGroupFrame*>(colGroups.get());
cgFrame->SetStartColumnIndex(colIndex);
// XXXbz this sucks. AddColsToTable will actually remove colgroups from
// the list we're traversing! Need to fix things here. :( I guess this is
// why the old code used pointer-to-last-frame as opposed to
// pointer-to-frame-after-last....
// How about dealing with this by storing a const reference to the
// mNextSibling of the framelist's last frame, instead of storing a pointer
// to the first-after-next frame? Will involve making nsFrameList friend
// of nsIFrame, but it's time for that anyway.
cgFrame->AddColsToTable(colIndex, PR_FALSE,
colGroups.get()->GetChildList(nsnull));
PRInt32 numCols = cgFrame->GetColCount();
colIndex += numCols;
}
if (firstColGroupToReset) {
nsTableColGroupFrame::ResetColIndices(firstColGroupToReset, colIndex);
nsFrameList::Enumerator remainingColgroups = colGroups.GetUnlimitedEnumerator();
if (!remainingColgroups.AtEnd()) {
nsTableColGroupFrame::ResetColIndices(
static_cast<nsTableColGroupFrame*>(remainingColgroups.get()), colIndex);
}
}
@ -764,9 +758,8 @@ nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
}
nsFrameList& cols = aColGroupFrame->GetWritableChildList();
nsIFrame* oldLastCol = cols.LastChild();
nsIFrame* firstNewCol = newColFrames.FirstChild();
nsIFrame* lastNewCol = newColFrames.lastChild;
cols.InsertFrames(nsnull, oldLastCol, newColFrames);
const nsFrameList::Slice& newCols =
cols.InsertFrames(nsnull, oldLastCol, newColFrames);
if (aAddToTable) {
// get the starting col index in the cache
PRInt32 startColIndex;
@ -777,8 +770,7 @@ nsTableFrame::AppendAnonymousColFrames(nsTableColGroupFrame* aColGroupFrame,
startColIndex = aColGroupFrame->GetStartColumnIndex();
}
aColGroupFrame->AddColsToTable(startColIndex, PR_TRUE,
firstNewCol, lastNewCol);
aColGroupFrame->AddColsToTable(startColIndex, PR_TRUE, newCols);
}
}
@ -1023,17 +1015,6 @@ void nsTableFrame::RemoveRows(nsTableRowFrame& aFirstRowFrame,
#endif
}
void nsTableFrame::AppendRowGroups(nsIFrame* aFirstRowGroupFrame)
{
if (aFirstRowGroupFrame) {
nsTableCellMap* cellMap = GetCellMap();
if (cellMap) {
nsFrameList newList(aFirstRowGroupFrame);
InsertRowGroups(aFirstRowGroupFrame, newList.LastChild());
}
}
}
nsTableRowGroupFrame*
nsTableFrame::GetRowGroupFrame(nsIFrame* aFrame,
nsIAtom* aFrameTypeIn)
@ -1086,8 +1067,7 @@ nsTableFrame::CollectRows(nsIFrame* aFrame,
}
void
nsTableFrame::InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
nsIFrame* aLastRowGroupFrame)
nsTableFrame::InsertRowGroups(const nsFrameList::Slice& aRowGroups)
{
#ifdef DEBUG_TABLE_CELLMAP
printf("=== insertRowGroupsBefore\n");
@ -1101,11 +1081,13 @@ nsTableFrame::InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
nsAutoTArray<nsTableRowFrame*, 8> rows;
// Loop over the rowgroups and check if some of them are new, if they are
// insert cellmaps in the order that is predefined by OrderRowGroups,
// XXXbz this code is O(N*M) where N is number of new rowgroups
// and M is number of rowgroups we have!
PRUint32 rgIndex;
for (rgIndex = 0; rgIndex < orderedRowGroups.Length(); rgIndex++) {
nsIFrame* kidFrame = aFirstRowGroupFrame;
while (kidFrame) {
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(kidFrame);
for (nsFrameList::Enumerator rowgroups(aRowGroups); !rowgroups.AtEnd();
rowgroups.Next()) {
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(rowgroups.get());
if (orderedRowGroups[rgIndex] == rgFrame) {
nsTableRowGroupFrame* priorRG =
@ -1115,28 +1097,22 @@ nsTableFrame::InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
break;
}
else {
if (kidFrame == aLastRowGroupFrame) {
break;
}
kidFrame = kidFrame->GetNextSibling();
}
}
}
cellMap->Synchronize(this);
ResetRowIndices(aFirstRowGroupFrame, aLastRowGroupFrame);
ResetRowIndices(aRowGroups);
//now that the cellmaps are reordered too insert the rows
for (rgIndex = 0; rgIndex < orderedRowGroups.Length(); rgIndex++) {
nsIFrame* kidFrame = aFirstRowGroupFrame;
while (kidFrame) {
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(kidFrame);
for (nsFrameList::Enumerator rowgroups(aRowGroups); !rowgroups.AtEnd();
rowgroups.Next()) {
nsTableRowGroupFrame* rgFrame = GetRowGroupFrame(rowgroups.get());
if (orderedRowGroups[rgIndex] == rgFrame) {
nsTableRowGroupFrame* priorRG =
(0 == rgIndex) ? nsnull : orderedRowGroups[rgIndex - 1];
// collect the new row frames in an array and add them to the table
PRInt32 numRows = CollectRows(kidFrame, rows);
PRInt32 numRows = CollectRows(rowgroups.get(), rows);
if (numRows > 0) {
PRInt32 rowIndex = 0;
if (priorRG) {
@ -1148,12 +1124,6 @@ nsTableFrame::InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
}
break;
}
else {
if (kidFrame == aLastRowGroupFrame) {
break;
}
kidFrame = kidFrame->GetNextSibling();
}
}
}
@ -2020,10 +1990,9 @@ nsTableFrame::PushChildren(const FrameArray& aFrames,
}
// When pushing and pulling frames we need to check for whether any
// views need to be reparented.
for (nsIFrame* f = frames.FirstChild(); f; f = f->GetNextSibling()) {
nsHTMLContainerFrame::ReparentFrameView(PresContext(), f, this, nextInFlow);
}
nextInFlow->mFrames.InsertFrames(GetNextInFlow(), prevSibling, frames.FirstChild());
ReparentFrameViewList(PresContext(), frames, this, nextInFlow);
nextInFlow->mFrames.InsertFrames(nextInFlow, prevSibling,
frames);
}
else if (frames.NotEmpty()) {
// Add the frames to our overflow list
@ -2138,7 +2107,7 @@ nsTableFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
NS_IMETHODIMP
nsTableFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName || aListName == nsGkAtoms::colGroupList,
"unexpected child list");
@ -2147,43 +2116,33 @@ nsTableFrame::AppendFrames(nsIAtom* aListName,
// for everything else, we need to look at each frame individually
// XXX The frame construction code should be separating out child frames
// based on the type, bug 343048.
nsIFrame* f = aFrameList;
while (f) {
// Get the next frame and disconnect this frame from its sibling
nsIFrame* next = f->GetNextSibling();
f->SetNextSibling(nsnull);
while (!aFrameList.IsEmpty()) {
nsIFrame* f = aFrameList.FirstChild();
aFrameList.RemoveFrame(f);
// See what kind of frame we have
const nsStyleDisplay* display = f->GetStyleDisplay();
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {
nsTableColGroupFrame* lastColGroup;
PRBool doAppend = nsTableColGroupFrame::GetLastRealColGroup(this, (nsIFrame**) &lastColGroup);
nsTableColGroupFrame* lastColGroup =
nsTableColGroupFrame::GetLastRealColGroup(this);
PRInt32 startColIndex = (lastColGroup)
? lastColGroup->GetStartColumnIndex() + lastColGroup->GetColCount() : 0;
if (doAppend) {
// Append the new col group frame
mColGroups.AppendFrame(nsnull, f);
}
else {
// there is a colgroup after the last real one
mColGroups.InsertFrame(nsnull, lastColGroup, f);
}
mColGroups.InsertFrame(nsnull, lastColGroup, f);
// Insert the colgroup and its cols into the table
InsertColGroups(startColIndex, f, f);
InsertColGroups(startColIndex,
nsFrameList::Slice(mColGroups, f, f->GetNextSibling()));
} else if (IsRowGroup(display->mDisplay)) {
// Append the new row group frame to the sibling chain
mFrames.AppendFrame(nsnull, f);
// insert the row group and its rows into the table
InsertRowGroups(f, f);
InsertRowGroups(nsFrameList::Slice(mFrames, f, nsnull));
} else {
// Nothing special to do, just add the frame to our child list
NS_NOTREACHED("How did we get here? Frame construction screwed up");
mFrames.AppendFrame(nsnull, f);
}
// Move to the next frame
f = next;
}
#ifdef DEBUG_TABLE_CELLMAP
@ -2200,7 +2159,7 @@ nsTableFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsTableFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
// Asssume there's only one frame being inserted. The problem is that
// row group frames and col group frames go in separate child lists and
@ -2212,22 +2171,20 @@ nsTableFrame::InsertFrames(nsIAtom* aListName,
"inserting after sibling frame with different parent");
if ((aPrevFrame && !aPrevFrame->GetNextSibling()) ||
(!aPrevFrame && !GetFirstChild(aListName))) {
(!aPrevFrame && GetChildList(aListName).IsEmpty())) {
// Treat this like an append; still a workaround for bug 343048.
return AppendFrames(aListName, aFrameList);
}
// See what kind of frame we have
const nsStyleDisplay* display = aFrameList->GetStyleDisplay();
const nsStyleDisplay* display = aFrameList.FirstChild()->GetStyleDisplay();
#ifdef DEBUG
// verify that all sibling have the same type, if they do not, expect cellmap issues
nsIFrame* nextFrame = aFrameList->GetNextSibling();
while (nextFrame) {
const nsStyleDisplay* nextDisplay = nextFrame->GetStyleDisplay();
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
const nsStyleDisplay* nextDisplay = e.get()->GetStyleDisplay();
NS_ASSERTION((display->mDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP) ==
(nextDisplay->mDisplay == NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP),
"heterogenous childlist");
nextFrame = nextFrame->GetNextSibling();
}
#endif
if (aPrevFrame) {
@ -2238,7 +2195,7 @@ nsTableFrame::InsertFrames(nsIAtom* aListName,
// the previous frame is not valid, see comment at ::AppendFrames
// XXXbz Using content indices here means XBL will get screwed
// over... Oh, well.
nsIFrame* pseudoFrame = aFrameList;
nsIFrame* pseudoFrame = aFrameList.FirstChild();
nsIContent* parentContent = GetContent();
nsIContent* content;
aPrevFrame = nsnull;
@ -2255,8 +2212,7 @@ nsTableFrame::InsertFrames(nsIAtom* aListName,
nsTableColGroupFrame* lastColGroup;
if (isColGroup) {
kidFrame = mColGroups.FirstChild();
nsTableColGroupFrame::GetLastRealColGroup(this,
(nsIFrame**) &lastColGroup);
lastColGroup = nsTableColGroupFrame::GetLastRealColGroup(this);
}
else {
kidFrame = mFrames.FirstChild();
@ -2288,10 +2244,9 @@ nsTableFrame::InsertFrames(nsIAtom* aListName,
if (NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP == display->mDisplay) {
NS_ASSERTION(!aListName || aListName == nsGkAtoms::colGroupList,
"unexpected child list");
// Insert the column group frame
nsFrameList frames(aFrameList); // convience for getting last frame
nsIFrame* lastFrame = frames.LastChild();
mColGroups.InsertFrames(nsnull, aPrevFrame, aFrameList);
// Insert the column group frames
const nsFrameList::Slice& newColgroups =
mColGroups.InsertFrames(nsnull, aPrevFrame, aFrameList);
// find the starting col index for the first new col group
PRInt32 startColIndex = 0;
if (aPrevFrame) {
@ -2302,17 +2257,17 @@ nsTableFrame::InsertFrames(nsIAtom* aListName,
startColIndex = prevColGroup->GetStartColumnIndex() + prevColGroup->GetColCount();
}
}
InsertColGroups(startColIndex, aFrameList, lastFrame);
InsertColGroups(startColIndex, newColgroups);
} else if (IsRowGroup(display->mDisplay)) {
NS_ASSERTION(!aListName, "unexpected child list");
nsFrameList newList(aFrameList);
nsIFrame* lastSibling = newList.LastChild();
// Insert the frames in the sibling chain
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
const nsFrameList::Slice& newRowGroups =
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
InsertRowGroups(aFrameList, lastSibling);
InsertRowGroups(newRowGroups);
} else {
NS_ASSERTION(!aListName, "unexpected child list");
NS_NOTREACHED("How did we even get here?");
// Just insert the frame and don't worry about reflowing it
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
return NS_OK;
@ -2377,7 +2332,8 @@ nsTableFrame::RemoveFrame(nsIAtom* aListName,
// XXXldb [reflow branch merging 20060830] do we still need this?
if (cellMap) {
cellMap->Synchronize(this);
ResetRowIndices();
// Create an empty slice
ResetRowIndices(nsFrameList::Slice(mFrames, nsnull, nsnull));
nsRect damageArea;
cellMap->RebuildConsideringCells(nsnull, nsnull, 0, 0, PR_FALSE, damageArea);
}

Просмотреть файл

@ -200,10 +200,10 @@ public:
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -499,22 +499,12 @@ public:
PRBool aConsiderSpans);
/** Insert multiple rowgroups into the table cellmap handling
* @param aFirstRowGroupFrame - first row group to be inserted all siblings
* will be appended too.
* @param aRowGroups - iterator that iterates over the rowgroups to insert
*/
void AppendRowGroups(nsIFrame* aFirstRowGroupFrame);
void InsertRowGroups(const nsFrameList::Slice& aRowGroups);
/** Insert multiple rowgroups into the table cellmap handling
* @param aFirstRowGroupFrame - first row group to be inserted
* @param aLastRowGroupFrame - when inserting the siblings of
* aFirstRowGroupFrame stop at this row group
*/
void InsertRowGroups(nsIFrame* aFirstRowGroupFrame,
nsIFrame* aLastRowGroupFrame);
void InsertColGroups(PRInt32 aColIndex,
nsIFrame* aFirstFrame,
nsIFrame* aLastFrame = nsnull);
void InsertColGroups(PRInt32 aStartColIndex,
const nsFrameList::Slice& aColgroups);
virtual void RemoveCol(nsTableColGroupFrame* aColGroupFrame,
PRInt32 aColIndex,
@ -745,13 +735,10 @@ public:
/** Reset the rowindices of all rows as they might have changed due to
* rowgroup reordering, exclude new row group frames that show in the
* reordering but are not yet inserted into the cellmap
* @param aFirstRowGroupFrame - first row group to be excluded
* @param aLastRowGroupFrame - last sibling of aFirstRowGroupFrame that
* should be excluded when reseting the row
* indices.
* @param aRowGroupsToExclude - an iterator that will produce the row groups
* to exclude.
*/
void ResetRowIndices(nsIFrame* aFirstRowGroupFrame = nsnull,
nsIFrame* aLastRowGroupFrame = nsnull);
void ResetRowIndices(const nsFrameList::Slice& aRowGroupsToExclude);
nsTArray<nsTableColFrame*>& GetColCache();

Просмотреть файл

@ -266,15 +266,15 @@ nsTableOuterFrame::SetInitialChildList(nsIAtom* aListName,
NS_IMETHODIMP
nsTableOuterFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;
// We only have two child frames: the inner table and a caption frame.
// The inner frame is provided when we're initialized, and it cannot change
if (nsGkAtoms::captionList == aListName) {
NS_ASSERTION(!aFrameList ||
aFrameList->GetType() == nsGkAtoms::tableCaptionFrame,
NS_ASSERTION(aFrameList.IsEmpty() ||
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
"appending non-caption frame to captionList");
mCaptionFrames.AppendFrames(this, aFrameList);
mCaptionFrame = mCaptionFrames.FirstChild();
@ -297,13 +297,13 @@ nsTableOuterFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsTableOuterFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (nsGkAtoms::captionList == aListName) {
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
NS_ASSERTION(!aFrameList ||
aFrameList->GetType() == nsGkAtoms::tableCaptionFrame,
NS_ASSERTION(aFrameList.IsEmpty() ||
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
"inserting non-caption frame into captionList");
mCaptionFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
mCaptionFrame = mCaptionFrames.FirstChild();

Просмотреть файл

@ -110,11 +110,11 @@ public:
virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -199,18 +199,19 @@ nsTableRowFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
NS_IMETHODIMP
nsTableRowFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
// Append the frames
mFrames.AppendFrames(nsnull, aFrameList);
// XXXbz why do we append here first, then append to table, while
// for InsertFrames we do it in the other order? Bug 507419 covers this.
const nsFrameList::Slice& newCells = mFrames.AppendFrames(nsnull, aFrameList);
// Add the new cell frames to the table
nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
for (nsIFrame* childFrame = aFrameList; childFrame;
childFrame = childFrame->GetNextSibling()) {
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
for (nsFrameList::Enumerator e(newCells) ; !e.AtEnd(); e.Next()) {
nsTableCellFrame *cellFrame = do_QueryFrame(e.get());
NS_ASSERTION(cellFrame, "Unexpected frame");
if (cellFrame) {
// Add the cell to the cell map
@ -229,7 +230,7 @@ nsTableRowFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsTableRowFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
@ -239,12 +240,13 @@ nsTableRowFrame::InsertFrames(nsIAtom* aListName,
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
// gather the new frames (only those which are cells) into an array
// XXXbz there shouldn't be any other ones here... can we just put
// them all in the array and not do all this QI nonsense?
nsIAtom* cellFrameType = (tableFrame->IsBorderCollapse()) ? nsGkAtoms::bcTableCellFrame : nsGkAtoms::tableCellFrame;
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
nsTArray<nsTableCellFrame*> cellChildren;
for (nsIFrame* childFrame = aFrameList; childFrame;
childFrame = childFrame->GetNextSibling()) {
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
nsTableCellFrame *cellFrame = do_QueryFrame(e.get());
NS_ASSERTION(cellFrame, "Unexpected frame");
if (cellFrame) {
cellChildren.AppendElement(cellFrame);

Просмотреть файл

@ -80,10 +80,10 @@ public:
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -1390,20 +1390,21 @@ nsTableRowGroupFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
NS_IMETHODIMP
nsTableRowGroupFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
ClearRowCursor();
// collect the new row frames in an array
// XXXbz why are we doing the QI stuff? There shouldn't be any non-rows here.
nsAutoTArray<nsTableRowFrame*, 8> rows;
for (nsIFrame* childFrame = aFrameList; childFrame;
childFrame = childFrame->GetNextSibling()) {
nsTableRowFrame *rowFrame = do_QueryFrame(childFrame);
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
nsTableRowFrame *rowFrame = do_QueryFrame(e.get());
NS_ASSERTION(rowFrame, "Unexpected frame; frame constructor screwed up");
if (rowFrame) {
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW ==
childFrame->GetStyleDisplay()->mDisplay,
e.get()->GetStyleDisplay()->mDisplay,
"wrong display type on rowframe");
rows.AppendElement(rowFrame);
}
@ -1430,7 +1431,7 @@ nsTableRowGroupFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsTableRowGroupFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aListName, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
@ -1443,14 +1444,15 @@ nsTableRowGroupFrame::InsertFrames(nsIAtom* aListName,
return NS_ERROR_NULL_POINTER;
// collect the new row frames in an array
// XXXbz why are we doing the QI stuff? There shouldn't be any non-rows here.
nsTArray<nsTableRowFrame*> rows;
PRBool gotFirstRow = PR_FALSE;
for (nsIFrame* childFrame = aFrameList; childFrame;
childFrame = childFrame->GetNextSibling()) {
nsTableRowFrame *rowFrame = do_QueryFrame(childFrame);
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
nsTableRowFrame *rowFrame = do_QueryFrame(e.get());
NS_ASSERTION(rowFrame, "Unexpected frame; frame constructor screwed up");
if (rowFrame) {
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW ==
childFrame->GetStyleDisplay()->mDisplay,
e.get()->GetStyleDisplay()->mDisplay,
"wrong display type on rowframe");
rows.AppendElement(rowFrame);
if (!gotFirstRow) {

Просмотреть файл

@ -111,11 +111,11 @@ public:
virtual void DidSetStyleContext(nsStyleContext* aOldStyleContext);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -260,14 +260,15 @@ nsGridLayout2::GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal)
void
nsGridLayout2::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox, nsIBox* aChildList)
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren)
{
mGrid.NeedsRebuild(aState);
}
void
nsGridLayout2::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aChildList)
const nsFrameList::Slice& aNewChildren)
{
mGrid.NeedsRebuild(aState);
}

Просмотреть файл

@ -80,9 +80,10 @@ public:
virtual nsMargin GetTotalMargin(nsIBox* aBox, PRBool aIsHorizontal);
virtual Type GetType() { return eGrid; }
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox, nsIBox* aChildList);
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren);
virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aChildList);
const nsFrameList::Slice& aNewChildren);
virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aChildList);
virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState,

Просмотреть файл

@ -54,13 +54,16 @@ nsGridRowLayout::nsGridRowLayout():nsSprocketLayout()
}
void
nsGridRowLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)
nsGridRowLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren)
{
ChildAddedOrRemoved(aBox, aState);
}
void
nsGridRowLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
nsGridRowLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren)
{
ChildAddedOrRemoved(aBox, aState);
}

Просмотреть файл

@ -70,8 +70,11 @@ public:
virtual nsGridLayout2* CastToGridLayout() { return nsnull; }
virtual nsGrid* GetGrid(nsIBox* aBox, PRInt32* aIndex, nsGridRowLayout* aRequestor=nsnull);
virtual void GetParentGridPart(nsIBox* aBox, nsIBox** aParentBox, nsIGridPart** aParentGridRow);
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList);
virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren);
virtual void ChildrenAppended(nsIBox* 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, PRBool aIsHorizontal);

Просмотреть файл

@ -1036,7 +1036,7 @@ nsBoxFrame::RemoveFrame(nsIAtom* aListName,
NS_IMETHODIMP
nsBoxFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
@ -1046,11 +1046,12 @@ nsBoxFrame::InsertFrames(nsIAtom* aListName,
nsBoxLayoutState state(PresContext());
// insert the child frames
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
const nsFrameList::Slice& newFrames =
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
// notify the layout manager
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, aFrameList);
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
#ifdef DEBUG_LAYOUT
// if we are in debug make sure our children are in debug as well.
@ -1067,17 +1068,17 @@ nsBoxFrame::InsertFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsBoxFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
NS_PRECONDITION(!aListName, "We don't support out-of-flow kids");
nsBoxLayoutState state(PresContext());
// append the new frames
mFrames.AppendFrames(this, aFrameList);
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(this, aFrameList);
// notify the layout manager
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, state, aFrameList);
mLayoutManager->ChildrenAppended(this, state, newFrames);
#ifdef DEBUG_LAYOUT
// if we are in debug make sure our children are in debug as well.

Просмотреть файл

@ -129,11 +129,11 @@ public:
nsReflowStatus& aStatus);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);

Просмотреть файл

@ -146,12 +146,15 @@ nsBoxLayout::AddSmallestSize(nsSize& aSize, const nsSize& aSize2)
}
void
nsBoxLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)
nsBoxLayout::ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren)
{
}
void
nsBoxLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)
nsBoxLayout::ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren)
{
}

Просмотреть файл

@ -55,8 +55,11 @@ public:
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, nsIBox* aChildList);
virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList);
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren);
virtual void ChildrenAppended(nsIBox* 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);

Просмотреть файл

@ -47,10 +47,10 @@ class nsBoxLayoutState;
class nsIRenderingContext;
struct nsRect;
// c9bf9fe7-a2f4-4f38-bbed-11a05633d676
// 6a529924-c73d-4fae-af7a-0e8084e701d5
#define NS_IBOX_LAYOUT_IID \
{ 0xc9bf9fe7, 0xa2f4, 0x4f38, \
{ 0xbb, 0xed, 0x11, 0xa0, 0x56, 0x33, 0xd6, 0x76 } }
{ 0x6a529924, 0xc73d, 0x4fae, \
{ 0xaf, 0x7a, 0x0e, 0x80, 0x84, 0xe7, 0x01, 0xd5 } }
class nsIBoxLayout : public nsISupports {
@ -65,8 +65,13 @@ public:
virtual nsSize GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)=0;
virtual nscoord GetAscent(nsIBox* aBox, nsBoxLayoutState& aBoxLayoutState)=0;
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aPrevBox, nsIBox* aChildList)=0;
virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
// FIXME: Bug 507416. The Children* notifications don't actually
// use all those arguments. Can we just simplify the signatures?
virtual void ChildrenInserted(nsIBox* aBox, nsBoxLayoutState& aState,
nsIBox* aPrevBox,
const nsFrameList::Slice& aNewChildren)=0;
virtual void ChildrenAppended(nsIBox* aBox, nsBoxLayoutState& aState,
const nsFrameList::Slice& aNewChildren)=0;
virtual void ChildrenRemoved(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
virtual void ChildrenSet(nsIBox* aBox, nsBoxLayoutState& aState, nsIBox* aChildList)=0;
virtual void IntrinsicWidthsDirty(nsIBox* aBox, nsBoxLayoutState& aState)=0;

Просмотреть файл

@ -1310,13 +1310,13 @@ nsListBoxBodyFrame::ContinueReflow(nscoord height)
}
NS_IMETHODIMP
nsListBoxBodyFrame::ListBoxAppendFrames(nsIFrame* aFrameList)
nsListBoxBodyFrame::ListBoxAppendFrames(nsFrameList& aFrameList)
{
// append them after
nsBoxLayoutState state(PresContext());
mFrames.AppendFrames(nsnull, aFrameList);
const nsFrameList::Slice& newFrames = mFrames.AppendFrames(nsnull, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenAppended(this, state, aFrameList);
mLayoutManager->ChildrenAppended(this, state, newFrames);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
@ -1325,13 +1325,15 @@ nsListBoxBodyFrame::ListBoxAppendFrames(nsIFrame* aFrameList)
}
NS_IMETHODIMP
nsListBoxBodyFrame::ListBoxInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList)
nsListBoxBodyFrame::ListBoxInsertFrames(nsIFrame* aPrevFrame,
nsFrameList& aFrameList)
{
// insert the frames to our info list
nsBoxLayoutState state(PresContext());
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
const nsFrameList::Slice& newFrames =
mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
if (mLayoutManager)
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, aFrameList);
mLayoutManager->ChildrenInserted(this, state, aPrevFrame, newFrames);
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);

Просмотреть файл

@ -136,8 +136,8 @@ public:
nsIBox* GetFirstItemBox(PRInt32 aOffset, PRBool* aCreated);
nsIBox* GetNextItemBox(nsIBox* aBox, PRInt32 aOffset, PRBool* aCreated);
PRBool ContinueReflow(nscoord height);
NS_IMETHOD ListBoxAppendFrames(nsIFrame* aFrameList);
NS_IMETHOD ListBoxInsertFrames(nsIFrame* aPrevFrame, nsIFrame* aFrameList);
NS_IMETHOD ListBoxAppendFrames(nsFrameList& aFrameList);
NS_IMETHOD ListBoxInsertFrames(nsIFrame* aPrevFrame, nsFrameList& aFrameList);
void OnContentInserted(nsPresContext* aPresContext, nsIContent* aContent);
void OnContentRemoved(nsPresContext* aPresContext, nsIFrame* aChildFrame, PRInt32 aIndex);

Просмотреть файл

@ -334,15 +334,6 @@ nsMenuFrame::GetChildList(nsIAtom* aListName) const
return nsBoxFrame::GetChildList(aListName);
}
nsIFrame*
nsMenuFrame::SetPopupFrame(nsIFrame* aChildList)
{
// Check for a menupopup and move it to mPopupFrame
nsFrameList frames(aChildList);
SetPopupFrame(frames);
return frames.FirstChild();
}
void
nsMenuFrame::SetPopupFrame(nsFrameList& aFrameList)
{
@ -1214,12 +1205,11 @@ nsMenuFrame::RemoveFrame(nsIAtom* aListName,
NS_IMETHODIMP
nsMenuFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (!mPopupFrame && (!aListName || aListName == nsGkAtoms::popupList)) {
aFrameList = SetPopupFrame(aFrameList);
SetPopupFrame(aFrameList);
if (mPopupFrame) {
#ifdef DEBUG_LAYOUT
nsBoxLayoutState state(PresContext());
SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG);
@ -1228,12 +1218,10 @@ nsMenuFrame::InsertFrames(nsIAtom* aListName,
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
}
if (!aFrameList)
if (aFrameList.IsEmpty())
return NS_OK;
if (NS_UNLIKELY(aPrevFrame == mPopupFrame)) {
@ -1245,13 +1233,10 @@ nsMenuFrame::InsertFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsMenuFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (!aFrameList)
return NS_OK;
if (!mPopupFrame && (!aListName || aListName == nsGkAtoms::popupList)) {
aFrameList = SetPopupFrame(aFrameList);
SetPopupFrame(aFrameList);
if (mPopupFrame) {
#ifdef DEBUG_LAYOUT
@ -1261,12 +1246,10 @@ nsMenuFrame::AppendFrames(nsIAtom* aListName,
PresContext()->PresShell()->
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);
return NS_OK;
}
}
if (!aFrameList)
if (aFrameList.IsEmpty())
return NS_OK;
return nsBoxFrame::AppendFrames(aListName, aFrameList);

Просмотреть файл

@ -147,11 +147,11 @@ public:
nsEventStatus* aEventStatus);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -229,11 +229,8 @@ protected:
friend class nsMenuTimerMediator;
friend class nsASyncMenuInitialization;
// initialize mPopupFrame to the first popup frame within aChildList. Returns
// aChildList with the popup frame removed.
nsIFrame* SetPopupFrame(nsIFrame* aChildList);
// As above, but using an nsFrameList; modifies the passed-in list.
// initialize mPopupFrame to the first popup frame within
// aChildList. Removes the popup, if any, from aChildList.
void SetPopupFrame(nsFrameList& aChildList);
// set mMenuParent to the nearest enclosing menu bar or menupopup frame of

Просмотреть файл

@ -92,11 +92,10 @@ nsPopupSetFrame::GetType() const
NS_IMETHODIMP
nsPopupSetFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (aListName == nsGkAtoms::popupList) {
nsFrameList temp(aFrameList);
return AddPopupFrameList(temp);
return AddPopupFrameList(aFrameList);
}
return nsBoxFrame::AppendFrames(aListName, aFrameList);
}
@ -114,11 +113,10 @@ nsPopupSetFrame::RemoveFrame(nsIAtom* aListName,
NS_IMETHODIMP
nsPopupSetFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
if (aListName == nsGkAtoms::popupList) {
nsFrameList temp(aFrameList);
return AddPopupFrameList(temp);
return AddPopupFrameList(aFrameList);
}
return nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
}

Просмотреть файл

@ -73,12 +73,12 @@ public:
nsIFrame* aParent,
nsIFrame* aPrevInFlow);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
nsFrameList& aChildList);

Просмотреть файл

@ -90,10 +90,10 @@ public:
virtual nsresult RemoveTooltipSupport(nsIContent* aNode);
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);
@ -154,7 +154,7 @@ nsRootBoxFrame::nsRootBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext):
NS_IMETHODIMP
nsRootBoxFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;
@ -178,7 +178,7 @@ nsRootBoxFrame::AppendFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsRootBoxFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
nsresult rv;

Просмотреть файл

@ -140,7 +140,7 @@ nsSliderFrame::RemoveFrame(nsIAtom* aListName,
NS_IMETHODIMP
nsSliderFrame::InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
PRBool wasEmpty = mFrames.IsEmpty();
nsresult rv = nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList);
@ -152,7 +152,7 @@ nsSliderFrame::InsertFrames(nsIAtom* aListName,
NS_IMETHODIMP
nsSliderFrame::AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList)
nsFrameList& aFrameList)
{
// if we have no children and on was added then make sure we add the
// listener

Просмотреть файл

@ -134,11 +134,11 @@ public:
// nsIFrame overrides
NS_IMETHOD AppendFrames(nsIAtom* aListName,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD InsertFrames(nsIAtom* aListName,
nsIFrame* aPrevFrame,
nsIFrame* aFrameList);
nsFrameList& aFrameList);
NS_IMETHOD RemoveFrame(nsIAtom* aListName,
nsIFrame* aOldFrame);