Issue #1355 - Make nsTableCellFrame::GetColIndex/GetRowIndex faster

We can devirtualize it, remove some branches.
This commit is contained in:
win7-7 2020-02-16 16:06:53 +02:00 committed by Roy Tam
commit e8bb5560f7
12 changed files with 106 additions and 152 deletions

View file

@ -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;