зеркало из https://github.com/mozilla/pjs.git
reduce prescontext usage in basic layout strategy bug 229457 r/sr=roc
This commit is contained in:
Родитель
a44647974f
Коммит
118de5f62e
|
@ -108,8 +108,7 @@ BasicTableLayoutStrategy::~BasicTableLayoutStrategy()
|
|||
MOZ_COUNT_DTOR(BasicTableLayoutStrategy);
|
||||
}
|
||||
|
||||
PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
PRBool BasicTableLayoutStrategy::Initialize(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eInit, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
|
@ -122,21 +121,18 @@ PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContex
|
|||
mCellSpacingTotal = 0;
|
||||
mCols = mTableFrame->GetEffectiveCOLSAttribute();
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
mTableFrame->SetHasPctCol(PR_FALSE);
|
||||
|
||||
nscoord boxWidth = mTableFrame->CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
PRBool hasPctCol = AssignNonPctColumnWidths(aPresContext, boxWidth, aReflowState, p2t);
|
||||
nscoord boxWidth = mTableFrame->CalcBorderBoxWidth(aReflowState);
|
||||
PRBool hasPctCol = AssignNonPctColumnWidths(boxWidth, aReflowState);
|
||||
|
||||
mTableFrame->SetHasPctCol(hasPctCol);
|
||||
|
||||
// calc the min, desired, preferred widths from what we know so far
|
||||
nscoord minWidth, prefWidth;
|
||||
mTableFrame->CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
mTableFrame->CalcMinAndPreferredWidths(aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
if (hasPctCol && mTableFrame->IsAutoWidth()) {
|
||||
prefWidth = CalcPctAdjTableWidth(*aPresContext, aReflowState, boxWidth, p2t);
|
||||
prefWidth = CalcPctAdjTableWidth(aReflowState, boxWidth);
|
||||
}
|
||||
// calc the desired width, considering if there is a specified width.
|
||||
// don't use nsTableFrame::CalcDesiredWidth because it is based on table column widths.
|
||||
|
@ -165,8 +161,7 @@ void BasicTableLayoutStrategy::ContinuingFrameCheck()
|
|||
#endif
|
||||
}
|
||||
|
||||
PRBool BCW_Wrapup(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
PRBool BCW_Wrapup(const nsHTMLReflowState& aReflowState,
|
||||
BasicTableLayoutStrategy* aStrategy,
|
||||
nsTableFrame* aTableFrame,
|
||||
PRInt32* aAllocTypes)
|
||||
|
@ -174,7 +169,7 @@ PRBool BCW_Wrapup(nsIPresContext* aPresContext,
|
|||
if (aAllocTypes)
|
||||
delete [] aAllocTypes;
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("BalanceColumnWidths ex \n"); aTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("BalanceColumnWidths ex \n"); aTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eBalanceCols, *aTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE);
|
||||
|
@ -198,18 +193,16 @@ ResetPctValues(nsTableFrame* aTableFrame,
|
|||
}
|
||||
|
||||
PRBool
|
||||
BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
BasicTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
if (!aPresContext) ABORT1(PR_FALSE);
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("BalanceColumnWidths en count=%d \n", gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("BalanceColumnWidths en count=%d \n", gsDebugCount++); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eBalanceCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
#endif
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
ContinuingFrameCheck();
|
||||
|
||||
|
@ -218,16 +211,11 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
|
||||
nscoord horOffset;
|
||||
// get the reduction in available horizontal space due to borders and padding
|
||||
if (mTableFrame->IsBorderCollapse()) {
|
||||
nsMargin offset = mTableFrame->GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
horOffset = offset.left + offset.right;
|
||||
}
|
||||
else {
|
||||
horOffset = aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
||||
}
|
||||
nsMargin offset = mTableFrame->GetChildAreaOffset(&aReflowState);
|
||||
horOffset = offset.left + offset.right;
|
||||
|
||||
// determine if the table is auto/fixed and get the fixed width if available
|
||||
nscoord maxWidth = mTableFrame->CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
nscoord maxWidth = mTableFrame->CalcBorderBoxWidth(aReflowState);
|
||||
if (NS_UNCONSTRAINEDSIZE == maxWidth) {
|
||||
maxWidth = PR_MIN(maxWidth, aReflowState.availableWidth);
|
||||
if (NS_UNCONSTRAINEDSIZE == maxWidth) {
|
||||
|
@ -241,7 +229,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
// An auto table returns a new table width based on percent cells/cols if they exist
|
||||
nscoord perAdjTableWidth = 0;
|
||||
if (mTableFrame->HasPctCol()) {
|
||||
perAdjTableWidth = AssignPctColumnWidths(*aPresContext, aReflowState, maxWidth, tableIsAutoWidth, p2t);
|
||||
perAdjTableWidth = AssignPctColumnWidths(aReflowState, maxWidth, tableIsAutoWidth, p2t);
|
||||
if (perAdjTableWidth > 0) {
|
||||
// if an auto table has a pct col or cell, set the preferred table width
|
||||
// here so that CalcPctAdjTableWidth wont't need to be called by the table
|
||||
|
@ -286,13 +274,13 @@ 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 < minTableWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, nsnull);
|
||||
return BCW_Wrapup(aReflowState, 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 < minTableWidth) && (0 == perAdjTableWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, nsnull);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, nsnull);
|
||||
}
|
||||
|
||||
// the following are of size NUM_WIDTHS, but only MIN_CON, DES_CON, FIX, FIX_ADJ, PCT
|
||||
|
@ -325,7 +313,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, PCT, PR_FALSE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
// allocate FIX cols
|
||||
|
@ -336,7 +324,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, FIX, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
// allocate fixed adjusted cols
|
||||
|
@ -347,7 +335,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, FIX_ADJ, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,13 +348,13 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, DES_CON, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
|
||||
// if this is a nested non auto table and pass1 reflow, we are done
|
||||
if ((maxWidth == NS_UNCONSTRAINEDSIZE) && (!tableIsAutoWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
|
||||
// allocate the rest to auto columns, with some exceptions
|
||||
|
@ -387,7 +375,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
}
|
||||
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
|
||||
nscoord GetColWidth(nsTableColFrame* aColFrame,
|
||||
|
@ -962,16 +950,14 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(PRInt32 aWidthInd
|
|||
// Determine min, desired, fixed, and proportional sizes for the cols and
|
||||
// and calculate min/max table width. Return true if there is at least one pct cell or col
|
||||
PRBool
|
||||
BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPresContext,
|
||||
nscoord aMaxWidth,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
float aPixelToTwips)
|
||||
BasicTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aMaxWidth,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eNonPctCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
PRInt32 numRows = mTableFrame->GetRowCount();
|
||||
PRInt32 numCols = mTableFrame->GetColCount();
|
||||
|
@ -979,6 +965,8 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
PRInt32 colX, rowX;
|
||||
mCellSpacingTotal = 0;
|
||||
PRBool hasPctCol = PR_FALSE; // return value
|
||||
float pixelToTwips;
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
|
||||
|
||||
PRInt32 rawPropTotal = -1; // total of numbers of the type 1*, 2*, etc
|
||||
PRInt32 numColsForColsAttr = 0; // Nav Quirks cols attribute for equal width cols
|
||||
|
@ -1030,7 +1018,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
if (coordValue > 0) { // ignore if width == 0
|
||||
// need to add border and padding into fixed width
|
||||
nsSize percentBase(aReflowState.mComputedWidth, 0);
|
||||
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, aPixelToTwips, cellFrame);
|
||||
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, pixelToTwips, cellFrame);
|
||||
nscoord newFixWidth = coordValue + borderPadding.left + borderPadding.right;
|
||||
// 2nd part of condition is Nav/IE Quirk like below
|
||||
if ((newFixWidth > fixWidth) || ((newFixWidth == fixWidth) && (desContributor == cellFrame))) {
|
||||
|
@ -1113,7 +1101,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
}
|
||||
PRBool* pctRequest = (hasPctCol) ? nsnull : &hasPctCol;
|
||||
ComputeNonPctColspanWidths(aReflowState, PR_FALSE, aPixelToTwips, pctRequest);
|
||||
ComputeNonPctColspanWidths(aReflowState, PR_FALSE, pixelToTwips, pctRequest);
|
||||
PRInt32 numEffCols = mTableFrame->GetEffectiveColCount();
|
||||
// figure the proportional widths for porportional cols
|
||||
if (rawPropTotal > 0) {
|
||||
|
@ -1136,7 +1124,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
if (rawProp > 0) {
|
||||
nscoord desWidth = colFrame->GetDesWidth();
|
||||
nscoord propTotal = NSToCoordRound( ((float)desWidth) * ((float)rawPropTotal) / (float)rawProp );
|
||||
nsTableFrame::RoundToPixel(propTotal, aPixelToTwips);
|
||||
nsTableFrame::RoundToPixel(propTotal, pixelToTwips);
|
||||
maxPropTotal = PR_MAX(maxPropTotal, propTotal);
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1139,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
else if ((rawProp > 0) && (rawPropTotal > 0)) {
|
||||
nscoord propWidth = NSToCoordRound( ((float)maxPropTotal) * ((float)rawProp) / (float)rawPropTotal ) ;
|
||||
propWidth = nsTableFrame::RoundToPixel(propWidth, aPixelToTwips);
|
||||
propWidth = nsTableFrame::RoundToPixel(propWidth, pixelToTwips);
|
||||
colFrame->SetWidth(MIN_PRO, PR_MAX(propWidth, colFrame->GetMinWidth()));
|
||||
}
|
||||
}
|
||||
|
@ -1166,7 +1154,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eNonPctCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE);
|
||||
|
@ -1218,16 +1206,16 @@ inline nscoord WrapupAssignPctColumnWidths(nsTableFrame* aTableFrame,
|
|||
#endif
|
||||
|
||||
nscoord
|
||||
BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidthIn,
|
||||
float aPixelToTwips)
|
||||
BasicTableLayoutStrategy::CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidthIn)
|
||||
{
|
||||
NS_ASSERTION(mTableFrame->IsAutoWidth() && mTableFrame->HasPctCol(), "invalid call");
|
||||
|
||||
PRInt32 numRows = mTableFrame->GetRowCount();
|
||||
PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells
|
||||
PRInt32 colX, rowX;
|
||||
float pixelToTwips;
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
|
||||
|
||||
// For an auto table, determine the potentially new percent adjusted width based
|
||||
// on percent cells/cols. This probably should only be a NavQuirks thing, since
|
||||
|
@ -1239,7 +1227,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
rawPctValues[colX] = 0.0f;
|
||||
}
|
||||
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aReflowState);
|
||||
nscoord availWidth = aAvailWidthIn;
|
||||
if (NS_UNCONSTRAINEDSIZE != availWidth) {
|
||||
// adjust the avail width to exclude table border, padding and cell spacing
|
||||
|
@ -1273,7 +1261,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
}
|
||||
// consider the cell's preferred width
|
||||
cellDesWidth = PR_MAX(cellDesWidth, cellFrame->GetMaximumWidth());
|
||||
nscoord colBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)cellDesWidth / percent), aPixelToTwips);
|
||||
nscoord colBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)cellDesWidth / percent), pixelToTwips);
|
||||
maxColBasis = PR_MAX(maxColBasis, colBasis);
|
||||
}
|
||||
}
|
||||
|
@ -1287,7 +1275,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
if (percent > 0.0f) {
|
||||
rawPctValues[colX] = PR_MAX(rawPctValues[colX], percent);
|
||||
nscoord desWidth = colFrame->GetWidth(DES_CON); // don't consider DES_ADJ
|
||||
maxColBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)desWidth / percent), aPixelToTwips);
|
||||
maxColBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)desWidth / percent), pixelToTwips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1329,7 +1317,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
|
||||
// compute a basis considering total percentages and the desired width of everything else
|
||||
if ((perTotal > 0.0f) && (perTotal < 1.0f)) {
|
||||
nscoord otherBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)fixDesTotalNoPct / (1.0f - perTotal)), aPixelToTwips);
|
||||
nscoord otherBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)fixDesTotalNoPct / (1.0f - perTotal)), pixelToTwips);
|
||||
basis = PR_MAX(basis, otherBasis);
|
||||
}
|
||||
else if ((fixDesTotalNoPct > 0) && (NS_UNCONSTRAINEDSIZE != availWidth)) { // make the basis as big as possible
|
||||
|
@ -1348,8 +1336,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
|
||||
// Determine percentage col widths for each col frame
|
||||
nscoord
|
||||
BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
PRBool aTableIsAutoWidth,
|
||||
float aPixelToTwips)
|
||||
|
@ -1369,11 +1356,11 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
|
|||
// on percent cells/cols. This probably should only be a NavQuirks thing, since
|
||||
// a percentage based cell or column on an auto table should force the column to auto
|
||||
nscoord basis = (aTableIsAutoWidth)
|
||||
? CalcPctAdjTableWidth(aPresContext, aReflowState, aAvailWidth, aPixelToTwips)
|
||||
? CalcPctAdjTableWidth(aReflowState, aAvailWidth)
|
||||
: aAvailWidth;
|
||||
|
||||
// adjust the basis to exclude table border, padding and cell spacing
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aReflowState);
|
||||
basis -= borderPadding.left + borderPadding.right + mCellSpacingTotal;
|
||||
|
||||
nscoord colPctTotal = 0;
|
||||
|
|
|
@ -73,30 +73,24 @@ public:
|
|||
|
||||
/** call every time any table thing changes that might effect the width of any column
|
||||
* in the table (content, structure, or style)
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool Initialize(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/** Called during resize reflow to determine the new column widths
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
* @param aReflowState - the reflow state of the table
|
||||
* @param aAvailWidth - the available width for the table
|
||||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the basis for percent calculations
|
||||
*/
|
||||
virtual nscoord CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
float aPixelToTwips);
|
||||
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth);
|
||||
|
||||
void Dump(PRInt32 aIndent);
|
||||
|
||||
protected:
|
||||
|
@ -112,10 +106,8 @@ protected:
|
|||
* UNCONSTRAINED_SIZE if an auto width table
|
||||
* @return PR_TRUE has a pct cell or col, PR_FALSE otherwise
|
||||
*/
|
||||
virtual PRBool AssignNonPctColumnWidths(nsIPresContext* aPresContext,
|
||||
nscoord aComputedWidth,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
float aPixelToTwips);
|
||||
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the adjusted widths (min, desired, fixed, or pct) for a cell
|
||||
|
@ -160,8 +152,7 @@ protected:
|
|||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the adjusted basis including table border, padding and cell spacing
|
||||
*/
|
||||
nscoord AssignPctColumnWidths(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord AssignPctColumnWidths(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aBasis,
|
||||
PRBool aTableIsAutoWidth,
|
||||
float aPixelToTwips);
|
||||
|
|
|
@ -50,8 +50,7 @@ FixedTableLayoutStrategy::~FixedTableLayoutStrategy()
|
|||
{
|
||||
}
|
||||
|
||||
PRBool FixedTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
PRBool FixedTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -68,11 +68,9 @@ public:
|
|||
virtual ~FixedTableLayoutStrategy();
|
||||
|
||||
/** Called during resize reflow to determine the new column widths
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
|
|
|
@ -52,32 +52,25 @@ class nsITableLayoutStrategy
|
|||
public:
|
||||
virtual ~nsITableLayoutStrategy() {};
|
||||
|
||||
/** call once every time any table thing changes (content, structure, or style)
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
/** call once every time any table thing changes (content, structure, or style)
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)=0;
|
||||
virtual PRBool Initialize(const nsHTMLReflowState& aReflowState)=0;
|
||||
|
||||
/** assign widths for each column, taking into account the table content, the effective style,
|
||||
* the layout constraints, and the compatibility mode. Sets mColumnWidths as a side effect.
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)=0;
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState)=0;
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
* @param aReflowState - the reflow state of the table
|
||||
* @param aAvailWidth - the available width for the table
|
||||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the basis for percent calculations
|
||||
*/
|
||||
virtual nscoord CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
float aPixelToTwips)=0;
|
||||
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth)=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -124,7 +124,7 @@ struct nsTableReflowState {
|
|||
reason = aReason;
|
||||
|
||||
nsTableFrame* table = (nsTableFrame*)aTableFrame.GetFirstInFlow();
|
||||
nsMargin borderPadding = table->GetChildAreaOffset(&aPresContext, &reflowState);
|
||||
nsMargin borderPadding = table->GetChildAreaOffset(&reflowState);
|
||||
|
||||
x = borderPadding.left;
|
||||
y = borderPadding.top;
|
||||
|
@ -1126,7 +1126,7 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
|
|||
PRBool aConsiderSpans)
|
||||
{
|
||||
//printf("insertRowsBefore firstRow=%d \n", aRowIndex);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
PRInt32 numColsToAdd = 0;
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
|
@ -1158,7 +1158,7 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
//printf("insertRowsAfter \n");
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
return numColsToAdd;
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
|
|||
PRBool aConsiderSpans)
|
||||
{
|
||||
//printf("removeRowsBefore firstRow=%d numRows=%d\n", aFirstRowIndex, aNumRowsToRemove);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
|
||||
#ifdef TBD_OPTIMIZATION
|
||||
|
@ -1212,7 +1212,7 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
|
|||
}
|
||||
AdjustRowIndices(&aPresContext, firstRowIndex, -aNumRowsToRemove);
|
||||
//printf("removeRowsAfter\n");
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
||||
void nsTableFrame::AppendRowGroups(nsIPresContext& aPresContext,
|
||||
|
@ -1935,7 +1935,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
PR_FALSE, aStatus, lastReflowed,
|
||||
overflowArea);
|
||||
}
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
}
|
||||
}
|
||||
if (!mPrevInFlow) {
|
||||
|
@ -1981,7 +1981,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
if (NeedsReflow(aReflowState) && (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)) {
|
||||
// see if an extra reflow will be necessary in pagination mode when there is a specified table height
|
||||
if (isPaginated && !mPrevInFlow && (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight)) {
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((tableSpecifiedHeight > 0) &&
|
||||
(tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {
|
||||
SetNeedToInitiateSpecialReflow(PR_TRUE);
|
||||
|
@ -2006,7 +2006,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
// distribute extra vertical space to rows
|
||||
aDesiredSize.height = CalcDesiredHeight(aPresContext, aReflowState);
|
||||
aDesiredSize.height = CalcDesiredHeight(aReflowState);
|
||||
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE;
|
||||
// save the previous special height reflow initiator, install us as the new one
|
||||
nsIFrame* specialReflowInitiator = aReflowState.mPercentHeightReflowInitiator;
|
||||
|
@ -2022,7 +2022,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* 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(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
aDesiredSize.height = borderPadding.top + GetCellSpacingY() +
|
||||
lastChildReflowed->GetSize().height;
|
||||
}
|
||||
|
@ -2043,13 +2043,13 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
aDesiredSize.width = GetDesiredWidth();
|
||||
if (!haveDesiredHeight) {
|
||||
aDesiredSize.height = CalcDesiredHeight(aPresContext, aReflowState);
|
||||
aDesiredSize.height = CalcDesiredHeight(aReflowState);
|
||||
}
|
||||
if (IsRowInserted()) {
|
||||
ProcessRowInserted(aPresContext, *this, PR_TRUE, aDesiredSize.height);
|
||||
}
|
||||
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
SetColumnDimensions(aPresContext, aDesiredSize.height, borderPadding);
|
||||
if (doCollapse) {
|
||||
AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
|
||||
|
@ -2070,7 +2070,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
((eReflowReason_Resize == aReflowState.reason) &&
|
||||
HasPctCol() && IsAutoWidth())) {
|
||||
nscoord minWidth, prefWidth;
|
||||
CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_TRUE, minWidth, prefWidth);
|
||||
CalcMinAndPreferredWidths(aReflowState, PR_TRUE, minWidth, prefWidth);
|
||||
SetMinWidth(minWidth);
|
||||
SetPreferredWidth(prefWidth);
|
||||
}
|
||||
|
@ -2139,7 +2139,7 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
|
|||
PRBool haveReflowedColGroups = PR_TRUE;
|
||||
if (!mPrevInFlow) {
|
||||
if (NeedStrategyInit()) {
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
BalanceColumnWidths(aPresContext, aReflowState);
|
||||
aDidBalance = PR_TRUE;
|
||||
}
|
||||
|
@ -2754,15 +2754,15 @@ DivideBCBorderSize(nscoord aPixelSize,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetBCBorder(nsIPresContext* aPresContext) const
|
||||
nsTableFrame::GetBCBorder() const
|
||||
{
|
||||
nsMargin border(0, 0, 0, 0);
|
||||
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
GET_PIXELS_TO_TWIPS(presContext, p2t);
|
||||
BCPropertyData* propData =
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(aPresContext, (nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(presContext, (nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
if (propData) {
|
||||
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
|
||||
if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) {
|
||||
nscoord smallHalf, largeHalf;
|
||||
|
||||
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf);
|
||||
|
@ -2828,17 +2828,17 @@ void GetSeparateModelBorderPadding(const nsHTMLReflowState* aReflowState,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetChildAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const
|
||||
nsTableFrame::GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const
|
||||
{
|
||||
nsMargin offset(0,0,0,0);
|
||||
if (IsBorderCollapse()) {
|
||||
if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode()) {
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) {
|
||||
nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset);
|
||||
nscoord smallHalf, largeHalf;
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
GET_PIXELS_TO_TWIPS(presContext, p2t);
|
||||
BCPropertyData* propData =
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(aPresContext, (nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(presContext, (nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
if (!propData) ABORT1(offset);
|
||||
|
||||
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf);
|
||||
|
@ -2861,12 +2861,11 @@ nsTableFrame::GetChildAreaOffset(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetContentAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const
|
||||
nsTableFrame::GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const
|
||||
{
|
||||
nsMargin offset(0,0,0,0);
|
||||
if (IsBorderCollapse()) {
|
||||
offset = GetBCBorder(aPresContext);
|
||||
offset = GetBCBorder();
|
||||
}
|
||||
else {
|
||||
GetSeparateModelBorderPadding(aReflowState, *mStyleContext, offset);
|
||||
|
@ -2878,11 +2877,10 @@ nsTableFrame::GetContentAreaOffset(nsIPresContext* aPresContext,
|
|||
// reflowed. Restores y, footerFrame, firstBodySection and availSize.height (if
|
||||
// the height is constrained)
|
||||
nsresult
|
||||
nsTableFrame::RecoverState(nsIPresContext& aPresContext,
|
||||
nsTableReflowState& aReflowState,
|
||||
nsTableFrame::RecoverState(nsTableReflowState& aReflowState,
|
||||
nsIFrame* aKidFrame)
|
||||
{
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aPresContext, &aReflowState.reflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState.reflowState);
|
||||
aReflowState.y = borderPadding.top;
|
||||
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
|
@ -2963,7 +2961,7 @@ nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|||
if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER);
|
||||
nsresult rv;
|
||||
// Recover the state as if aNextFrame is about to be reflowed
|
||||
RecoverState(*aPresContext, aReflowState, aNextFrame);
|
||||
RecoverState(aReflowState, aNextFrame);
|
||||
|
||||
// Remember the old rect
|
||||
nsRect oldKidRect = aNextFrame->GetRect();
|
||||
|
@ -3358,20 +3356,20 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// reflow gets called twice and the 2nd time has the correct space available.
|
||||
// XXX this is very bad and needs to be changed
|
||||
if (!IsAutoLayout()) {
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
}
|
||||
|
||||
// need to figure out the overall table width constraint
|
||||
// default case, get 100% of available space
|
||||
|
||||
mTableLayoutStrategy->BalanceColumnWidths(aPresContext, aReflowState);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_TRUE);
|
||||
mTableLayoutStrategy->BalanceColumnWidths(aReflowState);
|
||||
//Dump(PR_TRUE, PR_TRUE);
|
||||
SetNeedStrategyBalance(PR_FALSE); // we have just balanced
|
||||
// cache the min, desired, and preferred widths
|
||||
nscoord minWidth, prefWidth;
|
||||
CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
CalcMinAndPreferredWidths(aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
SetMinWidth(minWidth);
|
||||
nscoord desWidth = CalcDesiredWidth(*aPresContext, aReflowState);
|
||||
nscoord desWidth = CalcDesiredWidth(aReflowState);
|
||||
SetDesiredWidth(desWidth);
|
||||
SetPreferredWidth(prefWidth);
|
||||
|
||||
|
@ -3380,8 +3378,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// This width is based on the column widths array of the table.
|
||||
// sum the width of each column and add in table insets
|
||||
nscoord
|
||||
nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
nsTableFrame::CalcDesiredWidth(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
NS_ASSERTION(!mPrevInFlow, "never ever call me on a continuing frame!");
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
|
@ -3412,7 +3409,7 @@ nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
|||
tableWidth = PR_MAX(tableWidth, compWidth);
|
||||
|
||||
// Add the width between the border edge and the child area
|
||||
nsMargin childOffset = GetChildAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin childOffset = GetChildAreaOffset(&aReflowState);
|
||||
tableWidth += childOffset.left + childOffset.right;
|
||||
|
||||
return tableWidth;
|
||||
|
@ -3420,8 +3417,7 @@ nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
|||
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
if (!cellMap) {
|
||||
|
@ -3429,7 +3425,7 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
return 0;
|
||||
}
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
|
||||
// get the natural height based on the last child's (row group or scroll frame) rect
|
||||
nsAutoVoidArray rowGroups;
|
||||
|
@ -3437,7 +3433,7 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
OrderRowGroups(rowGroups, numRowGroups, nsnull);
|
||||
if (numRowGroups <= 0) {
|
||||
// tables can be used as rectangular items without content
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((NS_UNCONSTRAINEDSIZE != tableSpecifiedHeight) &&
|
||||
(tableSpecifiedHeight > 0))
|
||||
return tableSpecifiedHeight;
|
||||
|
@ -3454,14 +3450,14 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
|
||||
// see if a specified table height requires dividing additional space to rows
|
||||
if (!mPrevInFlow) {
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((tableSpecifiedHeight > 0) &&
|
||||
(tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE) &&
|
||||
(tableSpecifiedHeight > desiredHeight)) {
|
||||
// proportionately distribute the excess height to unconstrained rows in each
|
||||
// unconstrained row group.We don't need to do this if it's an unconstrained reflow
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
|
||||
DistributeHeightToRows(aPresContext, aReflowState, tableSpecifiedHeight - desiredHeight);
|
||||
DistributeHeightToRows(aReflowState, tableSpecifiedHeight - desiredHeight);
|
||||
}
|
||||
desiredHeight = tableSpecifiedHeight;
|
||||
}
|
||||
|
@ -3509,16 +3505,16 @@ void ResizeCells(nsTableFrame& aTableFrame,
|
|||
}
|
||||
|
||||
void
|
||||
nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAmount)
|
||||
{
|
||||
{
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
presContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
|
||||
nsVoidArray rowGroups;
|
||||
PRUint32 numRowGroups;
|
||||
|
@ -3552,13 +3548,13 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
amountUsed += amountForRow;
|
||||
amountUsedByRG += amountForRow;
|
||||
//rowFrame->DidResize(aPresContext, aReflowState);
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (amountUsed > 0) {
|
||||
rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
yOriginRow += rowRect.height + cellSpacingY;
|
||||
yEndRG += rowRect.height + cellSpacingY;
|
||||
|
@ -3574,13 +3570,13 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
else if (amountUsed > 0) {
|
||||
rgFrame->SetPosition(nsPoint(0, yOriginRG));
|
||||
// Make sure child views are properly positioned
|
||||
nsTableFrame::RePositionViews(aPresContext, rgFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rgFrame);
|
||||
}
|
||||
yOriginRG = yEndRG;
|
||||
}
|
||||
|
||||
if (amountUsed >= aAmount) {
|
||||
ResizeCells(*this, aPresContext, aReflowState);
|
||||
ResizeCells(*this, presContext, aReflowState);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3657,12 +3653,12 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
amountUsedByRG += amountForRow;
|
||||
NS_ASSERTION((amountUsed <= aAmount), "invalid row allocation");
|
||||
//rowFrame->DidResize(aPresContext, aReflowState);
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
else {
|
||||
if (amountUsed > 0) {
|
||||
rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
yOriginRow += rowRect.height + cellSpacingY;
|
||||
yEndRG += rowRect.height + cellSpacingY;
|
||||
|
@ -3680,12 +3676,12 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
else if (amountUsed > 0) {
|
||||
rgFrame->SetPosition(nsPoint(0, yOriginRG));
|
||||
// Make sure child views are properly positioned
|
||||
nsTableFrame::RePositionViews(aPresContext, rgFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rgFrame);
|
||||
}
|
||||
yOriginRG = yEndRG;
|
||||
}
|
||||
|
||||
ResizeCells(*this, aPresContext, aReflowState);
|
||||
ResizeCells(*this, presContext, aReflowState);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4127,8 +4123,7 @@ nsTableFrame::IsAutoHeight()
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aState)
|
||||
nsTableFrame::CalcBorderBoxWidth(const nsHTMLReflowState& aState)
|
||||
{
|
||||
nscoord width = aState.mComputedWidth;
|
||||
|
||||
|
@ -4141,14 +4136,14 @@ nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else if (width != NS_UNCONSTRAINEDSIZE) {
|
||||
nsMargin borderPadding = GetContentAreaOffset(aPresContext, &aState);
|
||||
nsMargin borderPadding = GetContentAreaOffset(&aState);
|
||||
width += borderPadding.left + borderPadding.right;
|
||||
}
|
||||
width = PR_MAX(width, 0);
|
||||
|
||||
if (NS_UNCONSTRAINEDSIZE != width) {
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
GetPresContext()->GetPixelsToTwips(&p2t);
|
||||
width = RoundToPixel(width, p2t);
|
||||
}
|
||||
|
||||
|
@ -4156,12 +4151,11 @@ nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcBorderBoxHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aState)
|
||||
nsTableFrame::CalcBorderBoxHeight(const nsHTMLReflowState& aState)
|
||||
{
|
||||
nscoord height = aState.mComputedHeight;
|
||||
if (NS_AUTOHEIGHT != height) {
|
||||
nsMargin borderPadding = GetContentAreaOffset(aPresContext, &aState);
|
||||
nsMargin borderPadding = GetContentAreaOffset(&aState);
|
||||
height += borderPadding.top + borderPadding.bottom;
|
||||
}
|
||||
height = PR_MAX(0, height);
|
||||
|
@ -4197,13 +4191,11 @@ nsTableFrame::GetFrameName(nsAString& aResult) const
|
|||
|
||||
|
||||
void
|
||||
nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsTableFrame::CalcMinAndPreferredWidths(const nsHTMLReflowState& aReflowState,
|
||||
PRBool aCalcPrefWidthIfAutoWithPctCol,
|
||||
nscoord& aMinWidth,
|
||||
nscoord& aPrefWidth)
|
||||
{
|
||||
if (!aPresContext) ABORT0();
|
||||
aMinWidth = aPrefWidth = 0;
|
||||
|
||||
nscoord spacingX = GetCellSpacingX();
|
||||
|
@ -4225,7 +4217,7 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
}
|
||||
// if it is not a degenerate table, add the last spacing on the right and the borderPadding
|
||||
if (numCols > 0) {
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin childAreaOffset = GetChildAreaOffset( &aReflowState);
|
||||
nscoord extra = spacingX + childAreaOffset.left + childAreaOffset.right;
|
||||
aMinWidth += extra;
|
||||
aPrefWidth += extra;
|
||||
|
@ -4237,12 +4229,10 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
if (HasPctCol() && aCalcPrefWidthIfAutoWithPctCol &&
|
||||
(NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)) {
|
||||
// for an auto table with a pct cell, use the strategy's CalcPctAdjTableWidth
|
||||
nscoord availWidth = CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
nscoord availWidth = CalcBorderBoxWidth(aReflowState);
|
||||
availWidth = PR_MIN(availWidth, aReflowState.availableWidth);
|
||||
if (mTableLayoutStrategy && IsAutoLayout()) {
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
aPrefWidth = mTableLayoutStrategy->CalcPctAdjTableWidth(*aPresContext, aReflowState, availWidth, p2t);
|
||||
aPrefWidth = mTableLayoutStrategy->CalcPctAdjTableWidth(aReflowState, availWidth);
|
||||
}
|
||||
}
|
||||
if (0 == numCols) { // degenerate case
|
||||
|
@ -4252,7 +4242,7 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
else { // a specified fix width becomes the min or preferred width
|
||||
nscoord compWidth = aReflowState.mComputedWidth;
|
||||
if ((NS_UNCONSTRAINEDSIZE != compWidth) && (0 != compWidth) && !isPctWidth) {
|
||||
nsMargin contentOffset = GetContentAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin contentOffset = GetContentAreaOffset(&aReflowState);
|
||||
compWidth += contentOffset.left + contentOffset.right;
|
||||
aMinWidth = PR_MAX(aMinWidth, compWidth);
|
||||
aPrefWidth = PR_MAX(aMinWidth, compWidth);
|
||||
|
@ -4323,8 +4313,7 @@ nsTableFrame::DumpRowGroup(nsIPresContext* aPresContext, nsIFrame* aKidFrame)
|
|||
}
|
||||
|
||||
void
|
||||
nsTableFrame::Dump(nsIPresContext* aPresContext,
|
||||
PRBool aDumpRows,
|
||||
nsTableFrame::Dump(PRBool aDumpRows,
|
||||
PRBool aDumpCols,
|
||||
PRBool aDumpCellMap)
|
||||
{
|
||||
|
@ -4341,7 +4330,7 @@ nsTableFrame::Dump(nsIPresContext* aPresContext,
|
|||
if (aDumpRows) {
|
||||
nsIFrame* kidFrame = mFrames.FirstChild();
|
||||
while (kidFrame) {
|
||||
DumpRowGroup(aPresContext, kidFrame);
|
||||
DumpRowGroup(GetPresContext(), kidFrame);
|
||||
kidFrame = kidFrame->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
@ -6580,7 +6569,7 @@ nsTableFrame::PaintBCBorders(nsIPresContext* aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(aPresContext, nsnull);
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(nsnull);
|
||||
nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT0();
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
|
||||
|
|
|
@ -272,12 +272,10 @@ public:
|
|||
nsIFrame* aOldFrame);
|
||||
|
||||
// Get the offset from the border box to the area where the row groups fit
|
||||
nsMargin GetChildAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const;
|
||||
nsMargin GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const;
|
||||
|
||||
// Get the offset from the border box to the area where the content fits
|
||||
nsMargin GetContentAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const;
|
||||
nsMargin GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const;
|
||||
|
||||
/** helper method to find the table parent of any table frame object */
|
||||
// TODO: today, this depends on display types. This should be changed to rely
|
||||
|
@ -331,7 +329,7 @@ public:
|
|||
nsFramePaintLayer aWhichLayer,
|
||||
PRUint32 aFlags = 0);
|
||||
|
||||
nsMargin GetBCBorder(nsIPresContext* aPresContext) const;
|
||||
nsMargin GetBCBorder() const;
|
||||
|
||||
// get the area that the border leak out from the inner table frame into
|
||||
// the surrounding margin space
|
||||
|
@ -662,8 +660,7 @@ protected:
|
|||
nsIFrame* aKidFrame,
|
||||
nscoord aDeltaY);
|
||||
|
||||
nsresult RecoverState(nsIPresContext& aPresContext,
|
||||
nsTableReflowState& aReflowState,
|
||||
nsresult RecoverState(nsTableReflowState& aReflowState,
|
||||
nsIFrame* aKidFrame);
|
||||
|
||||
NS_METHOD CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
|
||||
|
@ -685,35 +682,29 @@ public:
|
|||
|
||||
// calculate the computed width of aFrame including its border and padding given
|
||||
// its reflow state.
|
||||
nscoord CalcBorderBoxWidth(nsIPresContext* aPresContex,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcBorderBoxWidth(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// calculate the computed height of aFrame including its border and padding given
|
||||
// its reflow state.
|
||||
nscoord CalcBorderBoxHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcBorderBoxHeight(const nsHTMLReflowState& aReflowState);
|
||||
// calculate the minimum width to layout aFrame and its desired width
|
||||
// including border and padding given its reflow state and column width information
|
||||
void CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
void CalcMinAndPreferredWidths(const nsHTMLReflowState& aReflowState,
|
||||
PRBool aCalcPrefWidthIfAutoWithPctCol,
|
||||
nscoord& aMinWidth,
|
||||
nscoord& aPreferredWidth);
|
||||
protected:
|
||||
|
||||
// calcs the width of the table according to the computed widths of each column.
|
||||
virtual PRInt32 CalcDesiredWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRInt32 CalcDesiredWidth(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// return the desired height of this table accounting for the current
|
||||
// reflow state, and for the table attributes and parent
|
||||
nscoord CalcDesiredHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcDesiredHeight(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// The following is a helper for CalcDesiredHeight
|
||||
|
||||
void DistributeHeightToRows(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
void DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAmount);
|
||||
|
||||
void PlaceChild(nsIPresContext* aPresContext,
|
||||
|
@ -912,8 +903,7 @@ public: /* ----- Cell Map public methods ----- */
|
|||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
#ifdef DEBUG
|
||||
void Dump(nsIPresContext* aPresContext,
|
||||
PRBool aDumpRows,
|
||||
void Dump(PRBool aDumpRows,
|
||||
PRBool aDumpCols,
|
||||
PRBool aDumpCellMap);
|
||||
#endif
|
||||
|
|
|
@ -466,7 +466,7 @@ nsTableOuterFrame::InitChildReflowState(nsIPresContext& aPresContext,
|
|||
if (mInnerTableFrame->NeedToCalcBCBorders()) {
|
||||
mInnerTableFrame->CalcBCBorders(aPresContext);
|
||||
}
|
||||
collapseBorder = mInnerTableFrame->GetBCBorder(&aPresContext);
|
||||
collapseBorder = mInnerTableFrame->GetBCBorder();
|
||||
pCollapseBorder = &collapseBorder;
|
||||
pCollapsePadding = &collapsePadding;
|
||||
}
|
||||
|
|
|
@ -108,8 +108,7 @@ BasicTableLayoutStrategy::~BasicTableLayoutStrategy()
|
|||
MOZ_COUNT_DTOR(BasicTableLayoutStrategy);
|
||||
}
|
||||
|
||||
PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
PRBool BasicTableLayoutStrategy::Initialize(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eInit, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
|
@ -122,21 +121,18 @@ PRBool BasicTableLayoutStrategy::Initialize(nsIPresContext* aPresContex
|
|||
mCellSpacingTotal = 0;
|
||||
mCols = mTableFrame->GetEffectiveCOLSAttribute();
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
mTableFrame->SetHasPctCol(PR_FALSE);
|
||||
|
||||
nscoord boxWidth = mTableFrame->CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
PRBool hasPctCol = AssignNonPctColumnWidths(aPresContext, boxWidth, aReflowState, p2t);
|
||||
nscoord boxWidth = mTableFrame->CalcBorderBoxWidth(aReflowState);
|
||||
PRBool hasPctCol = AssignNonPctColumnWidths(boxWidth, aReflowState);
|
||||
|
||||
mTableFrame->SetHasPctCol(hasPctCol);
|
||||
|
||||
// calc the min, desired, preferred widths from what we know so far
|
||||
nscoord minWidth, prefWidth;
|
||||
mTableFrame->CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
mTableFrame->CalcMinAndPreferredWidths(aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
if (hasPctCol && mTableFrame->IsAutoWidth()) {
|
||||
prefWidth = CalcPctAdjTableWidth(*aPresContext, aReflowState, boxWidth, p2t);
|
||||
prefWidth = CalcPctAdjTableWidth(aReflowState, boxWidth);
|
||||
}
|
||||
// calc the desired width, considering if there is a specified width.
|
||||
// don't use nsTableFrame::CalcDesiredWidth because it is based on table column widths.
|
||||
|
@ -165,8 +161,7 @@ void BasicTableLayoutStrategy::ContinuingFrameCheck()
|
|||
#endif
|
||||
}
|
||||
|
||||
PRBool BCW_Wrapup(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
PRBool BCW_Wrapup(const nsHTMLReflowState& aReflowState,
|
||||
BasicTableLayoutStrategy* aStrategy,
|
||||
nsTableFrame* aTableFrame,
|
||||
PRInt32* aAllocTypes)
|
||||
|
@ -174,7 +169,7 @@ PRBool BCW_Wrapup(nsIPresContext* aPresContext,
|
|||
if (aAllocTypes)
|
||||
delete [] aAllocTypes;
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("BalanceColumnWidths ex \n"); aTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("BalanceColumnWidths ex \n"); aTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eBalanceCols, *aTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE);
|
||||
|
@ -198,18 +193,16 @@ ResetPctValues(nsTableFrame* aTableFrame,
|
|||
}
|
||||
|
||||
PRBool
|
||||
BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
BasicTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
if (!aPresContext) ABORT1(PR_FALSE);
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("BalanceColumnWidths en count=%d \n", gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("BalanceColumnWidths en count=%d \n", gsDebugCount++); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eBalanceCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
#endif
|
||||
float p2t;
|
||||
aPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&p2t);
|
||||
|
||||
ContinuingFrameCheck();
|
||||
|
||||
|
@ -218,16 +211,11 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
|
||||
nscoord horOffset;
|
||||
// get the reduction in available horizontal space due to borders and padding
|
||||
if (mTableFrame->IsBorderCollapse()) {
|
||||
nsMargin offset = mTableFrame->GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
horOffset = offset.left + offset.right;
|
||||
}
|
||||
else {
|
||||
horOffset = aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
|
||||
}
|
||||
nsMargin offset = mTableFrame->GetChildAreaOffset(&aReflowState);
|
||||
horOffset = offset.left + offset.right;
|
||||
|
||||
// determine if the table is auto/fixed and get the fixed width if available
|
||||
nscoord maxWidth = mTableFrame->CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
nscoord maxWidth = mTableFrame->CalcBorderBoxWidth(aReflowState);
|
||||
if (NS_UNCONSTRAINEDSIZE == maxWidth) {
|
||||
maxWidth = PR_MIN(maxWidth, aReflowState.availableWidth);
|
||||
if (NS_UNCONSTRAINEDSIZE == maxWidth) {
|
||||
|
@ -241,7 +229,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
// An auto table returns a new table width based on percent cells/cols if they exist
|
||||
nscoord perAdjTableWidth = 0;
|
||||
if (mTableFrame->HasPctCol()) {
|
||||
perAdjTableWidth = AssignPctColumnWidths(*aPresContext, aReflowState, maxWidth, tableIsAutoWidth, p2t);
|
||||
perAdjTableWidth = AssignPctColumnWidths(aReflowState, maxWidth, tableIsAutoWidth, p2t);
|
||||
if (perAdjTableWidth > 0) {
|
||||
// if an auto table has a pct col or cell, set the preferred table width
|
||||
// here so that CalcPctAdjTableWidth wont't need to be called by the table
|
||||
|
@ -286,13 +274,13 @@ 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 < minTableWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, nsnull);
|
||||
return BCW_Wrapup(aReflowState, 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 < minTableWidth) && (0 == perAdjTableWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, nsnull);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, nsnull);
|
||||
}
|
||||
|
||||
// the following are of size NUM_WIDTHS, but only MIN_CON, DES_CON, FIX, FIX_ADJ, PCT
|
||||
|
@ -325,7 +313,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, PCT, PR_FALSE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
// allocate FIX cols
|
||||
|
@ -336,7 +324,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, FIX, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
// allocate fixed adjusted cols
|
||||
|
@ -347,7 +335,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, FIX_ADJ, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,13 +348,13 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
else {
|
||||
AllocateConstrained(maxWidth - totalAllocated, DES_CON, PR_TRUE, allocTypes, p2t);
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
}
|
||||
|
||||
// if this is a nested non auto table and pass1 reflow, we are done
|
||||
if ((maxWidth == NS_UNCONSTRAINEDSIZE) && (!tableIsAutoWidth)) {
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
|
||||
// allocate the rest to auto columns, with some exceptions
|
||||
|
@ -387,7 +375,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresCont
|
|||
}
|
||||
}
|
||||
|
||||
return BCW_Wrapup(aPresContext, aReflowState, this, mTableFrame, allocTypes);
|
||||
return BCW_Wrapup(aReflowState, this, mTableFrame, allocTypes);
|
||||
}
|
||||
|
||||
nscoord GetColWidth(nsTableColFrame* aColFrame,
|
||||
|
@ -962,16 +950,14 @@ BasicTableLayoutStrategy::ComputeNonPctColspanWidths(PRInt32 aWidthInd
|
|||
// Determine min, desired, fixed, and proportional sizes for the cols and
|
||||
// and calculate min/max table width. Return true if there is at least one pct cell or col
|
||||
PRBool
|
||||
BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPresContext,
|
||||
nscoord aMaxWidth,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
float aPixelToTwips)
|
||||
BasicTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aMaxWidth,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eNonPctCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("AssignNonPctColWidths en max=%d count=%d \n", aMaxWidth, gsDebugCount++); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
PRInt32 numRows = mTableFrame->GetRowCount();
|
||||
PRInt32 numCols = mTableFrame->GetColCount();
|
||||
|
@ -979,6 +965,8 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
PRInt32 colX, rowX;
|
||||
mCellSpacingTotal = 0;
|
||||
PRBool hasPctCol = PR_FALSE; // return value
|
||||
float pixelToTwips;
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
|
||||
|
||||
PRInt32 rawPropTotal = -1; // total of numbers of the type 1*, 2*, etc
|
||||
PRInt32 numColsForColsAttr = 0; // Nav Quirks cols attribute for equal width cols
|
||||
|
@ -1030,7 +1018,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
if (coordValue > 0) { // ignore if width == 0
|
||||
// need to add border and padding into fixed width
|
||||
nsSize percentBase(aReflowState.mComputedWidth, 0);
|
||||
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, aPixelToTwips, cellFrame);
|
||||
nsMargin borderPadding = nsTableFrame::GetBorderPadding(percentBase, pixelToTwips, cellFrame);
|
||||
nscoord newFixWidth = coordValue + borderPadding.left + borderPadding.right;
|
||||
// 2nd part of condition is Nav/IE Quirk like below
|
||||
if ((newFixWidth > fixWidth) || ((newFixWidth == fixWidth) && (desContributor == cellFrame))) {
|
||||
|
@ -1113,7 +1101,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
}
|
||||
PRBool* pctRequest = (hasPctCol) ? nsnull : &hasPctCol;
|
||||
ComputeNonPctColspanWidths(aReflowState, PR_FALSE, aPixelToTwips, pctRequest);
|
||||
ComputeNonPctColspanWidths(aReflowState, PR_FALSE, pixelToTwips, pctRequest);
|
||||
PRInt32 numEffCols = mTableFrame->GetEffectiveColCount();
|
||||
// figure the proportional widths for porportional cols
|
||||
if (rawPropTotal > 0) {
|
||||
|
@ -1136,7 +1124,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
if (rawProp > 0) {
|
||||
nscoord desWidth = colFrame->GetDesWidth();
|
||||
nscoord propTotal = NSToCoordRound( ((float)desWidth) * ((float)rawPropTotal) / (float)rawProp );
|
||||
nsTableFrame::RoundToPixel(propTotal, aPixelToTwips);
|
||||
nsTableFrame::RoundToPixel(propTotal, pixelToTwips);
|
||||
maxPropTotal = PR_MAX(maxPropTotal, propTotal);
|
||||
}
|
||||
}
|
||||
|
@ -1151,7 +1139,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
else if ((rawProp > 0) && (rawPropTotal > 0)) {
|
||||
nscoord propWidth = NSToCoordRound( ((float)maxPropTotal) * ((float)rawProp) / (float)rawPropTotal ) ;
|
||||
propWidth = nsTableFrame::RoundToPixel(propWidth, aPixelToTwips);
|
||||
propWidth = nsTableFrame::RoundToPixel(propWidth, pixelToTwips);
|
||||
colFrame->SetWidth(MIN_PRO, PR_MAX(propWidth, colFrame->GetMinWidth()));
|
||||
}
|
||||
}
|
||||
|
@ -1166,7 +1154,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
|
|||
}
|
||||
|
||||
#ifdef DEBUG_TABLE_STRATEGY
|
||||
printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(aPresContext, PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
printf("AssignNonPctColWidths ex\n"); mTableFrame->Dump(PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
#endif
|
||||
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
||||
nsTableFrame::DebugTimeMethod(nsTableFrame::eNonPctCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_FALSE);
|
||||
|
@ -1218,16 +1206,16 @@ inline nscoord WrapupAssignPctColumnWidths(nsTableFrame* aTableFrame,
|
|||
#endif
|
||||
|
||||
nscoord
|
||||
BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidthIn,
|
||||
float aPixelToTwips)
|
||||
BasicTableLayoutStrategy::CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidthIn)
|
||||
{
|
||||
NS_ASSERTION(mTableFrame->IsAutoWidth() && mTableFrame->HasPctCol(), "invalid call");
|
||||
|
||||
PRInt32 numRows = mTableFrame->GetRowCount();
|
||||
PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells
|
||||
PRInt32 colX, rowX;
|
||||
float pixelToTwips;
|
||||
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
|
||||
|
||||
// For an auto table, determine the potentially new percent adjusted width based
|
||||
// on percent cells/cols. This probably should only be a NavQuirks thing, since
|
||||
|
@ -1239,7 +1227,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
rawPctValues[colX] = 0.0f;
|
||||
}
|
||||
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aReflowState);
|
||||
nscoord availWidth = aAvailWidthIn;
|
||||
if (NS_UNCONSTRAINEDSIZE != availWidth) {
|
||||
// adjust the avail width to exclude table border, padding and cell spacing
|
||||
|
@ -1273,7 +1261,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
}
|
||||
// consider the cell's preferred width
|
||||
cellDesWidth = PR_MAX(cellDesWidth, cellFrame->GetMaximumWidth());
|
||||
nscoord colBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)cellDesWidth / percent), aPixelToTwips);
|
||||
nscoord colBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)cellDesWidth / percent), pixelToTwips);
|
||||
maxColBasis = PR_MAX(maxColBasis, colBasis);
|
||||
}
|
||||
}
|
||||
|
@ -1287,7 +1275,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
if (percent > 0.0f) {
|
||||
rawPctValues[colX] = PR_MAX(rawPctValues[colX], percent);
|
||||
nscoord desWidth = colFrame->GetWidth(DES_CON); // don't consider DES_ADJ
|
||||
maxColBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)desWidth / percent), aPixelToTwips);
|
||||
maxColBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)desWidth / percent), pixelToTwips);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1329,7 +1317,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
|
||||
// compute a basis considering total percentages and the desired width of everything else
|
||||
if ((perTotal > 0.0f) && (perTotal < 1.0f)) {
|
||||
nscoord otherBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)fixDesTotalNoPct / (1.0f - perTotal)), aPixelToTwips);
|
||||
nscoord otherBasis = nsTableFrame::RoundToPixel(NSToCoordRound((float)fixDesTotalNoPct / (1.0f - perTotal)), pixelToTwips);
|
||||
basis = PR_MAX(basis, otherBasis);
|
||||
}
|
||||
else if ((fixDesTotalNoPct > 0) && (NS_UNCONSTRAINEDSIZE != availWidth)) { // make the basis as big as possible
|
||||
|
@ -1348,8 +1336,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(nsIPresContext& aPresCon
|
|||
|
||||
// Determine percentage col widths for each col frame
|
||||
nscoord
|
||||
BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
BasicTableLayoutStrategy::AssignPctColumnWidths(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
PRBool aTableIsAutoWidth,
|
||||
float aPixelToTwips)
|
||||
|
@ -1369,11 +1356,11 @@ BasicTableLayoutStrategy::AssignPctColumnWidths(nsIPresContext& aPresCo
|
|||
// on percent cells/cols. This probably should only be a NavQuirks thing, since
|
||||
// a percentage based cell or column on an auto table should force the column to auto
|
||||
nscoord basis = (aTableIsAutoWidth)
|
||||
? CalcPctAdjTableWidth(aPresContext, aReflowState, aAvailWidth, aPixelToTwips)
|
||||
? CalcPctAdjTableWidth(aReflowState, aAvailWidth)
|
||||
: aAvailWidth;
|
||||
|
||||
// adjust the basis to exclude table border, padding and cell spacing
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = mTableFrame->GetContentAreaOffset(&aReflowState);
|
||||
basis -= borderPadding.left + borderPadding.right + mCellSpacingTotal;
|
||||
|
||||
nscoord colPctTotal = 0;
|
||||
|
|
|
@ -73,30 +73,24 @@ public:
|
|||
|
||||
/** call every time any table thing changes that might effect the width of any column
|
||||
* in the table (content, structure, or style)
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool Initialize(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/** Called during resize reflow to determine the new column widths
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
* @param aReflowState - the reflow state of the table
|
||||
* @param aAvailWidth - the available width for the table
|
||||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the basis for percent calculations
|
||||
*/
|
||||
virtual nscoord CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
float aPixelToTwips);
|
||||
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth);
|
||||
|
||||
void Dump(PRInt32 aIndent);
|
||||
|
||||
protected:
|
||||
|
@ -112,10 +106,8 @@ protected:
|
|||
* UNCONSTRAINED_SIZE if an auto width table
|
||||
* @return PR_TRUE has a pct cell or col, PR_FALSE otherwise
|
||||
*/
|
||||
virtual PRBool AssignNonPctColumnWidths(nsIPresContext* aPresContext,
|
||||
nscoord aComputedWidth,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
float aPixelToTwips);
|
||||
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the adjusted widths (min, desired, fixed, or pct) for a cell
|
||||
|
@ -160,8 +152,7 @@ protected:
|
|||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the adjusted basis including table border, padding and cell spacing
|
||||
*/
|
||||
nscoord AssignPctColumnWidths(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord AssignPctColumnWidths(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aBasis,
|
||||
PRBool aTableIsAutoWidth,
|
||||
float aPixelToTwips);
|
||||
|
|
|
@ -50,8 +50,7 @@ FixedTableLayoutStrategy::~FixedTableLayoutStrategy()
|
|||
{
|
||||
}
|
||||
|
||||
PRBool FixedTableLayoutStrategy::BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
PRBool FixedTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -68,11 +68,9 @@ public:
|
|||
virtual ~FixedTableLayoutStrategy();
|
||||
|
||||
/** Called during resize reflow to determine the new column widths
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
|
|
|
@ -52,32 +52,25 @@ class nsITableLayoutStrategy
|
|||
public:
|
||||
virtual ~nsITableLayoutStrategy() {};
|
||||
|
||||
/** call once every time any table thing changes (content, structure, or style)
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
/** call once every time any table thing changes (content, structure, or style)
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool Initialize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)=0;
|
||||
virtual PRBool Initialize(const nsHTMLReflowState& aReflowState)=0;
|
||||
|
||||
/** assign widths for each column, taking into account the table content, the effective style,
|
||||
* the layout constraints, and the compatibility mode. Sets mColumnWidths as a side effect.
|
||||
* @param aPresContext - the presentation context
|
||||
* @param aReflowState - the reflow state for mTableFrame
|
||||
*/
|
||||
virtual PRBool BalanceColumnWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)=0;
|
||||
virtual PRBool BalanceColumnWidths(const nsHTMLReflowState& aReflowState)=0;
|
||||
|
||||
/**
|
||||
* Calculate the basis for percent width calculations of the table elements
|
||||
* @param aReflowState - the reflow state of the table
|
||||
* @param aAvailWidth - the available width for the table
|
||||
* @param aPixelToTwips - the number of twips in a pixel.
|
||||
* @return - the basis for percent calculations
|
||||
*/
|
||||
virtual nscoord CalcPctAdjTableWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth,
|
||||
float aPixelToTwips)=0;
|
||||
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAvailWidth)=0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -124,7 +124,7 @@ struct nsTableReflowState {
|
|||
reason = aReason;
|
||||
|
||||
nsTableFrame* table = (nsTableFrame*)aTableFrame.GetFirstInFlow();
|
||||
nsMargin borderPadding = table->GetChildAreaOffset(&aPresContext, &reflowState);
|
||||
nsMargin borderPadding = table->GetChildAreaOffset(&reflowState);
|
||||
|
||||
x = borderPadding.left;
|
||||
y = borderPadding.top;
|
||||
|
@ -1126,7 +1126,7 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
|
|||
PRBool aConsiderSpans)
|
||||
{
|
||||
//printf("insertRowsBefore firstRow=%d \n", aRowIndex);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
PRInt32 numColsToAdd = 0;
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
|
@ -1158,7 +1158,7 @@ nsTableFrame::InsertRows(nsIPresContext& aPresContext,
|
|||
}
|
||||
|
||||
//printf("insertRowsAfter \n");
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
return numColsToAdd;
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
|
|||
PRBool aConsiderSpans)
|
||||
{
|
||||
//printf("removeRowsBefore firstRow=%d numRows=%d\n", aFirstRowIndex, aNumRowsToRemove);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
|
||||
|
||||
#ifdef TBD_OPTIMIZATION
|
||||
|
@ -1212,7 +1212,7 @@ void nsTableFrame::RemoveRows(nsIPresContext& aPresContext,
|
|||
}
|
||||
AdjustRowIndices(&aPresContext, firstRowIndex, -aNumRowsToRemove);
|
||||
//printf("removeRowsAfter\n");
|
||||
//Dump(&aPresContext, PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
//Dump(PR_TRUE, PR_FALSE, PR_TRUE);
|
||||
}
|
||||
|
||||
void nsTableFrame::AppendRowGroups(nsIPresContext& aPresContext,
|
||||
|
@ -1935,7 +1935,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
PR_FALSE, aStatus, lastReflowed,
|
||||
overflowArea);
|
||||
}
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
}
|
||||
}
|
||||
if (!mPrevInFlow) {
|
||||
|
@ -1981,7 +1981,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
if (NeedsReflow(aReflowState) && (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)) {
|
||||
// see if an extra reflow will be necessary in pagination mode when there is a specified table height
|
||||
if (isPaginated && !mPrevInFlow && (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight)) {
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((tableSpecifiedHeight > 0) &&
|
||||
(tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE)) {
|
||||
SetNeedToInitiateSpecialReflow(PR_TRUE);
|
||||
|
@ -2006,7 +2006,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
}
|
||||
if (willInitiateSpecialReflow && NS_FRAME_IS_COMPLETE(aStatus)) {
|
||||
// distribute extra vertical space to rows
|
||||
aDesiredSize.height = CalcDesiredHeight(aPresContext, aReflowState);
|
||||
aDesiredSize.height = CalcDesiredHeight(aReflowState);
|
||||
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = PR_TRUE;
|
||||
// save the previous special height reflow initiator, install us as the new one
|
||||
nsIFrame* specialReflowInitiator = aReflowState.mPercentHeightReflowInitiator;
|
||||
|
@ -2022,7 +2022,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* 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(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
aDesiredSize.height = borderPadding.top + GetCellSpacingY() +
|
||||
lastChildReflowed->GetSize().height;
|
||||
}
|
||||
|
@ -2043,13 +2043,13 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
|
||||
aDesiredSize.width = GetDesiredWidth();
|
||||
if (!haveDesiredHeight) {
|
||||
aDesiredSize.height = CalcDesiredHeight(aPresContext, aReflowState);
|
||||
aDesiredSize.height = CalcDesiredHeight(aReflowState);
|
||||
}
|
||||
if (IsRowInserted()) {
|
||||
ProcessRowInserted(aPresContext, *this, PR_TRUE, aDesiredSize.height);
|
||||
}
|
||||
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
SetColumnDimensions(aPresContext, aDesiredSize.height, borderPadding);
|
||||
if (doCollapse) {
|
||||
AdjustForCollapsingRows(aPresContext, aDesiredSize.height);
|
||||
|
@ -2070,7 +2070,7 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext,
|
|||
((eReflowReason_Resize == aReflowState.reason) &&
|
||||
HasPctCol() && IsAutoWidth())) {
|
||||
nscoord minWidth, prefWidth;
|
||||
CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_TRUE, minWidth, prefWidth);
|
||||
CalcMinAndPreferredWidths(aReflowState, PR_TRUE, minWidth, prefWidth);
|
||||
SetMinWidth(minWidth);
|
||||
SetPreferredWidth(prefWidth);
|
||||
}
|
||||
|
@ -2139,7 +2139,7 @@ nsTableFrame::ReflowTable(nsIPresContext* aPresContext,
|
|||
PRBool haveReflowedColGroups = PR_TRUE;
|
||||
if (!mPrevInFlow) {
|
||||
if (NeedStrategyInit()) {
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
BalanceColumnWidths(aPresContext, aReflowState);
|
||||
aDidBalance = PR_TRUE;
|
||||
}
|
||||
|
@ -2754,15 +2754,15 @@ DivideBCBorderSize(nscoord aPixelSize,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetBCBorder(nsIPresContext* aPresContext) const
|
||||
nsTableFrame::GetBCBorder() const
|
||||
{
|
||||
nsMargin border(0, 0, 0, 0);
|
||||
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
GET_PIXELS_TO_TWIPS(presContext, p2t);
|
||||
BCPropertyData* propData =
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(aPresContext, (nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(presContext, (nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
if (propData) {
|
||||
if (eCompatibility_NavQuirks != aPresContext->CompatibilityMode()) {
|
||||
if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) {
|
||||
nscoord smallHalf, largeHalf;
|
||||
|
||||
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf);
|
||||
|
@ -2828,17 +2828,17 @@ void GetSeparateModelBorderPadding(const nsHTMLReflowState* aReflowState,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetChildAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const
|
||||
nsTableFrame::GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const
|
||||
{
|
||||
nsMargin offset(0,0,0,0);
|
||||
if (IsBorderCollapse()) {
|
||||
if (eCompatibility_NavQuirks == aPresContext->CompatibilityMode()) {
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) {
|
||||
nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset);
|
||||
nscoord smallHalf, largeHalf;
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
GET_PIXELS_TO_TWIPS(presContext, p2t);
|
||||
BCPropertyData* propData =
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(aPresContext, (nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
(BCPropertyData*)nsTableFrame::GetProperty(presContext, (nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE);
|
||||
if (!propData) ABORT1(offset);
|
||||
|
||||
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf);
|
||||
|
@ -2861,12 +2861,11 @@ nsTableFrame::GetChildAreaOffset(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nsMargin
|
||||
nsTableFrame::GetContentAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const
|
||||
nsTableFrame::GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const
|
||||
{
|
||||
nsMargin offset(0,0,0,0);
|
||||
if (IsBorderCollapse()) {
|
||||
offset = GetBCBorder(aPresContext);
|
||||
offset = GetBCBorder();
|
||||
}
|
||||
else {
|
||||
GetSeparateModelBorderPadding(aReflowState, *mStyleContext, offset);
|
||||
|
@ -2878,11 +2877,10 @@ nsTableFrame::GetContentAreaOffset(nsIPresContext* aPresContext,
|
|||
// reflowed. Restores y, footerFrame, firstBodySection and availSize.height (if
|
||||
// the height is constrained)
|
||||
nsresult
|
||||
nsTableFrame::RecoverState(nsIPresContext& aPresContext,
|
||||
nsTableReflowState& aReflowState,
|
||||
nsTableFrame::RecoverState(nsTableReflowState& aReflowState,
|
||||
nsIFrame* aKidFrame)
|
||||
{
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aPresContext, &aReflowState.reflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState.reflowState);
|
||||
aReflowState.y = borderPadding.top;
|
||||
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
|
@ -2963,7 +2961,7 @@ nsTableFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|||
if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER);
|
||||
nsresult rv;
|
||||
// Recover the state as if aNextFrame is about to be reflowed
|
||||
RecoverState(*aPresContext, aReflowState, aNextFrame);
|
||||
RecoverState(aReflowState, aNextFrame);
|
||||
|
||||
// Remember the old rect
|
||||
nsRect oldKidRect = aNextFrame->GetRect();
|
||||
|
@ -3358,20 +3356,20 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// reflow gets called twice and the 2nd time has the correct space available.
|
||||
// XXX this is very bad and needs to be changed
|
||||
if (!IsAutoLayout()) {
|
||||
mTableLayoutStrategy->Initialize(aPresContext, aReflowState);
|
||||
mTableLayoutStrategy->Initialize(aReflowState);
|
||||
}
|
||||
|
||||
// need to figure out the overall table width constraint
|
||||
// default case, get 100% of available space
|
||||
|
||||
mTableLayoutStrategy->BalanceColumnWidths(aPresContext, aReflowState);
|
||||
//Dump(&aPresContext, PR_TRUE, PR_TRUE);
|
||||
mTableLayoutStrategy->BalanceColumnWidths(aReflowState);
|
||||
//Dump(PR_TRUE, PR_TRUE);
|
||||
SetNeedStrategyBalance(PR_FALSE); // we have just balanced
|
||||
// cache the min, desired, and preferred widths
|
||||
nscoord minWidth, prefWidth;
|
||||
CalcMinAndPreferredWidths(aPresContext, aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
CalcMinAndPreferredWidths(aReflowState, PR_FALSE, minWidth, prefWidth);
|
||||
SetMinWidth(minWidth);
|
||||
nscoord desWidth = CalcDesiredWidth(*aPresContext, aReflowState);
|
||||
nscoord desWidth = CalcDesiredWidth(aReflowState);
|
||||
SetDesiredWidth(desWidth);
|
||||
SetPreferredWidth(prefWidth);
|
||||
|
||||
|
@ -3380,8 +3378,7 @@ void nsTableFrame::BalanceColumnWidths(nsIPresContext* aPresContext,
|
|||
// This width is based on the column widths array of the table.
|
||||
// sum the width of each column and add in table insets
|
||||
nscoord
|
||||
nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
nsTableFrame::CalcDesiredWidth(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
NS_ASSERTION(!mPrevInFlow, "never ever call me on a continuing frame!");
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
|
@ -3412,7 +3409,7 @@ nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
|||
tableWidth = PR_MAX(tableWidth, compWidth);
|
||||
|
||||
// Add the width between the border edge and the child area
|
||||
nsMargin childOffset = GetChildAreaOffset(&aPresContext, &aReflowState);
|
||||
nsMargin childOffset = GetChildAreaOffset(&aReflowState);
|
||||
tableWidth += childOffset.left + childOffset.right;
|
||||
|
||||
return tableWidth;
|
||||
|
@ -3420,8 +3417,7 @@ nsTableFrame::CalcDesiredWidth(nsIPresContext& aPresContext,
|
|||
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState)
|
||||
nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState)
|
||||
{
|
||||
nsTableCellMap* cellMap = GetCellMap();
|
||||
if (!cellMap) {
|
||||
|
@ -3429,7 +3425,7 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
return 0;
|
||||
}
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
|
||||
// get the natural height based on the last child's (row group or scroll frame) rect
|
||||
nsAutoVoidArray rowGroups;
|
||||
|
@ -3437,7 +3433,7 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
OrderRowGroups(rowGroups, numRowGroups, nsnull);
|
||||
if (numRowGroups <= 0) {
|
||||
// tables can be used as rectangular items without content
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((NS_UNCONSTRAINEDSIZE != tableSpecifiedHeight) &&
|
||||
(tableSpecifiedHeight > 0))
|
||||
return tableSpecifiedHeight;
|
||||
|
@ -3454,14 +3450,14 @@ nsTableFrame::CalcDesiredHeight(nsIPresContext* aPresContext,
|
|||
|
||||
// see if a specified table height requires dividing additional space to rows
|
||||
if (!mPrevInFlow) {
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aPresContext, aReflowState);
|
||||
nscoord tableSpecifiedHeight = CalcBorderBoxHeight(aReflowState);
|
||||
if ((tableSpecifiedHeight > 0) &&
|
||||
(tableSpecifiedHeight != NS_UNCONSTRAINEDSIZE) &&
|
||||
(tableSpecifiedHeight > desiredHeight)) {
|
||||
// proportionately distribute the excess height to unconstrained rows in each
|
||||
// unconstrained row group.We don't need to do this if it's an unconstrained reflow
|
||||
if (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth) {
|
||||
DistributeHeightToRows(aPresContext, aReflowState, tableSpecifiedHeight - desiredHeight);
|
||||
DistributeHeightToRows(aReflowState, tableSpecifiedHeight - desiredHeight);
|
||||
}
|
||||
desiredHeight = tableSpecifiedHeight;
|
||||
}
|
||||
|
@ -3509,16 +3505,16 @@ void ResizeCells(nsTableFrame& aTableFrame,
|
|||
}
|
||||
|
||||
void
|
||||
nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAmount)
|
||||
{
|
||||
{
|
||||
nsIPresContext *presContext = GetPresContext();
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
presContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nscoord cellSpacingY = GetCellSpacingY();
|
||||
|
||||
nsMargin borderPadding = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin borderPadding = GetChildAreaOffset(&aReflowState);
|
||||
|
||||
nsVoidArray rowGroups;
|
||||
PRUint32 numRowGroups;
|
||||
|
@ -3552,13 +3548,13 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
amountUsed += amountForRow;
|
||||
amountUsedByRG += amountForRow;
|
||||
//rowFrame->DidResize(aPresContext, aReflowState);
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (amountUsed > 0) {
|
||||
rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
yOriginRow += rowRect.height + cellSpacingY;
|
||||
yEndRG += rowRect.height + cellSpacingY;
|
||||
|
@ -3574,13 +3570,13 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
else if (amountUsed > 0) {
|
||||
rgFrame->SetPosition(nsPoint(0, yOriginRG));
|
||||
// Make sure child views are properly positioned
|
||||
nsTableFrame::RePositionViews(aPresContext, rgFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rgFrame);
|
||||
}
|
||||
yOriginRG = yEndRG;
|
||||
}
|
||||
|
||||
if (amountUsed >= aAmount) {
|
||||
ResizeCells(*this, aPresContext, aReflowState);
|
||||
ResizeCells(*this, presContext, aReflowState);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3657,12 +3653,12 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
amountUsedByRG += amountForRow;
|
||||
NS_ASSERTION((amountUsed <= aAmount), "invalid row allocation");
|
||||
//rowFrame->DidResize(aPresContext, aReflowState);
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
else {
|
||||
if (amountUsed > 0) {
|
||||
rowFrame->SetPosition(nsPoint(rowRect.x, yOriginRow));
|
||||
nsTableFrame::RePositionViews(aPresContext, rowFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rowFrame);
|
||||
}
|
||||
yOriginRow += rowRect.height + cellSpacingY;
|
||||
yEndRG += rowRect.height + cellSpacingY;
|
||||
|
@ -3680,12 +3676,12 @@ nsTableFrame::DistributeHeightToRows(nsIPresContext* aPresContext,
|
|||
else if (amountUsed > 0) {
|
||||
rgFrame->SetPosition(nsPoint(0, yOriginRG));
|
||||
// Make sure child views are properly positioned
|
||||
nsTableFrame::RePositionViews(aPresContext, rgFrame);
|
||||
nsTableFrame::RePositionViews(presContext, rgFrame);
|
||||
}
|
||||
yOriginRG = yEndRG;
|
||||
}
|
||||
|
||||
ResizeCells(*this, aPresContext, aReflowState);
|
||||
ResizeCells(*this, presContext, aReflowState);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4127,8 +4123,7 @@ nsTableFrame::IsAutoHeight()
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aState)
|
||||
nsTableFrame::CalcBorderBoxWidth(const nsHTMLReflowState& aState)
|
||||
{
|
||||
nscoord width = aState.mComputedWidth;
|
||||
|
||||
|
@ -4141,14 +4136,14 @@ nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else if (width != NS_UNCONSTRAINEDSIZE) {
|
||||
nsMargin borderPadding = GetContentAreaOffset(aPresContext, &aState);
|
||||
nsMargin borderPadding = GetContentAreaOffset(&aState);
|
||||
width += borderPadding.left + borderPadding.right;
|
||||
}
|
||||
width = PR_MAX(width, 0);
|
||||
|
||||
if (NS_UNCONSTRAINEDSIZE != width) {
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
GetPresContext()->GetPixelsToTwips(&p2t);
|
||||
width = RoundToPixel(width, p2t);
|
||||
}
|
||||
|
||||
|
@ -4156,12 +4151,11 @@ nsTableFrame::CalcBorderBoxWidth(nsIPresContext* aPresContext,
|
|||
}
|
||||
|
||||
nscoord
|
||||
nsTableFrame::CalcBorderBoxHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aState)
|
||||
nsTableFrame::CalcBorderBoxHeight(const nsHTMLReflowState& aState)
|
||||
{
|
||||
nscoord height = aState.mComputedHeight;
|
||||
if (NS_AUTOHEIGHT != height) {
|
||||
nsMargin borderPadding = GetContentAreaOffset(aPresContext, &aState);
|
||||
nsMargin borderPadding = GetContentAreaOffset(&aState);
|
||||
height += borderPadding.top + borderPadding.bottom;
|
||||
}
|
||||
height = PR_MAX(0, height);
|
||||
|
@ -4197,13 +4191,11 @@ nsTableFrame::GetFrameName(nsAString& aResult) const
|
|||
|
||||
|
||||
void
|
||||
nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsTableFrame::CalcMinAndPreferredWidths(const nsHTMLReflowState& aReflowState,
|
||||
PRBool aCalcPrefWidthIfAutoWithPctCol,
|
||||
nscoord& aMinWidth,
|
||||
nscoord& aPrefWidth)
|
||||
{
|
||||
if (!aPresContext) ABORT0();
|
||||
aMinWidth = aPrefWidth = 0;
|
||||
|
||||
nscoord spacingX = GetCellSpacingX();
|
||||
|
@ -4225,7 +4217,7 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
}
|
||||
// if it is not a degenerate table, add the last spacing on the right and the borderPadding
|
||||
if (numCols > 0) {
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin childAreaOffset = GetChildAreaOffset( &aReflowState);
|
||||
nscoord extra = spacingX + childAreaOffset.left + childAreaOffset.right;
|
||||
aMinWidth += extra;
|
||||
aPrefWidth += extra;
|
||||
|
@ -4237,12 +4229,10 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
if (HasPctCol() && aCalcPrefWidthIfAutoWithPctCol &&
|
||||
(NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)) {
|
||||
// for an auto table with a pct cell, use the strategy's CalcPctAdjTableWidth
|
||||
nscoord availWidth = CalcBorderBoxWidth(aPresContext, aReflowState);
|
||||
nscoord availWidth = CalcBorderBoxWidth(aReflowState);
|
||||
availWidth = PR_MIN(availWidth, aReflowState.availableWidth);
|
||||
if (mTableLayoutStrategy && IsAutoLayout()) {
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
aPrefWidth = mTableLayoutStrategy->CalcPctAdjTableWidth(*aPresContext, aReflowState, availWidth, p2t);
|
||||
aPrefWidth = mTableLayoutStrategy->CalcPctAdjTableWidth(aReflowState, availWidth);
|
||||
}
|
||||
}
|
||||
if (0 == numCols) { // degenerate case
|
||||
|
@ -4252,7 +4242,7 @@ nsTableFrame::CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
|||
else { // a specified fix width becomes the min or preferred width
|
||||
nscoord compWidth = aReflowState.mComputedWidth;
|
||||
if ((NS_UNCONSTRAINEDSIZE != compWidth) && (0 != compWidth) && !isPctWidth) {
|
||||
nsMargin contentOffset = GetContentAreaOffset(aPresContext, &aReflowState);
|
||||
nsMargin contentOffset = GetContentAreaOffset(&aReflowState);
|
||||
compWidth += contentOffset.left + contentOffset.right;
|
||||
aMinWidth = PR_MAX(aMinWidth, compWidth);
|
||||
aPrefWidth = PR_MAX(aMinWidth, compWidth);
|
||||
|
@ -4323,8 +4313,7 @@ nsTableFrame::DumpRowGroup(nsIPresContext* aPresContext, nsIFrame* aKidFrame)
|
|||
}
|
||||
|
||||
void
|
||||
nsTableFrame::Dump(nsIPresContext* aPresContext,
|
||||
PRBool aDumpRows,
|
||||
nsTableFrame::Dump(PRBool aDumpRows,
|
||||
PRBool aDumpCols,
|
||||
PRBool aDumpCellMap)
|
||||
{
|
||||
|
@ -4341,7 +4330,7 @@ nsTableFrame::Dump(nsIPresContext* aPresContext,
|
|||
if (aDumpRows) {
|
||||
nsIFrame* kidFrame = mFrames.FirstChild();
|
||||
while (kidFrame) {
|
||||
DumpRowGroup(aPresContext, kidFrame);
|
||||
DumpRowGroup(GetPresContext(), kidFrame);
|
||||
kidFrame = kidFrame->GetNextSibling();
|
||||
}
|
||||
}
|
||||
|
@ -6580,7 +6569,7 @@ nsTableFrame::PaintBCBorders(nsIPresContext* aPresContext,
|
|||
nsIRenderingContext& aRenderingContext,
|
||||
const nsRect& aDirtyRect)
|
||||
{
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(aPresContext, nsnull);
|
||||
nsMargin childAreaOffset = GetChildAreaOffset(nsnull);
|
||||
nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT0();
|
||||
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
||||
|
||||
|
|
|
@ -272,12 +272,10 @@ public:
|
|||
nsIFrame* aOldFrame);
|
||||
|
||||
// Get the offset from the border box to the area where the row groups fit
|
||||
nsMargin GetChildAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const;
|
||||
nsMargin GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const;
|
||||
|
||||
// Get the offset from the border box to the area where the content fits
|
||||
nsMargin GetContentAreaOffset(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState* aReflowState) const;
|
||||
nsMargin GetContentAreaOffset(const nsHTMLReflowState* aReflowState) const;
|
||||
|
||||
/** helper method to find the table parent of any table frame object */
|
||||
// TODO: today, this depends on display types. This should be changed to rely
|
||||
|
@ -331,7 +329,7 @@ public:
|
|||
nsFramePaintLayer aWhichLayer,
|
||||
PRUint32 aFlags = 0);
|
||||
|
||||
nsMargin GetBCBorder(nsIPresContext* aPresContext) const;
|
||||
nsMargin GetBCBorder() const;
|
||||
|
||||
// get the area that the border leak out from the inner table frame into
|
||||
// the surrounding margin space
|
||||
|
@ -662,8 +660,7 @@ protected:
|
|||
nsIFrame* aKidFrame,
|
||||
nscoord aDeltaY);
|
||||
|
||||
nsresult RecoverState(nsIPresContext& aPresContext,
|
||||
nsTableReflowState& aReflowState,
|
||||
nsresult RecoverState(nsTableReflowState& aReflowState,
|
||||
nsIFrame* aKidFrame);
|
||||
|
||||
NS_METHOD CollapseRowGroupIfNecessary(nsIPresContext* aPresContext,
|
||||
|
@ -685,35 +682,29 @@ public:
|
|||
|
||||
// calculate the computed width of aFrame including its border and padding given
|
||||
// its reflow state.
|
||||
nscoord CalcBorderBoxWidth(nsIPresContext* aPresContex,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcBorderBoxWidth(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// calculate the computed height of aFrame including its border and padding given
|
||||
// its reflow state.
|
||||
nscoord CalcBorderBoxHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcBorderBoxHeight(const nsHTMLReflowState& aReflowState);
|
||||
// calculate the minimum width to layout aFrame and its desired width
|
||||
// including border and padding given its reflow state and column width information
|
||||
void CalcMinAndPreferredWidths(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
void CalcMinAndPreferredWidths(const nsHTMLReflowState& aReflowState,
|
||||
PRBool aCalcPrefWidthIfAutoWithPctCol,
|
||||
nscoord& aMinWidth,
|
||||
nscoord& aPreferredWidth);
|
||||
protected:
|
||||
|
||||
// calcs the width of the table according to the computed widths of each column.
|
||||
virtual PRInt32 CalcDesiredWidth(nsIPresContext& aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
virtual PRInt32 CalcDesiredWidth(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// return the desired height of this table accounting for the current
|
||||
// reflow state, and for the table attributes and parent
|
||||
nscoord CalcDesiredHeight(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState);
|
||||
nscoord CalcDesiredHeight(const nsHTMLReflowState& aReflowState);
|
||||
|
||||
// The following is a helper for CalcDesiredHeight
|
||||
|
||||
void DistributeHeightToRows(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
void DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
|
||||
nscoord aAmount);
|
||||
|
||||
void PlaceChild(nsIPresContext* aPresContext,
|
||||
|
@ -912,8 +903,7 @@ public: /* ----- Cell Map public methods ----- */
|
|||
public:
|
||||
static nsIAtom* gColGroupAtom;
|
||||
#ifdef DEBUG
|
||||
void Dump(nsIPresContext* aPresContext,
|
||||
PRBool aDumpRows,
|
||||
void Dump(PRBool aDumpRows,
|
||||
PRBool aDumpCols,
|
||||
PRBool aDumpCellMap);
|
||||
#endif
|
||||
|
|
|
@ -466,7 +466,7 @@ nsTableOuterFrame::InitChildReflowState(nsIPresContext& aPresContext,
|
|||
if (mInnerTableFrame->NeedToCalcBCBorders()) {
|
||||
mInnerTableFrame->CalcBCBorders(aPresContext);
|
||||
}
|
||||
collapseBorder = mInnerTableFrame->GetBCBorder(&aPresContext);
|
||||
collapseBorder = mInnerTableFrame->GetBCBorder();
|
||||
pCollapseBorder = &collapseBorder;
|
||||
pCollapsePadding = &collapsePadding;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче