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]
Created attachment 417839 [details]
Created attachment 417840 [details]
Committed r271584: <https://trac.webkit.org/changeset/271584>
All reviewed patches have been landed. Closing bug and clearing flags on attachment 417840 [details].
I suspect this caused bug 220862.