Files
serenity/Userland/Libraries/LibWeb/DOM/Element.cpp
Andreas Kling ba6d3aaece LibWeb: Only recompute before and after pseudo element styles
Before this change, we would go through every known pseudo element and
compute style for it whenever recomputing the style of an element.

This led to disastrous performance on pages with selectors like
`::selection` or `::placeholder`, as they'd effectively match every
single element and thus we'd compute multiple additional styles for
every element in the DOM.

The fix is simple: only recompute `before` and `after` pseudo element
styles, since those are the only two pseudo elements that generate
*new* nodes -- other pseudo elements refer to (possibly) existing
nodes or concepts within the DOM (or internal shadow DOM).

This makes style updates take ~40ms on our GitHub repo instead of
~220ms. It's still slower than it should be, but a huge improvement.

(cherry picked from commit 62083bf586a816eea61db4a09a60cc6474585444)
2024-10-11 20:25:41 -04:00

132 KiB