Bug 1873414. In MaybeCreateDisplayPortInFirstScrollFrameEncountered descend into leaf frames because they can contain anonymous content. r=layout-reviewers,emilio

Leaf frames can contain anonymous content, for example text control frames, and we were activating them before and not activating them caused a perf regression in some tests, so restore that behaviour.

This illustrates that some of the performance improvement of using the leaf check came from not descending into some subtrees and changes the perf balance of the patch from bug 1872564. I re-did the measurements with this new constraint and now the IsScrollContainer check is faster, so I switched to using that.

Differential Revision: https://phabricator.services.mozilla.com/D197904
This commit is contained in:
Timothy Nikkel 2024-01-08 11:56:19 +00:00
Родитель 791095bd37
Коммит 7fc94186f1
1 изменённых файлов: 4 добавлений и 14 удалений

Просмотреть файл

@ -854,14 +854,7 @@ bool DisplayPortUtils::MaybeCreateDisplayPortInFirstScrollFrameEncountered(
aFrame->GetContent()->GetID() == nsGkAtoms::tabbrowser_arrowscrollbox) {
return false;
}
// The do_QueryFrame call below is the most expensive part of this function.
// IsLeaf is a quick function we can call to avoid this in a lot of cases. It
// also neatly lines up with we check below (subdocument and placeholder
// frames are leaves, and leaves don't have child lists) so it speeds this
// function up whether it is true or false. Using IsScrollContainer is
// slightly less fast.
const bool isLeaf = aFrame->IsLeaf();
if (!isLeaf) {
if (aFrame->IsScrollContainer()) {
if (nsIScrollableFrame* sf = do_QueryFrame(aFrame)) {
if (MaybeCreateDisplayPort(aBuilder, aFrame, sf, RepaintMode::Repaint)) {
// If this was the first displayport found in the first scroll frame
@ -896,12 +889,9 @@ bool DisplayPortUtils::MaybeCreateDisplayPortInFirstScrollFrameEncountered(
// Only descend the visible card of deck / tabpanels
return false;
}
if (!isLeaf) {
for (nsIFrame* child : aFrame->PrincipalChildList()) {
if (MaybeCreateDisplayPortInFirstScrollFrameEncountered(child,
aBuilder)) {
return true;
}
for (nsIFrame* child : aFrame->PrincipalChildList()) {
if (MaybeCreateDisplayPortInFirstScrollFrameEncountered(child, aBuilder)) {
return true;
}
}
return false;