From 9772df345f8496a69c8d415fbeb7a70d4055b1c9 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Thu, 22 Feb 2007 20:22:12 +0000 Subject: [PATCH] Remove the remainder of the pixel rounding in the table code. b=371187 r=bernd sr=roc --- layout/reftests/table-width/reftest.list | 8 +++---- layout/tables/nsTableCellFrame.cpp | 8 ------- layout/tables/nsTableFrame.cpp | 27 ++---------------------- layout/tables/nsTableFrame.h | 5 ----- layout/tables/nsTableOuterFrame.cpp | 7 +----- layout/tables/nsTableRowGroupFrame.cpp | 18 ++++++---------- 6 files changed, 14 insertions(+), 59 deletions(-) diff --git a/layout/reftests/table-width/reftest.list b/layout/reftests/table-width/reftest.list index 197a0f9cdda..7d37991b9d0 100644 --- a/layout/reftests/table-width/reftest.list +++ b/layout/reftests/table-width/reftest.list @@ -38,9 +38,9 @@ == balancing-1.html balancing-1-ref.html == balancing-2.html balancing-2-ref.html == cellpadding.html cellpadding-ref.html -random == cellspacing.html cellspacing-ref.html # bug 371187 (via bug 371188) -random == percent-basis.html percent-basis-ref.html # bug 371187 (plus bug 371188 too) -fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") random == default-box-sizing-separate-standards.html default-box-sizing-separate-standards-ref.html # bug 361523, bug 371187 -fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") random == default-box-sizing-separate-quirks.html default-box-sizing-separate-quirks-ref.html # bug 361523, bug 371187 +== cellspacing.html cellspacing-ref.html +== percent-basis.html percent-basis-ref.html +fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == default-box-sizing-separate-standards.html default-box-sizing-separate-standards-ref.html # bug 361523 +fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == default-box-sizing-separate-quirks.html default-box-sizing-separate-quirks-ref.html # bug 361523 fails == default-box-sizing-collapse-standards.html default-box-sizing-collapse-standards-ref.html # bug 155955, bug 371180, bug 371182 fails == default-box-sizing-collapse-quirks.html default-box-sizing-collapse-quirks-ref.html # bug 371180, bug 371182 diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 78e466ead76..dbe164e799e 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -568,7 +568,6 @@ void nsTableCellFrame::VerticallyAlignChild(nscoord aMaxAscent) case NS_STYLE_VERTICAL_ALIGN_MIDDLE: // Align the middle of the child frame with the middle of the content area, kidYTop = (height - childHeight - bottomInset + topInset) / 2; - kidYTop = nsTableFrame::RoundToPixel(kidYTop, eAlwaysRoundDown); } // if the content is larger than the cell height align from top kidYTop = PR_MAX(0, kidYTop); @@ -758,9 +757,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, // work around pixel rounding errors, round down to ensure we don't exceed the avail height in nscoord availHeight = aReflowState.availableHeight; - if (NS_UNCONSTRAINEDSIZE != availHeight) { - availHeight = nsTableFrame::RoundToPixel(availHeight, eAlwaysRoundDown); - } // see if a special height reflow needs to occur due to having a pct height nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState); @@ -851,9 +847,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, if (NS_UNCONSTRAINEDSIZE != cellHeight) { cellHeight += topInset + bottomInset; - // work around block rounding errors, round down to ensure we don't exceed the avail height in - nsPixelRound roundMethod = (NS_UNCONSTRAINEDSIZE == availHeight) ? eAlwaysRoundUp : eAlwaysRoundDown; - cellHeight = nsTableFrame::RoundToPixel(cellHeight, roundMethod); } // next determine the cell's width @@ -863,7 +856,6 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, if (NS_UNCONSTRAINEDSIZE != cellWidth) { cellWidth += leftInset + rightInset; } - cellWidth = nsTableFrame::RoundToPixel(cellWidth); // work around block rounding errors // set the cell's desired size and max element size aDesiredSize.width = cellWidth; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 97fec85d9fa..19fd37661bf 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -273,29 +273,6 @@ nsTableFrame::Destroy() nsHTMLContainerFrame::Destroy(); } -nscoord -nsTableFrame::RoundToPixel(nscoord aValue, - nsPixelRound aRound) -{ - nscoord fullPixel = nsPresContext::CSSPixelsToAppUnits(1); - - PRInt32 excess = aValue % fullPixel; - if (0 == excess) - return aValue; - - nscoord halfPixel = nsPresContext::CSSPixelsToAppUnits(0.5f); - switch(aRound) { - case eRoundUpIfHalfOrMore: - if (excess >= halfPixel) { // eRoundUpIfHalfOrMore - return aValue + (fullPixel - excess); - } - case eAlwaysRoundDown: - return aValue - excess; - default: // eAlwaysRoundUp - return aValue + (fullPixel - excess); - } -} - // Make sure any views are positioned properly void nsTableFrame::RePositionViews(nsIFrame* aFrame) @@ -3115,7 +3092,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, while (rowFrame) { nsRect rowRect = rowFrame->GetRect(); if ((amountUsed < aAmount) && rowFrame->HasPctHeight()) { - nscoord pctHeight = nsTableFrame::RoundToPixel(rowFrame->GetHeight(pctBasis)); + nscoord pctHeight = rowFrame->GetHeight(pctBasis); nscoord amountForRow = PR_MIN(aAmount - amountUsed, pctHeight - rowRect.height); if (amountForRow > 0) { rowRect.height += amountForRow; @@ -3219,7 +3196,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState, // give rows their percentage, except for the last row which gets the remainder nscoord amountForRow = (rowFrame == lastElligibleRow) ? aAmount - amountUsed : NSToCoordRound(((float)(pctBasis)) * percent); - amountForRow = PR_MIN(nsTableFrame::RoundToPixel(amountForRow), aAmount - amountUsed); + amountForRow = PR_MIN(amountForRow, aAmount - amountUsed); // update the row height nsRect newRowRect(rowRect.x, yOriginRow, rowRect.width, rowRect.height + amountForRow); rowFrame->SetRect(newRowRect); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index b1612df31d4..aafe863dcb6 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -59,8 +59,6 @@ class nsStyleContext; struct nsTableReflowState; struct nsStylePosition; -enum nsPixelRound {eAlwaysRoundUp=0, eAlwaysRoundDown, eRoundUpIfHalfOrMore}; - /** * Child list name indices * @see #GetAdditionalChildListName() @@ -117,9 +115,6 @@ public: static float GetTwipsToPixels(nsPresContext* aPresContext); - static nscoord RoundToPixel(nscoord aValue, - nsPixelRound aRound= eAlwaysRoundUp); - // See if a special height reflow will occur due to having a pct height when // the pct height basis may not yet be valid. static void CheckRequestSpecialHeightReflow(const nsHTMLReflowState& aReflowState); diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index eab6d50161e..bb17305ea60 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -453,7 +453,7 @@ nscoord CalcAutoMargin(nscoord aAutoMargin, { nscoord margin; if (NS_AUTOMARGIN == aOppositeMargin) - margin = nsTableFrame::RoundToPixel((aContainBlockSize - aFrameSize) / 2); + margin = (aContainBlockSize - aFrameSize) / 2; else { margin = aContainBlockSize - aFrameSize - aOppositeMargin; } @@ -804,8 +804,6 @@ nsTableOuterFrame::BalanceLeftRightCaption(PRUint8 aCaptionSide, else { aCaptionWidth = (nscoord) ((capPercent / innerPercent) * aInnerWidth); } - aCaptionWidth = nsTableFrame::RoundToPixel(aCaptionWidth, - eAlwaysRoundDown); } nsresult @@ -1079,9 +1077,6 @@ nsTableOuterFrame::OuterReflowChild(nsPresContext* aPresContext, NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.bottom, "No unconstrainedsize arithmetic, please"); availHeight -= margin.bottom; - - availHeight = nsTableFrame::RoundToPixel(availHeight, - eAlwaysRoundDown); } nsSize availSize(aAvailWidth, availHeight); // create and init the child reflow state, using placement new on diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index 96697bf51bf..3b2f54b6b7b 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -601,10 +601,10 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, if (!rowFrame->GetPrevInFlow()) { if (rowFrame->HasPctHeight()) { rowInfo[rowIndex].hasPctHeight = PR_TRUE; - rowInfo[rowIndex].pctHeight = nsTableFrame::RoundToPixel(rowFrame->GetHeight(pctHeightBasis)); + rowInfo[rowIndex].pctHeight = rowFrame->GetHeight(pctHeightBasis); } rowInfo[rowIndex].hasStyleHeight = rowFrame->HasStyleHeight(); - nonPctHeight = nsTableFrame::RoundToPixel(PR_MAX(nonPctHeight, rowFrame->GetFixedHeight())); + nonPctHeight = PR_MAX(nonPctHeight, rowFrame->GetFixedHeight()); } UpdateHeights(rowInfo[rowIndex], nonPctHeight, heightOfRows, heightOfUnStyledRows); @@ -699,7 +699,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, // give rows their percentage, except for the first row which gets the remainder nscoord extraForRow = (0 == spanX) ? extra - extraUsed : NSToCoordRound(((float)(extra)) * percent); - extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow), extra - extraUsed); + extraForRow = PR_MIN(extraForRow, extra - extraUsed); // update the row height UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows); extraUsed += extraForRow; @@ -727,7 +727,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, nscoord extraForRow = (numSpecialRowsSpanned - 1 == numSpecialRowsAllocated) ? extra - extraUsed : NSToCoordRound(((float)(extra)) * percent); - extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow), extra - extraUsed); + extraForRow = PR_MIN(extraForRow, extra - extraUsed); // update the row height UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows); extraUsed += extraForRow; @@ -780,7 +780,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, nscoord extraForRow = (numRows - 1 == rowIndex) ? extraComputedHeight - extraUsed : NSToCoordRound(((float)extraComputedHeight) * percent); - extraForRow = PR_MIN(nsTableFrame::RoundToPixel(extraForRow), extraComputedHeight - extraUsed); + extraForRow = PR_MIN(extraForRow, extraComputedHeight - extraUsed); // update the row height UpdateHeights(rowInfo[rowIndex], extraForRow, heightOfRows, heightOfUnStyledRows); extraUsed += extraForRow; @@ -1040,12 +1040,8 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext, nsTableRowFrame* prevRowFrame = nsnull; aDesiredSize.height = 0; - nscoord availWidth = (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) ? - NS_UNCONSTRAINEDSIZE : - nsTableFrame::RoundToPixel(aReflowState.availableWidth); - nscoord availHeight = (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) ? - NS_UNCONSTRAINEDSIZE : - nsTableFrame::RoundToPixel(aReflowState.availableHeight); + nscoord availWidth = aReflowState.availableWidth; + nscoord availHeight = aReflowState.availableHeight; PRBool borderCollapse = ((nsTableFrame*)aTableFrame->GetFirstInFlow())->IsBorderCollapse(); nscoord cellSpacingY = aTableFrame->GetCellSpacingY();