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

This commit is contained in:
dbaron%dbaron.org 2005-04-07 18:04:38 +00:00
Родитель 44a780ce95
Коммит f62b4fe8e0
10 изменённых файлов: 125 добавлений и 189 удалений

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

@ -179,10 +179,21 @@ enum BCBorderOwner
eAjaCellOwner = 10 // cell to the top or to the left 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 // 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. // the actual value is computed when needed.
#define MAX_BORDER_WIDTH 64 #define MAX_BORDER_WIDTH nscoord(PR_BITMASK(sizeof(BCPixelSize) * 8))
#define MAX_CORNER_SUB_WIDTH 128
#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. // BCData stores the top and left border info and the corner connecting the two.
class BCData class BCData
@ -206,11 +217,11 @@ public:
nscoord aSize, nscoord aSize,
PRBool aStart); PRBool aStart);
PRUint8 GetCorner(PRUint8& aCornerOwner, BCPixelSize GetCorner(PRUint8& aCornerOwner,
PRPackedBool& aBevel) const; PRPackedBool& aBevel) const;
void SetCorner(PRUint8 aOwner, void SetCorner(BCPixelSize aSubSize,
PRUint8 aSubSize, PRUint8 aOwner,
PRBool aBevel); PRBool aBevel);
PRBool IsLeftStart() const; PRBool IsLeftStart() const;
@ -223,17 +234,19 @@ public:
protected: 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 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 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 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 // 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; mTopStart = aStart;
} }
inline PRUint8 BCData::GetCorner(PRUint8& aOwnerSide, inline BCPixelSize BCData::GetCorner(PRUint8& aOwnerSide,
PRPackedBool& aBevel) const PRPackedBool& aBevel) const
{ {
aOwnerSide = mCornerSide; aOwnerSide = mCornerSide;
aBevel = (PRBool)mCornerBevel; aBevel = (PRBool)mCornerBevel;
return (PRUint8)mCornerSubSize; return mCornerSubSize;
} }
inline void BCData::SetCorner(PRUint8 aSubSize, inline void BCData::SetCorner(BCPixelSize aSubSize,
PRUint8 aOwnerSide, PRUint8 aOwnerSide,
PRBool aBevel) PRBool aBevel)
{ {
mCornerSubSize = (aSubSize > MAX_CORNER_SUB_WIDTH) ? MAX_CORNER_SUB_WIDTH : aSubSize; mCornerSubSize = aSubSize;
mCornerSide = aOwnerSide; mCornerSide = aOwnerSide;
mCornerBevel = aBevel; mCornerBevel = aBevel;
} }

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

