Skip to content

Commit

Permalink
Bug 1873473: Part 2 - Move variables in CalcBCBorders to be more sc…
Browse files Browse the repository at this point in the history
…ope-specific where possible. r=layout-reviewers,TYLin

Differential Revision: https://phabricator.services.mozilla.com/D197931
  • Loading branch information
dshin-moz committed Feb 13, 2024
1 parent 02b1a97 commit da35194
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions layout/tables/nsTableFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5049,11 +5049,9 @@ void nsTableFrame::CalcBCBorders() {
BCCellBorders lastBEndBorders(damageArea.ColCount() + 1,
damageArea.StartCol());
if (!lastBEndBorders.borders) ABORT0();
bool startSeg;

BCMapCellInfo info(this), ajaInfo(this);
BCMapCellInfo info(this);

BCCellBorder currentBorder, adjacentBorder;
BCCorners bStartCorners(damageArea.ColCount() + 1, damageArea.StartCol());
if (!bStartCorners.corners) ABORT0();
BCCorners bEndCorners(damageArea.ColCount() + 1, damageArea.StartCol());
Expand Down Expand Up @@ -5090,7 +5088,7 @@ void nsTableFrame::CalcBCBorders() {
for (int32_t colIdx = info.mColIndex; colIdx <= info.GetCellEndColIndex();
colIdx++) {
info.SetColumn(colIdx);
currentBorder = info.GetBStartEdgeBorder();
BCCellBorder currentBorder = info.GetBStartEdgeBorder();
// update/store the bStart-iStart & bStart-iEnd corners of the seg
BCCornerInfo& tlCorner = bStartCorners[colIdx]; // bStart-iStart
if (0 == colIdx) {
Expand All @@ -5108,10 +5106,10 @@ void nsTableFrame::CalcBCBorders() {
MOZ_ASSERT(firstRowBStartEdgeBorder,
"Inline start border tracking not set?");
// update firstRowBStartEdgeBorder and see if a new segment starts
startSeg = firstRowBStartEdgeBorder
? SetInlineDirBorder(currentBorder, tlCorner,
firstRowBStartEdgeBorder.ref())
: true;
bool startSeg = firstRowBStartEdgeBorder
? SetInlineDirBorder(currentBorder, tlCorner,
firstRowBStartEdgeBorder.ref())
: true;
// store the border segment in the cell map
tableCellMap->SetBCBorderEdge(eLogicalSideBStart, *iter.mCellMap, 0, 0,
colIdx, 1, currentBorder.owner,
Expand Down Expand Up @@ -5148,7 +5146,7 @@ void nsTableFrame::CalcBCBorders() {
for (int32_t rowB = info.mRowIndex; rowB <= info.GetCellEndRowIndex();
rowB++) {
info.IncrementRow(rowB == info.mRowIndex);
currentBorder = info.GetIStartEdgeBorder();
BCCellBorder currentBorder = info.GetIStartEdgeBorder();
BCCornerInfo& tlCorner =
(0 == rowB) ? bStartCorners[0] : bEndCorners[0];
tlCorner.Update(eLogicalSideBEnd, currentBorder);
Expand All @@ -5159,7 +5157,7 @@ void nsTableFrame::CalcBCBorders() {
bEndCorners[0].Set(eLogicalSideBStart, currentBorder); // bEnd-iStart

// update lastBlockDirBorders and see if a new segment starts
startSeg = SetBorder(currentBorder, lastBlockDirBorders[0]);
bool startSeg = SetBorder(currentBorder, lastBlockDirBorders[0]);
// store the border segment in the cell map
tableCellMap->SetBCBorderEdge(eLogicalSideIStart, *iter.mCellMap,
iter.mRowGroupStart, rowB, info.mColIndex,
Expand All @@ -5182,7 +5180,7 @@ void nsTableFrame::CalcBCBorders() {
for (int32_t rowB = info.mRowIndex; rowB <= info.GetCellEndRowIndex();
rowB++) {
info.IncrementRow(rowB == info.mRowIndex);
currentBorder = info.GetIEndEdgeBorder();
BCCellBorder currentBorder = info.GetIEndEdgeBorder();
// update/store the bStart-iEnd & bEnd-iEnd corners
BCCornerInfo& trCorner =
(0 == rowB) ? bStartCorners[info.GetCellEndColIndex() + 1]
Expand All @@ -5199,7 +5197,7 @@ void nsTableFrame::CalcBCBorders() {
info.GetCellEndColIndex(), LogicalSide(brCorner.ownerSide),
brCorner.subWidth, brCorner.bevel);
// update lastBlockDirBorders and see if a new segment starts
startSeg = SetBorder(
bool startSeg = SetBorder(
currentBorder, lastBlockDirBorders[info.GetCellEndColIndex() + 1]);
// store the border segment in the cell map and update cellBorders
tableCellMap->SetBCBorderEdge(
Expand All @@ -5211,20 +5209,21 @@ void nsTableFrame::CalcBCBorders() {
}
} else {
int32_t segLength = 0;
BCMapCellInfo ajaInfo(this);
BCMapCellInfo priorAjaInfo(this);
for (int32_t rowB = info.mRowIndex; rowB <= info.GetCellEndRowIndex();
rowB += segLength) {
iter.PeekIEnd(info, rowB, ajaInfo);
currentBorder = info.GetIEndInternalBorder();
adjacentBorder = ajaInfo.GetIStartInternalBorder();
BCCellBorder currentBorder = info.GetIEndInternalBorder();
BCCellBorder adjacentBorder = ajaInfo.GetIStartInternalBorder();
currentBorder = CompareBorders(!CELL_CORNER, currentBorder,
adjacentBorder, !INLINE_DIR);

segLength = std::max(1, ajaInfo.mRowIndex + ajaInfo.mRowSpan - rowB);
segLength = std::min(segLength, info.mRowIndex + info.mRowSpan - rowB);

// update lastBlockDirBorders and see if a new segment starts
startSeg = SetBorder(
bool startSeg = SetBorder(
currentBorder, lastBlockDirBorders[info.GetCellEndColIndex() + 1]);
// store the border segment in the cell map and update cellBorders
if (info.GetCellEndColIndex() < damageArea.EndCol() &&
Expand All @@ -5248,7 +5247,7 @@ void nsTableFrame::CalcBCBorders() {
// consider the segment to the iEnd side
if (rowB != info.mRowIndex) {
currentBorder = priorAjaInfo.GetBEndInternalBorder();
adjacentBorder = ajaInfo.GetBStartInternalBorder();
BCCellBorder adjacentBorder = ajaInfo.GetBStartInternalBorder();
currentBorder = CompareBorders(!CELL_CORNER, currentBorder,
adjacentBorder, INLINE_DIR);
trCorner->Update(eLogicalSideIEnd, currentBorder);
Expand Down Expand Up @@ -5297,7 +5296,7 @@ void nsTableFrame::CalcBCBorders() {
for (int32_t colIdx = info.mColIndex; colIdx <= info.GetCellEndColIndex();
colIdx++) {
info.SetColumn(colIdx);
currentBorder = info.GetBEndEdgeBorder();
BCCellBorder currentBorder = info.GetBEndEdgeBorder();
// update/store the bEnd-iStart & bEnd-IEnd corners
BCCornerInfo& blCorner = bEndCorners[colIdx]; // bEnd-iStart
blCorner.Update(eLogicalSideIEnd, currentBorder);
Expand All @@ -5316,7 +5315,8 @@ void nsTableFrame::CalcBCBorders() {
brCorner.bevel, true);
}
// update lastBEndBorder and see if a new segment starts
startSeg = SetInlineDirBorder(currentBorder, blCorner, lastBEndBorder);
bool startSeg =
SetInlineDirBorder(currentBorder, blCorner, lastBEndBorder);
if (!startSeg) {
// make sure that we did not compare apples to oranges i.e. the
// current border should be a continuation of the lastBEndBorder,
Expand All @@ -5340,11 +5340,12 @@ void nsTableFrame::CalcBCBorders() {
}
} else {
int32_t segLength = 0;
BCMapCellInfo ajaInfo(this);
for (int32_t colIdx = info.mColIndex; colIdx <= info.GetCellEndColIndex();
colIdx += segLength) {
iter.PeekBEnd(info, colIdx, ajaInfo);
currentBorder = info.GetBEndInternalBorder();
adjacentBorder = ajaInfo.GetBStartInternalBorder();
BCCellBorder currentBorder = info.GetBEndInternalBorder();
BCCellBorder adjacentBorder = ajaInfo.GetBStartInternalBorder();
currentBorder = CompareBorders(!CELL_CORNER, currentBorder,
adjacentBorder, INLINE_DIR);
segLength = std::max(1, ajaInfo.mColIndex + ajaInfo.mColSpan - colIdx);
Expand Down Expand Up @@ -5392,7 +5393,8 @@ void nsTableFrame::CalcBCBorders() {
}
}
// update lastBEndBorders and see if a new segment starts
startSeg = SetInlineDirBorder(currentBorder, blCorner, lastBEndBorder);
bool startSeg =
SetInlineDirBorder(currentBorder, blCorner, lastBEndBorder);
if (!startSeg) {
// make sure that we did not compare apples to oranges i.e. the
// current border should be a continuation of the lastBEndBorder,
Expand Down

0 comments on commit da35194

Please sign in to comment.