From f94ce773977e7b343d2de4fdf56830b08de8da0e Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Thu, 7 Apr 2005 18:04:38 +0000 Subject: [PATCH] Fix too-much-overflow regression by making border-collapse cells store the full width of the border rather than just the inside half of it. Also make BCPixelSize 16-bit instead of 8-bit and use it in more places, and a little other cleanup. b=286794 r=bernd sr=roc a=brendan git-svn-id: svn://10.0.0.236/trunk@171857 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/tables/celldata.h | 51 +++++--- mozilla/layout/tables/nsTableCellFrame.cpp | 43 +++--- mozilla/layout/tables/nsTableCellFrame.h | 21 +-- mozilla/layout/tables/nsTableColFrame.h | 2 +- mozilla/layout/tables/nsTableFrame.cpp | 122 +++++++----------- mozilla/layout/tables/nsTableFrame.h | 33 ----- mozilla/layout/tables/nsTableOuterFrame.cpp | 23 ++-- mozilla/layout/tables/nsTablePainter.h | 12 +- mozilla/layout/tables/nsTableRowFrame.h | 3 +- .../layout/tables/nsTableRowGroupFrame.cpp | 4 +- 10 files changed, 125 insertions(+), 189 deletions(-) diff --git a/mozilla/layout/tables/celldata.h b/mozilla/layout/tables/celldata.h index 6a66adf45c6..28c75c1d059 100644 --- a/mozilla/layout/tables/celldata.h +++ b/mozilla/layout/tables/celldata.h @@ -179,10 +179,21 @@ enum BCBorderOwner eAjaCellOwner = 10 // cell to the top or to the left }; +typedef PRUint16 BCPixelSize; + // These are the max sizes that are stored. If they are exceeded, then the max is stored and // the actual value is computed when needed. -#define MAX_BORDER_WIDTH 64 -#define MAX_CORNER_SUB_WIDTH 128 +#define MAX_BORDER_WIDTH nscoord(PR_BITMASK(sizeof(BCPixelSize) * 8)) + +#define BC_BORDER_TOP_HALF_COORD(p2t,px) NSToCoordRound(float((px) - (px) / 2) * (p2t) ) +#define BC_BORDER_RIGHT_HALF_COORD(p2t,px) NSToCoordRound(float( (px) / 2) * (p2t) ) +#define BC_BORDER_BOTTOM_HALF_COORD(p2t,px) NSToCoordRound(float( (px) / 2) * (p2t) ) +#define BC_BORDER_LEFT_HALF_COORD(p2t,px) NSToCoordRound(float((px) - (px) / 2) * (p2t) ) + +#define BC_BORDER_TOP_HALF(px) ((px) - (px) / 2) +#define BC_BORDER_RIGHT_HALF(px) ((px) / 2) +#define BC_BORDER_BOTTOM_HALF(px) ((px) / 2) +#define BC_BORDER_LEFT_HALF(px) ((px) - (px) / 2) // BCData stores the top and left border info and the corner connecting the two. class BCData @@ -206,11 +217,11 @@ public: nscoord aSize, PRBool aStart); - PRUint8 GetCorner(PRUint8& aCornerOwner, - PRPackedBool& aBevel) const; + BCPixelSize GetCorner(PRUint8& aCornerOwner, + PRPackedBool& aBevel) const; - void SetCorner(PRUint8 aOwner, - PRUint8 aSubSize, + void SetCorner(BCPixelSize aSubSize, + PRUint8 aOwner, PRBool aBevel); PRBool IsLeftStart() const; @@ -223,17 +234,19 @@ public: protected: + BCPixelSize mLeftSize; // size in pixels of left border + BCPixelSize mTopSize; // size in pixels of top border + BCPixelSize mCornerSubSize; // size of the largest border not in the + // dominant plane (for example, if corner is + // owned by the segment to its top or bottom, + // then the size is the max of the border + // sizes of the segments to its left or right. unsigned mLeftOwner: 4; // owner of left border - unsigned mLeftSize: 6; // size in pixels of left border - unsigned mLeftStart: 1; // set if this is the start of a vertical border segment - unsigned mCornerSide: 2; // side of the owner of the upper left corner relative to the corner - unsigned mCornerSubSize: 7; // size of the largest border not in the dominate plane (for example, if - // corner is owned by the segment to its top or bottom, then the size is the - // max of the border sizes of the segments to its left or right. - unsigned mCornerBevel: 1; // is the corner beveled (only two segments, perpendicular, not dashed or dotted). unsigned mTopOwner: 4; // owner of top border - unsigned mTopSize: 6; // size in pixels of top border + unsigned mLeftStart: 1; // set if this is the start of a vertical border segment unsigned mTopStart: 1; // set if this is the start of a horizontal border segment + unsigned mCornerSide: 2; // side of the owner of the upper left corner relative to the corner + unsigned mCornerBevel: 1; // is the corner beveled (only two segments, perpendicular, not dashed or dotted). }; // BCCellData entries replace CellData entries in the cell map if the border collapsing model is in @@ -437,19 +450,19 @@ inline void BCData::SetTopEdge(BCBorderOwner aOwner, mTopStart = aStart; } -inline PRUint8 BCData::GetCorner(PRUint8& aOwnerSide, - PRPackedBool& aBevel) const +inline BCPixelSize BCData::GetCorner(PRUint8& aOwnerSide, + PRPackedBool& aBevel) const { aOwnerSide = mCornerSide; aBevel = (PRBool)mCornerBevel; - return (PRUint8)mCornerSubSize; + return mCornerSubSize; } -inline void BCData::SetCorner(PRUint8 aSubSize, +inline void BCData::SetCorner(BCPixelSize aSubSize, PRUint8 aOwnerSide, PRBool aBevel) { - mCornerSubSize = (aSubSize > MAX_CORNER_SUB_WIDTH) ? MAX_CORNER_SUB_WIDTH : aSubSize; + mCornerSubSize = aSubSize; mCornerSide = aOwnerSide; mCornerBevel = aBevel; } diff --git a/mozilla/layout/tables/nsTableCellFrame.cpp b/mozilla/layout/tables/nsTableCellFrame.cpp index e24baaf9662..0cd19226155 100644 --- a/mozilla/layout/tables/nsTableCellFrame.cpp +++ b/mozilla/layout/tables/nsTableCellFrame.cpp @@ -1240,44 +1240,35 @@ nsBCTableCellFrame::GetFrameName(nsAString& aResult) const } #endif -void -nsBCTableCellFrame::SetBorderWidth(const nsMargin& aBorder) -{ - mTopBorder = aBorder.top; - mRightBorder = aBorder.right; - mBottomBorder = aBorder.bottom; - mLeftBorder = aBorder.left; -} - nsMargin* nsBCTableCellFrame::GetBorderWidth(float aPixelsToTwips, nsMargin& aBorder) const { - aBorder.top = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mTopBorder) : mTopBorder; - aBorder.right = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mRightBorder) : mRightBorder; - aBorder.bottom = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mBottomBorder): mBottomBorder; - aBorder.left = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mLeftBorder): mLeftBorder; + aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips, mTopBorder); + aBorder.right = BC_BORDER_LEFT_HALF_COORD(aPixelsToTwips, mRightBorder); + aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips, mBottomBorder); + aBorder.left = BC_BORDER_RIGHT_HALF_COORD(aPixelsToTwips, mLeftBorder); return &aBorder; } -nscoord +BCPixelSize nsBCTableCellFrame::GetBorderWidth(PRUint8 aSide) const { switch(aSide) { case NS_SIDE_TOP: - return (PRUint8)mTopBorder; + return BC_BORDER_BOTTOM_HALF(mTopBorder); case NS_SIDE_RIGHT: - return (PRUint8)mRightBorder; + return BC_BORDER_LEFT_HALF(mRightBorder); case NS_SIDE_BOTTOM: - return (PRUint8)mBottomBorder; + return BC_BORDER_TOP_HALF(mBottomBorder); default: - return (PRUint8)mLeftBorder; + return BC_BORDER_RIGHT_HALF(mLeftBorder); } } void nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide, - nscoord aValue) + BCPixelSize aValue) { switch(aSide) { case NS_SIDE_TOP: @@ -1298,15 +1289,11 @@ nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide, nsBCTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea) { nsMargin halfBorder; - GetBorderWidth(GetPresContext()->PixelsToTwips(), halfBorder); - // Since we have the inner half and we want an outer bound for the - // outer half, just inflate the right and bottom sides by a pixel. - // XXX Overestimating could lead to problems with outlines (although - // this is probably bad for outlines to begin with) and scrollable - // regions in 'overflow: auto' or 'overflow: scroll' containers. - nscoord onePixel = nscoord(GetPresContext()->PixelsToTwips() + 0.999); - halfBorder.right += onePixel; - halfBorder.bottom += onePixel; + float p2t = GetPresContext()->PixelsToTwips(); + halfBorder.top = BC_BORDER_TOP_HALF_COORD(p2t, mTopBorder); + halfBorder.right = BC_BORDER_RIGHT_HALF_COORD(p2t, mRightBorder); + halfBorder.bottom = BC_BORDER_BOTTOM_HALF_COORD(p2t, mBottomBorder); + halfBorder.left = BC_BORDER_LEFT_HALF_COORD(p2t, mLeftBorder); nsRect overflow(nsPoint(0,0), GetSize()); overflow.Inflate(halfBorder); diff --git a/mozilla/layout/tables/nsTableCellFrame.h b/mozilla/layout/tables/nsTableCellFrame.h index 95b62ce37d6..34573b91399 100644 --- a/mozilla/layout/tables/nsTableCellFrame.h +++ b/mozilla/layout/tables/nsTableCellFrame.h @@ -452,12 +452,15 @@ public: virtual nsIAtom* GetType() const; + // Get the *inner half of the border only*, in twips. virtual nsMargin* GetBorderWidth(float aPixelsToTwips, nsMargin& aBorder) const; - nscoord GetBorderWidth(PRUint8 aSide) const; - void SetBorderWidth(const nsMargin& aBorder); - void SetBorderWidth(PRUint8 aSide, nscoord aPixelValue); + // Get the *inner half of the border only*, in pixels. + BCPixelSize GetBorderWidth(PRUint8 aSide) const; + + // Set the full (both halves) width of the border + void SetBorderWidth(PRUint8 aSide, BCPixelSize aPixelValue); virtual void GetSelfOverflow(nsRect& aOverflowArea); @@ -477,12 +480,12 @@ protected: private: - // These are the half of the border width that goes inside the cell - // boundary, in pixels. - PRUint32 mTopBorder: 8; - PRUint32 mRightBorder: 8; - PRUint32 mBottomBorder: 8; - PRUint32 mLeftBorder: 8; + // These are the entire width of the border (the cell edge contains only + // the inner half, per the macros in nsTablePainter.h). + BCPixelSize mTopBorder; + BCPixelSize mRightBorder; + BCPixelSize mBottomBorder; + BCPixelSize mLeftBorder; }; #endif diff --git a/mozilla/layout/tables/nsTableColFrame.h b/mozilla/layout/tables/nsTableColFrame.h index 3b60f75ccac..d03a6e1bbd7 100644 --- a/mozilla/layout/tables/nsTableColFrame.h +++ b/mozilla/layout/tables/nsTableColFrame.h @@ -195,7 +195,7 @@ protected: // the starting index of the column (starting at 0) that this col object represents // PRUint32 mColIndex: 16; - // border width in pixels + // border width in pixels of the inner half of the border only BCPixelSize mLeftBorderWidth; BCPixelSize mRightBorderWidth; BCPixelSize mTopContBorderWidth; diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 643ec13db11..893a8a28959 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -171,10 +171,10 @@ struct BCPropertyData BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width = mDamageArea.height = mTopBorderWidth = mRightBorderWidth = mBottomBorderWidth = mLeftBorderWidth = 0; } nsRect mDamageArea; - PRUint8 mTopBorderWidth; - PRUint8 mRightBorderWidth; - PRUint8 mBottomBorderWidth; - PRUint8 mLeftBorderWidth; + BCPixelSize mTopBorderWidth; + BCPixelSize mRightBorderWidth; + BCPixelSize mBottomBorderWidth; + BCPixelSize mLeftBorderWidth; }; NS_IMETHODIMP @@ -2736,19 +2736,10 @@ nsTableFrame::GetBCBorder() const (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE); if (propData) { if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) { - nscoord smallHalf, largeHalf; - - DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); - border.top += NSToCoordRound(p2t * (float)smallHalf); - - DivideBCBorderSize(propData->mRightBorderWidth, smallHalf, largeHalf); - border.right += NSToCoordRound(p2t * (float)largeHalf); - - DivideBCBorderSize(propData->mBottomBorderWidth, smallHalf, largeHalf); - border.bottom += NSToCoordRound(p2t * (float)largeHalf); - - DivideBCBorderSize(propData->mLeftBorderWidth, smallHalf, largeHalf); - border.left += NSToCoordRound(p2t * (float)smallHalf); + border.top += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mTopBorderWidth); + border.right += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mRightBorderWidth); + border.bottom += BC_BORDER_TOP_HALF_COORD(p2t, propData->mBottomBorderWidth); + border.left += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mLeftBorderWidth); } else { border.top += NSToCoordRound(p2t * (float)propData->mTopBorderWidth); @@ -2772,19 +2763,10 @@ nsTableFrame::GetBCMargin() const PR_FALSE); if (propData) { if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) { - nscoord smallHalf, largeHalf; - - DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); - overflow.top += NSToCoordRound(p2t * (float)largeHalf); - - DivideBCBorderSize(propData->mRightBorderWidth, smallHalf, largeHalf); - overflow.right += NSToCoordRound(p2t * (float)smallHalf); - - DivideBCBorderSize(propData->mBottomBorderWidth, smallHalf, largeHalf); - overflow.bottom += NSToCoordRound(p2t * (float)smallHalf); - - DivideBCBorderSize(propData->mLeftBorderWidth, smallHalf, largeHalf); - overflow.left += NSToCoordRound(p2t * (float)largeHalf); + overflow.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth); + overflow.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth); + overflow.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth); + overflow.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth); } } return overflow; @@ -2809,23 +2791,15 @@ nsTableFrame::GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const nsPresContext* presContext = GetPresContext(); if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) { nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset); - nscoord smallHalf, largeHalf; GET_PIXELS_TO_TWIPS(presContext, p2t); BCPropertyData* propData = (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE); if (!propData) ABORT1(offset); - DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); - offset.top += NSToCoordRound(p2t * (float)largeHalf); - - DivideBCBorderSize(propData->mRightBorderWidth, smallHalf, largeHalf); - offset.right += NSToCoordRound(p2t * (float)smallHalf); - - DivideBCBorderSize(propData->mBottomBorderWidth, smallHalf, largeHalf); - offset.bottom += NSToCoordRound(p2t * (float)smallHalf); - - DivideBCBorderSize(propData->mLeftBorderWidth, smallHalf, largeHalf); - offset.left += NSToCoordRound(p2t * (float)largeHalf); + offset.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth); + offset.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth); + offset.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth); + offset.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth); } } else { @@ -4208,7 +4182,7 @@ nsTableFrame::CalcMinAndPreferredWidths(const nsHTMLReflowState& aRefl for (PRInt32 colX = 0; colX < numCols; colX++) { nsTableColFrame* colFrame = GetColFrame(colX); if (!colFrame) continue; - aMinWidth += PR_MAX(colFrame->GetMinWidth(), colFrame->GetWidth(MIN_ADJ)); + aMinWidth += colFrame->GetMinWidth(); nscoord width = colFrame->GetFixWidth(); if (width <= 0) { width = colFrame->GetDesWidth(); @@ -5811,7 +5785,6 @@ nsTableFrame::CalcBCBorders() BCCellBorder currentBorder, adjacentBorder; PRInt32 cellEndRowIndex = -1; PRInt32 cellEndColIndex = -1; - nscoord smallHalf, largeHalf; BCCorners topCorners(damageArea.width + 1, damageArea.x); if (!topCorners.corners) ABORT0(); BCCorners bottomCorners(damageArea.width + 1, damageArea.x); if (!bottomCorners.corners) ABORT0(); @@ -5871,12 +5844,12 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_TOP, *info.cellMap, 0, 0, colX, 1, currentBorder.owner, currentBorder.width, startSeg); // update the affected borders of the cell, row, and table - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(NS_SIDE_TOP, PR_MAX(smallHalf, info.cell->GetBorderWidth(NS_SIDE_TOP))); + info.cell->SetBorderWidth(NS_SIDE_TOP, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(NS_SIDE_TOP))); } if (info.topRow) { - info.topRow->SetTopBCBorderWidth(PR_MAX(smallHalf, info.topRow->GetTopBCBorderWidth())); + BCPixelSize half = BC_BORDER_BOTTOM_HALF(currentBorder.width); + info.topRow->SetTopBCBorderWidth(PR_MAX(half, info.topRow->GetTopBCBorderWidth())); } propData->mTopBorderWidth = LimitBorderWidth(PR_MAX(propData->mTopBorderWidth, (PRUint8)currentBorder.width)); //calculate column continuous borders @@ -5960,12 +5933,12 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_LEFT, *info.cellMap, iter.mRowGroupStart, rowX, info.colIndex, 1, currentBorder.owner, currentBorder.width, startSeg); // update the left border of the cell, col and table - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(firstSide, PR_MAX(smallHalf, info.cell->GetBorderWidth(firstSide))); + info.cell->SetBorderWidth(firstSide, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(firstSide))); } if (info.leftCol) { - info.leftCol->SetLeftBorderWidth(PR_MAX(smallHalf, info.leftCol->GetLeftBorderWidth())); + BCPixelSize half = BC_BORDER_RIGHT_HALF(currentBorder.width); + info.leftCol->SetLeftBorderWidth(PR_MAX(half, info.leftCol->GetLeftBorderWidth())); } propData->mLeftBorderWidth = LimitBorderWidth(PR_MAX(propData->mLeftBorderWidth, currentBorder.width)); //get row continuous borders @@ -6011,12 +5984,12 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX, cellEndColIndex, 1, currentBorder.owner, currentBorder.width, startSeg); // update the affected borders of the cell, col, and table - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(secondSide, PR_MAX(largeHalf, info.cell->GetBorderWidth(secondSide))); + info.cell->SetBorderWidth(secondSide, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(secondSide))); } if (info.rightCol) { - info.rightCol->SetRightBorderWidth(PR_MAX(largeHalf, info.rightCol->GetRightBorderWidth())); + BCPixelSize half = BC_BORDER_LEFT_HALF(currentBorder.width); + info.rightCol->SetRightBorderWidth(PR_MAX(half, info.rightCol->GetRightBorderWidth())); } propData->mRightBorderWidth = LimitBorderWidth(PR_MAX(propData->mRightBorderWidth, currentBorder.width)); //get row continuous borders @@ -6058,18 +6031,19 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX, cellEndColIndex, segLength, currentBorder.owner, currentBorder.width, startSeg); // update the borders of the cells and cols affected - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(secondSide, PR_MAX(largeHalf, info.cell->GetBorderWidth(secondSide))); + info.cell->SetBorderWidth(secondSide, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(secondSide))); } if (info.rightCol) { - info.rightCol->SetRightBorderWidth(PR_MAX(largeHalf, info.rightCol->GetRightBorderWidth())); + BCPixelSize half = BC_BORDER_LEFT_HALF(currentBorder.width); + info.rightCol->SetRightBorderWidth(PR_MAX(half, info.rightCol->GetRightBorderWidth())); } if (ajaInfo.cell) { - ajaInfo.cell->SetBorderWidth(firstSide, PR_MAX(smallHalf, ajaInfo.cell->GetBorderWidth(firstSide))); + ajaInfo.cell->SetBorderWidth(firstSide, PR_MAX(currentBorder.width, ajaInfo.cell->GetBorderWidth(firstSide))); } if (ajaInfo.leftCol) { - ajaInfo.leftCol->SetLeftBorderWidth(PR_MAX(smallHalf, ajaInfo.leftCol->GetLeftBorderWidth())); + BCPixelSize half = BC_BORDER_RIGHT_HALF(currentBorder.width); + ajaInfo.leftCol->SetLeftBorderWidth(PR_MAX(half, ajaInfo.leftCol->GetLeftBorderWidth())); } } // update the top right corner @@ -6146,12 +6120,12 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex, colX, 1, currentBorder.owner, currentBorder.width, startSeg); // update the bottom borders of the cell, the bottom row, and the table - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(NS_SIDE_BOTTOM, PR_MAX(largeHalf, info.cell->GetBorderWidth(NS_SIDE_BOTTOM))); + info.cell->SetBorderWidth(NS_SIDE_BOTTOM, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(NS_SIDE_BOTTOM))); } if (info.bottomRow) { - info.bottomRow->SetBottomBCBorderWidth(PR_MAX(largeHalf, info.bottomRow->GetBottomBCBorderWidth())); + BCPixelSize half = BC_BORDER_TOP_HALF(currentBorder.width); + info.bottomRow->SetBottomBCBorderWidth(PR_MAX(half, info.bottomRow->GetBottomBCBorderWidth())); } propData->mBottomBorderWidth = LimitBorderWidth(PR_MAX(propData->mBottomBorderWidth, currentBorder.width)); // update lastBottomBorders @@ -6243,18 +6217,19 @@ nsTableFrame::CalcBCBorders() tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex, colX, segLength, currentBorder.owner, currentBorder.width, startSeg); // update the borders of the affected cells and rows - DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf); if (info.cell) { - info.cell->SetBorderWidth(NS_SIDE_BOTTOM, PR_MAX(largeHalf, info.cell->GetBorderWidth(NS_SIDE_BOTTOM))); + info.cell->SetBorderWidth(NS_SIDE_BOTTOM, PR_MAX(currentBorder.width, info.cell->GetBorderWidth(NS_SIDE_BOTTOM))); } if (info.bottomRow) { - info.bottomRow->SetBottomBCBorderWidth(PR_MAX(largeHalf, info.bottomRow->GetBottomBCBorderWidth())); + BCPixelSize half = BC_BORDER_TOP_HALF(currentBorder.width); + info.bottomRow->SetBottomBCBorderWidth(PR_MAX(half, info.bottomRow->GetBottomBCBorderWidth())); } if (ajaInfo.cell) { - ajaInfo.cell->SetBorderWidth(NS_SIDE_TOP, PR_MAX(smallHalf, ajaInfo.cell->GetBorderWidth(NS_SIDE_TOP))); + ajaInfo.cell->SetBorderWidth(NS_SIDE_TOP, PR_MAX(currentBorder.width, ajaInfo.cell->GetBorderWidth(NS_SIDE_TOP))); } if (ajaInfo.topRow) { - ajaInfo.topRow->SetTopBCBorderWidth(PR_MAX(smallHalf, ajaInfo.topRow->GetTopBCBorderWidth())); + BCPixelSize half = BC_BORDER_BOTTOM_HALF(currentBorder.width); + ajaInfo.topRow->SetTopBCBorderWidth(PR_MAX(half, ajaInfo.topRow->GetTopBCBorderWidth())); } } // update bottom right corner @@ -6603,6 +6578,7 @@ CalcVerCornerOffset(PRUint8 aCornerOwnerSide, float aPixelsToTwips) { nscoord offset = 0; + // XXX These should be replaced with appropriate side-specific macros (which?). nscoord smallHalf, largeHalf; if ((NS_SIDE_TOP == aCornerOwnerSide) || (NS_SIDE_BOTTOM == aCornerOwnerSide)) { DivideBCBorderSize(aCornerSubWidth, smallHalf, largeHalf); @@ -6645,6 +6621,7 @@ CalcHorCornerOffset(PRUint8 aCornerOwnerSide, PRBool aTableIsLTR) { nscoord offset = 0; + // XXX These should be replaced with appropriate side-specific macros (which?). nscoord smallHalf, largeHalf; if ((NS_SIDE_LEFT == aCornerOwnerSide) || (NS_SIDE_RIGHT == aCornerOwnerSide)) { if (aTableIsLTR) { @@ -7594,7 +7571,7 @@ DestroyCoordFunc(void* aFrame, void* aPropertyValue, void* aDtorData) { - delete (nscoord*)aPropertyValue; + delete NS_STATIC_CAST(nscoord*, aPropertyValue); } // Destructor function point properties @@ -7604,7 +7581,7 @@ DestroyPointFunc(void* aFrame, void* aPropertyValue, void* aDtorData) { - delete (nsPoint*)aPropertyValue; + delete NS_STATIC_CAST(nsPoint*, aPropertyValue); } // Destructor function for nscoord properties @@ -7614,7 +7591,7 @@ DestroyBCPropertyDataFunc(void* aFrame, void* aPropertyValue, void* aDtorData) { - delete (BCPropertyData*)aPropertyValue; + delete NS_STATIC_CAST(BCPropertyData*, aPropertyValue); } void* @@ -7626,7 +7603,7 @@ nsTableFrame::GetProperty(nsIFrame* aFrame, void *value = propTable->GetProperty(aFrame, aPropertyName); if (value) { return (nsPoint*)value; // the property already exists - } + } if (aCreateIfNecessary) { // The property isn't set yet, so allocate a new value, set the property, // and return the newly allocated value @@ -7643,8 +7620,9 @@ nsTableFrame::GetProperty(nsIFrame* aFrame, value = new BCPropertyData; dtorFunc = DestroyBCPropertyDataFunc; } - if (!value) return nsnull; - propTable->SetProperty(aFrame, aPropertyName, value, dtorFunc, nsnull); + if (value) { + propTable->SetProperty(aFrame, aPropertyName, value, dtorFunc, nsnull); + } return value; } return nsnull; diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 913314eed47..537d02b979c 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -170,8 +170,6 @@ private: * - "ColGroup-list" which contains the col group frames * * @see nsLayoutAtoms::colGroupList - * - * TODO: make methods virtual so nsTableFrame can be used as a base class in the future. */ class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout { @@ -1116,34 +1114,3 @@ return aReturn;} var = 1.0f / var; #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 673ffa70d82..3e79a212a71 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -409,7 +409,7 @@ nsTableOuterFrame::ZeroAutoMargin(nsHTMLReflowState& aReflowState, } } -void +static void FixAutoMargins(nscoord aAvailWidth, nscoord aChildWidth, nsHTMLReflowState& aReflowState) @@ -474,6 +474,7 @@ nsTableOuterFrame::GetMarginPadding(nsPresContext* aPresContext, aPadding = childRS.mComputedPadding; } +static nscoord CalcAutoMargin(nscoord aAutoMargin, nscoord aOppositeMargin, nscoord aContainBlockSize, @@ -489,7 +490,7 @@ nscoord CalcAutoMargin(nscoord aAutoMargin, return PR_MAX(0, margin); } -void +static void MoveFrameTo(nsIFrame* aFrame, nscoord aX, nscoord aY) @@ -501,7 +502,7 @@ MoveFrameTo(nsIFrame* aFrame, } } -nsSize +static nsSize GetContainingBlockSize(const nsHTMLReflowState& aOuterRS) { nsSize size(0,0); @@ -755,11 +756,10 @@ nsTableOuterFrame::GetMaxWidth(PRUint8 aCaptionSide, switch(aCaptionSide) { case NS_SIDE_LEFT: case NS_SIDE_RIGHT: + maxWidth += mCaptionFrame->GetSize().width + aCaptionMargin.left + aCaptionMargin.right; // the caption plus it margins should cover the corresponding inner table side // margin - don't count it twice. - maxWidth = mCaptionFrame->GetSize().width + aCaptionMargin.left + aCaptionMargin.right + - ((nsTableFrame *)mInnerTableFrame)->GetPreferredWidth(); - maxWidth += (NS_SIDE_LEFT == aCaptionSide) ? aInnerMargin.right : aInnerMargin.left; + maxWidth -= (NS_SIDE_LEFT == aCaptionSide) ? aInnerMargin.left : aInnerMargin.right; break; case NS_SIDE_TOP: case NS_SIDE_BOTTOM: @@ -785,12 +785,10 @@ nsTableOuterFrame::GetCaptionSide() PRUint8 nsTableOuterFrame::GetCaptionVerticalAlign() { - const nsStyleTextReset* textStyle = mCaptionFrame->GetStyleTextReset(); - PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_TOP; - if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) { - verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue(); - } - return verticalAlignFlags; + const nsStyleCoord& va = mCaptionFrame->GetStyleTextReset()->mVerticalAlign; + return (va.GetUnit() == eStyleUnit_Enumerated) + ? va.GetIntValue() + : NS_STYLE_VERTICAL_ALIGN_TOP; } void @@ -1233,7 +1231,6 @@ nsTableOuterFrame::OuterReflowChild(nsPresContext* aPresContext, nsReflowStatus& aStatus, PRBool* aNeedToReflowCaption) { - if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER); aMargin = aPadding = nsMargin(0,0,0,0); // work around pixel rounding errors, round down to ensure we don't exceed the avail height in diff --git a/mozilla/layout/tables/nsTablePainter.h b/mozilla/layout/tables/nsTablePainter.h index 246cd156130..d65ed2363e2 100644 --- a/mozilla/layout/tables/nsTablePainter.h +++ b/mozilla/layout/tables/nsTablePainter.h @@ -38,17 +38,7 @@ #ifndef nsTablePainter_h__ #define nsTablePainter_h__ -typedef PRUint8 BCPixelSize; - -#define BC_BORDER_TOP_HALF_COORD(p2t,px) NSToCoordRound(((px) - (px) / 2) * (p2t) ) -#define BC_BORDER_RIGHT_HALF_COORD(p2t,px) NSToCoordRound(( (px) / 2) * (p2t) ) -#define BC_BORDER_BOTTOM_HALF_COORD(p2t,px) NSToCoordRound(( (px) / 2) * (p2t) ) -#define BC_BORDER_LEFT_HALF_COORD(p2t,px) NSToCoordRound(((px) - (px) / 2) * (p2t) ) - -#define BC_BORDER_TOP_HALF(px) ((px) - (px) / 2) -#define BC_BORDER_RIGHT_HALF(px) ((px) / 2) -#define BC_BORDER_BOTTOM_HALF(px) ((px) / 2) -#define BC_BORDER_LEFT_HALF(px) ((px) - (px) / 2) +#include "celldata.h" // flags for Paint, PaintChild, PaintChildren are currently only used by tables. //Table-based paint call; not a direct call as with views diff --git a/mozilla/layout/tables/nsTableRowFrame.h b/mozilla/layout/tables/nsTableRowFrame.h index b5bb25bb4ad..9e9ca512988 100644 --- a/mozilla/layout/tables/nsTableRowFrame.h +++ b/mozilla/layout/tables/nsTableRowFrame.h @@ -333,7 +333,8 @@ private: nscoord mMaxCellAscent; // does include cells with rowspan > 1 nscoord mMaxCellDescent; // does *not* include cells with rowspan > 1 - // border widths in pixels in the collapsing border model + // border widths in pixels in the collapsing border model of the *inner* + // half of the border only BCPixelSize mTopBorderWidth; BCPixelSize mBottomBorderWidth; BCPixelSize mRightContBorderWidth; diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 70c5e7e88d8..2b908e9a895 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -517,7 +517,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext, { nsTableFrame* tableFrame = nsnull; nsTableFrame::GetTableFrame(this, tableFrame); - if (!aPresContext || !tableFrame) return; + if (!tableFrame) return; PRBool isPaginated = aPresContext->IsPaginated(); @@ -1212,7 +1212,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext, nsTableFrame* tableFrame = nsnull; rv = nsTableFrame::GetTableFrame(this, tableFrame); - if (!aPresContext || !tableFrame) return NS_ERROR_NULL_POINTER; + if (!tableFrame) return NS_ERROR_NULL_POINTER; // see if a special height reflow needs to occur due to having a pct height if (!NeedSpecialReflow())