Backed out changeset 248103817c8b (bug 330964)

This commit is contained in:
Carsten "Tomcat" Book 2014-06-16 13:08:53 +02:00
parent 819806e0c3
commit 0b4e324ca8
7 changed files with 79 additions and 188 deletions

View File

@ -435,9 +435,9 @@ BasicTableLayoutStrategy::ComputeIntrinsicWidths(nsRenderingContext* aRenderingC
nscoord min = 0, pref = 0, max_small_pct_pref = 0, nonpct_pref_total = 0;
float pct_total = 0.0f; // always from 0.0f - 1.0f
int32_t colCount = cellMap->GetColCount();
// add a total of (colcount + 1) lots of cellSpacingX for columns where a
// cell originates
nscoord add = mTableFrame->GetCellSpacingX(colCount);
nscoord spacing = mTableFrame->GetCellSpacingX();
nscoord add = spacing; // add (colcount + 1) * spacing for columns
// where a cell originates
for (int32_t col = 0; col < colCount; ++col) {
nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
@ -446,7 +446,7 @@ BasicTableLayoutStrategy::ComputeIntrinsicWidths(nsRenderingContext* aRenderingC
continue;
}
if (mTableFrame->ColumnHasCellSpacingBefore(col)) {
add += mTableFrame->GetCellSpacingX(col - 1);
add += spacing;
}
min += colFrame->GetMinCoord();
pref = NSCoordSaturatingAdd(pref, colFrame->GetPrefCoord());
@ -654,23 +654,22 @@ BasicTableLayoutStrategy::DistributeWidthToColumns(nscoord aWidth,
aColCount == mTableFrame->GetCellMap()->GetColCount()),
"Computing final column widths, but didn't get full column range");
nscoord subtract = 0;
// border-spacing isn't part of the basis for percentages.
nscoord spacing = mTableFrame->GetCellSpacingX();
nscoord subtract = 0;
// aWidth initially includes border-spacing for the boundaries in between
// each of the columns. We start at aFirstCol + 1 because the first
// in-between boundary would be at the left edge of column aFirstCol + 1
for (int32_t col = aFirstCol + 1; col < aFirstCol + aColCount; ++col) {
if (mTableFrame->ColumnHasCellSpacingBefore(col)) {
// border-spacing isn't part of the basis for percentages.
subtract += mTableFrame->GetCellSpacingX(col - 1);
subtract += spacing;
}
}
if (aWidthType == BTLS_FINAL_WIDTH) {
// If we're computing final col-width, then aWidth initially includes
// border spacing on the table's far left + far right edge, too. Need
// to subtract those out, too.
subtract += (mTableFrame->GetCellSpacingX(-1) +
mTableFrame->GetCellSpacingX(aColCount));
subtract += spacing * 2;
}
aWidth = NSCoordSaturatingSubtract(aWidth, subtract, nscoord_MAX);

View File

@ -51,11 +51,12 @@ FixedTableLayoutStrategy::GetMinWidth(nsRenderingContext* aRenderingContext)
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
int32_t colCount = cellMap->GetColCount();
nscoord spacing = mTableFrame->GetCellSpacingX();
nscoord result = 0;
if (colCount > 0) {
result += mTableFrame->GetCellSpacingX(-1, colCount);
result += spacing * (colCount + 1);
}
for (int32_t col = 0; col < colCount; ++col) {
@ -64,7 +65,6 @@ FixedTableLayoutStrategy::GetMinWidth(nsRenderingContext* aRenderingContext)
NS_ERROR("column frames out of sync with cell map");
continue;
}
nscoord spacing = mTableFrame->GetCellSpacingX(col);
const nsStyleCoord *styleWidth =
&colFrame->StylePosition()->mWidth;
if (styleWidth->ConvertsToLength()) {
@ -161,6 +161,7 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
int32_t colCount = cellMap->GetColCount();
nscoord spacing = mTableFrame->GetCellSpacingX();
if (colCount == 0) {
// No Columns - nothing to compute
@ -168,8 +169,8 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
}
// border-spacing isn't part of the basis for percentages.
tableWidth -= mTableFrame->GetCellSpacingX(-1, colCount);
tableWidth -= spacing * (colCount + 1);
// store the old column widths. We might call multiple times SetFinalWidth
// on the columns, due to this we can't compare at the last call that the
// width has changed with the respect to the last call to
@ -280,7 +281,6 @@ FixedTableLayoutStrategy::ComputeColumnWidths(const nsHTMLReflowState& aReflowSt
// row, split up the space evenly. (XXX This
// isn't quite right if some of the columns it's
// in have specified widths. Should we care?)
nscoord spacing = mTableFrame->GetCellSpacingX(col);
colWidth = ((colWidth + spacing) / colSpan) - spacing;
if (colWidth < 0)
colWidth = 0;

View File

@ -828,10 +828,9 @@ CalcUnpaginagedHeight(nsPresContext* aPresContext,
int32_t rowIndex;
firstCellInFlow->GetRowIndex(rowIndex);
int32_t rowSpan = aTableFrame.GetEffectiveRowSpan(*firstCellInFlow);
nscoord cellSpacing = firstTableInFlow->GetCellSpacingY();
nscoord computedHeight = firstTableInFlow->GetCellSpacingY(rowIndex,
rowIndex + rowSpan - 1);
computedHeight -= aVerticalBorderPadding;
nscoord computedHeight = ((rowSpan - 1) * cellSpacing) - aVerticalBorderPadding;
int32_t rowX;
for (row = firstRGInFlow->GetFirstRow(), rowX = 0; row; row = row->GetNextRow(), rowX++) {
if (rowX > rowIndex + rowSpan - 1) {

View File

@ -84,24 +84,22 @@ struct nsTableReflowState {
{
nsTableFrame* table = static_cast<nsTableFrame*>(aTableFrame.FirstInFlow());
nsMargin borderPadding = table->GetChildAreaOffset(&reflowState);
nscoord cellSpacingX = table->GetCellSpacingX();
x = borderPadding.left + table->GetCellSpacingX(-1);
x = borderPadding.left + cellSpacingX;
y = borderPadding.top; //cellspacing added during reflow
availSize.width = aAvailWidth;
if (NS_UNCONSTRAINEDSIZE != availSize.width) {
int32_t colCount = table->GetColCount();
availSize.width -= borderPadding.left + borderPadding.right
+ table->GetCellSpacingX(-1)
+ table->GetCellSpacingX(colCount);
+ (2 * cellSpacingX);
availSize.width = std::max(0, availSize.width);
}
availSize.height = aAvailHeight;
if (NS_UNCONSTRAINEDSIZE != availSize.height) {
availSize.height -= borderPadding.top + borderPadding.bottom
+ table->GetCellSpacingY(-1)
+ table->GetCellSpacingY(table->GetRowCount());
+ (2 * table->GetCellSpacingY());
availSize.height = std::max(0, availSize.height);
}
}
@ -1421,18 +1419,18 @@ void
nsTableFrame::SetColumnDimensions(nscoord aHeight,
const nsMargin& aBorderPadding)
{
nscoord cellSpacingX = GetCellSpacingX();
nscoord cellSpacingY = GetCellSpacingY();
nscoord colHeight = aHeight -= aBorderPadding.top + aBorderPadding.bottom +
GetCellSpacingY(-1) +
GetCellSpacingY(GetRowCount());
2* cellSpacingY;
nsTableIterator iter(mColGroups);
nsIFrame* colGroupFrame = iter.First();
bool tableIsLTR = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR;
int32_t colX =tableIsLTR ? 0 : std::max(0, GetColCount() - 1);
nscoord cellSpacingX = GetCellSpacingX(colX);
int32_t tableColIncr = tableIsLTR ? 1 : -1;
nsPoint colGroupOrigin(aBorderPadding.left + GetCellSpacingX(-1),
aBorderPadding.top + GetCellSpacingY(-1));
nsPoint colGroupOrigin(aBorderPadding.left + cellSpacingX,
aBorderPadding.top + cellSpacingY);
while (colGroupFrame) {
MOZ_ASSERT(colGroupFrame->GetType() == nsGkAtoms::tableColGroupFrame);
nscoord colGroupWidth = 0;
@ -1446,7 +1444,6 @@ nsTableFrame::SetColumnDimensions(nscoord aHeight,
nscoord colWidth = GetColumnWidth(colX);
nsRect colRect(colOrigin.x, colOrigin.y, colWidth, colHeight);
colFrame->SetRect(colRect);
cellSpacingX = GetCellSpacingX(colX);
colOrigin.x += colWidth + cellSpacingX;
colGroupWidth += colWidth + cellSpacingX;
colX += tableColIncr;
@ -1858,7 +1855,7 @@ nsTableFrame::Reflow(nsPresContext* aPresContext,
if (lastChildReflowed && NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
// if there is an incomplete child, then set the desired height to include it but not the next one
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
aDesiredSize.Height() = borderPadding.bottom + GetCellSpacingY(GetRowCount()) +
aDesiredSize.Height() = borderPadding.bottom + GetCellSpacingY() +
lastChildReflowed->GetRect().YMost();
}
haveDesiredHeight = true;
@ -2112,8 +2109,7 @@ nsTableFrame::AdjustForCollapsingRowsCols(nsHTMLReflowMetrics& aDesiredSize,
nsTableFrame* firstInFlow = static_cast<nsTableFrame*>(FirstInFlow());
nscoord width = firstInFlow->GetCollapsedWidth(aBorderPadding);
nscoord rgWidth = width - GetCellSpacingX(-1) -
GetCellSpacingX(GetColCount());
nscoord rgWidth = width - 2 * GetCellSpacingX();
nsOverflowAreas overflow;
// Walk the list of children
for (uint32_t childX = 0; childX < rowGroups.Length(); childX++) {
@ -2135,7 +2131,8 @@ nscoord
nsTableFrame::GetCollapsedWidth(nsMargin aBorderPadding)
{
NS_ASSERTION(!GetPrevInFlow(), "GetCollapsedWidth called on next in flow");
nscoord width = GetCellSpacingX(GetColCount());
nscoord cellSpacingX = GetCellSpacingX();
nscoord width = cellSpacingX;
width += aBorderPadding.left + aBorderPadding.right;
for (nsIFrame* groupFrame = mColGroups.FirstChild(); groupFrame;
groupFrame = groupFrame->GetNextSibling()) {
@ -2153,7 +2150,7 @@ nsTableFrame::GetCollapsedWidth(nsMargin aBorderPadding)
if (!collapseGroup && !collapseCol) {
width += colWidth;
if (ColumnHasCellSpacingBefore(colX))
width += GetCellSpacingX(colX-1);
width += cellSpacingX;
}
else {
SetNeedToCollapse(true);
@ -2841,7 +2838,7 @@ nsTableFrame::PlaceRepeatedFooter(nsTableReflowState& aReflowState,
-1, -1,
nsHTMLReflowState::CALLER_WILL_INIT);
InitChildReflowState(footerReflowState);
aReflowState.y += GetCellSpacingY(GetRowCount());
aReflowState.y += GetCellSpacingY();
nsRect origTfootRect = aTfoot->GetRect();
nsRect origTfootVisualOverflow = aTfoot->GetVisualOverflowRect();
@ -2867,6 +2864,7 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
aLastChildReflowed = nullptr;
nsIFrame* prevKidFrame = nullptr;
nscoord cellSpacingY = GetCellSpacingY();
nsPresContext* presContext = PresContext();
// XXXldb Should we be checking constrained height instead?
@ -2914,9 +2912,6 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState,
bool allowRepeatedFooter = false;
for (size_t childX = 0; childX < rowGroups.Length(); childX++) {
nsIFrame* kidFrame = rowGroups[childX];
nsTableRowGroupFrame* rowGroupFrame = rowGroups[childX];
nscoord cellSpacingY = GetCellSpacingY(rowGroupFrame->GetStartRowIndex()+
rowGroupFrame->GetRowCount());
// Get the frame state bits
// See if we should only reflow the dirty child frames
if (reflowAllKids ||
@ -3172,6 +3167,7 @@ nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState, nsHTMLRef
aDesiredSize.Height() = 0;
return;
}
nscoord cellSpacingY = GetCellSpacingY();
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
// get the natural height based on the last child's (row group) rect
@ -3194,11 +3190,9 @@ nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState, nsHTMLRef
int32_t colCount = cellMap->GetColCount();
nscoord desiredHeight = borderPadding.top + borderPadding.bottom;
if (rowCount > 0 && colCount > 0) {
desiredHeight += GetCellSpacingY(-1);
desiredHeight += cellSpacingY;
for (uint32_t rgX = 0; rgX < rowGroups.Length(); rgX++) {
desiredHeight += rowGroups[rgX]->GetSize().height +
GetCellSpacingY(rowGroups[rgX]->GetRowCount() +
rowGroups[rgX]->GetStartRowIndex());
desiredHeight += rowGroups[rgX]->GetSize().height + cellSpacingY;
}
}
@ -3258,6 +3252,8 @@ void
nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nscoord aAmount)
{
nscoord cellSpacingY = GetCellSpacingY();
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
RowGroupArray rowGroups;
@ -3267,8 +3263,8 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
// distribute space to each pct height row whose row group doesn't have a computed
// height, and base the pct on the table height. If the row group had a computed
// height, then this was already done in nsTableRowGroupFrame::CalculateRowHeights
nscoord pctBasis = aReflowState.ComputedHeight() - GetCellSpacingY(-1, GetRowCount());
nscoord yOriginRG = borderPadding.top + GetCellSpacingY(0);
nscoord pctBasis = aReflowState.ComputedHeight() - (GetCellSpacingY() * (GetRowCount() + 1));
nscoord yOriginRG = borderPadding.top + GetCellSpacingY();
nscoord yEndRG = yOriginRG;
uint32_t rgX;
for (rgX = 0; rgX < rowGroups.Length(); rgX++) {
@ -3280,7 +3276,6 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
nsRect rowRect = rowFrame->GetRect();
nscoord cellSpacingY = GetCellSpacingY(rowFrame->GetRowIndex());
if ((amountUsed < aAmount) && rowFrame->HasPctHeight()) {
nscoord pctHeight = rowFrame->GetHeight(pctBasis);
nscoord amountForRow = std::min(aAmount - amountUsed, pctHeight - rowRect.height);
@ -3406,7 +3401,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
}
// allocate the extra height to the unstyled row groups and rows
nscoord heightToDistribute = aAmount - amountUsed;
yOriginRG = borderPadding.top + GetCellSpacingY(-1);
yOriginRG = borderPadding.top + cellSpacingY;
yEndRG = yOriginRG;
for (rgX = 0; rgX < rowGroups.Length(); rgX++) {
nsTableRowGroupFrame* rgFrame = rowGroups[rgX];
@ -3418,7 +3413,6 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
if (!firstUnStyledRG || !rgFrame->HasStyleHeight() || !eligibleRows) {
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
nscoord cellSpacingY = GetCellSpacingY(rowFrame->GetRowIndex());
nsRect rowRect = rowFrame->GetRect();
nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect();
// see if there is an eligible row or we distribute to all rows
@ -3513,6 +3507,7 @@ int32_t nsTableFrame::GetColumnWidth(int32_t aColIndex)
return firstInFlow->GetColumnWidth(aColIndex);
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingX()
{
if (IsBorderCollapse())
@ -3521,31 +3516,7 @@ nscoord nsTableFrame::GetCellSpacingX()
return StyleTableBorder()->mBorderSpacingX;
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingX(int32_t aColIndex)
{
NS_ASSERTION(aColIndex >= -1 && aColIndex <= GetColCount(),
"Column index exceeds the bounds of the table");
// Index is irrelevant for ordinary tables. We check that it falls within
// appropriate bounds to increase confidence of correctness in situations
// where it does matter.
return GetCellSpacingX();
}
nscoord nsTableFrame::GetCellSpacingX(int32_t aStartColIndex,
int32_t aEndColIndex)
{
NS_ASSERTION(aStartColIndex >= -1 && aStartColIndex <= GetColCount(),
"Start column index exceeds the bounds of the table");
NS_ASSERTION(aEndColIndex >= -1 && aEndColIndex <= GetColCount(),
"End column index exceeds the bounds of the table");
NS_ASSERTION(aStartColIndex <= aEndColIndex,
"End index must not be less than start index");
// Only one possible value so just multiply it out. Tables where index
// matters will override this function
return GetCellSpacingX() * (aEndColIndex - aStartColIndex);
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY()
{
if (IsBorderCollapse())
@ -3554,30 +3525,6 @@ nscoord nsTableFrame::GetCellSpacingY()
return StyleTableBorder()->mBorderSpacingY;
}
// XXX: could cache this. But be sure to check style changes if you do!
nscoord nsTableFrame::GetCellSpacingY(int32_t aRowIndex)
{
NS_ASSERTION(aRowIndex >= -1 && aRowIndex <= GetRowCount(),
"Row index exceeds the bounds of the table");
// Index is irrelevant for ordinary tables. We check that it falls within
// appropriate bounds to increase confidence of correctness in situations
// where it does matter.
return GetCellSpacingY();
}
nscoord nsTableFrame::GetCellSpacingY(int32_t aStartRowIndex,
int32_t aEndRowIndex)
{
NS_ASSERTION(aStartRowIndex >= -1 && aStartRowIndex <= GetRowCount(),
"Start row index exceeds the bounds of the table");
NS_ASSERTION(aEndRowIndex >= -1 && aEndRowIndex <= GetRowCount(),
"End row index exceeds the bounds of the table");
NS_ASSERTION(aStartRowIndex <= aEndRowIndex,
"End index must not be less than start index");
// Only one possible value so just multiply it out. Tables where index
// matters will override this function
return GetCellSpacingY() * (aEndRowIndex - aStartRowIndex);
}
/* virtual */ nscoord
nsTableFrame::GetBaseline() const

View File

@ -373,68 +373,12 @@ public:
/** return the width of the column at aColIndex */
int32_t GetColumnWidth(int32_t aColIndex);
/** Helper to get the cell spacing X style value.
* The argument refers to the space between column aColIndex and column
* aColIndex + 1. An index of -1 indicates the padding between the table
* and the left border, an index equal to the number of columns indicates
* the padding between the table and the right border.
*
* Although in this class cell spacing does not depend on the index, it
* may be important for overriding classes.
*/
virtual nscoord GetCellSpacingX(int32_t aColIndex);
/** Helper to find the sum of the cell spacing between arbitrary columns.
* The argument refers to the space between column aColIndex and column
* aColIndex + 1. An index of -1 indicates the padding between the table
* and the left border, an index equal to the number of columns indicates
* the padding between the table and the right border.
*
* This method is equivalent to
* nscoord result = 0;
* for (i = aStartColIndex; i < aEndColIndex; i++) {
* result += GetCellSpacingX(i);
* }
* return result;
*/
virtual nscoord GetCellSpacingX(int32_t aStartColIndex,
int32_t aEndColIndex);
/** Helper to get the cell spacing Y style value.
* The argument refers to the space between row aRowIndex and row
* aRowIndex + 1. An index of -1 indicates the padding between the table
* and the top border, an index equal to the number of rows indicates
* the padding between the table and the bottom border.
*
* Although in this class cell spacing does not depend on the index, it
* may be important for overriding classes.
*/
virtual nscoord GetCellSpacingY(int32_t aRowIndex);
/** Helper to find the sum of the cell spacing between arbitrary rows.
* The argument refers to the space between row aRowIndex and row
* aRowIndex + 1. An index of -1 indicates the padding between the table
* and the top border, an index equal to the number of rows indicates
* the padding between the table and the bottom border.
*
* This method is equivalent to
* nscoord result = 0;
* for (i = aStartRowIndex; i < aEndRowIndex; i++) {
* result += GetCellSpacingY(i);
* }
* return result;
*/
virtual nscoord GetCellSpacingY(int32_t aStartRowIndex,
int32_t aEndRowIndex);
private:
/* For the base implementation of nsTableFrame, cell spacing does not depend
* on row/column indexing.
*/
/** helper to get the cell spacing X style value */
nscoord GetCellSpacingX();
nscoord GetCellSpacingY();
public:
/** helper to get the cell spacing Y style value */
nscoord GetCellSpacingY();
virtual nscoord GetBaseline() const MOZ_OVERRIDE;
/** return the row span of a cell, taking into account row span magic at the bottom
* of a table. The row span equals the number of rows spanned by aCell starting at

View File

@ -276,6 +276,7 @@ GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
nsTableFrame& aTableFrame)
{
nscoord height = 0;
nscoord cellSpacingY = aTableFrame.GetCellSpacingY();
int32_t rowSpan = aTableFrame.GetEffectiveRowSpan(aTableCellFrame);
// add in height of rows spanned beyond the 1st one
nsIFrame* nextRow = aTableCellFrame.GetParent()->GetNextSibling();
@ -284,7 +285,7 @@ GetHeightOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
height += nextRow->GetSize().height;
rowX++;
}
height += aTableFrame.GetCellSpacingY(rowX);
height += cellSpacingY;
nextRow = nextRow->GetNextSibling();
}
return height;
@ -681,7 +682,8 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
// column widths taking into account column spans and column spacing
static nscoord
CalcAvailWidth(nsTableFrame& aTableFrame,
nsTableCellFrame& aCellFrame)
nsTableCellFrame& aCellFrame,
nscoord aCellSpacingX)
{
nscoord cellAvailWidth = 0;
int32_t colIndex;
@ -693,7 +695,7 @@ CalcAvailWidth(nsTableFrame& aTableFrame,
cellAvailWidth += aTableFrame.GetColumnWidth(colIndex + spanX);
if (spanX > 0 &&
aTableFrame.ColumnHasCellSpacingBefore(colIndex + spanX)) {
cellAvailWidth += aTableFrame.GetCellSpacingX(colIndex + spanX - 1);
cellAvailWidth += aCellSpacingX;
}
}
return cellAvailWidth;
@ -704,6 +706,7 @@ GetSpaceBetween(int32_t aPrevColIndex,
int32_t aColIndex,
int32_t aColSpan,
nsTableFrame& aTableFrame,
nscoord aCellSpacingX,
bool aIsLeftToRight,
bool aCheckVisibility)
{
@ -728,7 +731,7 @@ GetSpaceBetween(int32_t aPrevColIndex,
space += aTableFrame.GetColumnWidth(colX);
}
if (!isCollapsed && aTableFrame.ColumnHasCellSpacingBefore(colX)) {
space += aTableFrame.GetCellSpacingX(colX - 1);
space += aCellSpacingX;
}
}
}
@ -752,7 +755,7 @@ GetSpaceBetween(int32_t aPrevColIndex,
space += aTableFrame.GetColumnWidth(colX);
}
if (!isCollapsed && aTableFrame.ColumnHasCellSpacingBefore(colX)) {
space += aTableFrame.GetCellSpacingX(colX - 1);
space += aCellSpacingX;
}
}
}
@ -790,6 +793,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
const bool isPaginated = aPresContext->IsPaginated();
const bool borderCollapse = aTableFrame.IsBorderCollapse();
nscoord cellSpacingX = aTableFrame.GetCellSpacingX();
int32_t cellColSpan = 1; // must be defined here so it's set properly for non-cell kids
nsTableIterator iter(*this);
@ -851,7 +855,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
if ((iter.IsLeftToRight() && (prevColIndex != (cellColIndex - 1))) ||
(!iter.IsLeftToRight() && (prevColIndex != cellColIndex + cellColSpan))) {
x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame,
iter.IsLeftToRight(), false);
cellSpacingX, iter.IsLeftToRight(), false);
}
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
@ -866,7 +870,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
if (doReflowChild) {
// Calculate the available width for the table cell using the known column widths
nscoord availCellWidth =
CalcAvailWidth(aTableFrame, *cellFrame);
CalcAvailWidth(aTableFrame, *cellFrame, cellSpacingX);
nsHTMLReflowMetrics desiredSize(aReflowState);
@ -975,7 +979,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
}
}
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, kidFrame);
x += aTableFrame.GetCellSpacingX(cellColIndex);
x += cellSpacingX;
}
// just set our width to what was available. The table will calculate the width and not use our value.
@ -1140,13 +1144,13 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
rowRect.width = aWidth;
nsOverflowAreas overflow;
nscoord shift = 0;
nscoord cellSpacingX = tableFrame->GetCellSpacingX();
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
if (aCollapseGroup || collapseRow) {
nsTableCellFrame* cellFrame = GetFirstCell();
aDidCollapse = true;
int32_t rowIndex;
cellFrame->GetRowIndex(rowIndex);
shift = rowRect.height + tableFrame->GetCellSpacingY(rowIndex);
shift = rowRect.height + cellSpacingY;
while (cellFrame) {
nsRect cRect = cellFrame->GetRect();
// If aRowOffset != 0, there's no point in invalidating the cells, since
@ -1173,6 +1177,8 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
int32_t colIncrement = iter.IsLeftToRight() ? 1 : -1;
//nscoord x = cellSpacingX;
nsIFrame* kidFrame = iter.First();
while (kidFrame) {
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
@ -1187,7 +1193,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
(!iter.IsLeftToRight() &&
(prevColIndex != cellColIndex + cellColSpan))) {
x += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan,
*tableFrame, iter.IsLeftToRight(),
*tableFrame, cellSpacingX, iter.IsLeftToRight(),
true);
}
nsRect cRect(x, 0, 0, rowRect.height);
@ -1222,14 +1228,14 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
nextColFrame->StyleVisibility();
if ( (NS_STYLE_VISIBILITY_COLLAPSE != nextColVis->mVisible) &&
tableFrame->ColumnHasCellSpacingBefore(colX + colIncrement)) {
cRect.width += tableFrame->GetCellSpacingX(cellColIndex);
cRect.width += cellSpacingX;
}
}
}
}
x += cRect.width;
if (isVisible)
x += tableFrame->GetCellSpacingX(cellColIndex);
x += cellSpacingX;
int32_t actualRowSpan = tableFrame->GetEffectiveRowSpan(*cellFrame);
nsTableRowFrame* rowFrame = GetNextRow();
for (actualRowSpan--; actualRowSpan > 0 && rowFrame; actualRowSpan--) {
@ -1238,8 +1244,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
nextRowVis->mVisible);
if (!collapseNextRow) {
nsRect nextRect = rowFrame->GetRect();
cRect.height += nextRect.height +
tableFrame->GetCellSpacingY(rowFrame->GetRowIndex());
cRect.height += nextRect.height + cellSpacingY;
}
rowFrame = rowFrame->GetNextRow();
}

View File

@ -341,6 +341,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
const bool borderCollapse = tableFrame->IsBorderCollapse();
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
// XXXldb Should we really be checking this rather than available height?
// (Think about multi-column layout!)
@ -361,7 +362,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
NS_NOTREACHED("yikes, a non-row child");
continue;
}
nscoord cellSpacingY = tableFrame->GetCellSpacingY(rowFrame->GetRowIndex());
haveRow = true;
// Reflow the row frame
@ -452,8 +453,7 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
}
if (haveRow)
aReflowState.y -= tableFrame->GetCellSpacingY(GetStartRowIndex() +
GetRowCount());
aReflowState.y -= cellSpacingY;
// Return our desired rect
aDesiredSize.Width() = aReflowState.reflowState.AvailableWidth();
@ -537,6 +537,9 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
const bool isPaginated = aPresContext->IsPaginated();
// all table cells have the same top and bottom margins, namely cellSpacingY
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
int32_t numEffCols = tableFrame->GetEffectiveColCount();
int32_t startRowIndex = GetStartRowIndex();
@ -616,7 +619,6 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
// iteratate the row's cell frames
while (cellFrame) {
nscoord cellSpacingY = tableFrame->GetCellSpacingY(startRowIndex + rowIndex);
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
if ((rowIndex + rowSpan) > numRows) {
// there might be rows pushed already to the nextInFlow
@ -734,8 +736,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
}
bool styleHeightAllocation = false;
nscoord rowGroupHeight = startRowGroupHeight + heightOfRows +
tableFrame->GetCellSpacingY(0, numRows-1);
nscoord rowGroupHeight = startRowGroupHeight + heightOfRows + ((numRows - 1) * cellSpacingY);
// if we have a style height, allocate the extra height to unconstrained rows
if ((aReflowState.ComputedHeight() > rowGroupHeight) &&
(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight())) {
@ -794,7 +795,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
nsTableFrame::RePositionViews(rowFrame);
// XXXbz we don't need to update our overflow area?
}
yOrigin += rowHeight + tableFrame->GetCellSpacingY(startRowIndex + rowIndex);
yOrigin += rowHeight + cellSpacingY;
}
if (isPaginated && styleHeightAllocation) {
@ -838,8 +839,7 @@ nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aYTotalOffset,
groupRect.height -= yGroupOffset;
if (didCollapse) {
// add back the cellspacing between rowgroups
groupRect.height += tableFrame->GetCellSpacingY(GetStartRowIndex() +
GetRowCount());
groupRect.height += tableFrame->GetCellSpacingY();
}
groupRect.y -= aYTotalOffset;
@ -1050,6 +1050,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
nscoord availHeight = aReflowState.AvailableHeight();
const bool borderCollapse = aTableFrame->IsBorderCollapse();
nscoord cellSpacingY = aTableFrame->GetCellSpacingY();
// get the page height
nscoord pageHeight = aPresContext->GetPageSize().height;
@ -1067,7 +1068,6 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
// in the available space
for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) {
bool rowIsOnPage = true;
nscoord cellSpacingY = aTableFrame->GetCellSpacingY(rowFrame->GetRowIndex());
nsRect rowRect = rowFrame->GetRect();
// See if the row fits on this page
if (rowRect.YMost() > availHeight) {
@ -1512,11 +1512,8 @@ nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
{
nscoord result = 0;
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
int32_t startRowIndex = GetStartRowIndex();
if ((aReflowState.ComputedHeight() > 0) && (aReflowState.ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
nscoord cellSpacing = tableFrame->GetCellSpacingY(startRowIndex,
std::max(startRowIndex,
startRowIndex + GetRowCount() - 1));
nscoord cellSpacing = std::max(0, GetRowCount() - 1) * tableFrame->GetCellSpacingY();
result = aReflowState.ComputedHeight() - cellSpacing;
}
else {
@ -1526,7 +1523,7 @@ nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
}
if (parentRS && (tableFrame == parentRS->frame) &&
(parentRS->ComputedHeight() > 0) && (parentRS->ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
nscoord cellSpacing = tableFrame->GetCellSpacingY(-1, tableFrame->GetRowCount());
nscoord cellSpacing = std::max(0, tableFrame->GetRowCount() + 1) * tableFrame->GetCellSpacingY();
result = parentRS->ComputedHeight() - cellSpacing;
}
}