mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-27 07:34:20 +00:00
Optimized CalculateRowHeights() to skip step 2 if there are no cells that
have row spans
This commit is contained in:
parent
d56538941d
commit
6bfc3a2edf
@ -574,7 +574,9 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// all table cells have the same top and bottom margins, namely cellSpacingY
|
||||
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
||||
|
||||
// iterate children and for each row get the height of the tallest cell
|
||||
// iterate children and for each row get the height of the tallest cell. Keep
|
||||
// track of whether any of the rows have a cell that spans into the row
|
||||
PRBool hasRowSpanningCell = PR_FALSE;
|
||||
PRInt32 numRows;
|
||||
GetRowCount(numRows, PR_FALSE);
|
||||
nscoord *rowHeights = new nscoord[numRows];
|
||||
@ -610,6 +612,13 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// only the top row has a top margin. Other rows start at the bottom of the prev row's bottom margin.
|
||||
// save the row height for pass 2 below
|
||||
rowHeights[rowIndex] = maxRowHeight;
|
||||
|
||||
// See if a cell spans into the row. If so we'll have to do step 2
|
||||
if (!hasRowSpanningCell) {
|
||||
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
|
||||
hasRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
// Get the next row
|
||||
@ -617,7 +626,8 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
}
|
||||
|
||||
|
||||
/* Step 2: Now account for cells that span rows.
|
||||
/* Step 2: Now account for cells that span rows. We only do this if there are cells
|
||||
* that span rows.
|
||||
* A spanning cell's height is the sum of the heights of the rows it spans,
|
||||
* or it's own desired height, whichever is greater.
|
||||
* If the cell's desired height is the larger value, resize the rows and contained
|
||||
@ -629,16 +639,10 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
* Since we are guaranteed to have found the max height spanners the first time through,
|
||||
* we know we only need two passes, not an arbitrary number.
|
||||
*/
|
||||
/* TODO
|
||||
* 1. optimization, if (PR_TRUE==atLeastOneRowSpanningCell) ... otherwise skip this step entirely
|
||||
* we can get this info trivially from the cell map
|
||||
*/
|
||||
|
||||
PRInt32 rowGroupHeight;
|
||||
if (hasRowSpanningCell) {
|
||||
nscoord deltaY = 0;
|
||||
for (PRInt32 counter=0; counter<2; counter++)
|
||||
{
|
||||
rowGroupHeight = 0;
|
||||
rowFrame = GetFirstFrame();
|
||||
rowIndex = 0;
|
||||
while (nsnull != rowFrame)
|
||||
@ -740,23 +744,17 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
rowFrame->SetRect(rowBounds);
|
||||
}
|
||||
|
||||
// Update the running row group height
|
||||
rowGroupHeight += rowHeights[rowIndex];
|
||||
rowIndex++;
|
||||
}
|
||||
else {
|
||||
// Anything that isn't a row contributes to the row group's total height.
|
||||
nsSize frameSize;
|
||||
rowFrame->GetSize(frameSize);
|
||||
rowGroupHeight += frameSize.height;
|
||||
}
|
||||
|
||||
// Get the next rowgroup child (row frame)
|
||||
GetNextFrame(rowFrame, &rowFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// step 3: notify the rows of their new heights
|
||||
nscoord rowGroupHeight = 0;
|
||||
rowFrame = GetFirstFrame();
|
||||
rowIndex = 0;
|
||||
while (nsnull != rowFrame)
|
||||
@ -767,6 +765,13 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// Notify the row of the new size
|
||||
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
||||
}
|
||||
|
||||
// Update the running row group height. The height includes frames that
|
||||
// aren't rows as well
|
||||
nsSize rowSize;
|
||||
rowFrame->GetSize(rowSize);
|
||||
rowGroupHeight += rowSize.height;
|
||||
|
||||
// Get the next row
|
||||
GetNextFrame(rowFrame, &rowFrame);
|
||||
rowIndex++;
|
||||
|
@ -574,7 +574,9 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// all table cells have the same top and bottom margins, namely cellSpacingY
|
||||
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
|
||||
|
||||
// iterate children and for each row get the height of the tallest cell
|
||||
// iterate children and for each row get the height of the tallest cell. Keep
|
||||
// track of whether any of the rows have a cell that spans into the row
|
||||
PRBool hasRowSpanningCell = PR_FALSE;
|
||||
PRInt32 numRows;
|
||||
GetRowCount(numRows, PR_FALSE);
|
||||
nscoord *rowHeights = new nscoord[numRows];
|
||||
@ -610,6 +612,13 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// only the top row has a top margin. Other rows start at the bottom of the prev row's bottom margin.
|
||||
// save the row height for pass 2 below
|
||||
rowHeights[rowIndex] = maxRowHeight;
|
||||
|
||||
// See if a cell spans into the row. If so we'll have to do step 2
|
||||
if (!hasRowSpanningCell) {
|
||||
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex)) {
|
||||
hasRowSpanningCell = PR_TRUE;
|
||||
}
|
||||
}
|
||||
rowIndex++;
|
||||
}
|
||||
// Get the next row
|
||||
@ -617,7 +626,8 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
}
|
||||
|
||||
|
||||
/* Step 2: Now account for cells that span rows.
|
||||
/* Step 2: Now account for cells that span rows. We only do this if there are cells
|
||||
* that span rows.
|
||||
* A spanning cell's height is the sum of the heights of the rows it spans,
|
||||
* or it's own desired height, whichever is greater.
|
||||
* If the cell's desired height is the larger value, resize the rows and contained
|
||||
@ -629,16 +639,10 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
* Since we are guaranteed to have found the max height spanners the first time through,
|
||||
* we know we only need two passes, not an arbitrary number.
|
||||
*/
|
||||
/* TODO
|
||||
* 1. optimization, if (PR_TRUE==atLeastOneRowSpanningCell) ... otherwise skip this step entirely
|
||||
* we can get this info trivially from the cell map
|
||||
*/
|
||||
|
||||
PRInt32 rowGroupHeight;
|
||||
if (hasRowSpanningCell) {
|
||||
nscoord deltaY = 0;
|
||||
for (PRInt32 counter=0; counter<2; counter++)
|
||||
{
|
||||
rowGroupHeight = 0;
|
||||
rowFrame = GetFirstFrame();
|
||||
rowIndex = 0;
|
||||
while (nsnull != rowFrame)
|
||||
@ -740,23 +744,17 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
rowFrame->SetRect(rowBounds);
|
||||
}
|
||||
|
||||
// Update the running row group height
|
||||
rowGroupHeight += rowHeights[rowIndex];
|
||||
rowIndex++;
|
||||
}
|
||||
else {
|
||||
// Anything that isn't a row contributes to the row group's total height.
|
||||
nsSize frameSize;
|
||||
rowFrame->GetSize(frameSize);
|
||||
rowGroupHeight += frameSize.height;
|
||||
}
|
||||
|
||||
// Get the next rowgroup child (row frame)
|
||||
GetNextFrame(rowFrame, &rowFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// step 3: notify the rows of their new heights
|
||||
nscoord rowGroupHeight = 0;
|
||||
rowFrame = GetFirstFrame();
|
||||
rowIndex = 0;
|
||||
while (nsnull != rowFrame)
|
||||
@ -767,6 +765,13 @@ void nsTableRowGroupFrame::CalculateRowHeights(nsIPresContext& aPresContext,
|
||||
// Notify the row of the new size
|
||||
((nsTableRowFrame *)rowFrame)->DidResize(aPresContext, aReflowState);
|
||||
}
|
||||
|
||||
// Update the running row group height. The height includes frames that
|
||||
// aren't rows as well
|
||||
nsSize rowSize;
|
||||
rowFrame->GetSize(rowSize);
|
||||
rowGroupHeight += rowSize.height;
|
||||
|
||||
// Get the next row
|
||||
GetNextFrame(rowFrame, &rowFrame);
|
||||
rowIndex++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user