prescontext removal part 2 bug 229631 r/sr=roc

This commit is contained in:
bmlk%gmx.de 2003-12-29 16:58:20 +00:00
Родитель 5bd21833b4
Коммит e763429e44
6 изменённых файлов: 34 добавлений и 46 удалений

Просмотреть файл

@ -102,8 +102,6 @@ protected:
* Computes the minimum and maximum table widths.
* Set column width information in each column frame and in the table frame.
*
* @param aMaxWidth - the computed width of the table or
* UNCONSTRAINED_SIZE if an auto width table
* @return PR_TRUE has a pct cell or col, PR_FALSE otherwise
*/
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,

Просмотреть файл

@ -64,10 +64,8 @@ PRBool FixedTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aR
* as determined by the table width attribute. If no table width attribute, it gets 0 width
*/
PRBool
FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState,
float aPixelToTwips)
FixedTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState)
{
// NS_ASSERTION(aComputedWidth != NS_UNCONSTRAINEDSIZE, "bad computed width");
const nsStylePosition* tablePosition = mTableFrame->GetStylePosition();
@ -76,6 +74,8 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
PRInt32 numCols = mTableFrame->GetColCount();
PRInt32 colX;
float pixelToTwips;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
// availWidth is used as the basis for percentage width columns. It is aComputedWidth
// minus table border, padding, & cellspacing
nscoord spacingX = mTableFrame->GetCellSpacingX();
@ -128,7 +128,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
// Only apply percentages if we're constrained.
float percent = colPosition->mWidth.GetPercentValue();
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth), aPixelToTwips);
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth), pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal+=colWidths[colX];
}
@ -150,10 +150,10 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add border and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
pixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
aPixelToTwips);
pixelToTwips);
colFrame->SetWidth(MIN_CON, colWidths[colX]);
}
else if ((eStyleUnit_Percent == cellPosition->mWidth.GetUnit()) &&
@ -161,10 +161,10 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
float percent = cellPosition->mWidth.GetPercentValue();
// need to add border and padding into percent width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
pixelToTwips, cellFrame);
cellWidth = NSToCoordRound(percent * (float) availWidth) + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
aPixelToTwips);
pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal += colWidths[colX];
}
@ -194,7 +194,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
float percent = ((float)propInfo[colX])/((float)propTotal);
amountToAllocate += NSToCoordRound(percent * (float)remainingWidth);
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
@ -214,7 +214,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
amountToAllocate += colAlloc;
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate,
aPixelToTwips,
pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
@ -229,7 +229,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (colWidths[colX] > 0) {
amountToAllocate += NSToCoordRound(remainingWidth * colWidths[colX] / divisor);
nscoord colAlloc = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] += colAlloc;
totalColWidth += colAlloc;
@ -249,7 +249,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
colWidths[colX] = 0;
// if there was too much allocated due to rounding, remove it from the last col
if ((colX == lastColAllocated) && (overAllocation != 0)) {
nscoord thisRemoval = nsTableFrame::RoundToPixel(overAllocation, aPixelToTwips);
nscoord thisRemoval = nsTableFrame::RoundToPixel(overAllocation, pixelToTwips);
colWidths[colX] -= thisRemoval;
totalColWidth -= thisRemoval;
@ -267,7 +267,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if(( colFrame->GetWidth(PCT) > 0) && ( percTotal > 0)){
amountToRemove += NSToCoordRound(overAllocation* colWidths[colX] / (float) percTotal);
nscoord thisRemoval = (amountToRemove > 0) ?
nsTableFrame::RoundToPixel(amountToRemove, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToRemove, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] -= thisRemoval;
amountToRemove -= thisRemoval;

Просмотреть файл

@ -76,12 +76,10 @@ public:
* Calculate the basis for percent width calculations of the table elements
* @param aReflowState - the reflow state of the table
* @param aAvailWidth - the available width for the table
* @param aPixelToTwips - the number of twips in a pixel.
* @return - the basis for percent calculations
*/
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
nscoord aAvailWidth,
float aPixelToTwips) {return 0;};
nscoord aAvailWidth) {return 0;};
protected:
/* assign the width of all columns
@ -97,10 +95,8 @@ protected:
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
*/
virtual PRBool AssignNonPctColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState,
float aPixelToTwips);
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState);
};

Просмотреть файл

