Bug 1931736. Add missing braces around if/loop statements in layout/tables/. r=layout-reviewers,emilio

Depends on D229254

Differential Revision: https://phabricator.services.mozilla.com/D229255
This commit is contained in:
Jonathan Watt
2024-11-17 05:04:01 +00:00
parent bf1b5d95f9
commit 6a6a264e38
11 changed files with 223 additions and 85 deletions

View File

@@ -481,7 +481,9 @@ void BasicTableLayoutStrategy::ComputeIntrinsicISizes(
(nonpct_pref_total == nscoord_MAX
? nscoord_MAX
: nscoord(float(nonpct_pref_total) / (1.0f - pct_total)));
if (large_pct_pref > pref_pct_expand) pref_pct_expand = large_pct_pref;
if (large_pct_pref > pref_pct_expand) {
pref_pct_expand = large_pct_pref;
}
}
// border-spacing isn't part of the basis for percentages
@@ -527,7 +529,9 @@ void BasicTableLayoutStrategy::ComputeColumnISizes(
nsTableCellMap* cellMap = mTableFrame->GetCellMap();
int32_t colCount = cellMap->GetColCount();
if (colCount <= 0) return; // nothing to do
if (colCount <= 0) {
return; // nothing to do
}
DistributeISizeToColumns(iSize, 0, colCount, BtlsISizeType::FinalISize,
false);
@@ -877,8 +881,9 @@ void BasicTableLayoutStrategy::DistributeISizeToColumns(
col_iSize = NSCoordSaturatingAdd(
col_iSize, NSToCoordRound(float(pref_minus_min) * c));
}
} else
} else {
col_iSize = col_iSize_before_adjust = colFrame->GetMinCoord();
}
}
break;
case FLEX_FLEX_SMALL:

View File

