Permalink
Browse files

Bug 507419-Consistent ordering of AppendFrames and InsertFrames

  • Loading branch information...
1 parent c9d0698 commit 2efef826099e26b751e2ac644dbd5689ff3d137f @drexler drexler committed Dec 27, 2011
Showing with 9 additions and 21 deletions.
  1. +9 −21 layout/tables/nsTableRowFrame.cpp
@@ -206,20 +206,14 @@ nsTableRowFrame::AppendFrames(ChildListID aListID,
{
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
- // Append the frames
- // 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 (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
- tableFrame->AppendCell(*cellFrame, GetRowIndex());
- }
+ nsIFrame *childFrame = e.get();
+ NS_ASSERTION(IS_TABLE_CELL(childFrame->GetType()),"Not a table cell frame/pseudo frame construction failure");
+ tableFrame->AppendCell(static_cast<nsTableCellFrame&>(*childFrame), GetRowIndex());
}
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
@@ -238,32 +232,26 @@ nsTableRowFrame::InsertFrames(ChildListID aListID,
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
"inserting after sibling frame with different parent");
+ //Insert Frames in the frame list
+ const nsFrameList::Slice& newCells = mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
// Get the table frame
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 (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
- nsTableCellFrame *cellFrame = do_QueryFrame(e.get());
- NS_ASSERTION(cellFrame, "Unexpected frame");
- if (cellFrame) {
- cellChildren.AppendElement(cellFrame);
- }
+ for (nsFrameList::Enumerator e(newCells); !e.AtEnd(); e.Next()) {
+ nsIFrame *childFrame = e.get();
+ NS_ASSERTION(IS_TABLE_CELL(childFrame->GetType()),"Not a table cell frame/pseudo frame construction failure");
+ cellChildren.AppendElement(static_cast<nsTableCellFrame*>(childFrame));
}
// insert the cells into the cell map
PRInt32 colIndex = -1;
if (prevCellFrame) {
prevCellFrame->GetColIndex(colIndex);
}
tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
-
- // Insert the frames in the frame list
- mFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
NS_FRAME_HAS_DIRTY_CHILDREN);

0 comments on commit 2efef82

Please sign in to comment.