@ -1240,44 +1240,35 @@ nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
} }
#endif #endif
void
nsBCTableCellFrame::SetBorderWidth(const nsMargin& aBorder)
{
mTopBorder = aBorder.top;
mRightBorder = aBorder.right;
mBottomBorder = aBorder.bottom;
mLeftBorder = aBorder.left;
}
nsMargin* nsMargin*
nsBCTableCellFrame::GetBorderWidth(float aPixelsToTwips, nsBCTableCellFrame::GetBorderWidth(float aPixelsToTwips,
nsMargin& aBorder) const nsMargin& aBorder) const
{ {
aBorder.top = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mTopBorder) : mTopBorder; aBorder.top = BC_BORDER_BOTTOM_HALF_COORD(aPixelsToTwips, mTopBorder);
aBorder.right = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mRightBorder) : mRightBorder; aBorder.right = BC_BORDER_LEFT_HALF_COORD(aPixelsToTwips, mRightBorder);
aBorder.bottom = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mBottomBorder): mBottomBorder; aBorder.bottom = BC_BORDER_TOP_HALF_COORD(aPixelsToTwips, mBottomBorder);
aBorder.left = (aPixelsToTwips) ? NSToCoordRound(aPixelsToTwips * mLeftBorder): mLeftBorder; aBorder.left = BC_BORDER_RIGHT_HALF_COORD(aPixelsToTwips, mLeftBorder);
return &aBorder; return &aBorder;
} }
nscoord BCPixelSize
nsBCTableCellFrame::GetBorderWidth(PRUint8 aSide) const nsBCTableCellFrame::GetBorderWidth(PRUint8 aSide) const
{ {
switch(aSide) { switch(aSide) {
case NS_SIDE_TOP: case NS_SIDE_TOP:
return (PRUint8)mTopBorder; return BC_BORDER_BOTTOM_HALF(mTopBorder);
case NS_SIDE_RIGHT: case NS_SIDE_RIGHT:
return (PRUint8)mRightBorder; return BC_BORDER_LEFT_HALF(mRightBorder);
case NS_SIDE_BOTTOM: case NS_SIDE_BOTTOM:
return (PRUint8)mBottomBorder; return BC_BORDER_TOP_HALF(mBottomBorder);
default: default:
return (PRUint8)mLeftBorder; return BC_BORDER_RIGHT_HALF(mLeftBorder);
} }
} }
void void
nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide, nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide,
nscoord aValue) BCPixelSize aValue)
{ {
switch(aSide) { switch(aSide) {
case NS_SIDE_TOP: case NS_SIDE_TOP:
@ -1298,15 +1289,11 @@ nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide,
nsBCTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea) nsBCTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea)
{ {
nsMargin halfBorder; nsMargin halfBorder;
GetBorderWidth(GetPresContext()->PixelsToTwips(), halfBorder); float p2t = GetPresContext()->PixelsToTwips();
// Since we have the inner half and we want an outer bound for the halfBorder.top = BC_BORDER_TOP_HALF_COORD(p2t, mTopBorder);
// outer half, just inflate the right and bottom sides by a pixel. halfBorder.right = BC_BORDER_RIGHT_HALF_COORD(p2t, mRightBorder);
// XXX Overestimating could lead to problems with outlines (although halfBorder.bottom = BC_BORDER_BOTTOM_HALF_COORD(p2t, mBottomBorder);
// this is probably bad for outlines to begin with) and scrollable halfBorder.left = BC_BORDER_LEFT_HALF_COORD(p2t, mLeftBorder);
// regions in 'overflow: auto' or 'overflow: scroll' containers.
nscoord onePixel = nscoord(GetPresContext()->PixelsToTwips() + 0.999);
halfBorder.right += onePixel;
halfBorder.bottom += onePixel;
nsRect overflow(nsPoint(0,0), GetSize()); nsRect overflow(nsPoint(0,0), GetSize());
overflow.Inflate(halfBorder); overflow.Inflate(halfBorder);

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

@ -452,12 +452,15 @@ public:
virtual nsIAtom* GetType() const; virtual nsIAtom* GetType() const;
// Get the *inner half of the border only*, in twips.
virtual nsMargin* GetBorderWidth(float aPixelsToTwips, virtual nsMargin* GetBorderWidth(float aPixelsToTwips,
nsMargin& aBorder) const; nsMargin& aBorder) const;
nscoord GetBorderWidth(PRUint8 aSide) const;
void SetBorderWidth(const nsMargin& aBorder); // Get the *inner half of the border only*, in pixels.
void SetBorderWidth(PRUint8 aSide, nscoord aPixelValue); 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); virtual void GetSelfOverflow(nsRect& aOverflowArea);
@ -477,12 +480,12 @@ protected:
private: private:
// These are the half of the border width that goes inside the cell // These are the entire width of the border (the cell edge contains only
// boundary, in pixels. // the inner half, per the macros in nsTablePainter.h).
PRUint32 mTopBorder: 8; BCPixelSize mTopBorder;
PRUint32 mRightBorder: 8; BCPixelSize mRightBorder;
PRUint32 mBottomBorder: 8; BCPixelSize mBottomBorder;
PRUint32 mLeftBorder: 8; BCPixelSize mLeftBorder;
}; };
#endif #endif

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

@ -195,7 +195,7 @@ protected:
// the starting index of the column (starting at 0) that this col object represents // // the starting index of the column (starting at 0) that this col object represents //
PRUint32 mColIndex: 16; PRUint32 mColIndex: 16;
// border width in pixels // border width in pixels of the inner half of the border only
BCPixelSize mLeftBorderWidth; BCPixelSize mLeftBorderWidth;
BCPixelSize mRightBorderWidth; BCPixelSize mRightBorderWidth;
BCPixelSize mTopContBorderWidth; BCPixelSize mTopContBorderWidth;

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

@ -171,10 +171,10 @@ struct BCPropertyData
BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width = mDamageArea.height = BCPropertyData() { mDamageArea.x = mDamageArea.y = mDamageArea.width = mDamageArea.height =
mTopBorderWidth = mRightBorderWidth = mBottomBorderWidth = mLeftBorderWidth = 0; } mTopBorderWidth = mRightBorderWidth = mBottomBorderWidth = mLeftBorderWidth = 0; }
nsRect mDamageArea; nsRect mDamageArea;
PRUint8 mTopBorderWidth; BCPixelSize mTopBorderWidth;
PRUint8 mRightBorderWidth; BCPixelSize mRightBorderWidth;
PRUint8 mBottomBorderWidth; BCPixelSize mBottomBorderWidth;
PRUint8 mLeftBorderWidth; BCPixelSize mLeftBorderWidth;
}; };
NS_IMETHODIMP NS_IMETHODIMP
@ -2736,19 +2736,10 @@ nsTableFrame::GetBCBorder() const
(BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE); (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)this, nsLayoutAtoms::tableBCProperty, PR_FALSE);
if (propData) { if (propData) {
if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) { if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) {
nscoord smallHalf, largeHalf; border.top += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mTopBorderWidth);
border.right += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mRightBorderWidth);
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); border.bottom += BC_BORDER_TOP_HALF_COORD(p2t, propData->mBottomBorderWidth);
border.top += NSToCoordRound(p2t * (float)smallHalf); border.left += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mLeftBorderWidth);
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);
} }
else { else {
border.top += NSToCoordRound(p2t * (float)propData->mTopBorderWidth); border.top += NSToCoordRound(p2t * (float)propData->mTopBorderWidth);
@ -2772,19 +2763,10 @@ nsTableFrame::GetBCMargin() const
PR_FALSE); PR_FALSE);
if (propData) { if (propData) {
if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) { if (eCompatibility_NavQuirks != presContext->CompatibilityMode()) {
nscoord smallHalf, largeHalf; overflow.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
overflow.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth);
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); overflow.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
overflow.top += NSToCoordRound(p2t * (float)largeHalf); overflow.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
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);
} }
} }
return overflow; return overflow;
@ -2809,23 +2791,15 @@ nsTableFrame::GetChildAreaOffset(const nsHTMLReflowState* aReflowState) const
nsPresContext* presContext = GetPresContext(); nsPresContext* presContext = GetPresContext();
if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) { if (eCompatibility_NavQuirks == presContext->CompatibilityMode()) {
nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset); nsTableFrame* firstInFlow = (nsTableFrame*)GetFirstInFlow(); if (!firstInFlow) ABORT1(offset);
nscoord smallHalf, largeHalf;
GET_PIXELS_TO_TWIPS(presContext, p2t); GET_PIXELS_TO_TWIPS(presContext, p2t);
BCPropertyData* propData = BCPropertyData* propData =
(BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE); (BCPropertyData*)nsTableFrame::GetProperty((nsIFrame*)firstInFlow, nsLayoutAtoms::tableBCProperty, PR_FALSE);
if (!propData) ABORT1(offset); if (!propData) ABORT1(offset);
DivideBCBorderSize(propData->mTopBorderWidth, smallHalf, largeHalf); offset.top += BC_BORDER_TOP_HALF_COORD(p2t, propData->mTopBorderWidth);
offset.top += NSToCoordRound(p2t * (float)largeHalf); offset.right += BC_BORDER_RIGHT_HALF_COORD(p2t, propData->mRightBorderWidth);
offset.bottom += BC_BORDER_BOTTOM_HALF_COORD(p2t, propData->mBottomBorderWidth);
DivideBCBorderSize(propData->mRightBorderWidth, smallHalf, largeHalf); offset.left += BC_BORDER_LEFT_HALF_COORD(p2t, propData->mLeftBorderWidth);
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);
} }
} }
else { else {
@ -4208,7 +4182,7 @@ nsTableFrame::CalcMinAndPreferredWidths(const nsHTMLReflowState& aRefl
for (PRInt32 colX = 0; colX < numCols; colX++) { for (PRInt32 colX = 0; colX < numCols; colX++) {
nsTableColFrame* colFrame = GetColFrame(colX); nsTableColFrame* colFrame = GetColFrame(colX);
if (!colFrame) continue; if (!colFrame) continue;
aMinWidth += PR_MAX(colFrame->GetMinWidth(), colFrame->GetWidth(MIN_ADJ)); aMinWidth += colFrame->GetMinWidth();
nscoord width = colFrame->GetFixWidth(); nscoord width = colFrame->GetFixWidth();
if (width <= 0) { if (width <= 0) {
width = colFrame->GetDesWidth(); width = colFrame->GetDesWidth();
@ -5811,7 +5785,6 @@ nsTableFrame::CalcBCBorders()
BCCellBorder currentBorder, adjacentBorder; BCCellBorder currentBorder, adjacentBorder;
PRInt32 cellEndRowIndex = -1; PRInt32 cellEndRowIndex = -1;
PRInt32 cellEndColIndex = -1; PRInt32 cellEndColIndex = -1;
nscoord smallHalf, largeHalf;
BCCorners topCorners(damageArea.width + 1, damageArea.x); if (!topCorners.corners) ABORT0(); BCCorners topCorners(damageArea.width + 1, damageArea.x); if (!topCorners.corners) ABORT0();
BCCorners bottomCorners(damageArea.width + 1, damageArea.x); if (!bottomCorners.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, tableCellMap->SetBCBorderEdge(NS_SIDE_TOP, *info.cellMap, 0, 0, colX,
1, currentBorder.owner, currentBorder.width, startSeg); 1, currentBorder.owner, currentBorder.width, startSeg);
// update the affected borders of the cell, row, and table // update the affected borders of the cell, row, and table
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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)); propData->mTopBorderWidth = LimitBorderWidth(PR_MAX(propData->mTopBorderWidth, (PRUint8)currentBorder.width));
//calculate column continuous borders //calculate column continuous borders
@ -5960,12 +5933,12 @@ nsTableFrame::CalcBCBorders()
tableCellMap->SetBCBorderEdge(NS_SIDE_LEFT, *info.cellMap, iter.mRowGroupStart, rowX, tableCellMap->SetBCBorderEdge(NS_SIDE_LEFT, *info.cellMap, iter.mRowGroupStart, rowX,
info.colIndex, 1, currentBorder.owner, currentBorder.width, startSeg); info.colIndex, 1, currentBorder.owner, currentBorder.width, startSeg);
// update the left border of the cell, col and table // update the left border of the cell, col and table
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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)); propData->mLeftBorderWidth = LimitBorderWidth(PR_MAX(propData->mLeftBorderWidth, currentBorder.width));
//get row continuous borders //get row continuous borders
@ -6011,12 +5984,12 @@ nsTableFrame::CalcBCBorders()
tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX, tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX,
cellEndColIndex, 1, currentBorder.owner, currentBorder.width, startSeg); cellEndColIndex, 1, currentBorder.owner, currentBorder.width, startSeg);
// update the affected borders of the cell, col, and table // update the affected borders of the cell, col, and table
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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)); propData->mRightBorderWidth = LimitBorderWidth(PR_MAX(propData->mRightBorderWidth, currentBorder.width));
//get row continuous borders //get row continuous borders
@ -6058,18 +6031,19 @@ nsTableFrame::CalcBCBorders()
tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX, tableCellMap->SetBCBorderEdge(NS_SIDE_RIGHT, *info.cellMap, iter.mRowGroupStart, rowX,
cellEndColIndex, segLength, currentBorder.owner, currentBorder.width, startSeg); cellEndColIndex, segLength, currentBorder.owner, currentBorder.width, startSeg);
// update the borders of the cells and cols affected // update the borders of the cells and cols affected
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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) { 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) { 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 // update the top right corner
@ -6146,12 +6120,12 @@ nsTableFrame::CalcBCBorders()
tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex, tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex,
colX, 1, currentBorder.owner, currentBorder.width, startSeg); colX, 1, currentBorder.owner, currentBorder.width, startSeg);
// update the bottom borders of the cell, the bottom row, and the table // update the bottom borders of the cell, the bottom row, and the table
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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)); propData->mBottomBorderWidth = LimitBorderWidth(PR_MAX(propData->mBottomBorderWidth, currentBorder.width));
// update lastBottomBorders // update lastBottomBorders
@ -6243,18 +6217,19 @@ nsTableFrame::CalcBCBorders()
tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex, tableCellMap->SetBCBorderEdge(NS_SIDE_BOTTOM, *info.cellMap, iter.mRowGroupStart, cellEndRowIndex,
colX, segLength, currentBorder.owner, currentBorder.width, startSeg); colX, segLength, currentBorder.owner, currentBorder.width, startSeg);
// update the borders of the affected cells and rows // update the borders of the affected cells and rows
DivideBCBorderSize(currentBorder.width, smallHalf, largeHalf);
if (info.cell) { 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) { 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) { 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) { 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 // update bottom right corner
@ -6603,6 +6578,7 @@ CalcVerCornerOffset(PRUint8 aCornerOwnerSide,
float aPixelsToTwips) float aPixelsToTwips)
{ {
nscoord offset = 0; nscoord offset = 0;
// XXX These should be replaced with appropriate side-specific macros (which?).
nscoord smallHalf, largeHalf; nscoord smallHalf, largeHalf;
if ((NS_SIDE_TOP == aCornerOwnerSide) || (NS_SIDE_BOTTOM == aCornerOwnerSide)) { if ((NS_SIDE_TOP == aCornerOwnerSide) || (NS_SIDE_BOTTOM == aCornerOwnerSide)) {
DivideBCBorderSize(aCornerSubWidth, smallHalf, largeHalf); DivideBCBorderSize(aCornerSubWidth, smallHalf, largeHalf);
@ -6645,6 +6621,7 @@ CalcHorCornerOffset(PRUint8 aCornerOwnerSide,
PRBool aTableIsLTR) PRBool aTableIsLTR)
{ {
nscoord offset = 0; nscoord offset = 0;
// XXX These should be replaced with appropriate side-specific macros (which?).
nscoord smallHalf, largeHalf; nscoord smallHalf, largeHalf;
if ((NS_SIDE_LEFT == aCornerOwnerSide) || (NS_SIDE_RIGHT == aCornerOwnerSide)) { if ((NS_SIDE_LEFT == aCornerOwnerSide) || (NS_SIDE_RIGHT == aCornerOwnerSide)) {
if (aTableIsLTR) { if (aTableIsLTR) {
@ -7594,7 +7571,7 @@ DestroyCoordFunc(void* aFrame,
void* aPropertyValue, void* aPropertyValue,
void* aDtorData) void* aDtorData)
{ {
delete (nscoord*)aPropertyValue; delete NS_STATIC_CAST(nscoord*, aPropertyValue);
} }
// Destructor function point properties // Destructor function point properties
@ -7604,7 +7581,7 @@ DestroyPointFunc(void* aFrame,
void* aPropertyValue, void* aPropertyValue,
void* aDtorData) void* aDtorData)
{ {
delete (nsPoint*)aPropertyValue; delete NS_STATIC_CAST(nsPoint*, aPropertyValue);
} }
// Destructor function for nscoord properties // Destructor function for nscoord properties
@ -7614,7 +7591,7 @@ DestroyBCPropertyDataFunc(void* aFrame,
void* aPropertyValue, void* aPropertyValue,
void* aDtorData) void* aDtorData)
{ {
delete (BCPropertyData*)aPropertyValue; delete NS_STATIC_CAST(BCPropertyData*, aPropertyValue);
} }
void* void*
@ -7626,7 +7603,7 @@ nsTableFrame::GetProperty(nsIFrame* aFrame,
void *value = propTable->GetProperty(aFrame, aPropertyName); void *value = propTable->GetProperty(aFrame, aPropertyName);
if (value) { if (value) {
return (nsPoint*)value; // the property already exists return (nsPoint*)value; // the property already exists
} }
if (aCreateIfNecessary) { if (aCreateIfNecessary) {
// The property isn't set yet, so allocate a new value, set the property, // The property isn't set yet, so allocate a new value, set the property,
// and return the newly allocated value // and return the newly allocated value
@ -7643,8 +7620,9 @@ nsTableFrame::GetProperty(nsIFrame* aFrame,
value = new BCPropertyData; value = new BCPropertyData;
dtorFunc = DestroyBCPropertyDataFunc; dtorFunc = DestroyBCPropertyDataFunc;
} }
if (!value) return nsnull; if (value) {
propTable->SetProperty(aFrame, aPropertyName, value, dtorFunc, nsnull); propTable->SetProperty(aFrame, aPropertyName, value, dtorFunc, nsnull);
}
return value; return value;
} }
return nsnull; return nsnull;

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

@ -170,8 +170,6 @@ private:
* - "ColGroup-list" which contains the col group frames * - "ColGroup-list" which contains the col group frames
* *
* @see nsLayoutAtoms::colGroupList * @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 class nsTableFrame : public nsHTMLContainerFrame, public nsITableLayout
{ {
@ -1116,34 +1114,3 @@ return aReturn;}
var = 1.0f / var; var = 1.0f / var;
#endif #endif

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

@ -409,7 +409,7 @@ nsTableOuterFrame::ZeroAutoMargin(nsHTMLReflowState& aReflowState,
} }
} }
void static void
FixAutoMargins(nscoord aAvailWidth, FixAutoMargins(nscoord aAvailWidth,
nscoord aChildWidth, nscoord aChildWidth,
nsHTMLReflowState& aReflowState) nsHTMLReflowState& aReflowState)
@ -474,6 +474,7 @@ nsTableOuterFrame::GetMarginPadding(nsPresContext* aPresContext,
aPadding = childRS.mComputedPadding; aPadding = childRS.mComputedPadding;
} }
static
nscoord CalcAutoMargin(nscoord aAutoMargin, nscoord CalcAutoMargin(nscoord aAutoMargin,
nscoord aOppositeMargin, nscoord aOppositeMargin,
nscoord aContainBlockSize, nscoord aContainBlockSize,
@ -489,7 +490,7 @@ nscoord CalcAutoMargin(nscoord aAutoMargin,
return PR_MAX(0, margin); return PR_MAX(0, margin);
} }
void static void
MoveFrameTo(nsIFrame* aFrame, MoveFrameTo(nsIFrame* aFrame,
nscoord aX, nscoord aX,
nscoord aY) nscoord aY)
@ -501,7 +502,7 @@ MoveFrameTo(nsIFrame* aFrame,
} }
} }
nsSize static nsSize
GetContainingBlockSize(const nsHTMLReflowState& aOuterRS) GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
{ {
nsSize size(0,0); nsSize size(0,0);
@ -755,11 +756,10 @@ nsTableOuterFrame::GetMaxWidth(PRUint8 aCaptionSide,
switch(aCaptionSide) { switch(aCaptionSide) {
case NS_SIDE_LEFT: case NS_SIDE_LEFT:
case NS_SIDE_RIGHT: case NS_SIDE_RIGHT:
maxWidth += mCaptionFrame->GetSize().width + aCaptionMargin.left + aCaptionMargin.right;
// the caption plus it margins should cover the corresponding inner table side // the caption plus it margins should cover the corresponding inner table side
// margin - don't count it twice. // margin - don't count it twice.
maxWidth = mCaptionFrame->GetSize().width + aCaptionMargin.left + aCaptionMargin.right + maxWidth -= (NS_SIDE_LEFT == aCaptionSide) ? aInnerMargin.left : aInnerMargin.right;
((nsTableFrame *)mInnerTableFrame)->GetPreferredWidth();
maxWidth += (NS_SIDE_LEFT == aCaptionSide) ? aInnerMargin.right : aInnerMargin.left;
break; break;
case NS_SIDE_TOP: case NS_SIDE_TOP:
case NS_SIDE_BOTTOM: case NS_SIDE_BOTTOM:
@ -785,12 +785,10 @@ nsTableOuterFrame::GetCaptionSide()
PRUint8 PRUint8
nsTableOuterFrame::GetCaptionVerticalAlign() nsTableOuterFrame::GetCaptionVerticalAlign()
{ {
const nsStyleTextReset* textStyle = mCaptionFrame->GetStyleTextReset(); const nsStyleCoord& va = mCaptionFrame->GetStyleTextReset()->mVerticalAlign;
PRUint8 verticalAlignFlags = NS_STYLE_VERTICAL_ALIGN_TOP; return (va.GetUnit() == eStyleUnit_Enumerated)
if (textStyle->mVerticalAlign.GetUnit() == eStyleUnit_Enumerated) { ? va.GetIntValue()
verticalAlignFlags = textStyle->mVerticalAlign.GetIntValue(); : NS_STYLE_VERTICAL_ALIGN_TOP;
}
return verticalAlignFlags;
} }
void void
@ -1233,7 +1231,6 @@ nsTableOuterFrame::OuterReflowChild(nsPresContext* aPresContext,
nsReflowStatus& aStatus, nsReflowStatus& aStatus,
PRBool* aNeedToReflowCaption) PRBool* aNeedToReflowCaption)
{ {
if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER);
aMargin = aPadding = nsMargin(0,0,0,0); aMargin = aPadding = nsMargin(0,0,0,0);
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in // work around pixel rounding errors, round down to ensure we don't exceed the avail height in

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

@ -38,17 +38,7 @@
#ifndef nsTablePainter_h__ #ifndef nsTablePainter_h__
#define nsTablePainter_h__ #define nsTablePainter_h__
typedef PRUint8 BCPixelSize; #include "celldata.h"
#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)
// flags for Paint, PaintChild, PaintChildren are currently only used by tables. // flags for Paint, PaintChild, PaintChildren are currently only used by tables.
//Table-based paint call; not a direct call as with views //Table-based paint call; not a direct call as with views

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

@ -333,7 +333,8 @@ private:
nscoord mMaxCellAscent; // does include cells with rowspan > 1 nscoord mMaxCellAscent; // does include cells with rowspan > 1
nscoord mMaxCellDescent; // does *not* 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 mTopBorderWidth;
BCPixelSize mBottomBorderWidth; BCPixelSize mBottomBorderWidth;
BCPixelSize mRightContBorderWidth; BCPixelSize mRightContBorderWidth;

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

@ -517,7 +517,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
{ {
nsTableFrame* tableFrame = nsnull; nsTableFrame* tableFrame = nsnull;
nsTableFrame::GetTableFrame(this, tableFrame); nsTableFrame::GetTableFrame(this, tableFrame);
if (!aPresContext || !tableFrame) return; if (!tableFrame) return;
PRBool isPaginated = aPresContext->IsPaginated(); PRBool isPaginated = aPresContext->IsPaginated();
@ -1212,7 +1212,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
nsTableFrame* tableFrame = nsnull; nsTableFrame* tableFrame = nsnull;
rv = nsTableFrame::GetTableFrame(this, tableFrame); 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 // see if a special height reflow needs to occur due to having a pct height
if (!NeedSpecialReflow()) if (!NeedSpecialReflow())