summaryrefslogtreecommitdiffstats
path: root/layout/tables/nsTableFrame.cpp
diff options
context:
space:
mode:
authorwin7-7 <win7-7@users.noreply.github.com>2020-02-16 16:06:53 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:45:15 +0200
commitc9fd86cb784b81ab30461b773667b7251347fae6 (patch)
tree2b11c58b75866de08e091d27ea1d4ec289c20873 /layout/tables/nsTableFrame.cpp
parent550d634ff522b0fa1a586f8d85692cff361dca17 (diff)
downloadUXP-c9fd86cb784b81ab30461b773667b7251347fae6.tar
UXP-c9fd86cb784b81ab30461b773667b7251347fae6.tar.gz
UXP-c9fd86cb784b81ab30461b773667b7251347fae6.tar.lz
UXP-c9fd86cb784b81ab30461b773667b7251347fae6.tar.xz
UXP-c9fd86cb784b81ab30461b773667b7251347fae6.zip
Issue #1355 - Make nsTableCellFrame::GetColIndex/GetRowIndex faster
We can devirtualize it, remove some branches.
Diffstat (limited to 'layout/tables/nsTableFrame.cpp')
-rw-r--r--layout/tables/nsTableFrame.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index 868f83bda..4257c9c57 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -368,9 +368,8 @@ nsTableFrame::AttributeChangedFor(nsIFrame* aFrame,
nsTableCellMap* cellMap = GetCellMap();
if (cellMap) {
// for now just remove the cell from the map and reinsert it
- int32_t rowIndex, colIndex;
- cellFrame->GetRowIndex(rowIndex);
- cellFrame->GetColIndex(colIndex);
+ uint32_t rowIndex = cellFrame->RowIndex();
+ uint32_t colIndex = cellFrame->ColIndex();
RemoveCell(cellFrame, rowIndex);
AutoTArray<nsTableCellFrame*, 1> cells;
cells.AppendElement(cellFrame);
@@ -447,9 +446,7 @@ nsTableFrame::GetEffectiveRowSpan(int32_t aRowIndex,
nsTableCellMap* cellMap = GetCellMap();
NS_PRECONDITION (nullptr != cellMap, "bad call, cellMap not yet allocated.");
- int32_t colIndex;
- aCell.GetColIndex(colIndex);
- return cellMap->GetEffectiveRowSpan(aRowIndex, colIndex);
+ return cellMap->GetEffectiveRowSpan(aRowIndex, aCell.ColIndex());
}
int32_t
@@ -458,9 +455,8 @@ nsTableFrame::GetEffectiveRowSpan(const nsTableCellFrame& aCell,
{
nsTableCellMap* tableCellMap = GetCellMap(); if (!tableCellMap) ABORT1(1);
- int32_t colIndex, rowIndex;
- aCell.GetColIndex(colIndex);
- aCell.GetRowIndex(rowIndex);
+ uint32_t colIndex = aCell.ColIndex();
+ uint32_t rowIndex = aCell.RowIndex();
if (aCellMap)
return aCellMap->GetRowSpan(rowIndex, colIndex, true);
@@ -474,9 +470,8 @@ nsTableFrame::GetEffectiveColSpan(const nsTableCellFrame& aCell,
{
nsTableCellMap* tableCellMap = GetCellMap(); if (!tableCellMap) ABORT1(1);
- int32_t colIndex, rowIndex;
- aCell.GetColIndex(colIndex);
- aCell.GetRowIndex(rowIndex);
+ uint32_t colIndex = aCell.ColIndex();
+ uint32_t rowIndex = aCell.RowIndex();
if (aCellMap)
return aCellMap->GetEffectiveColSpan(*tableCellMap, rowIndex, colIndex);
@@ -1221,9 +1216,9 @@ PaintRowGroupBackground(nsTableRowGroupFrame* aRowGroup,
const nsRect& aDirtyRect)
{
for (nsTableRowFrame* row = aRowGroup->GetFirstRow(); row; row = row->GetNextRow()) {
- if (!aDirtyRect.Intersects(nsRect(row->GetNormalPosition(), row->GetSize()))) {
- continue;
- }
+ if (!aDirtyRect.Intersects(nsRect(row->GetNormalPosition(), row->GetSize()))) {
+ continue;
+ }
PaintRowBackground(row, aFrame, aBuilder, aLists, aDirtyRect, row->GetNormalPosition());
}
}
@@ -1234,7 +1229,7 @@ PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup,
nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists,
const nsRect& aDirtyRect,
- const nsTArray<int32_t>& aColIdx,
+ const nsTArray<uint32_t>& aColIdx,
const nsPoint& aOffset)
{
MOZ_DIAGNOSTIC_ASSERT(!aColIdx.IsEmpty(),
@@ -1246,8 +1241,7 @@ PaintRowGroupBackgroundByColIdx(nsTableRowGroupFrame* aRowGroup,
}
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
- int32_t curColIdx;
- cell->GetColIndex(curColIdx);
+ uint32_t curColIdx = cell->ColIndex();
if (!aColIdx.Contains(curColIdx)) {
if (curColIdx > aColIdx.LastElement()) {
// We can just stop looking at this row.
@@ -1318,10 +1312,10 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder,
// Compute background rect by iterating all cell frame.
nsTableColGroupFrame* colGroup = static_cast<nsTableColGroupFrame*>(aFrame);
// Collecting column index.
- AutoTArray<int32_t, 1> colIdx;
+ AutoTArray<uint32_t, 1> colIdx;
for (nsTableColFrame* col = colGroup->GetFirstColumn(); col; col = col->GetNextCol()) {
MOZ_ASSERT(colIdx.IsEmpty() ||
- col->GetColIndex() > colIdx.LastElement());
+ static_cast<uint32_t>(col->GetColIndex()) > colIdx.LastElement());
colIdx.AppendElement(col->GetColIndex());
}
@@ -1341,7 +1335,7 @@ nsTableFrame::DisplayGenericTablePart(nsDisplayListBuilder* aBuilder,
} else if (aFrame->GetType() == nsGkAtoms::tableColFrame) {
// Compute background rect by iterating all cell frame.
nsTableColFrame* col = static_cast<nsTableColFrame*>(aFrame);
- AutoTArray<int32_t, 1> colIdx;
+ AutoTArray<uint32_t, 1> colIdx;
colIdx.AppendElement(col->GetColIndex());
nsTableFrame* table = col->GetTableFrame();
@@ -3973,9 +3967,8 @@ nsTableFrame::DumpRowGroup(nsIFrame* aKidFrame)
for (nsIFrame* childFrame : cFrame->PrincipalChildList()) {
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
if (cellFrame) {
- int32_t colIndex;
- cellFrame->GetColIndex(colIndex);
- printf("cell(%d)=%p ", colIndex, static_cast<void*>(childFrame));
+ uint32_t colIndex = cellFrame->ColIndex();
+ printf("cell(%u)=%p ", colIndex, static_cast<void*>(childFrame));
}
}
printf("\n");