diff options
author | win7-7 <win7-7@users.noreply.github.com> | 2020-02-16 16:06:53 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:45:15 +0200 |
commit | c9fd86cb784b81ab30461b773667b7251347fae6 (patch) | |
tree | 2b11c58b75866de08e091d27ea1d4ec289c20873 /accessible | |
parent | 550d634ff522b0fa1a586f8d85692cff361dca17 (diff) | |
download | UXP-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 'accessible')
-rw-r--r-- | accessible/html/HTMLTableAccessible.cpp | 48 | ||||
-rw-r--r-- | accessible/html/HTMLTableAccessible.h | 6 |
2 files changed, 27 insertions, 27 deletions
diff --git a/accessible/html/HTMLTableAccessible.cpp b/accessible/html/HTMLTableAccessible.cpp index b0cdc0932..af7dd561f 100644 --- a/accessible/html/HTMLTableAccessible.cpp +++ b/accessible/html/HTMLTableAccessible.cpp @@ -175,23 +175,17 @@ HTMLTableCellAccessible::Table() const uint32_t HTMLTableCellAccessible::ColIdx() const { - nsITableCellLayout* cellLayout = GetCellLayout(); - NS_ENSURE_TRUE(cellLayout, 0); - - int32_t colIdx = 0; - cellLayout->GetColIndex(colIdx); - return colIdx > 0 ? static_cast<uint32_t>(colIdx) : 0; + nsTableCellFrame* cellFrame = GetCellFrame(); + NS_ENSURE_TRUE(cellFrame, 0); + return cellFrame->ColIndex(); } uint32_t HTMLTableCellAccessible::RowIdx() const { - nsITableCellLayout* cellLayout = GetCellLayout(); - NS_ENSURE_TRUE(cellLayout, 0); - - int32_t rowIdx = 0; - cellLayout->GetRowIndex(rowIdx); - return rowIdx > 0 ? static_cast<uint32_t>(rowIdx) : 0; + nsTableCellFrame* cellFrame = GetCellFrame(); + NS_ENSURE_TRUE(cellFrame, 0); + return cellFrame->RowIndex(); } uint32_t @@ -285,6 +279,12 @@ HTMLTableCellAccessible::GetCellLayout() const return do_QueryFrame(mContent->GetPrimaryFrame()); } +nsTableCellFrame* +HTMLTableCellAccessible::GetCellFrame() const +{ + return do_QueryFrame(mContent->GetPrimaryFrame()); +} + nsresult HTMLTableCellAccessible::GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const { @@ -520,11 +520,9 @@ HTMLTableAccessible::SelectedCellCount() if (!cellFrame || !cellFrame->IsSelected()) continue; - int32_t startRow = -1, startCol = -1; - cellFrame->GetRowIndex(startRow); - cellFrame->GetColIndex(startCol); - if (startRow >= 0 && (uint32_t)startRow == rowIdx && - startCol >= 0 && (uint32_t)startCol == colIdx) + uint32_t startRow = cellFrame->RowIndex(); + uint32_t startCol = cellFrame->ColIndex(); + if (startRow == rowIdx && startCol == colIdx) count++; } } @@ -570,11 +568,9 @@ HTMLTableAccessible::SelectedCells(nsTArray<Accessible*>* aCells) if (!cellFrame || !cellFrame->IsSelected()) continue; - int32_t startCol = -1, startRow = -1; - cellFrame->GetRowIndex(startRow); - cellFrame->GetColIndex(startCol); - if ((startRow >= 0 && (uint32_t)startRow != rowIdx) || - (startCol >= 0 && (uint32_t)startCol != colIdx)) + uint32_t startRow = cellFrame->RowIndex(); + uint32_t startCol = cellFrame->ColIndex(); + if (startRow != rowIdx || startCol != colIdx) continue; Accessible* cell = mDoc->GetAccessible(cellFrame->GetContent()); @@ -597,11 +593,9 @@ HTMLTableAccessible::SelectedCellIndices(nsTArray<uint32_t>* aCells) if (!cellFrame || !cellFrame->IsSelected()) continue; - int32_t startRow = -1, startCol = -1; - cellFrame->GetColIndex(startCol); - cellFrame->GetRowIndex(startRow); - if (startRow >= 0 && (uint32_t)startRow == rowIdx && - startCol >= 0 && (uint32_t)startCol == colIdx) + uint32_t startCol = cellFrame->ColIndex(); + uint32_t startRow = cellFrame->RowIndex(); + if (startRow == rowIdx && startCol == colIdx) aCells->AppendElement(CellIndexAt(rowIdx, colIdx)); } } diff --git a/accessible/html/HTMLTableAccessible.h b/accessible/html/HTMLTableAccessible.h index 830d34ae9..c7cfc9ddf 100644 --- a/accessible/html/HTMLTableAccessible.h +++ b/accessible/html/HTMLTableAccessible.h @@ -11,6 +11,7 @@ #include "TableCellAccessible.h" class nsITableCellLayout; +class nsTableCellFrame; namespace mozilla { namespace a11y { @@ -54,6 +55,11 @@ protected: nsITableCellLayout* GetCellLayout() const; /** + * Return the table cell frame. + */ + nsTableCellFrame* GetCellFrame() const; + + /** * Return row and column indices of the cell. */ nsresult GetCellIndexes(int32_t& aRowIdx, int32_t& aColIdx) const; |