diff options
author | win7-7 <win7-7@users.noreply.github.com> | 2020-02-16 16:06:53 +0200 |
---|---|---|
committer | win7-7 <win7-7@users.noreply.github.com> | 2020-02-16 16:06:53 +0200 |
commit | d4098037a4a6bee464fde4b70644e730e13b487f (patch) | |
tree | 60ff499425a2c3acad1c0d66f88aae3a85f2509c /layout/generic/nsSelection.cpp | |
parent | 4234b3a36b364da2d5dd4f243f2543a9d76057d8 (diff) | |
download | UXP-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/generic/nsSelection.cpp')
-rw-r--r-- | layout/generic/nsSelection.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index ff75ab85d..f2959dc9d 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -2882,16 +2882,15 @@ nsFrameSelection::UnselectCells(nsIContent *aTableContent, nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(curRowIndex, curColIndex); - int32_t origRowIndex, origColIndex; - cellFrame->GetRowIndex(origRowIndex); - cellFrame->GetColIndex(origColIndex); + uint32_t origRowIndex = cellFrame->RowIndex(); + uint32_t origColIndex = cellFrame->ColIndex(); uint32_t actualRowSpan = tableFrame->GetEffectiveRowSpanAt(origRowIndex, origColIndex); uint32_t actualColSpan = tableFrame->GetEffectiveColSpanAt(curRowIndex, curColIndex); - if (origRowIndex <= maxRowIndex && maxRowIndex >= 0 && + if (origRowIndex <= static_cast<uint32_t>(maxRowIndex) && maxRowIndex >= 0 && origRowIndex + actualRowSpan - 1 >= static_cast<uint32_t>(minRowIndex) && - origColIndex <= maxColIndex && maxColIndex >= 0 && + origColIndex <= static_cast<uint32_t>(maxColIndex) && maxColIndex >= 0 && origColIndex + actualColSpan - 1 >= static_cast<uint32_t>(minColIndex)) { mDomSelections[index]->RemoveRange(range); @@ -2925,33 +2924,32 @@ nsFrameSelection::AddCellsToSelection(nsIContent *aTableContent, return NS_ERROR_FAILURE; nsresult result = NS_OK; - int32_t row = aStartRowIndex; + uint32_t row = aStartRowIndex; while(true) { - int32_t col = aStartColumnIndex; + uint32_t col = aStartColumnIndex; while(true) { nsTableCellFrame* cellFrame = tableFrame->GetCellFrameAt(row, col); // Skip cells that are spanned from previous locations or are already selected if (cellFrame) { - int32_t origRow, origCol; - cellFrame->GetRowIndex(origRow); - cellFrame->GetColIndex(origCol); + uint32_t origRow = cellFrame->RowIndex(); + uint32_t origCol = cellFrame->ColIndex(); if (origRow == row && origCol == col && !cellFrame->IsSelected()) { result = SelectCellElement(cellFrame->GetContent()); if (NS_FAILED(result)) return result; } } // Done when we reach end column - if (col == aEndColumnIndex) break; + if (col == static_cast<uint32_t>(aEndColumnIndex)) break; if (aStartColumnIndex < aEndColumnIndex) col ++; else col--; } - if (row == aEndRowIndex) break; + if (row == static_cast<uint32_t>(aEndRowIndex)) break; if (aStartRowIndex < aEndRowIndex) row++; |