@ -102,8 +102,6 @@ protected:
* Computes the minimum and maximum table widths.
* Set column width information in each column frame and in the table frame.
*
* @param aMaxWidth - the computed width of the table or
* UNCONSTRAINED_SIZE if an auto width table
* @return PR_TRUE has a pct cell or col, PR_FALSE otherwise
*/
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,

Просмотреть файл

@ -64,10 +64,8 @@ PRBool FixedTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aR
* as determined by the table width attribute. If no table width attribute, it gets 0 width
*/
PRBool
FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState,
float aPixelToTwips)
FixedTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState)
{
// NS_ASSERTION(aComputedWidth != NS_UNCONSTRAINEDSIZE, "bad computed width");
const nsStylePosition* tablePosition = mTableFrame->GetStylePosition();
@ -76,6 +74,8 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
PRInt32 numCols = mTableFrame->GetColCount();
PRInt32 colX;
float pixelToTwips;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
// availWidth is used as the basis for percentage width columns. It is aComputedWidth
// minus table border, padding, & cellspacing
nscoord spacingX = mTableFrame->GetCellSpacingX();
@ -128,7 +128,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
// Only apply percentages if we're constrained.
float percent = colPosition->mWidth.GetPercentValue();
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth), aPixelToTwips);
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth), pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal+=colWidths[colX];
}
@ -150,10 +150,10 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add border and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
pixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
aPixelToTwips);
pixelToTwips);
colFrame->SetWidth(MIN_CON, colWidths[colX]);
}
else if ((eStyleUnit_Percent == cellPosition->mWidth.GetUnit()) &&
@ -161,10 +161,10 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
float percent = cellPosition->mWidth.GetPercentValue();
// need to add border and padding into percent width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
aPixelToTwips, cellFrame);
pixelToTwips, cellFrame);
cellWidth = NSToCoordRound(percent * (float) availWidth) + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
aPixelToTwips);
pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal += colWidths[colX];
}
@ -194,7 +194,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
float percent = ((float)propInfo[colX])/((float)propTotal);
amountToAllocate += NSToCoordRound(percent * (float)remainingWidth);
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
@ -214,7 +214,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
amountToAllocate += colAlloc;
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate,
aPixelToTwips,
pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
@ -229,7 +229,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if (colWidths[colX] > 0) {
amountToAllocate += NSToCoordRound(remainingWidth * colWidths[colX] / divisor);
nscoord colAlloc = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] += colAlloc;
totalColWidth += colAlloc;
@ -249,7 +249,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
colWidths[colX] = 0;
// if there was too much allocated due to rounding, remove it from the last col
if ((colX == lastColAllocated) && (overAllocation != 0)) {
nscoord thisRemoval = nsTableFrame::RoundToPixel(overAllocation, aPixelToTwips);
nscoord thisRemoval = nsTableFrame::RoundToPixel(overAllocation, pixelToTwips);
colWidths[colX] -= thisRemoval;
totalColWidth -= thisRemoval;
@ -267,7 +267,7 @@ FixedTableLayoutStrategy::AssignNonPctColumnWidths(nsIPresContext* aPre
if(( colFrame->GetWidth(PCT) > 0) && ( percTotal > 0)){
amountToRemove += NSToCoordRound(overAllocation* colWidths[colX] / (float) percTotal);
nscoord thisRemoval = (amountToRemove > 0) ?
nsTableFrame::RoundToPixel(amountToRemove, aPixelToTwips,
nsTableFrame::RoundToPixel(amountToRemove, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] -= thisRemoval;
amountToRemove -= thisRemoval;

Просмотреть файл

@ -76,12 +76,10 @@ public:
* Calculate the basis for percent width calculations of the table elements
* @param aReflowState - the reflow state of the table
* @param aAvailWidth - the available width for the table
* @param aPixelToTwips - the number of twips in a pixel.
* @return - the basis for percent calculations
*/
virtual nscoord CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowState,
nscoord aAvailWidth,
float aPixelToTwips) {return 0;};
nscoord aAvailWidth) {return 0;};
protected:
/* assign the width of all columns
@ -97,10 +95,8 @@ protected:
* @return PR_TRUE if all is well, PR_FALSE if there was an unrecoverable error
*
*/
virtual PRBool AssignNonPctColumnWidths(nsIPresContext* aPresContext,
nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState,
float aPixelToTwips);
virtual PRBool AssignNonPctColumnWidths(nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState);
};