Support color-scheme in Servo - #438
Draft
TimvdLippe wants to merge 1 commit into
Draft
Conversation
With these changes, both the `color-scheme` CSS property is supported, as well as the required logic to act upon it. Co-authored-by: Nico Burns <nico@nicoburns.com> Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
nicoburns
approved these changes
Aug 5, 2026
mrobinson
approved these changes
Aug 5, 2026
Member
|
Is there a corresponding Servo PR for this change? Typically for Stylo PRs they should have a link to a Servo PR unless it is guaranteed to not change test results / affect the build. |
Contributor
Author
|
It's still a draft as I ran out of time to create the Servo PR. Once I have that finished, I will mark this PR as ready |
Contributor
Author
|
Stylo is currently being upgraded in servo/servo#46987 which means that test results will be muddied by the upgrade. Will wait on that |
Loirooriol
reviewed
Aug 6, 2026
Comment on lines
+343
to
+356
| // If both are supported, then use the prefered color scheme to determine | ||
| // whether the user wants dark mode | ||
| if supports_dark_mode && supports_light_mode { | ||
| return prefers_color_scheme == PrefersColorScheme::Dark; | ||
| } | ||
|
|
||
| // If only one is chosen, then it should only support dark mode if it was dark | ||
| // mode enabled. | ||
| if supports_dark_mode || supports_light_mode { | ||
| return supports_dark_mode; | ||
| } | ||
|
|
||
| // Neither was chosen. In that case, fallback to the preferred color scheme | ||
| return prefers_color_scheme == PrefersColorScheme::Dark; |
Collaborator
There was a problem hiding this comment.
I think this would be simpler as
Suggested change
| // If both are supported, then use the prefered color scheme to determine | |
| // whether the user wants dark mode | |
| if supports_dark_mode && supports_light_mode { | |
| return prefers_color_scheme == PrefersColorScheme::Dark; | |
| } | |
| // If only one is chosen, then it should only support dark mode if it was dark | |
| // mode enabled. | |
| if supports_dark_mode || supports_light_mode { | |
| return supports_dark_mode; | |
| } | |
| // Neither was chosen. In that case, fallback to the preferred color scheme | |
| return prefers_color_scheme == PrefersColorScheme::Dark; | |
| // If only one is supported, then use dark mode if it was the supported one. | |
| if supports_dark_mode != supports_light_mode { | |
| return supports_dark_mode; | |
| } | |
| // If either both or none are supported, then use the preferred color scheme | |
| // to determine whether the user wants dark mode. | |
| return prefers_color_scheme == PrefersColorScheme::Dark; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With these changes, both the
color-schemeCSS property is supported, as well as the required logic to act upon it.Supersedes and closes #411