RESOLVED FIXED 243172
:has(:lang(~)) doesn't get invalidated
https://bugs.webkit.org/show_bug.cgi?id=243172
Summary :has(:lang(~)) doesn't get invalidated
Ryosuke Niwa
Reported 2022-07-25 12:17:20 PDT
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.
Attachments
test case (1.39 KB, text/html)
2022-07-25 12:17 PDT, Ryosuke Niwa
no flags
Test case (1.43 KB, text/html)
2022-07-25 22:45 PDT, Ryosuke Niwa
no flags
WIP (4.38 KB, patch)
2022-07-25 22:46 PDT, Ryosuke Niwa
no flags
WIP2 (14.79 KB, patch)
2022-08-14 22:59 PDT, Ryosuke Niwa
no flags
Ryosuke Niwa
Comment 1 2022-07-25 12:19:41 PDT
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.
Ryosuke Niwa
Comment 2 2022-07-25 22:45:00 PDT
Created attachment 461213 [details] Test case
Ryosuke Niwa
Comment 3 2022-07-25 22:46:52 PDT
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.
Ryosuke Niwa
Comment 4 2022-07-25 23:04:52 PDT
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.
Radar WebKit Bug Importer
Comment 5 2022-08-01 12:18:17 PDT
Ryosuke Niwa
Comment 6 2022-08-14 22:59:45 PDT
Ryosuke Niwa
Comment 7 2022-08-16 01:40:20 PDT
EWS
Comment 8 2022-08-17 12:19:32 PDT
Committed 253530@main (c01b88a3c523): <https://commits.webkit.org/253530@main> Reviewed commits have been landed. Closing PR #3353 and removing active labels.
Hercules Hjalmarsson
Comment 9 2022-08-18 11:15:19 PDT
EWS
Comment 10 2022-08-18 11:19:08 PDT
Committed 253566@main (5c847bef1a06): <https://commits.webkit.org/253566@main> Reviewed commits have been landed. Closing PR #3461 and removing active labels.
Ryosuke Niwa
Comment 11 2022-08-18 22:34:46 PDT
Re-opening for pull request https://github.com/WebKit/WebKit/pull/3472
EWS
Comment 12 2022-08-19 16:55:34 PDT
Committed 253610@main (84698f551725): <https://commits.webkit.org/253610@main> Reviewed commits have been landed. Closing PR #3472 and removing active labels.
Ryosuke Niwa
Comment 13 2022-08-23 17:27:16 PDT
Re-opening for pull request https://github.com/WebKit/WebKit/pull/3600
EWS
Comment 14 2022-08-24 19:46:29 PDT
Committed 253764@main (0c6665bbc951): <https://commits.webkit.org/253764@main> Reviewed commits have been landed. Closing PR #3600 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.