style: Add support for is() and where() selectors (#34066)

Additionally, changes now need to be made to `servo.css` in order to
ensure that `<button>` text is centered the same way that it is for
`<input type=button>`. In the past the rule for centering text for the
latter was ignored because it used `:is()`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-11-19 15:05:46 +01:00 committed by GitHub
parent 975e2ae859
commit 0eda2de19f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 12 additions and 393 deletions

24
Cargo.lock generated
View file

@ -1641,7 +1641,7 @@ dependencies = [
[[package]]
name = "dom"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"bitflags 2.6.0",
]
@ -4277,7 +4277,7 @@ dependencies = [
[[package]]
name = "malloc_size_of"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"accountable-refcell",
"app_units",
@ -6313,7 +6313,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.25.0"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"bitflags 2.6.0",
"cssparser",
@ -6601,7 +6601,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.4.0"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"serde",
"stable_deref_trait",
@ -6610,7 +6610,7 @@ dependencies = [
[[package]]
name = "servo_atoms"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -6963,7 +6963,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "static_prefs"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
[[package]]
name = "strck"
@ -7022,7 +7022,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "style"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"app_units",
"arrayvec",
@ -7080,7 +7080,7 @@ dependencies = [
[[package]]
name = "style_config"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"lazy_static",
]
@ -7088,7 +7088,7 @@ dependencies = [
[[package]]
name = "style_derive"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"darling",
"proc-macro2",
@ -7118,7 +7118,7 @@ dependencies = [
[[package]]
name = "style_traits"
version = "0.0.1"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"app_units",
"bitflags 2.6.0",
@ -7469,7 +7469,7 @@ dependencies = [
[[package]]
name = "to_shmem"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"cssparser",
"servo_arc",
@ -7482,7 +7482,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#1c069c5e62fb70a64f3305fcafed2c12073608b8"
source = "git+https://github.com/servo/stylo?branch=2024-10-04#bedab74ee38a04c9b8a8fe97e963a133ef5228c0"
dependencies = [
"darling",
"proc-macro2",

View file

@ -9,7 +9,6 @@ input {
color: black;
font-family: sans-serif;
font-size: 0.8333em;
text-align: left;
}
textarea {

View file

@ -2,9 +2,6 @@
[Single scope]
expected: FAIL
[Scope can not match its own root without :scope]
expected: FAIL
[Selecting self with :scope]
expected: FAIL
@ -26,15 +23,9 @@
[Multiple scopes from same @scope-rule, only one limited]
expected: FAIL
[Multiple scopes from same @scope-rule, both limited]
expected: FAIL
[Nested scopes]
expected: FAIL
[Nested scopes, reverse]
expected: FAIL
[Nested scopes, with to-selector]
expected: FAIL
@ -47,21 +38,9 @@
[Simulated inclusive scoping limit]
expected: FAIL
[Scope with no elements]
expected: FAIL
[:scope direct adjacent sibling]
expected: FAIL
[:scope indirect adjacent sibling]
expected: FAIL
[Relative selector inside @scope]
expected: FAIL
[:scope in two different compounds]
expected: FAIL
[Scope root with :has()]
expected: FAIL

View file

@ -14,15 +14,9 @@
[:link as scoping root]
expected: FAIL
[:visited as scoping root]
expected: FAIL
[:not(:visited) as scoping root]
expected: FAIL
[:not(:link) as scoping root]
expected: FAIL
[:link as scoping root, :scope]
expected: FAIL

View file

@ -1,36 +0,0 @@
[is-where-pseudo-containing-hard-pseudo.html]
[subject1 is red when .other-match added]
expected: FAIL
[subject1 is orangered when .parent added to parent]
expected: FAIL
[subject1 is orangered when .parent removed from parent]
expected: FAIL
[subject2 is darkred when .other-match added]
expected: FAIL
[subject2 is pink when .parent added to parent]
expected: FAIL
[subject2 is pink when .parent removed from parent]
expected: FAIL
[subject3 is green when .other-match added]
expected: FAIL
[subject3 is lightgreen when .parent added to parent]
expected: FAIL
[subject3 is lightgreen when .parent removed from parent]
expected: FAIL
[subject4 is darkgreen when .other-match added]
expected: FAIL
[subject4 is yellowgreen when .parent added to parent]
expected: FAIL
[subject4 is yellowgreen when .parent removed from parent]
expected: FAIL

View file

@ -1,15 +0,0 @@
[is.html]
[Invalidate :is() for simple selector arguments.]
expected: FAIL
[Invalidate :is() for compound selector arguments.]
expected: FAIL
[Invalidate :is() for complex selector arguments.]
expected: FAIL
[Invalidate nested :is().]
expected: FAIL
[Test specificity of :is().]
expected: FAIL

View file

@ -1,3 +0,0 @@
[not-002.html]
[Invalidate nested :is() inside :not().]
expected: FAIL

View file

@ -1,15 +0,0 @@
[where.html]
[Preconditions.]
expected: FAIL
[Invalidate :where() for simple selector arguments.]
expected: FAIL
[Invalidate :where() for compound selector arguments.]
expected: FAIL
[Invalidate :where() for complex selector arguments.]
expected: FAIL
[Invalidate nested :where().]
expected: FAIL

View file

@ -1,2 +0,0 @@
[is-default-ns-002.html]
expected: FAIL

View file

@ -1,6 +0,0 @@
[is-nested.html]
[Test nested :is() chooses highest specificity for class outside :is().]
expected: FAIL
[Test nested :is() specificity for class within arguments.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[is-specificity-shadow.html]
[Specificity of :host() inside :is()]
expected: FAIL

View file

@ -1,3 +0,0 @@
[is-specificity.html]
[Test :is() uses highest possible specificity]
expected: FAIL

View file

@ -1,45 +0,0 @@
[is-where-basic.html]
[:is() matches expected elements]
expected: FAIL
[:is(#a) matches expected elements]
expected: FAIL
[:is(#a, #f) matches expected elements]
expected: FAIL
[:is(#a, #c) :where(#a #d, #c #f) matches expected elements]
expected: FAIL
[#c > :is(#c > #f) matches expected elements]
expected: FAIL
[#c > :is(#b > #f) matches expected elements]
expected: FAIL
[#a div:is(#d) matches expected elements]
expected: FAIL
[:is(div) > div matches expected elements]
expected: FAIL
[:is(*) > div matches expected elements]
expected: FAIL
[:is(*) div matches expected elements]
expected: FAIL
[div > :where(#e, #f) matches expected elements]
expected: FAIL
[div > :where(*) matches expected elements]
expected: FAIL
[:is(*) > :where(*) matches expected elements]
expected: FAIL
[:is(#a + #b) + :is(#c) matches expected elements]
expected: FAIL
[:is(#a, #b) + div matches expected elements]
expected: FAIL

View file

@ -1,4 +0,0 @@
[is-where-error-recovery.html]
[CSS Selectors: :is() and :where() error recovery]
expected: FAIL

View file

@ -1,54 +0,0 @@
[is-where-not.html]
[:not(:is(#a)) matches expected elements]
expected: FAIL
[:not(:where(#b)) matches expected elements]
expected: FAIL
[:not(:where(:root #c)) matches expected elements]
expected: FAIL
[:not(:is(#a, #b)) matches expected elements]
expected: FAIL
[:not(:is(#b div)) matches expected elements]
expected: FAIL
[:not(:is(#a div, div + div)) matches expected elements]
expected: FAIL
[:not(:is(span)) matches expected elements]
expected: FAIL
[:not(:is(div)) matches expected elements]
expected: FAIL
[:not(:is(*|div)) matches expected elements]
expected: FAIL
[:not(:is(*|*)) matches expected elements]
expected: FAIL
[:not(:is(*)) matches expected elements]
expected: FAIL
[:not(:is(svg|div)) matches expected elements]
expected: FAIL
[:not(:is(:not(div))) matches expected elements]
expected: FAIL
[:not(:is(span, b, i)) matches expected elements]
expected: FAIL
[:not(:is(span, b, i, div)) matches expected elements]
expected: FAIL
[:not(:is(#b ~ div div, * + #c)) matches expected elements]
expected: FAIL
[:not(:is(div > :not(#e))) matches expected elements]
expected: FAIL
[:not(:is(div > :not(:where(#e, #f)))) matches expected elements]
expected: FAIL

View file

@ -1,4 +0,0 @@
[is-where-pseudo-classes.html]
[:is() combined with pseudo-classes]
expected: FAIL

View file

@ -1,2 +0,0 @@
[is-where-pseudo-elements.html]
expected: FAIL

View file

@ -1,76 +1,4 @@
[parse-is-where.html]
[":is(div )" should be a valid selector]
expected: FAIL
[":where(div )" should be a valid selector]
expected: FAIL
[":is(div + bar, div ~ .baz)" should be a valid selector]
expected: FAIL
[":where(div + bar, div ~ .baz)" should be a valid selector]
expected: FAIL
[":is(:is(div))" should be a valid selector]
expected: FAIL
[":where(:is(div))" should be a valid selector]
expected: FAIL
[":is(:where(div))" should be a valid selector]
expected: FAIL
[":where(:where(div))" should be a valid selector]
expected: FAIL
[":host(:is(div))" should be a valid selector]
expected: FAIL
[":host(:where(div))" should be a valid selector]
expected: FAIL
[":host(:is(div ))" should be a valid selector]
expected: FAIL
[":host(:where(div ))" should be a valid selector]
expected: FAIL
[":host(:is(div .foo))" should be a valid selector]
expected: FAIL
[":host(:where(div .foo))" should be a valid selector]
expected: FAIL
[":is(:hover, :active)" should be a valid selector]
expected: FAIL
[":where(:hover, :active)" should be a valid selector]
expected: FAIL
[":is(div):hover" should be a valid selector]
expected: FAIL
[":where(div):hover" should be a valid selector]
expected: FAIL
[":is(div)::before" should be a valid selector]
expected: FAIL
[":where(div)::before" should be a valid selector]
expected: FAIL
[":is(::before)" should be a valid selector]
expected: FAIL
[":where(::before)" should be a valid selector]
expected: FAIL
[":is(div) + bar" should be a valid selector]
expected: FAIL
[":where(div) + bar" should be a valid selector]
expected: FAIL
["::part(foo):is(:hover)" should be a valid selector]
expected: FAIL
@ -82,15 +10,3 @@
["::part(foo):where([attr='value'\])" should be a valid selector]
expected: FAIL
[":not(:is(div))" should be a valid selector]
expected: FAIL
[":not(:where(div))" should be a valid selector]
expected: FAIL
[":not(:is(div .foo))" should be a valid selector]
expected: FAIL
[":not(:where(div .foo))" should be a valid selector]
expected: FAIL

View file

@ -1,19 +0,0 @@
[parse-is.html]
[":is(#a)" should be a valid selector]
expected: FAIL
[".a.b ~ :is(.c.d ~ .e.f)" should be a valid selector]
expected: FAIL
[".a.b ~ .c.d:is(span.e + .f, .g.h > .i.j .k)" should be a valid selector]
expected: FAIL
[":is(:hover,:focus)" should be a valid selector]
expected: FAIL
["a:is(:not(:hover))" should be a valid selector]
expected: FAIL
[":is(ul,ol,.list) > [hidden\]" should be a valid selector]
expected: FAIL

View file

@ -1,19 +0,0 @@
[parse-where.html]
[":where(#a)" should be a valid selector]
expected: FAIL
[":where(:hover,:focus)" should be a valid selector]
expected: FAIL
[".a.b ~ .c.d:where(span.e + .f, .g.h > .i.j .k)" should be a valid selector]
expected: FAIL
[":where(ul,ol,.list) > [hidden\]" should be a valid selector]
expected: FAIL
["a:where(:not(:hover))" should be a valid selector]
expected: FAIL
[".a.b ~ :where(.c.d ~ .e.f)" should be a valid selector]
expected: FAIL

View file

@ -1,19 +0,0 @@
[query-is.html]
[Selector '.a :is(:where(:where(.b ~ .c)))" should find the expected elements]
expected: FAIL
[Selector '.a+:is(.b+.f, :is(.c>.e, .g))" should find the expected elements]
expected: FAIL
[Selector '.b + :is(.c + .c + .c, .b + .c:not(span), .b + .c + .e) ~ .h" should find the expected elements]
expected: FAIL
[Selector '.a :is(.b, .c)" should find the expected elements]
expected: FAIL
[Selector '.a :is(.e+.f, .g>.b, .h)" should find the expected elements]
expected: FAIL
[Selector '.a :is(.c#d, .e)" should find the expected elements]
expected: FAIL

View file

@ -1,19 +0,0 @@
[query-where.html]
[Selector '.a+:where(.b+.f, :where(.c>.e, .g))" should find the expected elements]
expected: FAIL
[Selector '.a :where(:is(:is(.b ~ .c)))" should find the expected elements]
expected: FAIL
[Selector '.a :where(.e+.f, .g>.b, .h)" should find the expected elements]
expected: FAIL
[Selector '.a :where(.c#d, .e)" should find the expected elements]
expected: FAIL
[Selector '.b + :where(.c + .c + .c, .b + .c:not(span), .b + .c + .e) ~ .h" should find the expected elements]
expected: FAIL
[Selector '.a :where(.b, .c)" should find the expected elements]
expected: FAIL