@@ -92,8 +92,9 @@ SpanningCellSorter::Item* SpanningCellSorter::GetNext(int32_t* aColSpan) {
mEnumerationIndex = 0;
[[fallthrough]];
case ENUMERATING_ARRAY:
while (mEnumerationIndex < ARRAY_SIZE && !mArray[mEnumerationIndex])
while (mEnumerationIndex < ARRAY_SIZE && !mArray[mEnumerationIndex]) {
++mEnumerationIndex;
}
if (mEnumerationIndex < ARRAY_SIZE) {
Item* result = mArray[mEnumerationIndex];
*aColSpan = IndexToSpan(mEnumerationIndex);

View File

@@ -415,14 +415,17 @@ void nsTableCellMap::RemoveColsAtEnd() {
mBCInfo->mBEndBorders.RemoveElementAt(colX);
}
}
} else
} else {
break; // only remove until we encounter the 1st valid one
}
}
}
void nsTableCellMap::ClearCols() {
mCols.Clear();
if (mBCInfo) mBCInfo->mBEndBorders.Clear();
if (mBCInfo) {
mBCInfo->mBEndBorders.Clear();
}
}
void nsTableCellMap::InsertRows(nsTableRowGroupFrame* aParent,
nsTArray<nsTableRowFrame*>& aRows,
@@ -506,9 +509,13 @@ CellData* nsTableCellMap::AppendCell(nsTableCellFrame& aCellFrame,
MOZ_ASSERT(&aCellFrame == aCellFrame.FirstInFlow(),
"invalid call on continuing frame");
nsIFrame* rgFrame = aCellFrame.GetParent(); // get the row
if (!rgFrame) return 0;
if (!rgFrame) {
return 0;
}
rgFrame = rgFrame->GetParent(); // get the row group
if (!rgFrame) return 0;
if (!rgFrame) {
return 0;
}
CellData* result = nullptr;
int32_t rowIndex = aRowIndex;
@@ -734,14 +741,18 @@ int32_t nsTableCellMap::GetIndexByRowAndColumn(int32_t aRow,
rowIndex -= rowCount;
int32_t cellMapIdx = cellMap->GetHighestIndex(colCount);
if (cellMapIdx != -1) index += cellMapIdx + 1;
if (cellMapIdx != -1) {
index += cellMapIdx + 1;
}
} else {
// Index is in valid range for this cellmap, so get the index of rowIndex
// and aColumn.
int32_t cellMapIdx =
cellMap->GetIndexByRowAndColumn(colCount, rowIndex, aColumn);
if (cellMapIdx == -1) return -1; // no cell at the given row and column.
if (cellMapIdx == -1) {
return -1; // no cell at the given row and column.
}
index += cellMapIdx;
return index; // no need to look through further maps here
@@ -932,8 +943,9 @@ void nsTableCellMap::SetBCBorderEdge(LogicalSide aSide, nsCellMap& aCellMap,
}
if (bcData) {
bcData->SetBStartEdge(aOwner, aSize, changed);
} else
} else {
NS_ERROR("Cellmap: BStart edge not found");
}
}
break;
case LogicalSide::IEnd:
@@ -953,8 +965,9 @@ void nsTableCellMap::SetBCBorderEdge(LogicalSide aSide, nsCellMap& aCellMap,
BCData* bcData = GetIEndMostBorder(yIndex + aCellMapStart);
if (bcData) {
bcData->SetIStartEdge(aOwner, aSize, changed);
} else
} else {
NS_ERROR("Cellmap: IStart edge not found");
}
}
}
break;
@@ -1032,8 +1045,9 @@ void nsTableCellMap::SetBCBorderCorner(LogicalCorner aCorner,
}
if (bcData) {
bcData->SetCorner(aSubSize, aOwner, aBevel);
} else
} else {
NS_ERROR("program error: Corner not found");
}
}
nsCellMap::nsCellMap(nsTableRowGroupFrame* aRowGroup, bool aIsBC)
@@ -1099,9 +1113,13 @@ int32_t nsCellMap::GetHighestIndex(int32_t aColCount) {
for (int32_t colIdx = 0; colIdx < aColCount; colIdx++) {
CellData* data = row.SafeElementAt(colIdx);
// No data means row doesn't have more cells.
if (!data) break;
if (!data) {
break;
}
if (data->IsOrig()) index++;
if (data->IsOrig()) {
index++;
}
}
}
@@ -1110,7 +1128,9 @@ int32_t nsCellMap::GetHighestIndex(int32_t aColCount) {
int32_t nsCellMap::GetIndexByRowAndColumn(int32_t aColCount, int32_t aRow,
int32_t aColumn) const {
if (uint32_t(aRow) >= mRows.Length()) return -1;
if (uint32_t(aRow) >= mRows.Length()) {
return -1;
}
int32_t index = -1;
int32_t lastColsIdx = aColCount - 1;
@@ -1128,14 +1148,20 @@ int32_t nsCellMap::GetIndexByRowAndColumn(int32_t aColCount, int32_t aRow,
for (int32_t colIdx = 0; colIdx <= colCount; colIdx++) {
data = row.SafeElementAt(colIdx);
// No data means row doesn't have more cells.
if (!data) break;
if (!data) {
break;
}
if (data->IsOrig()) index++;
if (data->IsOrig()) {
index++;
}
}
}
// Given row and column don't point to the cell.
if (!data) return -1;
if (!data) {
return -1;
}
return index;
}
@@ -1155,9 +1181,13 @@ void nsCellMap::GetRowAndColumnByIndex(int32_t aColCount, int32_t aIndex,
CellData* data = row.SafeElementAt(colIdx);
// The row doesn't have more cells.
if (!data) break;
if (!data) {
break;
}
if (data->IsOrig()) index--;
if (data->IsOrig()) {
index--;
}
if (index < 0) {
*aRow = rowIdx;
@@ -1293,10 +1323,14 @@ CellData* nsCellMap::AppendCell(nsTableCellMap& aMap,
// origNumCols if there are none
CellData* origData = nullptr;
int32_t startColIndex = 0;
if (aColToBeginSearch) startColIndex = *aColToBeginSearch;
if (aColToBeginSearch) {
startColIndex = *aColToBeginSearch;
}
for (; startColIndex < origNumCols; startColIndex++) {
CellData* data = GetDataAt(aRowIndex, startColIndex);
if (!data) break;
if (!data) {
break;
}
// The border collapse code relies on having multiple dead cell data entries
// in a row.
if (data->IsDead() && aCellFrame) {
@@ -1307,7 +1341,9 @@ CellData* nsCellMap::AppendCell(nsTableCellMap& aMap,
// We found the place to append the cell, when the next cell is appended
// the next search does not need to duplicate the search but can start
// just at the next cell.
if (aColToBeginSearch) *aColToBeginSearch = startColIndex + 1;
if (aColToBeginSearch) {
*aColToBeginSearch = startColIndex + 1;
}
int32_t colSpan = aCellFrame ? aCellFrame->GetColSpan() : 1;
@@ -1404,7 +1440,9 @@ CellData* nsCellMap::AppendCell(nsTableCellMap& aMap,
}
} else {
cellData = AllocCellData(nullptr);
if (!cellData) return origData;
if (!cellData) {
return origData;
}
if (rowX > aRowIndex) {
cellData->SetRowSpanOffset(rowX - aRowIndex);
if (zeroRowSpan) {
@@ -1508,7 +1546,9 @@ void nsCellMap::InsertCells(nsTableCellMap& aMap,
nsTArray<nsTableCellFrame*>& aCellFrames,
int32_t aRowIndex, int32_t aColIndexBefore,
int32_t aRgFirstRowIndex, TableArea& aDamageArea) {
if (aCellFrames.Length() == 0) return;
if (aCellFrames.Length() == 0) {
return;
}
NS_ASSERTION(aColIndexBefore >= -1, "index out of range");
int32_t numCols = aMap.GetColCount();
if (aColIndexBefore >= numCols) {
@@ -1624,7 +1664,9 @@ void nsCellMap::ExpandWithCells(nsTableCellMap& aMap,
for (int32_t cellX = 0; cellX < numCells; cellX++) {
nsTableCellFrame* cellFrame = aCellFrames.ElementAt(cellX);
CellData* origData = AllocCellData(cellFrame); // the originating cell
if (!origData) return;
if (!origData) {
return;
}
// set the starting and ending col index for the new cell
int32_t colSpan = cellFrame->GetColSpan();
@@ -1654,7 +1696,9 @@ void nsCellMap::ExpandWithCells(nsTableCellMap& aMap,
CellData* data = origData;
if ((rowX != aRowIndex) || (colX != startColIndex)) {
data = AllocCellData(nullptr);
if (!data) return;
if (!data) {
return;
}
if (rowX > aRowIndex) {
data->SetRowSpanOffset(rowX - aRowIndex);
if (aRowSpanIsZero) {
@@ -1786,7 +1830,9 @@ int32_t nsCellMap::GetEffectiveColSpan(const nsTableCellMap& aMap,
if (cellFrame) {
// possible change the number of colums to iterate
maxCols = std::min(aColIndex + cellFrame->GetColSpan(), maxCols);
if (colX >= maxCols) break;
if (colX >= maxCols) {
break;
}
}
}
}
@@ -1795,8 +1841,9 @@ int32_t nsCellMap::GetEffectiveColSpan(const nsTableCellMap& aMap,
} else {
break;
}
} else
} else {
break;
}
}
return colSpan;
}
@@ -1839,7 +1886,9 @@ int32_t nsCellMap::GetNumCellsOriginatingInRow(int32_t aRowIndex) const {
uint32_t colIndex;
for (colIndex = 0; colIndex < maxColIndex; colIndex++) {
CellData* cellData = row[colIndex];
if (cellData && cellData->IsOrig()) count++;
if (cellData && cellData->IsOrig()) {
count++;
}
}
return count;
}
@@ -1857,8 +1906,9 @@ int32_t nsCellMap::GetRowSpan(int32_t aRowIndex, int32_t aColIndex,
} else {
break;
}
} else
} else {
break;
}
}
return rowSpan;
}
@@ -2299,8 +2349,9 @@ void nsCellMap::SetDataAt(nsTableCellMap& aMap, CellData& aNewCell,
} else if (aNewCell.IsColSpan()) {
colInfo->mNumCellsSpan++;
}
} else
} else {
NS_ERROR("SetDataAt called with col index > table map num cols");
}
}
nsTableCellFrame* nsCellMap::GetCellInfoAt(const nsTableCellMap& aMap,
@@ -2315,7 +2366,9 @@ nsTableCellFrame* nsCellMap::GetCellInfoAt(const nsTableCellMap& aMap,
if (data) {
if (data->IsOrig()) {
cellFrame = data->GetCellFrame();
if (aOriginates) *aOriginates = true;
if (aOriginates) {
*aOriginates = true;
}
} else {
cellFrame = GetCellFrame(aRowX, aColX, *data, true);
}

View File

@@ -127,7 +127,9 @@ void nsTableCellFrame::NotifyPercentBSize(const ReflowInput& aReflowInput) {
// below that
bool nsTableCellFrame::NeedsToObserve(const ReflowInput& aReflowInput) {
const ReflowInput* rs = aReflowInput.mParentReflowInput;
if (!rs) return false;
if (!rs) {
return false;
}
if (rs->mFrame == this) {
// We always observe the child block. It will never send any
// notifications, but we need this so that the observer gets
@@ -917,10 +919,11 @@ nsTableCellFrame::GetCellIndexes(int32_t& aRowIndex, int32_t& aColIndex) {
nsTableCellFrame* NS_NewTableCellFrame(PresShell* aPresShell,
ComputedStyle* aStyle,
nsTableFrame* aTableFrame) {
if (aTableFrame->IsBorderCollapse())
if (aTableFrame->IsBorderCollapse()) {
return new (aPresShell) nsBCTableCellFrame(aStyle, aTableFrame);
else
} else {
return new (aPresShell) nsTableCellFrame(aStyle, aTableFrame);
}
}
NS_IMPL_FRAMEARENA_HELPERS(nsBCTableCellFrame)

View File

@@ -65,8 +65,9 @@ void nsTableColFrame::SetColType(nsTableColType aType) {
void nsTableColFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
nsSplittableFrame::DidSetComputedStyle(aOldComputedStyle);
if (!aOldComputedStyle) // avoid this on init
if (!aOldComputedStyle) { // avoid this on init
return;
}
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&

View File

@@ -154,8 +154,12 @@ class nsTableColFrame final : public nsSplittableFrame {
aPrefCoord = aMinCoord; // NOTE: modifying argument
}
if (aMinCoord > mMinCoord) mMinCoord = aMinCoord;
if (aPrefCoord > mPrefCoord) mPrefCoord = aPrefCoord;
if (aMinCoord > mMinCoord) {
mMinCoord = aMinCoord;
}
if (aPrefCoord > mPrefCoord) {
mPrefCoord = aPrefCoord;
}
NS_ASSERTION(mMinCoord <= mPrefCoord, "min larger than pref");
}
@@ -166,7 +170,9 @@ class nsTableColFrame final : public nsSplittableFrame {
* column-spanning cell.
*/
void AddPrefPercent(float aPrefPercent) {
if (aPrefPercent > mPrefPercent) mPrefPercent = aPrefPercent;
if (aPrefPercent > mPrefPercent) {
mPrefPercent = aPrefPercent;
}
}
/**
@@ -204,8 +210,12 @@ class nsTableColFrame final : public nsSplittableFrame {
aSpanPrefCoord = aSpanMinCoord; // NOTE: modifying argument
}
if (aSpanMinCoord > mSpanMinCoord) mSpanMinCoord = aSpanMinCoord;
if (aSpanPrefCoord > mSpanPrefCoord) mSpanPrefCoord = aSpanPrefCoord;
if (aSpanMinCoord > mSpanMinCoord) {
mSpanMinCoord = aSpanMinCoord;
}
if (aSpanPrefCoord > mSpanPrefCoord) {
mSpanPrefCoord = aSpanPrefCoord;
}
NS_ASSERTION(mSpanMinCoord <= mSpanPrefCoord, "min larger than pref");
}
@@ -215,8 +225,9 @@ class nsTableColFrame final : public nsSplittableFrame {
* temporary variables.
*/
void AddSpanPrefPercent(float aSpanPrefPercent) {
if (aSpanPrefPercent > mSpanPrefPercent)
if (aSpanPrefPercent > mSpanPrefPercent) {
mSpanPrefPercent = aSpanPrefPercent;
}
}
/*
@@ -233,7 +244,9 @@ class nsTableColFrame final : public nsSplittableFrame {
// starting at the first column, until they reach 100%).
void AdjustPrefPercent(float* aTableTotalPercent) {
float allowed = 1.0f - *aTableTotalPercent;
if (mPrefPercent > allowed) mPrefPercent = allowed;
if (mPrefPercent > allowed) {
mPrefPercent = allowed;
}
*aTableTotalPercent += mPrefPercent;
}

View File

@@ -141,14 +141,17 @@ void nsTableColGroupFrame::DidSetComputedStyle(
ComputedStyle* aOldComputedStyle) {
nsContainerFrame::DidSetComputedStyle(aOldComputedStyle);
if (!aOldComputedStyle) // avoid this on init
if (!aOldComputedStyle) { // avoid this on init
return;
}
nsTableFrame* tableFrame = GetTableFrame();
if (tableFrame->IsBorderCollapse() &&
tableFrame->BCRecalcNeeded(aOldComputedStyle, Style())) {
int32_t colCount = GetColCount();
if (!colCount) return; // this is a degenerated colgroup
if (!colCount) {
return; // this is a degenerated colgroup
}
TableArea damageArea(GetFirstColumn()->GetColIndex(), 0, colCount,
tableFrame->GetRowCount());
tableFrame->AddBCDamageArea(damageArea);
@@ -259,8 +262,9 @@ void nsTableColGroupFrame::RemoveChild(DestroyContext& aContext,
ResetColIndices(this, colIndex, nextChild);
} else {
nsIFrame* nextGroup = GetNextSibling();
if (nextGroup) // reset next and all following colgroups
if (nextGroup) { // reset next and all following colgroups
ResetColIndices(nextGroup, colIndex);
}
}
}
@@ -431,7 +435,9 @@ nsresult nsTableColGroupFrame::GetFrameName(nsAString& aResult) const {
void nsTableColGroupFrame::Dump(int32_t aIndent) {
char* indent = new char[aIndent + 1];
if (!indent) return;
if (!indent) {
return;
}
for (int32_t i = 0; i < aIndent + 1; i++) {
indent[i] = ' ';
}

View File

@@ -439,10 +439,11 @@ int32_t nsTableFrame::GetEffectiveRowSpan(const nsTableCellFrame& aCell,
uint32_t colIndex = aCell.ColIndex();
uint32_t rowIndex = aCell.RowIndex();
if (aCellMap)
if (aCellMap) {
return aCellMap->GetRowSpan(rowIndex, colIndex, true);
else
} else {
return tableCellMap->GetEffectiveRowSpan(rowIndex, colIndex);
}
}
int32_t nsTableFrame::GetEffectiveColSpan(const nsTableCellFrame& aCell,
@@ -453,10 +454,11 @@ int32_t nsTableFrame::GetEffectiveColSpan(const nsTableCellFrame& aCell,
uint32_t colIndex = aCell.ColIndex();
uint32_t rowIndex = aCell.RowIndex();
if (aCellMap)
if (aCellMap) {
return aCellMap->GetEffectiveColSpan(*tableCellMap, rowIndex, colIndex);
else
} else {
return tableCellMap->GetEffectiveColSpan(rowIndex, colIndex);
}
}
bool nsTableFrame::HasMoreThanOneCell(int32_t aRowIndex) const {
@@ -740,11 +742,14 @@ void nsTableFrame::MatchCellMapToColCache(nsTableCellMap* aCellMap) {
void nsTableFrame::DidResizeColumns() {
MOZ_ASSERT(!GetPrevInFlow(), "should only be called on first-in-flow");
if (mBits.mResizedColumns) return; // already marked
if (mBits.mResizedColumns) {
return; // already marked
}
for (nsTableFrame* f = this; f;
f = static_cast<nsTableFrame*>(f->GetNextInFlow()))
f = static_cast<nsTableFrame*>(f->GetNextInFlow())) {
f->mBits.mResizedColumns = true;
}
}
void nsTableFrame::AppendCell(nsTableCellFrame& aCellFrame, int32_t aRowIndex) {
@@ -954,7 +959,9 @@ void nsTableFrame::AddDeletedRowIndex(int32_t aDeletedRowStoredIndex) {
}
int32_t nsTableFrame::GetAdjustmentForStoredIndex(int32_t aStoredIndex) {
if (mDeletedRowIndexRanges.empty()) return 0;
if (mDeletedRowIndexRanges.empty()) {
return 0;
}
int32_t adjustment = 0;
@@ -1993,22 +2000,26 @@ nscoord nsTableFrame::GetCollapsedISize(const WritingMode aWM,
void nsTableFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
nsContainerFrame::DidSetComputedStyle(aOldComputedStyle);
if (!aOldComputedStyle) // avoid this on init
if (!aOldComputedStyle) { // avoid this on init
return;
}
if (IsBorderCollapse() && BCRecalcNeeded(aOldComputedStyle, Style())) {
SetFullBCDamageArea();
}
// avoid this on init or nextinflow
if (!mTableLayoutStrategy || GetPrevInFlow()) return;
if (!mTableLayoutStrategy || GetPrevInFlow()) {
return;
}
bool isAuto = IsAutoLayout();
if (isAuto != (LayoutStrategy()->GetType() == nsITableLayoutStrategy::Auto)) {
if (isAuto)
if (isAuto) {
mTableLayoutStrategy = MakeUnique<BasicTableLayoutStrategy>(this);
else
} else {
mTableLayoutStrategy = MakeUnique<FixedTableLayoutStrategy>(this);
}
}
}
@@ -2350,7 +2361,9 @@ void nsTableFrame::RemoveFrame(DestroyContext& aContext, ChildListID aListID,
/* virtual */
nsMargin nsTableFrame::GetUsedBorder() const {
if (!IsBorderCollapse()) return nsContainerFrame::GetUsedBorder();
if (!IsBorderCollapse()) {
return nsContainerFrame::GetUsedBorder();
}
WritingMode wm = GetWritingMode();
return GetOuterBCBorder(wm).GetPhysicalMargin(wm);
@@ -2358,7 +2371,9 @@ nsMargin nsTableFrame::GetUsedBorder() const {
/* virtual */
nsMargin nsTableFrame::GetUsedPadding() const {
if (!IsBorderCollapse()) return nsContainerFrame::GetUsedPadding();
if (!IsBorderCollapse()) {
return nsContainerFrame::GetUsedPadding();
}
return nsMargin(0, 0, 0, 0);
}
@@ -3473,7 +3488,9 @@ nscoord nsTableFrame::CalcBorderBoxBSize(const ReflowInput& aReflowInput,
}
bool nsTableFrame::IsAutoLayout() {
if (StyleTable()->mLayoutStrategy == StyleTableLayout::Auto) return true;
if (StyleTable()->mLayoutStrategy == StyleTableLayout::Auto) {
return true;
}
// a fixed-layout inline-table must have a inline size
// and tables with inline size set to 'max-content' must be
// auto-layout (at least as long as
@@ -4231,7 +4248,9 @@ void BCMapCellIterator::PeekBEnd(const BCMapCellInfo& aRefInfo,
nextRow = rg->GetFirstRow();
}
} while (rg && !nextRow);
if (!rg) return;
if (!rg) {
return;
}
} else {
// get the row within the same row group
nextRow = mRow;
@@ -4376,9 +4395,12 @@ bool nsTableFrame::BCRecalcNeeded(ComputedStyle* aOldComputedStyle,
const nsStyleBorder* oldStyleData = aOldComputedStyle->StyleBorder();
const nsStyleBorder* newStyleData = aNewComputedStyle->StyleBorder();
nsChangeHint change = newStyleData->CalcDifference(*oldStyleData);
if (!change) return false;
if (change & nsChangeHint_NeedReflow)
if (!change) {
return false;
}
if (change & nsChangeHint_NeedReflow) {
return true; // the caller only needs to mark the bc damage area
}
if (change & nsChangeHint_RepaintFrame) {
// we need to recompute the borders and the caller needs to mark
// the bc damage area
@@ -4421,9 +4443,13 @@ static const BCCellBorder& CompareBorders(
}
}
if (aFirstDominates) *aFirstDominates = firstDominates;
if (aFirstDominates) {
*aFirstDominates = firstDominates;
}
if (firstDominates) return aBorder1;
if (firstDominates) {
return aBorder1;
}
return aBorder2;
}
@@ -4765,7 +4791,9 @@ void nsTableFrame::ExpandBCDamageArea(TableArea& aArea) const {
nsTableRowGroupFrame* rgFrame = rowGroups[rgIdx];
int32_t rgStartY = rgFrame->GetStartRowIndex();
int32_t rgEndY = rgStartY + rgFrame->GetRowCount() - 1;
if (endRowIdx < rgStartY) break;
if (endRowIdx < rgStartY) {
break;
}
cellMap = tableCellMap->GetMapFor(rgFrame, cellMap);
if (!cellMap) ABORT0();
// check for spanners from above and below
@@ -5092,7 +5120,9 @@ void nsTableFrame::CalcBCBorders() {
if (!tableCellMap) ABORT0();
int32_t numRows = GetRowCount();
int32_t numCols = GetColCount();
if (!numRows || !numCols) return; // nothing to do
if (!numRows || !numCols) {
return; // nothing to do
}
// Get the property holding the table damage area and border widths
TableBCData* propData = GetTableBCData();
@@ -6022,8 +6052,9 @@ bool BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) {
nsTableRowFrame* fifRow =
static_cast<nsTableRowFrame*>(rowFrame->FirstInFlow());
endRowIndex = fifRow->GetRowIndex();
} else
} else {
done = true;
}
} else {
// conservatively estimate the half border widths outside the row
nscoord borderHalf = mTable->GetNextInFlow()
@@ -6050,10 +6081,14 @@ bool BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) {
// table wrapper borders overflow the table, so the table might be
// target to other areas as the NS_FRAME_OUTSIDE_CHILDREN is set
// on the table
if (!haveIntersect) return false;
if (!haveIntersect) {
return false;
}
// find startColIndex, endColIndex, startColX
haveIntersect = false;
if (0 == mNumTableCols) return false;
if (0 == mNumTableCols) {
return false;
}
LogicalMargin bp = mTable->GetOuterBCBorder(mTableWM);
@@ -6073,8 +6108,9 @@ bool BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) {
nscoord iStartBorderHalf = colFrame->GetIStartBorderWidth() + onePx;
if (dirtyRect.IEnd(mTableWM) >= x - iStartBorderHalf) {
endColIndex = colIdx;
} else
} else {
break;
}
} else {
// conservatively estimate the iEnd half border width outside the col
nscoord iEndBorderHalf = colFrame->GetIEndBorderWidth() + onePx;
@@ -6087,7 +6123,9 @@ bool BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect) {
}
x += colISize;
}
if (!haveIntersect) return false;
if (!haveIntersect) {
return false;
}
mDamageArea =
TableArea(startColIndex, startRowIndex,
1 + DeprecatedAbs<int32_t>(endColIndex - startColIndex),
@@ -7166,7 +7204,9 @@ void nsTableFrame::IterateBCBorders(BCPaintBorderAction& aAction,
// We first transfer the aDirtyRect into cellmap coordinates to compute which
// cell borders need to be painted
BCPaintBorderIterator iter(this);
if (!iter.SetDamageArea(aDirtyRect)) return;
if (!iter.SetDamageArea(aDirtyRect)) {
return;
}
// XXX comment still has physical terminology
// First, paint all of the vertical borders from top to bottom and left to

View File

@@ -636,8 +636,9 @@ static nscoord GetSpaceBetween(int32_t aPrevColIndex, int32_t aColIndex,
const nsStyleVisibility* groupVis = cgFrame->StyleVisibility();
bool collapseGroup = StyleVisibility::Collapse == groupVis->mVisible;
isCollapsed = collapseCol || collapseGroup;
if (!isCollapsed)
if (!isCollapsed) {
space += fifTable->GetColumnISizeFromFirstInFlow(colIdx);
}
}
if (!isCollapsed && aTableFrame.ColumnHasCellSpacingBefore(colIdx)) {
space += aTableFrame.GetColSpacing(colIdx - 1);

View File

@@ -98,8 +98,9 @@ void nsTableRowGroupFrame::AdjustRowIndices(int32_t aRowIndex,
for (nsIFrame* rowFrame : mFrames) {
if (mozilla::StyleDisplay::TableRow == rowFrame->StyleDisplay()->mDisplay) {
int32_t index = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
if (index >= aRowIndex)
if (index >= aRowIndex) {
((nsTableRowFrame*)rowFrame)->SetRowIndex(index + anAdjustment);
}
}
}
}
@@ -547,7 +548,9 @@ void nsTableRowGroupFrame::CalculateRowBSizes(nsPresContext* aPresContext,
int32_t numRows =
GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex());
// Collect the current bsize of each row.
if (numRows <= 0) return;
if (numRows <= 0) {
return;
}
AutoTArray<RowInfo, 32> rowInfo;
// XXX(Bug 1631371) Check if this should use a fallible operation as it
@@ -1005,7 +1008,9 @@ void nsTableRowGroupFrame::SplitSpanningCells(
// a continuation which doesn't have the same number of cells that now exist.
void nsTableRowGroupFrame::UndoContinuedRow(nsPresContext* aPresContext,
nsTableRowFrame* aRow) {
if (!aRow) return; // allow null aRow to avoid callers doing null checks
if (!aRow) {
return; // allow null aRow to avoid callers doing null checks
}
// rowBefore was the prev-sibling of aRow's next-sibling before aRow was
// created
@@ -1581,14 +1586,18 @@ bool nsTableRowGroupFrame::IsSimpleRowFrame(nsTableFrame* aTableFrame,
/** find page break before the first row **/
bool nsTableRowGroupFrame::HasInternalBreakBefore() const {
nsIFrame* firstChild = mFrames.FirstChild();
if (!firstChild) return false;
if (!firstChild) {
return false;
}
return firstChild->StyleDisplay()->BreakBefore();
}
/** find page break after the last row **/
bool nsTableRowGroupFrame::HasInternalBreakAfter() const {
nsIFrame* lastChild = mFrames.LastChild();
if (!lastChild) return false;
if (!lastChild) {
return false;
}
return lastChild->StyleDisplay()->BreakAfter();
}
/* ----- global methods ----- */
@@ -1779,7 +1788,9 @@ nsIFrame* nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY,
FrameCursorData* property = GetProperty(RowCursorProperty());
uint32_t cursorIndex = property->mCursorIndex;
uint32_t frameCount = property->mFrames.Length();
if (cursorIndex >= frameCount) return nullptr;
if (cursorIndex >= frameCount) {
return nullptr;
}
nsIFrame* cursorFrame = property->mFrames[cursorIndex];
// The cursor's frame list excludes frames with empty overflow-area, so
@@ -1819,7 +1830,9 @@ bool nsTableRowGroupFrame::FrameCursorData::AppendFrame(nsIFrame* aFrame) {
nsRect normalOverflowRect = positionedOverflowRect + positionedToNormal;
nsRect overflowRect = positionedOverflowRect.Union(normalOverflowRect);
if (overflowRect.IsEmpty()) return true;
if (overflowRect.IsEmpty()) {
return true;
}
nscoord overflowAbove = -overflowRect.y;
nscoord overflowBelow = overflowRect.YMost() - aFrame->GetSize().height;
mOverflowAbove = std::max(mOverflowAbove, overflowAbove);

View File

@@ -124,7 +124,9 @@ class nsTableWrapperFrame : public nsContainerFrame {
*/
int32_t GetIndexByRowAndColumn(int32_t aRowIdx, int32_t aColIdx) const {
nsTableCellMap* cellMap = InnerTableFrame()->GetCellMap();
if (!cellMap) return -1;
if (!cellMap) {
return -1;
}
return cellMap->GetIndexByRowAndColumn(aRowIdx, aColIdx);
}