Hover and active states are flipped for the entire ancestor chain. We compute invalidation for each element separately. If the selectors are of form ':active .descendant' then each of these invalidations need to traverse the whole subtree leading to O(n^2) behavior. We really only need to traverse the descendants once, starting from the element closest to the root that changes state.
Created attachment 417836 [details] patch
Created attachment 417839 [details] patch
Created attachment 417840 [details] patch
rdar://72138961
Committed r271584: <https://trac.webkit.org/changeset/271584> All reviewed patches have been landed. Closing bug and clearing flags on attachment 417840 [details].
<rdar://problem/73328176>
I suspect this caused bug 220862.