Skip to content

Add support for the ::color-swatch pseudo-element#212

Merged
Loirooriol merged 1 commit intoservo:mainfrom
stevennovaryo:input-color-pseudo-element
Jul 9, 2025
Merged

Add support for the ::color-swatch pseudo-element#212
Loirooriol merged 1 commit intoservo:mainfrom
stevennovaryo:input-color-pseudo-element

Conversation

@stevennovaryo
Copy link
Copy Markdown
Contributor

Define ::color-swatch pseudo element https://drafts.csswg.org/css-forms-1/#color-swatch-pseudo. It represents the element that display the chosen color value of Input type=color. Particularly, ::color-swatch is a pseudo element with a concrete DOM element behind it, and it is defined as lazy pseudo element.

The pseudo element would be public because of no additional requirement specified (e.g. property restriction) and the element is defined in Servo.

Stylo's companion of servo/servo#37427

This is a reopened PR of #208 due to the new upstream.

Copy link
Copy Markdown
Collaborator

@Loirooriol Loirooriol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with nits

@stevennovaryo stevennovaryo force-pushed the input-color-pseudo-element branch from 2afb8da to c179f93 Compare July 3, 2025 14:16
@Loirooriol
Copy link
Copy Markdown
Collaborator

This comment seems wrong now:

/// Servo doesn't have to deal with this.

@lukewarlow
Copy link
Copy Markdown
Member

lukewarlow commented Jul 3, 2025

Fwiw we may end up in a situation where these new pseudo elements only match (for author styles at least) when the element is in specific appearance modes. Such as appearance: base, idk if that changes how these things are wired up and obviously isn't necessarily needed for Servo initially, just an fyi.

Signed-off-by: stevennovaryo <[email protected]>
@stevennovaryo stevennovaryo force-pushed the input-color-pseudo-element branch from c179f93 to 14f9974 Compare July 4, 2025 01:24
@stevennovaryo
Copy link
Copy Markdown
Contributor Author

This comment seems wrong now:

/// Servo doesn't have to deal with this.

Thanks for the catch! It is definitely wrong with the new changes.

@stevennovaryo
Copy link
Copy Markdown
Contributor Author

Fwiw we may end up in a situation where these new pseudo elements only match (for author styles at least) when the element is in specific appearance modes. Such as appearance: base, idk if that changes how these things are wired up and obviously isn't necessarily needed for Servo initially, just an fyi.

Thanks for the heads up! With the development of Servo, these will definitely be necessary in the near future. Possibly extending the structs in the future.

@Loirooriol Loirooriol added this pull request to the merge queue Jul 9, 2025
Merged via the queue into servo:main with commit 673d963 Jul 9, 2025
3 checks passed
github-merge-queue bot pushed a commit to servo/servo that referenced this pull request Jul 9, 2025
…-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: servo/stylo#212

Testing: No WPT regression.

---------

Signed-off-by: stevennovaryo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants