From 2005083629c4b952abf3bf22e151bb9a76772956 Mon Sep 17 00:00:00 2001 From: "karnaze%netscape.com" Date: Wed, 10 May 2000 00:54:00 +0000 Subject: [PATCH] bug 29459 - strategy's table min and max width is calculated to include percent and proportional cells. Stopped caching it. Calculate max element size better. --- .../table/src/BasicTableLayoutStrategy.cpp | 58 +++++++++++-------- .../html/table/src/BasicTableLayoutStrategy.h | 13 +---- .../table/src/FixedTableLayoutStrategy.cpp | 3 - .../html/table/src/nsITableLayoutStrategy.h | 4 +- layout/html/table/src/nsTableFrame.cpp | 18 +++--- layout/html/table/src/nsTableFrame.h | 6 +- .../html/table/src/nsTableRowGroupFrame.cpp | 6 +- layout/tables/BasicTableLayoutStrategy.cpp | 58 +++++++++++-------- layout/tables/BasicTableLayoutStrategy.h | 13 +---- layout/tables/FixedTableLayoutStrategy.cpp | 3 - layout/tables/nsITableLayoutStrategy.h | 4 +- layout/tables/nsTableFrame.cpp | 18 +++--- layout/tables/nsTableFrame.h | 6 +- layout/tables/nsTableRowGroupFrame.cpp | 6 +- 14 files changed, 108 insertions(+), 108 deletions(-) diff --git a/layout/html/table/src/BasicTableLayoutStrategy.cpp b/layout/html/table/src/BasicTableLayoutStrategy.cpp index ef13243f4007..09e05353da4b 100644 --- a/layout/html/table/src/BasicTableLayoutStrategy.cpp +++ b/layout/html/table/src/BasicTableLayoutStrategy.cpp @@ -69,8 +69,6 @@ BasicTableLayoutStrategy::BasicTableLayoutStrategy(nsTableFrame *aFrame, PRBool NS_ASSERTION(nsnull != aFrame, "bad frame arg"); mTableFrame = aFrame; - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; mCellSpacingTotal = 0; mIsNavQuirksMode = aIsNavQuirks; } @@ -90,8 +88,6 @@ PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContex PRBool result = PR_TRUE; // re-init instance variables - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; mCellSpacingTotal = 0; mCols = mTableFrame->GetEffectiveCOLSAttribute(); // assign the width of all fixed-width columns @@ -117,14 +113,15 @@ BasicTableLayoutStrategy::SetMaxElementSize(nsSize* aMaxElementSize, mTableFrame->GetTableBorder(borderPadding); borderPadding += aPadding; nscoord horBorderPadding = borderPadding.left + borderPadding.right; + nscoord minTableWidth = GetTableMinWidth(); if (tablePosition->mWidth.GetUnit() == eStyleUnit_Coord) { aMaxElementSize->width = tablePosition->mWidth.GetCoordValue(); - if (mMinTableContentWidth + horBorderPadding > aMaxElementSize->width) { - aMaxElementSize->width = mMinTableContentWidth + horBorderPadding; + if (minTableWidth + horBorderPadding > aMaxElementSize->width) { + aMaxElementSize->width = minTableWidth + horBorderPadding; } } else { - aMaxElementSize->width = mMinTableContentWidth + horBorderPadding; + aMaxElementSize->width = minTableWidth + horBorderPadding; } } } @@ -216,13 +213,14 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont } // if the max width available is less than the min content width for fixed table, we're done - if (!tableIsAutoWidth && (maxWidth < mMinTableContentWidth)) { + nscoord minTableWidth = GetTableMinWidth(); + if (!tableIsAutoWidth && (maxWidth < minTableWidth)) { return BCW_Wrapup(aPresContext, this, mTableFrame, nsnull); } // if the max width available is less than the min content width for auto table // that had no % cells/cols, we're done - if (tableIsAutoWidth && (maxWidth < mMinTableContentWidth) && (0 == perAdjTableWidth)) { + if (tableIsAutoWidth && (maxWidth < minTableWidth) && (0 == perAdjTableWidth)) { return BCW_Wrapup(aPresContext, this, mTableFrame, nsnull); } @@ -885,7 +883,6 @@ BasicTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* nscoord minWidth = colFrame->GetMinWidth(); mTableFrame->SetColumnWidth(colX, minWidth); } - SetMinAndMaxTableContentWidths(); if (gsDebugAssign) {printf("AssignPrelimColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} return rv; @@ -1181,27 +1178,42 @@ BasicTableLayoutStrategy::AssignPercentageColumnWidths(nscoord aBasisIn, return basis; } -void BasicTableLayoutStrategy::SetMinAndMaxTableContentWidths() +nscoord BasicTableLayoutStrategy::GetTableMinWidth() const { - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; - + nscoord minWidth = 0; nscoord spacingX = mTableFrame->GetCellSpacingX(); PRInt32 numCols = mTableFrame->GetColCount(); for (PRInt32 colX = 0; colX < numCols; colX++) { nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX); - mMinTableContentWidth += colFrame->GetMinWidth(); - mMaxTableContentWidth += PR_MAX(colFrame->GetDesWidth(), colFrame->GetFixWidth()); + minWidth += PR_MAX(colFrame->GetMinWidth(), colFrame->GetWidth(MIN_ADJ)); + } + // if it is not a degenerate table, add the last spacing on the right + if (minWidth > 0) { + minWidth += spacingX; + } + return minWidth; +} + +nscoord BasicTableLayoutStrategy::GetTableMaxWidth() const +{ + nscoord spacingX = mTableFrame->GetCellSpacingX(); + PRInt32 numCols = mTableFrame->GetColCount(); + nscoord maxWidth = 0; + for (PRInt32 colX = 0; colX < numCols; colX++) { + nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX); + nscoord max = PR_MAX(colFrame->GetDesWidth(), colFrame->GetFixWidth()); + max = PR_MAX(max, colFrame->GetPctWidth()); + max = PR_MAX(max, colFrame->GetWidth(MIN_PRO)); + maxWidth += max; if (mTableFrame->GetNumCellsOriginatingInCol(colX) > 0) { - mMaxTableContentWidth += spacingX; - mMinTableContentWidth += spacingX; + maxWidth += spacingX; } } // if it is not a degenerate table, add the last spacing on the right - if (mMinTableContentWidth > 0) { - mMinTableContentWidth += spacingX; - mMaxTableContentWidth += spacingX; + if (maxWidth > 0) { + maxWidth += spacingX; } + return maxWidth; } // calculate totals by width type. @@ -1783,8 +1795,8 @@ void BasicTableLayoutStrategy::Dump(PRInt32 aIndent) printf("%s**START BASIC STRATEGY DUMP** table=%p cols=%X", indent, mTableFrame, mCols); - printf("\n%s minConWidth=%d maxConWidth=%d cellSpacing=%d propRatio=%.2f navQuirks=%d", - indent, mMinTableContentWidth, mMaxTableContentWidth, mCellSpacingTotal, mMinToDesProportionRatio, mIsNavQuirksMode); + printf("\n%s cellSpacing=%d propRatio=%.2f navQuirks=%d", + indent, mCellSpacingTotal, mMinToDesProportionRatio, mIsNavQuirksMode); printf(" **END BASIC STRATEGY DUMP** \n"); delete [] indent; } diff --git a/layout/html/table/src/BasicTableLayoutStrategy.h b/layout/html/table/src/BasicTableLayoutStrategy.h index c8afc5174e4f..dfe006d8d5d8 100644 --- a/layout/html/table/src/BasicTableLayoutStrategy.h +++ b/layout/html/table/src/BasicTableLayoutStrategy.h @@ -82,8 +82,8 @@ public: nscoord aMaxWidth); // these accessors are mostly for debugging purposes - nscoord GetTableMinContentWidth() const; - nscoord GetTableMaxContentWidth() const; + nscoord GetTableMinWidth() const; + nscoord GetTableMaxWidth() const; nscoord GetCOLSAttribute() const; void Dump(PRInt32 aIndent); @@ -210,20 +210,11 @@ protected: nsTableFrame * mTableFrame; PRInt32 mCols; // cached data - nscoord mMinTableContentWidth; // the smallest size for the table (excluding border and padding) - nscoord mMaxTableContentWidth; // the "natural" size for the table, if unconstrained (excluding border and padding) nscoord mCellSpacingTotal; // all of the cellspacing for all of the cols float mMinToDesProportionRatio; PRPackedBool mIsNavQuirksMode; }; -// these accessors are mostly for debugging purposes -inline nscoord BasicTableLayoutStrategy::GetTableMinContentWidth() const -{ return mMinTableContentWidth; }; - -inline nscoord BasicTableLayoutStrategy::GetTableMaxContentWidth() const -{ return mMaxTableContentWidth; }; - inline nscoord BasicTableLayoutStrategy::GetCOLSAttribute() const { return mCols; }; diff --git a/layout/html/table/src/FixedTableLayoutStrategy.cpp b/layout/html/table/src/FixedTableLayoutStrategy.cpp index 3ed6ebd863d2..1fdce56dfa9c 100644 --- a/layout/html/table/src/FixedTableLayoutStrategy.cpp +++ b/layout/html/table/src/FixedTableLayoutStrategy.cpp @@ -197,9 +197,6 @@ FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* mTableFrame->SetColumnWidth(colX, colWidths[colX]); } - // min/max TW is min/max of (specified table width, sum of specified column(cell) widths) - mMinTableContentWidth = mMaxTableContentWidth = totalColWidth; - // clean up if (nsnull != colWidths) { delete [] colWidths; diff --git a/layout/html/table/src/nsITableLayoutStrategy.h b/layout/html/table/src/nsITableLayoutStrategy.h index 05f999b95967..0b56eafbc881 100644 --- a/layout/html/table/src/nsITableLayoutStrategy.h +++ b/layout/html/table/src/nsITableLayoutStrategy.h @@ -72,7 +72,7 @@ public: * the actual table width in a given situation will depend on the available size * provided by the parent (especially for percent-width tables.) */ - virtual nscoord GetTableMaxContentWidth() const = 0; + virtual nscoord GetTableMaxWidth() const = 0; /** return the computed minimum possible size of the table. * this is the sum of the minimum sizes of the content taking into account table @@ -80,7 +80,7 @@ public: * the actual table width in a given situation will depend on the available size * provided by the parent (especially for percent-width tables.) */ - virtual nscoord GetTableMinContentWidth() const = 0; + virtual nscoord GetTableMinWidth() const = 0; /** return the value of the COLS attribute, used for balancing column widths */ virtual nscoord GetCOLSAttribute() const = 0; diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index ad2d1fc1a214..c14220e3597b 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -1666,7 +1666,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, if (isAutoOrPctWidth) { // Ask the strategy for the natural width of the content area - aDesiredSize.mMaximumWidth = mTableLayoutStrategy->GetTableMaxContentWidth(); + aDesiredSize.mMaximumWidth = mTableLayoutStrategy->GetTableMaxWidth(); // Add in space for border nsMargin border; @@ -2796,18 +2796,14 @@ NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext, nscoord nsTableFrame::ComputeDesiredWidth(const nsHTMLReflowState& aReflowState) const { nscoord desiredWidth = aReflowState.availableWidth; - // this is the biggest hack in the world. But there's no other rational way to handle nested percent tables - const nsStylePosition* position; - PRBool isNested = IsNested(aReflowState, position); - if ((eReflowReason_Initial==aReflowState.reason) && - (isNested) && (eStyleUnit_Percent == position->mWidth.GetUnit())) { + if (NS_UNCONSTRAINEDSIZE == desiredWidth) { nsITableLayoutStrategy* tableLayoutStrategy = mTableLayoutStrategy; if (mPrevInFlow) { // Get the table layout strategy from the first-in-flow nsTableFrame* table = (nsTableFrame*)GetFirstInFlow(); tableLayoutStrategy = table->mTableLayoutStrategy; } - desiredWidth = tableLayoutStrategy->GetTableMaxContentWidth(); + desiredWidth = tableLayoutStrategy->GetTableMaxWidth(); } return desiredWidth; } @@ -4146,20 +4142,20 @@ nscoord nsTableFrame::GetMinCaptionWidth() } /** return the minimum width of the table. Return 0 if the min width is unknown. */ -nscoord nsTableFrame::GetMinTableContentWidth() +nscoord nsTableFrame::GetMinTableWidth() { nscoord result = 0; if (nsnull!=mTableLayoutStrategy) - result = mTableLayoutStrategy->GetTableMinContentWidth(); + result = mTableLayoutStrategy->GetTableMinWidth(); return result; } /** return the maximum width of the table. Return 0 if the max width is unknown. */ -nscoord nsTableFrame::GetMaxTableContentWidth() +nscoord nsTableFrame::GetMaxTableWidth() { nscoord result = 0; if (nsnull!=mTableLayoutStrategy) - result = mTableLayoutStrategy->GetTableMaxContentWidth(); + result = mTableLayoutStrategy->GetTableMaxWidth(); return result; } diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index 3fa0e0a2ecf5..89c48a176cc0 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -793,13 +793,13 @@ public: /* ----- Cell Map public methods ----- */ /** return the minimum width of the table caption. Return 0 if there is no caption. */ nscoord GetMinCaptionWidth(); - /** return the minimum contend width of the table (excludes borders and padding). + /** return the minimum content width of the table (excludes borders and padding). Return 0 if the min width is unknown. */ - nscoord GetMinTableContentWidth(); + nscoord GetMinTableWidth(); /** return the maximum content width of the table (excludes borders and padding). Return 0 if the max width is unknown. */ - nscoord GetMaxTableContentWidth(); + nscoord GetMaxTableWidth(); /** compute the max-element-size for the table * @param aMaxElementSize [OUT] width field set to the min legal width of the table diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index 73ca343ab2ee..4b08d56e5a46 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -1404,6 +1404,10 @@ nsTableRowGroupFrame::RecoverState(RowGroupReflowState& aReflowState, nsIFrame* aKidFrame, nsSize* aMaxElementSize) { + nsTableFrame* tableFrame = nsnull; + nsTableFrame::GetTableFrame(this, tableFrame); + nscoord cellSpacingY = tableFrame->GetCellSpacingY(); + // Walk the list of children looking for aKidFrame for (nsIFrame* frame = mFrames.FirstChild(); frame; frame->GetNextSibling(&frame)) { if (frame == aKidFrame) { @@ -1413,7 +1417,7 @@ nsTableRowGroupFrame::RecoverState(RowGroupReflowState& aReflowState, // Update the running y-offset nsSize kidSize; frame->GetSize(kidSize); - aReflowState.y += kidSize.height; + aReflowState.y += cellSpacingY + kidSize.height; // If our height is constrained then update the available height if (PR_FALSE == aReflowState.unconstrainedHeight) { diff --git a/layout/tables/BasicTableLayoutStrategy.cpp b/layout/tables/BasicTableLayoutStrategy.cpp index ef13243f4007..09e05353da4b 100644 --- a/layout/tables/BasicTableLayoutStrategy.cpp +++ b/layout/tables/BasicTableLayoutStrategy.cpp @@ -69,8 +69,6 @@ BasicTableLayoutStrategy::BasicTableLayoutStrategy(nsTableFrame *aFrame, PRBool NS_ASSERTION(nsnull != aFrame, "bad frame arg"); mTableFrame = aFrame; - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; mCellSpacingTotal = 0; mIsNavQuirksMode = aIsNavQuirks; } @@ -90,8 +88,6 @@ PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContex PRBool result = PR_TRUE; // re-init instance variables - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; mCellSpacingTotal = 0; mCols = mTableFrame->GetEffectiveCOLSAttribute(); // assign the width of all fixed-width columns @@ -117,14 +113,15 @@ BasicTableLayoutStrategy::SetMaxElementSize(nsSize* aMaxElementSize, mTableFrame->GetTableBorder(borderPadding); borderPadding += aPadding; nscoord horBorderPadding = borderPadding.left + borderPadding.right; + nscoord minTableWidth = GetTableMinWidth(); if (tablePosition->mWidth.GetUnit() == eStyleUnit_Coord) { aMaxElementSize->width = tablePosition->mWidth.GetCoordValue(); - if (mMinTableContentWidth + horBorderPadding > aMaxElementSize->width) { - aMaxElementSize->width = mMinTableContentWidth + horBorderPadding; + if (minTableWidth + horBorderPadding > aMaxElementSize->width) { + aMaxElementSize->width = minTableWidth + horBorderPadding; } } else { - aMaxElementSize->width = mMinTableContentWidth + horBorderPadding; + aMaxElementSize->width = minTableWidth + horBorderPadding; } } } @@ -216,13 +213,14 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont } // if the max width available is less than the min content width for fixed table, we're done - if (!tableIsAutoWidth && (maxWidth < mMinTableContentWidth)) { + nscoord minTableWidth = GetTableMinWidth(); + if (!tableIsAutoWidth && (maxWidth < minTableWidth)) { return BCW_Wrapup(aPresContext, this, mTableFrame, nsnull); } // if the max width available is less than the min content width for auto table // that had no % cells/cols, we're done - if (tableIsAutoWidth && (maxWidth < mMinTableContentWidth) && (0 == perAdjTableWidth)) { + if (tableIsAutoWidth && (maxWidth < minTableWidth) && (0 == perAdjTableWidth)) { return BCW_Wrapup(aPresContext, this, mTableFrame, nsnull); } @@ -885,7 +883,6 @@ BasicTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* nscoord minWidth = colFrame->GetMinWidth(); mTableFrame->SetColumnWidth(colX, minWidth); } - SetMinAndMaxTableContentWidths(); if (gsDebugAssign) {printf("AssignPrelimColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);} return rv; @@ -1181,27 +1178,42 @@ BasicTableLayoutStrategy::AssignPercentageColumnWidths(nscoord aBasisIn, return basis; } -void BasicTableLayoutStrategy::SetMinAndMaxTableContentWidths() +nscoord BasicTableLayoutStrategy::GetTableMinWidth() const { - mMinTableContentWidth = 0; - mMaxTableContentWidth = 0; - + nscoord minWidth = 0; nscoord spacingX = mTableFrame->GetCellSpacingX(); PRInt32 numCols = mTableFrame->GetColCount(); for (PRInt32 colX = 0; colX < numCols; colX++) { nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX); - mMinTableContentWidth += colFrame->GetMinWidth(); - mMaxTableContentWidth += PR_MAX(colFrame->GetDesWidth(), colFrame->GetFixWidth()); + minWidth += PR_MAX(colFrame->GetMinWidth(), colFrame->GetWidth(MIN_ADJ)); + } + // if it is not a degenerate table, add the last spacing on the right + if (minWidth > 0) { + minWidth += spacingX; + } + return minWidth; +} + +nscoord BasicTableLayoutStrategy::GetTableMaxWidth() const +{ + nscoord spacingX = mTableFrame->GetCellSpacingX(); + PRInt32 numCols = mTableFrame->GetColCount(); + nscoord maxWidth = 0; + for (PRInt32 colX = 0; colX < numCols; colX++) { + nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX); + nscoord max = PR_MAX(colFrame->GetDesWidth(), colFrame->GetFixWidth()); + max = PR_MAX(max, colFrame->GetPctWidth()); + max = PR_MAX(max, colFrame->GetWidth(MIN_PRO)); + maxWidth += max; if (mTableFrame->GetNumCellsOriginatingInCol(colX) > 0) { - mMaxTableContentWidth += spacingX; - mMinTableContentWidth += spacingX; + maxWidth += spacingX; } } // if it is not a degenerate table, add the last spacing on the right - if (mMinTableContentWidth > 0) { - mMinTableContentWidth += spacingX; - mMaxTableContentWidth += spacingX; + if (maxWidth > 0) { + maxWidth += spacingX; } + return maxWidth; } // calculate totals by width type. @@ -1783,8 +1795,8 @@ void BasicTableLayoutStrategy::Dump(PRInt32 aIndent) printf("%s**START BASIC STRATEGY DUMP** table=%p cols=%X", indent, mTableFrame, mCols); - printf("\n%s minConWidth=%d maxConWidth=%d cellSpacing=%d propRatio=%.2f navQuirks=%d", - indent, mMinTableContentWidth, mMaxTableContentWidth, mCellSpacingTotal, mMinToDesProportionRatio, mIsNavQuirksMode); + printf("\n%s cellSpacing=%d propRatio=%.2f navQuirks=%d", + indent, mCellSpacingTotal, mMinToDesProportionRatio, mIsNavQuirksMode); printf(" **END BASIC STRATEGY DUMP** \n"); delete [] indent; } diff --git a/layout/tables/BasicTableLayoutStrategy.h b/layout/tables/BasicTableLayoutStrategy.h index c8afc5174e4f..dfe006d8d5d8 100644 --- a/layout/tables/BasicTableLayoutStrategy.h +++ b/layout/tables/BasicTableLayoutStrategy.h @@ -82,8 +82,8 @@ public: nscoord aMaxWidth); // these accessors are mostly for debugging purposes - nscoord GetTableMinContentWidth() const; - nscoord GetTableMaxContentWidth() const; + nscoord GetTableMinWidth() const; + nscoord GetTableMaxWidth() const; nscoord GetCOLSAttribute() const; void Dump(PRInt32 aIndent); @@ -210,20 +210,11 @@ protected: nsTableFrame * mTableFrame; PRInt32 mCols; // cached data - nscoord mMinTableContentWidth; // the smallest size for the table (excluding border and padding) - nscoord mMaxTableContentWidth; // the "natural" size for the table, if unconstrained (excluding border and padding) nscoord mCellSpacingTotal; // all of the cellspacing for all of the cols float mMinToDesProportionRatio; PRPackedBool mIsNavQuirksMode; }; -// these accessors are mostly for debugging purposes -inline nscoord BasicTableLayoutStrategy::GetTableMinContentWidth() const -{ return mMinTableContentWidth; }; - -inline nscoord BasicTableLayoutStrategy::GetTableMaxContentWidth() const -{ return mMaxTableContentWidth; }; - inline nscoord BasicTableLayoutStrategy::GetCOLSAttribute() const { return mCols; }; diff --git a/layout/tables/FixedTableLayoutStrategy.cpp b/layout/tables/FixedTableLayoutStrategy.cpp index 3ed6ebd863d2..1fdce56dfa9c 100644 --- a/layout/tables/FixedTableLayoutStrategy.cpp +++ b/layout/tables/FixedTableLayoutStrategy.cpp @@ -197,9 +197,6 @@ FixedTableLayoutStrategy::AssignPreliminaryColumnWidths(nsIPresContext* mTableFrame->SetColumnWidth(colX, colWidths[colX]); } - // min/max TW is min/max of (specified table width, sum of specified column(cell) widths) - mMinTableContentWidth = mMaxTableContentWidth = totalColWidth; - // clean up if (nsnull != colWidths) { delete [] colWidths; diff --git a/layout/tables/nsITableLayoutStrategy.h b/layout/tables/nsITableLayoutStrategy.h index 05f999b95967..0b56eafbc881 100644 --- a/layout/tables/nsITableLayoutStrategy.h +++ b/layout/tables/nsITableLayoutStrategy.h @@ -72,7 +72,7 @@ public: * the actual table width in a given situation will depend on the available size * provided by the parent (especially for percent-width tables.) */ - virtual nscoord GetTableMaxContentWidth() const = 0; + virtual nscoord GetTableMaxWidth() const = 0; /** return the computed minimum possible size of the table. * this is the sum of the minimum sizes of the content taking into account table @@ -80,7 +80,7 @@ public: * the actual table width in a given situation will depend on the available size * provided by the parent (especially for percent-width tables.) */ - virtual nscoord GetTableMinContentWidth() const = 0; + virtual nscoord GetTableMinWidth() const = 0; /** return the value of the COLS attribute, used for balancing column widths */ virtual nscoord GetCOLSAttribute() const = 0; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index ad2d1fc1a214..c14220e3597b 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1666,7 +1666,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, if (isAutoOrPctWidth) { // Ask the strategy for the natural width of the content area - aDesiredSize.mMaximumWidth = mTableLayoutStrategy->GetTableMaxContentWidth(); + aDesiredSize.mMaximumWidth = mTableLayoutStrategy->GetTableMaxWidth(); // Add in space for border nsMargin border; @@ -2796,18 +2796,14 @@ NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext, nscoord nsTableFrame::ComputeDesiredWidth(const nsHTMLReflowState& aReflowState) const { nscoord desiredWidth = aReflowState.availableWidth; - // this is the biggest hack in the world. But there's no other rational way to handle nested percent tables - const nsStylePosition* position; - PRBool isNested = IsNested(aReflowState, position); - if ((eReflowReason_Initial==aReflowState.reason) && - (isNested) && (eStyleUnit_Percent == position->mWidth.GetUnit())) { + if (NS_UNCONSTRAINEDSIZE == desiredWidth) { nsITableLayoutStrategy* tableLayoutStrategy = mTableLayoutStrategy; if (mPrevInFlow) { // Get the table layout strategy from the first-in-flow nsTableFrame* table = (nsTableFrame*)GetFirstInFlow(); tableLayoutStrategy = table->mTableLayoutStrategy; } - desiredWidth = tableLayoutStrategy->GetTableMaxContentWidth(); + desiredWidth = tableLayoutStrategy->GetTableMaxWidth(); } return desiredWidth; } @@ -4146,20 +4142,20 @@ nscoord nsTableFrame::GetMinCaptionWidth() } /** return the minimum width of the table. Return 0 if the min width is unknown. */ -nscoord nsTableFrame::GetMinTableContentWidth() +nscoord nsTableFrame::GetMinTableWidth() { nscoord result = 0; if (nsnull!=mTableLayoutStrategy) - result = mTableLayoutStrategy->GetTableMinContentWidth(); + result = mTableLayoutStrategy->GetTableMinWidth(); return result; } /** return the maximum width of the table. Return 0 if the max width is unknown. */ -nscoord nsTableFrame::GetMaxTableContentWidth() +nscoord nsTableFrame::GetMaxTableWidth() { nscoord result = 0; if (nsnull!=mTableLayoutStrategy) - result = mTableLayoutStrategy->GetTableMaxContentWidth(); + result = mTableLayoutStrategy->GetTableMaxWidth(); return result; } diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 3fa0e0a2ecf5..89c48a176cc0 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -793,13 +793,13 @@ public: /* ----- Cell Map public methods ----- */ /** return the minimum width of the table caption. Return 0 if there is no caption. */ nscoord GetMinCaptionWidth(); - /** return the minimum contend width of the table (excludes borders and padding). + /** return the minimum content width of the table (excludes borders and padding). Return 0 if the min width is unknown. */ - nscoord GetMinTableContentWidth(); + nscoord GetMinTableWidth(); /** return the maximum content width of the table (excludes borders and padding). Return 0 if the max width is unknown. */ - nscoord GetMaxTableContentWidth(); + nscoord GetMaxTableWidth(); /** compute the max-element-size for the table * @param aMaxElementSize [OUT] width field set to the min legal width of the table diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 73ca343ab2ee..4b08d56e5a46 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -1404,6 +1404,10 @@ nsTableRowGroupFrame::RecoverState(RowGroupReflowState& aReflowState, nsIFrame* aKidFrame, nsSize* aMaxElementSize) { + nsTableFrame* tableFrame = nsnull; + nsTableFrame::GetTableFrame(this, tableFrame); + nscoord cellSpacingY = tableFrame->GetCellSpacingY(); + // Walk the list of children looking for aKidFrame for (nsIFrame* frame = mFrames.FirstChild(); frame; frame->GetNextSibling(&frame)) { if (frame == aKidFrame) { @@ -1413,7 +1417,7 @@ nsTableRowGroupFrame::RecoverState(RowGroupReflowState& aReflowState, // Update the running y-offset nsSize kidSize; frame->GetSize(kidSize); - aReflowState.y += kidSize.height; + aReflowState.y += cellSpacingY + kidSize.height; // If our height is constrained then update the available height if (PR_FALSE == aReflowState.unconstrainedHeight) {