Skip to content

Enable system color#302

Merged
Loirooriol merged 1 commit intoservo:mainfrom
longvatrong111:system-color
Mar 3, 2026
Merged

Enable system color#302
Loirooriol merged 1 commit intoservo:mainfrom
longvatrong111:system-color

Conversation

@longvatrong111
Copy link
Copy Markdown
Contributor

@longvatrong111 longvatrong111 commented Feb 3, 2026

Enable system color and map keyword to value according to:
https://w3c.github.io/csswg-drafts/css-color-4/#valdef-color-canvastext
Values not mentioned are set to default.

Servo PR: servo/servo#42529

Comment thread style/values/specified/color.rs
Comment thread style/servo/media_queries.rs Outdated
@longvatrong111 longvatrong111 force-pushed the system-color branch 2 times, most recently from 78ec75d to 39096af Compare February 4, 2026 07:38
Comment thread style/values/specified/color.rs Outdated
@longvatrong111 longvatrong111 force-pushed the system-color branch 2 times, most recently from 4765f90 to 9985615 Compare February 4, 2026 11:16
Comment thread style/values/specified/color.rs Outdated
Comment thread style/servo/media_queries.rs
@longvatrong111 longvatrong111 force-pushed the system-color branch 2 times, most recently from 91fbcdd to 83812ce Compare February 5, 2026 05:59
Comment thread style/servo/media_queries.rs Outdated
Comment thread style/values/specified/color.rs Outdated
Comment thread style/servo/media_queries.rs Outdated
@Loirooriol
Copy link
Copy Markdown
Collaborator

I force-pushed main for the upgrade, can you rebase your changes?

@longvatrong111
Copy link
Copy Markdown
Contributor Author

I force-pushed main for the upgrade, can you rebase your changes?

sure, I updated.

@Loirooriol
Copy link
Copy Markdown
Collaborator

It seems you rebase the wrong one, it looks like the old code, not like c45ce85

@Loirooriol
Copy link
Copy Markdown
Collaborator

Also, can you open a Servo PR to run tests?

@longvatrong111
Copy link
Copy Markdown
Contributor Author

longvatrong111 commented Feb 11, 2026

@Loirooriol ah, I've updated again.
And here is the Servo PR: servo/servo#42529. Manual test is ok.

Now Servo Cargo.toml doesn't point to head of stylo:main anymore, if this PR is merged, do I need to update Servo? Seem like yes

Comment thread style/servo/media_queries.rs Outdated
Comment thread style/servo/media_queries.rs Outdated

// Refer to spec
// <https://www.w3.org/TR/css-color-4/#css-system-colors>
// and computed style from Chrome
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where from Chrome? I'm seeing different values in LayoutTheme::DefaultSystemColor

Are they platform-specific ones? For what platform? Would it be better to use the default ones?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I get the computed style from Chrome devtool in a linux device, but seem like they are slightly different across devices. Better not mention Chrome here, we can define the colors ourselves, the visual looks are similar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Loirooriol AFAIK there is no default value, do you want to use value in Chromium source code? The current values are from devtool.

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.

Sorry for the delay.

I think it's slightly weird that the colors are hardcoded from what Chrome used on your system. Possibly, in the future the resolution should happen in Servo using a trait. But I guess this looks good as a start.

Enable system color and map keyword to value according to https://w3c.github.io/csswg-drafts/css-color-4/#valdef-color-canvastext

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
@longvatrong111
Copy link
Copy Markdown
Contributor Author

Sorry for the delay.

I think it's slightly weird that the colors are hardcoded from what Chrome used on your system. Possibly, in the future the resolution should happen in Servo using a trait. But I guess this looks good as a start.

@Loirooriol I see, I've rebase both PRs, look like they are ready now.

@Loirooriol Loirooriol added this pull request to the merge queue Mar 3, 2026
Merged via the queue into servo:main with commit b22d59d Mar 3, 2026
5 checks passed
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Mar 3, 2026
Enable system color:
- stylo PR: servo/stylo#302
- Update WPT expectation
- Update UA styleshee to use system color value

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
github-merge-queue Bot pushed a commit to servo/servo that referenced this pull request Mar 3, 2026
Enable system color:
- stylo PR: servo/stylo#302
- Update WPT expectation
- Update UA styleshee to use system color value

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
minghuaw pushed a commit to minghuaw/stylo that referenced this pull request Mar 5, 2026
Enable system color and map keyword to value according to:
https://w3c.github.io/csswg-drafts/css-color-4/#valdef-color-canvastext
Values not mentioned are set to default.

Servo PR: servo/servo#42529

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Loirooriol pushed a commit that referenced this pull request Mar 5, 2026
Enable system color and map keyword to value according to:
https://w3c.github.io/csswg-drafts/css-color-4/#valdef-color-canvastext
Values not mentioned are set to default.

Servo PR: servo/servo#42529

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Mar 6, 2026
github-actions Bot pushed a commit that referenced this pull request Mar 7, 2026
@longvatrong111
Copy link
Copy Markdown
Contributor Author

Sorry for the delay.

I think it's slightly weird that the colors are hardcoded from what Chrome used on your system. Possibly, in the future the resolution should happen in Servo using a trait. But I guess this looks good as a start.

@Loirooriol can you explain how to implement this as a trait in Servo? I'm glad to continue

@Loirooriol
Copy link
Copy Markdown
Collaborator

See FontMetricsProvider in ExtraDeviceData, I was thinking something along these lines.

/// A trait used to query font metrics in clients of Stylo. This is used by Device to
/// query font metrics in a way that is specific to the client using Stylo.
pub trait FontMetricsProvider: Debug + Sync {
/// Query the font metrics for the given font and the given base font size.
fn query_font_metrics(
&self,
vertical: bool,
font: &Font,
base_size: CSSPixelLength,
flags: QueryFontMetricsFlags,
) -> FontMetrics;
/// Gets the base size given a generic font family.
fn base_size_for_generic(&self, generic: GenericFontFamily) -> Length;
}

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