Skip to content

Commit

Permalink
Merge pull request #1376 from win7-7/optimization-1-pr
Browse files Browse the repository at this point in the history
 Speed up the traversal of a table row frame's child cells
  • Loading branch information
wolfbeast authored Jan 30, 2020
2 parents 499b287 + fd26b84 commit 64c8c65
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
14 changes: 0 additions & 14 deletions layout/tables/nsTableCellFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 24 additions & 1 deletion layout/tables/nsTableCellFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,17 @@ class nsTableCellFrame : public nsContainerFrame,
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;

Expand Down Expand Up @@ -350,4 +360,17 @@ class nsBCTableCellFrame final : public nsTableCellFrame
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
12 changes: 0 additions & 12 deletions layout/tables/nsTableRowFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
4 changes: 3 additions & 1 deletion layout/tables/nsTableRowFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class nsTableRowFrame : public nsContainerFrame
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.
Expand Down

0 comments on commit 64c8c65

Please sign in to comment.