Created attachment 461200 [details] test case In the attached test case, you should only see green boxes but you see red because WebKit fails to invalidate elements with :has(:lang(~)) even when lang content attribute is mutated.
There is a bit of design problem here. :lang(~) relies on Element::computeInheritedLanguage(), which walks up the tree to find the nearest ancestor with lang content attribute. :has(~) walks descendants to find an element with a matching :lang(~). Combining these two naively results in O(n^2) behavior.
Created attachment 461213 [details] Test case
Created attachment 461214 [details] WIP We need something like this to invalidate :lang and :dir in a subtree whenever lang or dir content attributes are mutated.
The tricky thing is that lang and dir content attributes affect element's descendants. We need to either invalidate more than we need or need to walk over the entire subtree each time the attribute is mutated.
<rdar://problem/97928899>
Created attachment 461632 [details] WIP2
Pull request: https://github.com/WebKit/WebKit/pull/3353
Committed 253530@main (c01b88a3c523): <https://commits.webkit.org/253530@main> Reviewed commits have been landed. Closing PR #3353 and removing active labels.
Reverted by https://github.com/WebKit/WebKit/pull/3461
Committed 253566@main (5c847bef1a06): <https://commits.webkit.org/253566@main> Reviewed commits have been landed. Closing PR #3461 and removing active labels.
Re-opening for pull request https://github.com/WebKit/WebKit/pull/3472
Committed 253610@main (84698f551725): <https://commits.webkit.org/253610@main> Reviewed commits have been landed. Closing PR #3472 and removing active labels.
Re-opening for pull request https://github.com/WebKit/WebKit/pull/3600
Committed 253764@main (0c6665bbc951): <https://commits.webkit.org/253764@main> Reviewed commits have been landed. Closing PR #3600 and removing active labels.