зеркало из https://github.com/mozilla/gecko-dev.git
Clean up CalcAvailWidth. (Bug 444928) r=bernd
This commit is contained in:
Родитель
5b080ed588
Коммит
960d7facd3
|
@ -678,35 +678,25 @@ nsTableRowFrame::CalculateCellActualSize(nsIFrame* aCellFrame,
|
||||||
|
|
||||||
// Calculates the available width for the table cell based on the known
|
// Calculates the available width for the table cell based on the known
|
||||||
// column widths taking into account column spans and column spacing
|
// column widths taking into account column spans and column spacing
|
||||||
static void
|
static nscoord
|
||||||
CalcAvailWidth(nsTableFrame& aTableFrame,
|
CalcAvailWidth(nsTableFrame& aTableFrame,
|
||||||
nsTableCellFrame& aCellFrame,
|
nsTableCellFrame& aCellFrame,
|
||||||
nscoord aCellSpacingX,
|
nscoord aCellSpacingX)
|
||||||
nscoord& aColAvailWidth,
|
|
||||||
nscoord& aCellAvailWidth)
|
|
||||||
{
|
{
|
||||||
aColAvailWidth = aCellAvailWidth = NS_UNCONSTRAINEDSIZE;
|
nscoord cellAvailWidth = 0;
|
||||||
PRInt32 colIndex;
|
PRInt32 colIndex;
|
||||||
aCellFrame.GetColIndex(colIndex);
|
aCellFrame.GetColIndex(colIndex);
|
||||||
PRInt32 colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
|
PRInt32 colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
|
||||||
nscoord cellSpacing = 0;
|
NS_ASSERTION(colspan > 0, "effective colspan should be positive");
|
||||||
|
|
||||||
for (PRInt32 spanX = 0; spanX < colspan; spanX++) {
|
for (PRInt32 spanX = 0; spanX < colspan; spanX++) {
|
||||||
nscoord colWidth = aTableFrame.GetColumnWidth(colIndex + spanX);
|
cellAvailWidth += aTableFrame.GetColumnWidth(colIndex + spanX);
|
||||||
if (NS_UNCONSTRAINEDSIZE == aColAvailWidth) {
|
if (spanX > 0 &&
|
||||||
aColAvailWidth = colWidth;
|
aTableFrame.ColumnHasCellSpacingBefore(colIndex + spanX)) {
|
||||||
}
|
cellAvailWidth += aCellSpacingX;
|
||||||
else {
|
|
||||||
aColAvailWidth += colWidth;
|
|
||||||
}
|
|
||||||
if ((spanX > 0) && aTableFrame.ColumnHasCellSpacingBefore(colIndex + spanX)) {
|
|
||||||
cellSpacing += aCellSpacingX;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NS_UNCONSTRAINEDSIZE != aColAvailWidth) {
|
return cellAvailWidth;
|
||||||
aColAvailWidth += cellSpacing;
|
|
||||||
}
|
|
||||||
aCellAvailWidth = aColAvailWidth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nscoord
|
nscoord
|
||||||
|
@ -881,9 +871,8 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
||||||
|
|
||||||
if (doReflowChild) {
|
if (doReflowChild) {
|
||||||
// Calculate the available width for the table cell using the known column widths
|
// Calculate the available width for the table cell using the known column widths
|
||||||
nscoord availColWidth, availCellWidth;
|
nscoord availCellWidth =
|
||||||
CalcAvailWidth(aTableFrame, *cellFrame, cellSpacingX,
|
CalcAvailWidth(aTableFrame, *cellFrame, cellSpacingX);
|
||||||
availColWidth, availCellWidth);
|
|
||||||
|
|
||||||
nsHTMLReflowMetrics desiredSize;
|
nsHTMLReflowMetrics desiredSize;
|
||||||
|
|
||||||
|
@ -903,7 +892,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
||||||
HasPctHeight()) {
|
HasPctHeight()) {
|
||||||
// Reflow the cell to fit the available width, height
|
// Reflow the cell to fit the available width, height
|
||||||
// XXX The old IR_ChildIsDirty code used availCellWidth here.
|
// XXX The old IR_ChildIsDirty code used availCellWidth here.
|
||||||
nsSize kidAvailSize(availColWidth, aReflowState.availableHeight);
|
nsSize kidAvailSize(availCellWidth, aReflowState.availableHeight);
|
||||||
|
|
||||||
// Reflow the child
|
// Reflow the child
|
||||||
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
nsTableCellReflowState kidReflowState(aPresContext, aReflowState,
|
||||||
|
@ -970,9 +959,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place the child
|
// Place the child
|
||||||
if (NS_UNCONSTRAINEDSIZE != availColWidth) {
|
desiredSize.width = availCellWidth;
|
||||||
desiredSize.width = PR_MAX(availCellWidth, availColWidth);
|
|
||||||
}
|
|
||||||
|
|
||||||
FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
|
FinishReflowChild(kidFrame, aPresContext, nsnull, desiredSize, x, 0, 0);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче