summaryrefslogtreecommitdiffstats
path: root/layout/tables/nsTableRowFrame.cpp
diff options
context:
space:
mode:
authorwin7-7 <win7-7@users.noreply.github.com>2020-02-16 16:06:53 +0200
committerwin7-7 <win7-7@users.noreply.github.com>2020-02-16 16:06:53 +0200
commitd4098037a4a6bee464fde4b70644e730e13b487f (patch)
tree60ff499425a2c3acad1c0d66f88aae3a85f2509c /layout/tables/nsTableRowFrame.cpp
parent4234b3a36b364da2d5dd4f243f2543a9d76057d8 (diff)
downloadUXP-d4098037a4a6bee464fde4b70644e730e13b487f.tar
UXP-d4098037a4a6bee464fde4b70644e730e13b487f.tar.gz
UXP-d4098037a4a6bee464fde4b70644e730e13b487f.tar.lz
UXP-d4098037a4a6bee464fde4b70644e730e13b487f.tar.xz
UXP-d4098037a4a6bee464fde4b70644e730e13b487f.zip
Issue #1355 - Make nsTableCellFrame::GetColIndex/GetRowIndex faster
We can devirtualize it, remove some branches.
Diffstat (limited to 'layout/tables/nsTableRowFrame.cpp')
-rw-r--r--layout/tables/nsTableRowFrame.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp
index 8bbaf50f5..02b85a141 100644
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -235,7 +235,7 @@ nsTableRowFrame::InsertFrames(ChildListID aListID,
// insert the cells into the cell map
int32_t colIndex = -1;
if (prevCellFrame) {
- prevCellFrame->GetColIndex(colIndex);
+ colIndex = prevCellFrame->ColIndex();
}
tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
@@ -647,8 +647,7 @@ CalcAvailISize(nsTableFrame& aTableFrame,
nsTableCellFrame& aCellFrame)
{
nscoord cellAvailISize = 0;
- int32_t colIndex;
- aCellFrame.GetColIndex(colIndex);
+ uint32_t colIndex = aCellFrame.ColIndex();
int32_t colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
NS_ASSERTION(colspan > 0, "effective colspan should be positive");
nsTableFrame* fifTable =
@@ -787,12 +786,12 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
}
}
- int32_t cellColIndex;
- cellFrame->GetColIndex(cellColIndex);
+ uint32_t cellColIndex = cellFrame->ColIndex();
cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
// If the adjacent cell is in a prior row (because of a rowspan) add in the space
- if (prevColIndex != (cellColIndex - 1)) {
+ // NOTE: prevColIndex can be -1 here.
+ if (prevColIndex != (static_cast<int32_t>(cellColIndex) - 1)) {
iCoord += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame,
false);
}
@@ -1160,8 +1159,7 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
shift = rowRect.BSize(wm);
nsTableCellFrame* cellFrame = GetFirstCell();
if (cellFrame) {
- int32_t rowIndex;
- cellFrame->GetRowIndex(rowIndex);
+ uint32_t rowIndex = cellFrame->RowIndex();
shift += tableFrame->GetRowSpacing(rowIndex);
while (cellFrame) {
LogicalRect cRect = cellFrame->GetLogicalRect(wm, containerSize);
@@ -1192,13 +1190,13 @@ nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
for (nsIFrame* kidFrame : mFrames) {
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
if (cellFrame) {
- int32_t cellColIndex;
- cellFrame->GetColIndex(cellColIndex);
+ uint32_t cellColIndex = cellFrame->ColIndex();
int32_t cellColSpan = tableFrame->GetEffectiveColSpan(*cellFrame);
// If the adjacent cell is in a prior row (because of a rowspan) add in
// the space
- if (prevColIndex != (cellColIndex - 1)) {
+ // NOTE: prevColIndex can be -1 here.
+ if (prevColIndex != (static_cast<int32_t>(cellColIndex) - 1)) {
iPos += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan,
*tableFrame, true);
}
@@ -1311,9 +1309,9 @@ nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
for (nsIFrame* child : mFrames) {
nsTableCellFrame *cellFrame = do_QueryFrame(child);
if (cellFrame) {
- int32_t colIndex;
- cellFrame->GetColIndex(colIndex);
- if (colIndex < aColIndex) {
+ uint32_t colIndex = cellFrame->ColIndex();
+ // Can aColIndex be -1 here? Let's assume it can for now.
+ if (static_cast<int32_t>(colIndex) < aColIndex) {
priorCell = cellFrame;
}
else break;