You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simply creating an NGBoxFragmentPainter has a "significant" cost. When
hit-testing, we're typically going to miss most of the elements (in
search of the one to hit (along with its ancestors)), so this needs to
be as cheap as possible. Therefore, check for intersection earlier, and
only create an NGBoxFragmentPainter for hit-testing if it's likely at
all that we're going to hit something inside the fragment.
This fixes most of the performance regression in the following tests:
perf_tests/events/hit-test-lots-of-layers.html [1]
perf_tests/layout/hittest-block-children.html [2]
[1] Same, or possibly slightly faster (0.9%)
[2] Still slower (9%)
I suspect that perf_tests/layout/hittest-block-children.html is still
slower because of the overhead of creating NGInlineCursor and
NGInlineBackwardCursor objects without checking if we intersect first.
See crbug.com/1240036
We are also performing duplicate intersection checks in some cases now,
which has a tiny (but I *think* it's measurable) cost. With this change,
we'll check for intersection before creating an NGBoxFragmentPainter,
but, if we intersect, we'll check again nevertheless in e.g.
NGBoxFragmentPainter::NodeAtPoint(). Ideally, we should turn the latter
into a DCHECK, but there are still a few call-sites that would need to
be updated first. Added a couple of TODOs for now. It may be that we
could wait until the legacy layout engine is gone, before following up,
as that would be slightly easier (and the gain isn't huge anyway).
Bug: 1240034, 1240036
Change-Id: I11a91038de180b30d99263038f65c7c8bf6fa923
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3113968
Reviewed-by: Koji Ishii <[email protected]>
Commit-Queue: Morten Stenshorne <[email protected]>
Cr-Commit-Position: refs/heads/main@{#914849}
0 commit comments