mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-10 09:19:28 +00:00
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.
This commit is contained in:
parent
d743807245
commit
2005083629
@ -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;
|
||||
}
|
||||
|
@ -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; };
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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; };
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user