Bug 1157569 - part 14 - Finish conversion of border-collapse code in nsTableFrame to logical coordinates. r=dholbert

This commit is contained in:
Jonathan Kew 2015-06-27 11:16:10 -07:00
parent f9a52f8a25
commit d22a7ebb8c
5 changed files with 512 additions and 550 deletions

View File

@ -104,13 +104,13 @@ nsTableCellMap::GetRightMostBorder(int32_t aRowIndex)
{
if (!mBCInfo) ABORT1(nullptr);
int32_t numRows = mBCInfo->mRightBorders.Length();
int32_t numRows = mBCInfo->mIEndBorders.Length();
if (aRowIndex < numRows) {
return &mBCInfo->mRightBorders.ElementAt(aRowIndex);
return &mBCInfo->mIEndBorders.ElementAt(aRowIndex);
}
mBCInfo->mRightBorders.SetLength(aRowIndex+1);
return &mBCInfo->mRightBorders.ElementAt(aRowIndex);
mBCInfo->mIEndBorders.SetLength(aRowIndex+1);
return &mBCInfo->mIEndBorders.ElementAt(aRowIndex);
}
// Get the bcData holding the border segments of the bottom edge of the table
@ -119,13 +119,13 @@ nsTableCellMap::GetBottomMostBorder(int32_t aColIndex)
{
if (!mBCInfo) ABORT1(nullptr);
int32_t numCols = mBCInfo->mBottomBorders.Length();
int32_t numCols = mBCInfo->mBEndBorders.Length();
if (aColIndex < numCols) {
return &mBCInfo->mBottomBorders.ElementAt(aColIndex);
return &mBCInfo->mBEndBorders.ElementAt(aColIndex);
}
mBCInfo->mBottomBorders.SetLength(aColIndex+1);
return &mBCInfo->mBottomBorders.ElementAt(aColIndex);
mBCInfo->mBEndBorders.SetLength(aColIndex+1);
return &mBCInfo->mBEndBorders.ElementAt(aColIndex);
}
// delete the borders corresponding to the right and bottom edges of the table
@ -133,8 +133,8 @@ void
nsTableCellMap::DeleteRightBottomBorders()
{
if (mBCInfo) {
mBCInfo->mBottomBorders.Clear();
mBCInfo->mRightBorders.Clear();
mBCInfo->mBEndBorders.Clear();
mBCInfo->mIEndBorders.Clear();
}
}
@ -426,7 +426,7 @@ nsTableCellMap::AddColsAtEnd(uint32_t aNumCols)
NS_WARNING("Could not AppendElement");
}
if (mBCInfo) {
if (!mBCInfo->mBottomBorders.AppendElements(aNumCols)) {
if (!mBCInfo->mBEndBorders.AppendElements(aNumCols)) {
NS_WARNING("Could not AppendElement");
}
}
@ -445,9 +445,9 @@ nsTableCellMap::RemoveColsAtEnd()
mCols.RemoveElementAt(colX);
if (mBCInfo) {
int32_t count = mBCInfo->mBottomBorders.Length();
int32_t count = mBCInfo->mBEndBorders.Length();
if (colX < count) {
mBCInfo->mBottomBorders.RemoveElementAt(colX);
mBCInfo->mBEndBorders.RemoveElementAt(colX);
}
}
}
@ -460,7 +460,7 @@ nsTableCellMap::ClearCols()
{
mCols.Clear();
if (mBCInfo)
mBCInfo->mBottomBorders.Clear();
mBCInfo->mBEndBorders.Clear();
}
void
nsTableCellMap::InsertRows(nsTableRowGroupFrame* aParent,
@ -484,16 +484,16 @@ nsTableCellMap::InsertRows(nsTableRowGroupFrame* aParent,
Dump("after InsertRows");
#endif
if (mBCInfo) {
int32_t count = mBCInfo->mRightBorders.Length();
int32_t count = mBCInfo->mIEndBorders.Length();
if (aFirstRowIndex < count) {
for (int32_t rowX = aFirstRowIndex; rowX < aFirstRowIndex + numNewRows; rowX++) {
mBCInfo->mRightBorders.InsertElementAt(rowX);
mBCInfo->mIEndBorders.InsertElementAt(rowX);
}
}
else {
GetRightMostBorder(aFirstRowIndex); // this will create missing entries
for (int32_t rowX = aFirstRowIndex + 1; rowX < aFirstRowIndex + numNewRows; rowX++) {
mBCInfo->mRightBorders.AppendElement();
mBCInfo->mIEndBorders.AppendElement();
}
}
}
@ -524,8 +524,8 @@ nsTableCellMap::RemoveRows(int32_t aFirstRowIndex,
rgStartRowIndex, aDamageArea);
if (mBCInfo) {
for (int32_t rowX = aFirstRowIndex + aNumRowsToRemove - 1; rowX >= aFirstRowIndex; rowX--) {
if (uint32_t(rowX) < mBCInfo->mRightBorders.Length()) {
mBCInfo->mRightBorders.RemoveElementAt(rowX);
if (uint32_t(rowX) < mBCInfo->mIEndBorders.Length()) {
mBCInfo->mIEndBorders.RemoveElementAt(rowX);
}
}
}
@ -733,12 +733,12 @@ nsTableCellMap::Dump(char* aString) const
bool segStart;
bool bevel;
int32_t colIndex;
int32_t numCols = mBCInfo->mBottomBorders.Length();
int32_t numCols = mBCInfo->mBEndBorders.Length();
for (int32_t i = 0; i <= 2; i++) {
printf("\n ");
for (colIndex = 0; colIndex < numCols; colIndex++) {
BCData& cd = mBCInfo->mBottomBorders.ElementAt(colIndex);
BCData& cd = mBCInfo->mBEndBorders.ElementAt(colIndex);
if (0 == i) {
size = cd.GetBStartEdge(owner, segStart);
printf("t=%d%X%d ", int32_t(size), owner, segStart);
@ -752,7 +752,7 @@ nsTableCellMap::Dump(char* aString) const
printf("c=%d%X%d ", int32_t(size), side, bevel);
}
}
BCData& cd = mBCInfo->mLowerRightCorner;
BCData& cd = mBCInfo->mBEndIEndCorner;
if (0 == i) {
size = cd.GetBStartEdge(owner, segStart);
printf("t=%d%X%d ", int32_t(size), owner, segStart);
@ -1074,12 +1074,12 @@ nsTableCellMap::SetBCBorderCorner(Corner aCorner,
LogicalSide aOwner,
nscoord aSubSize,
bool aBevel,
bool aIsBottomRight)
bool aIsBEndIEnd)
{
if (!mBCInfo) ABORT0();
if (aIsBottomRight) {
mBCInfo->mLowerRightCorner.SetCorner(aSubSize, aOwner, aBevel);
if (aIsBEndIEnd) {
mBCInfo->mBEndIEndCorner.SetCorner(aSubSize, aOwner, aBevel);
return;
}
@ -1087,15 +1087,15 @@ nsTableCellMap::SetBCBorderCorner(Corner aCorner,
int32_t yPos = aRowIndex;
int32_t rgYPos = aRowIndex - aCellMapStart;
if (eTopRight == aCorner) {
if (eBStartIEnd == aCorner) {
xPos++;
}
else if (eBottomRight == aCorner) {
else if (eBEndIEnd == aCorner) {
xPos++;
rgYPos++;
yPos++;
}
else if (eBottomLeft == aCorner) {
else if (eBEndIStart == aCorner) {
rgYPos++;
yPos++;
}
@ -1105,7 +1105,7 @@ nsTableCellMap::SetBCBorderCorner(Corner aCorner,
if (GetColCount() <= xPos) {
NS_ASSERTION(xPos == GetColCount(), "program error");
// at the right edge of the table as we checked the corner before
NS_ASSERTION(!aIsBottomRight, "should be handled before");
NS_ASSERTION(!aIsBEndIEnd, "should be handled before");
bcData = GetRightMostBorder(yPos);
}
else {

View File

@ -38,17 +38,17 @@ struct nsColInfo
enum Corner
{
eTopLeft = 0,
eTopRight = 1,
eBottomRight = 2,
eBottomLeft = 3
eBStartIStart = 0,
eBStartIEnd = 1,
eBEndIEnd = 2,
eBEndIStart = 3
};
struct BCInfo
{
nsTArray<BCData> mRightBorders;
nsTArray<BCData> mBottomBorders;
BCData mLowerRightCorner;
nsTArray<BCData> mIEndBorders;
nsTArray<BCData> mBEndBorders;
BCData mBEndIEndCorner;
};
class nsTableCellMap

File diff suppressed because it is too large Load Diff

View File

@ -303,8 +303,8 @@ public:
* continue along the length of the whole left side.
* see nsTablePainter about continuous borders
*/
nscoord GetContinuousLeftBCBorderWidth() const;
void SetContinuousLeftBCBorderWidth(nscoord aValue);
nscoord GetContinuousIStartBCBorderWidth() const;
void SetContinuousIStartBCBorderWidth(nscoord aValue);
friend class nsDelayedCalcBCBorders;
@ -873,7 +873,7 @@ protected:
uint32_t mRowInserted:1;
uint32_t mNeedToCalcBCBorders:1;
uint32_t mGeometryDirty:1;
uint32_t mLeftContBCBorder:8;
uint32_t mIStartContBCBorder:8;
uint32_t mNeedToCollapse:1; // rows, cols that have visibility:collapse need to be collapsed
uint32_t mHasZeroColSpans:1;
uint32_t mNeedColSpanExpansion:1;
@ -995,15 +995,15 @@ inline void nsTableFrame::SetNeedToCalcBCBorders(bool aValue)
}
inline nscoord
nsTableFrame::GetContinuousLeftBCBorderWidth() const
nsTableFrame::GetContinuousIStartBCBorderWidth() const
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
return BC_BORDER_END_HALF_COORD(aPixelsToTwips, mBits.mLeftContBCBorder);
return BC_BORDER_END_HALF_COORD(aPixelsToTwips, mBits.mIStartContBCBorder);
}
inline void nsTableFrame::SetContinuousLeftBCBorderWidth(nscoord aValue)
inline void nsTableFrame::SetContinuousIStartBCBorderWidth(nscoord aValue)
{
mBits.mLeftContBCBorder = (unsigned) aValue;
mBits.mIStartContBCBorder = (unsigned) aValue;
}
#define ABORT0() \

View File

@ -230,7 +230,7 @@ TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
border.BStart(wm) = tempBorder.BStart(wm);
}
border.IStart(wm) = aTableFrame->GetContinuousLeftBCBorderWidth();
border.IStart(wm) = aTableFrame->GetContinuousIStartBCBorderWidth();
tableData.SetBCBorder(border.GetPhysicalMargin(wm));
}
@ -322,7 +322,7 @@ TableBackgroundPainter::PaintTable(nsTableFrame* aTableFrame,
/* BC left borders aren't stored on cols, but the previous column's
right border is the next one's left border.*/
//Start with table's left border.
nscoord lastLeftBorder = aTableFrame->GetContinuousLeftBCBorderWidth();
nscoord lastLeftBorder = aTableFrame->GetContinuousIStartBCBorderWidth();
for (nsTableColGroupFrame* cgFrame : colGroupFrames) {
/*Create data struct for column group*/
@ -495,14 +495,14 @@ TableBackgroundPainter::PaintRow(nsTableRowFrame* aFrame,
if (mIsBorderCollapse && aRowBGData.ShouldSetBCBorder()) {
LogicalMargin border(wm);
nsTableRowFrame* nextRow = aFrame->GetNextRow();
if (nextRow) { //outer top below us is inner bottom for us
if (nextRow) { //outer bStart after us is inner bEnd for us
border.BEnd(wm) = nextRow->GetOuterBStartContBCBorderWidth();
}
else { //acquire rg's bottom border
else { //acquire rg's bEnd border
nsTableRowGroupFrame* rowGroup = static_cast<nsTableRowGroupFrame*>(aFrame->GetParent());
rowGroup->GetContinuousBCBorderWidth(wm, border);
}
//get the rest of the borders; will overwrite all but bottom
//get the rest of the borders; will overwrite all but bEnd
aFrame->GetContinuousBCBorderWidth(wm, border);
aRowBGData.SetBCBorder(border.GetPhysicalMargin(wm));