Commit 0acb81f
Preserve invalid selectors in :is() and :where()
As per the resolution in w3c/csswg-drafts/issues/8356 [1], forgiving
selector lists (argument of :is(), :where()) need to preserve invalid
arguments for serialization, even though they never match anything.
Use the existing pseudo type kPseudoUnparsed with kNone nesting type
to keep an invalid selector text and change the css selector parser
so it creates the placeholder for the failed-parsing complex selector.
To keep the current First()/Next() behavior of CSSSelectorList, the
methods skip the unparsed-invalid selector.
FirstIncludingUnparsedInvalid() and NextIncludingUnparsedInvalid()
are added in CSSSelectorList to serialize with the unparsed-invalid
selectors.
Add a private method IsInvalidWithoutUnparsed() to CSSSelectorList
to distinguish an empty list (CSSSelectorList::Empty()) from an
invalid list that has unparsed-invalid selectors. Replace the IsValid()
checks that meant "empty" with it (e.g. in Copy() and ComputeLength()),
so the methods can handle the preserved unparsed invalid selectors.
The invalid selector serialization works behind the experimental
feature SerializeInvalidSelectorsInForgivingSelectorList.
[1] w3c/csswg-drafts#8356
Bug: 40277472
Change-Id: I5d350d815153fbf846ed8763707d0938a2327376
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8068106
Commit-Queue: Byungwoo Lee <blee@igalia.com>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1669314}1 parent f857cad commit 0acb81f
2 files changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
46 | 55 | | |
47 | 56 | | |
48 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
0 commit comments