Bug 281387. Make nsIFrame::Append/InsertFrames use nsFrameList. r=bernd,roc, sr=dbaron
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user