script: Use an implemented pseudo-element to fortype=color ::color-swatch (#37427)

Implement internal pseudo element, which would be resolved as a
"Implemented Pseudo Element" within style computation. This is an
concrete element that would has a primary style after the style
computation, but could match and style resolved like an pseudo element.
Therefore, it would have a different behavior compared to how does
`pseudo`s that `ServoLayoutNode` had. Where they would not have a
concrete element behind it. Note that, due to the nature of these pseudo
elements residing inside a UA widget, these pseudo elements would
therefore not be accessible in JavaScript by default.

This kind of element is required in order to implement the [form control
pseudo element](https://drafts.csswg.org/css-forms-1/#pseudo-elements)
like `::placeholder`, `::color-swatch`, `::field-text`, etc.
 
See [this docs](https://hackmd.io/@ChaKweTiau/BJ3zRdLQlg) for more
details of the implementation.

Then, the implemented pseudo element is utilized to implement style
matching for input `type=text`.

Servo's side of: https://github.com/servo/stylo/pull/212

Testing: No WPT regression.

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
Steven Novaryo 2025-07-09 23:36:58 +08:00 committed by GitHub
parent d2ccf419c3
commit 378c4648e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 201 additions and 163 deletions

24
Cargo.lock generated
View file

@ -7249,7 +7249,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.30.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"bitflags 2.9.1",
"cssparser",
@ -7555,7 +7555,7 @@ dependencies = [
[[package]]
name = "servo_arc"
version = "0.4.1"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"serde",
"stable_deref_trait",
@ -8017,7 +8017,7 @@ dependencies = [
[[package]]
name = "stylo"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"app_units",
"arrayvec",
@ -8074,7 +8074,7 @@ dependencies = [
[[package]]
name = "stylo_atoms"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"string_cache",
"string_cache_codegen",
@ -8083,12 +8083,12 @@ dependencies = [
[[package]]
name = "stylo_config"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
[[package]]
name = "stylo_derive"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"darling",
"proc-macro2",
@ -8100,7 +8100,7 @@ dependencies = [
[[package]]
name = "stylo_dom"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"bitflags 2.9.1",
"stylo_malloc_size_of",
@ -8109,7 +8109,7 @@ dependencies = [
[[package]]
name = "stylo_malloc_size_of"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"app_units",
"cssparser",
@ -8126,12 +8126,12 @@ dependencies = [
[[package]]
name = "stylo_static_prefs"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
[[package]]
name = "stylo_traits"
version = "0.5.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"app_units",
"bitflags 2.9.1",
@ -8548,7 +8548,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "to_shmem"
version = "0.2.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"cssparser",
"servo_arc",
@ -8561,7 +8561,7 @@ dependencies = [
[[package]]
name = "to_shmem_derive"
version = "0.1.0"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#ece49719ac02599750bd15901ecd7be24e96a26a"
source = "git+https://github.com/servo/stylo?branch=2025-07-01#673d9632edcec46250cfea9094eaa841f5dc8526"
dependencies = [
"darling",
"proc-macro2",