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