diff options
author | Moonchild <moonchild@palemoon.org> | 2020-01-30 17:54:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 17:54:48 +0000 |
commit | 64c8c65cf4e71af16f7961069a15e73323bf19e1 (patch) | |
tree | 6e542f930a48a991948a60b79d5a6e3f093bd848 /layout | |
parent | 499b2873944530396cc8aecbc7bdd1a2a2c66caa (diff) | |
parent | fd26b84536a851abf72cef32bdf35bd82031eb90 (diff) | |
download | UXP-64c8c65cf4e71af16f7961069a15e73323bf19e1.tar UXP-64c8c65cf4e71af16f7961069a15e73323bf19e1.tar.gz UXP-64c8c65cf4e71af16f7961069a15e73323bf19e1.tar.lz UXP-64c8c65cf4e71af16f7961069a15e73323bf19e1.tar.xz UXP-64c8c65cf4e71af16f7961069a15e73323bf19e1.zip |
Merge pull request #1376 from win7-7/optimization-1-pr
Speed up the traversal of a table row frame's child cells
Diffstat (limited to 'layout')
-rw-r--r-- | layout/tables/nsTableCellFrame.cpp | 14 | ||||
-rw-r--r-- | layout/tables/nsTableCellFrame.h | 25 | ||||
-rw-r--r-- | layout/tables/nsTableRowFrame.cpp | 12 | ||||
-rw-r--r-- | layout/tables/nsTableRowFrame.h | 4 |
4 files changed, 27 insertions, 28 deletions
diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index ec9458f76..043509fc4 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -59,20 +59,6 @@ nsTableCellFrame::~nsTableCellFrame() NS_IMPL_FRAMEARENA_HELPERS(nsTableCellFrame) -nsTableCellFrame* -nsTableCellFrame::GetNextCell() const -{ - nsIFrame* childFrame = GetNextSibling(); - while (childFrame) { - nsTableCellFrame *cellFrame = do_QueryFrame(childFrame); - if (cellFrame) { - return cellFrame; - } - childFrame = childFrame->GetNextSibling(); - } - return nullptr; -} - void nsTableCellFrame::Init(nsIContent* aContent, nsContainerFrame* aParent, diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index 5f87c5f6d..d8debe993 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -215,7 +215,17 @@ public: bool HasPctOverBSize(); void SetHasPctOverBSize(bool aValue); - nsTableCellFrame* GetNextCell() const; + nsTableCellFrame* GetNextCell() const + { + nsIFrame* sibling = GetNextSibling(); +#ifdef DEBUG + if (sibling) { + nsTableCellFrame* cellFrame = do_QueryFrame(sibling); + MOZ_ASSERT(cellFrame, "How do we have a non-cell sibling?"); + } +#endif // DEBUG + return static_cast<nsTableCellFrame*>(sibling); + } virtual LogicalMargin GetBorderWidth(WritingMode aWM) const; @@ -350,4 +360,17 @@ private: BCPixelSize mIStartBorder; }; +// Implemented here because that's a sane-ish way to make the includes work out. +inline nsTableCellFrame* nsTableRowFrame::GetFirstCell() const +{ + nsIFrame* firstChild = mFrames.FirstChild(); +#ifdef DEBUG + if (firstChild) { + nsTableCellFrame* cellFrame = do_QueryFrame(firstChild); + MOZ_ASSERT(cellFrame, "How do we have a non-cell sibling?"); + } +#endif // DEBUG + return static_cast<nsTableCellFrame*>(firstChild); +} + #endif diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index ea2477b73..8bbaf50f5 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -304,18 +304,6 @@ GetBSizeOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame, return bsize; } -nsTableCellFrame* -nsTableRowFrame::GetFirstCell() -{ - for (nsIFrame* childFrame : mFrames) { - nsTableCellFrame *cellFrame = do_QueryFrame(childFrame); - if (cellFrame) { - return cellFrame; - } - } - return nullptr; -} - /** * Post-reflow hook. This is where the table row does its post-processing */ diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 9e15d851f..c53c81ff1 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -82,7 +82,9 @@ public: const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; - nsTableCellFrame* GetFirstCell() ; + // Implemented in nsTableCellFrame.h, because it needs to know about the + // nsTableCellFrame class, but we can't include nsTableCellFrame.h here. + inline nsTableCellFrame* GetFirstCell() const; /** calls Reflow for all of its child cells. * Cells with rowspan=1 are all set to the same height and stacked horizontally. |