Implement the Device::is_dark_color_scheme function - #411
Conversation
Any ancestors of this commit are from upstream mozilla-central, with some filtering and renaming. Our patches and sync tooling start here. The sync tooling has all been squashed into this commit, based on: https://github.com/servo/stylo/commits/64731e10dc8ef87ef52aa2fb9f988c3b2530f3a7
This is a rebase of 2453c41 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The unit of (1 / 2px) is definitely not a px. Right now we disallow dividing by non-numbers, so enforce it. Once we implement unit math we could start tracking exponents (and support something like squared pixels etc). Differential Revision: https://phabricator.services.mozilla.com/D304694
Servo PR: servo/servo#44978 Signed-off-by: Josh Matthews <josh@joshmatthews.net>
We were previously using a mix of f32 and f64. Then it could happen that we would first check that `a < b` in f64, but when converting to f32, they might become equal due to the precision loss. Thus this could break invariants in the logic, making a `debug_unreachable!()` reachable. Servo PR: servo/servo#45682 Signed-off-by: Oriol Brufau <obrufau@igalia.com> Co-authored-by: Martin Robinson <mrobinson@abandonedwig.info>
Reverts servo#368 More work is required in Servo to integrate this.
Fixes servo#390 This feature is quite impactful as it is required for Tailwind's hover styles to work. Servo PR: servo/servo#45681 Signed-off-by: Nico Burns <nico@nicoburns.com>
…servo#388) It's not possible to properly calculate these only looking at style, because the results depends on the used `overflow` value. Servo PR: servo/servo#45629 Signed-off-by: Martin Robinson <martin@abandonedwig.info>
Fixes a compile warning from servo#388. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Performs some changes so that Servo will be able to use these: - `ComputedFontWeightRange` - `ComputedFontStretchRange` - `ComputedFontStyleDescriptor` Servo PR: servo/servo#45821 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
The implementation does the same as what gecko does (except that I didn't add support for `device-aspect-ratio`, hence slightly simpler / inlined. Servo PR: servo/servo#45490 --------- Signed-off-by: Martin Robinson <martin@abandonedwig.info> Co-authored-by: Martin Robinson <martin@abandonedwig.info>
…#400) This method was performing a single iteration. But most callers want to perform multiple iterations, so they were calling it in a loop. So this patch replaces `iterate()` with `iterate_by()`, which takes the desired number of iterations as a parameter, and returns the actual number of iterations that were performed. Servo PR: servo/servo#45978 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
servo#401) It was only incremented for finite animations, but infinite animations need to be incremented too. Servo PR: servo/servo#45990 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Needed for servo/servo#45901 The servo PR is already approved, feel free to merge this immediately. Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Servo PR: servo/servo#44978 Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Transitions can sometimes have 0 duration when the transition reversing shortening factor is also calculated to be 0. When that happens, we should always use 1.0 for the progress when calculating the value for the transition. This avoid division by zero. Servo PR: servo/servo#46016 Signed-off-by: Martin Robinson <mrobinson@abandonedwig.info>
It's fine to subtract `n` when the value is `n`, we just don't want to get negative. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
We were already passing viewport dimensions into Stylo as part of the `Device` which is sufficient to determine, `width`, `height` and `orientation`, but we were previously only exposing the `width` to CSS.| Servo PR: servo/servo#45707 --------- Signed-off-by: Nico Burns <nico@nicoburns.com>
Fixes: servo#407 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
I'm implementing this in Blitz, so I would like to enable it here if possible. Should be low cost/risk for Servo as it's just `u8` bitflags. Servo PR: servo/servo#46159 Signed-off-by: Nico Burns <nico@nicoburns.com>
Signed-off-by: Nico Burns <nico@nicoburns.com>
5fea073 to
9110962
Compare
| false | ||
| pub(crate) fn is_dark_color_scheme(&self, flags: ColorSchemeFlags) -> bool { | ||
| // The below is based on the implementation from Gecko: | ||
| // https://searchfox.org/firefox-main/source/widget/nsXPLookAndFeel.cpp#1296 |
There was a problem hiding this comment.
Line number is useless if it's not a permalink.
Loirooriol
left a comment
There was a problem hiding this comment.
I'm not sure I see the point of adding a function that isn't used. If you are implementing light-dark(), wouldn't it be better to add it as part of that PR?
|
Sorry, somehow failed to see the function already exists as returning false. |
Signed-off-by: Nico Burns <nico@nicoburns.com>
Loirooriol
left a comment
There was a problem hiding this comment.
So I guess this looks good if you use a permalink.
It's not really changing behavior because color-scheme doesn't parse, right?
In theory it should make it respect the system theme (light/dark mode) which we already plug in to Stylo for Possibly we ought to enable |
Then please ensure test coverage |
This is necessary (but may not be sufficient) to make
light-dark()functions work.Implementation based on the Gecko implementation: https://searchfox.org/firefox-main/source/widget/nsXPLookAndFeel.cpp#1296
The logic is:
color-scheme(lightordark) value then use that (value comes in from theColorSchemeFlags)Device