Bug 1643656 - Remove prefers-color-scheme: no-preference. r=gl,remote-protocol-reviewers,hiro,whimboo

It was removed from the spec.

Differential Revision: https://phabricator.services.mozilla.com/D78834
This commit is contained in:
Emilio Cobos Álvarez 2020-06-14 23:26:04 +00:00
parent fdba166d63
commit ffec6f608b
17 changed files with 18 additions and 94 deletions

View File

@ -10,4 +10,4 @@
exports.ELEMENT_STYLE = 100;
// An array of the possible color schemes that can be emulated.
exports.COLOR_SCHEMES = [null, "dark", "light", "no-preference"];
exports.COLOR_SCHEMES = [null, "dark", "light"];

View File

@ -775,10 +775,6 @@
fill: #bbb;
}
#color-scheme-simulation-toggle[state="no-preference"]::before {
fill-opacity: 0.5;
}
.flash-out {
transition: background 1s;
}

View File

@ -83,10 +83,6 @@ const ContentViewerActor = protocol.ActorClassWithSpec(contentViewerSpec, {
case "dark":
internalColorScheme = Ci.nsIContentViewer.PREFERS_COLOR_SCHEME_DARK;
break;
case "no-preference":
internalColorScheme =
Ci.nsIContentViewer.PREFERS_COLOR_SCHEME_NO_PREFERENCE;
break;
default:
internalColorScheme = Ci.nsIContentViewer.PREFERS_COLOR_SCHEME_NONE;
}

View File

@ -328,7 +328,6 @@ interface nsIContentViewer : nsISupports
cenum PrefersColorScheme : 8 {
PREFERS_COLOR_SCHEME_LIGHT,
PREFERS_COLOR_SCHEME_DARK,
PREFERS_COLOR_SCHEME_NO_PREFERENCE,
PREFERS_COLOR_SCHEME_NONE, /* This clears the override. */
};

View File

@ -16432,20 +16432,9 @@ StylePrefersColorScheme Document::PrefersColorScheme(
}
}
// If LookAndFeel::IntID::SystemUsesDarkTheme fails then return 2
// (no-preference)
switch (LookAndFeel::GetInt(LookAndFeel::IntID::SystemUsesDarkTheme, 2)) {
case 0:
return StylePrefersColorScheme::Light;
case 1:
return StylePrefersColorScheme::Dark;
case 2:
return StylePrefersColorScheme::NoPreference;
default:
// This only occurs if the user has set the ui.systemUsesDarkTheme pref to
// an invalid value.
return StylePrefersColorScheme::Light;
}
const bool dark =
!!LookAndFeel::GetInt(LookAndFeel::IntID::SystemUsesDarkTheme, 0);
return dark ? StylePrefersColorScheme::Dark : StylePrefersColorScheme::Light;
}
// static

View File

@ -2743,8 +2743,6 @@ nsDocumentViewer::EmulatePrefersColorScheme(PrefersColorScheme aScheme) {
return Some(StylePrefersColorScheme::Light);
case PREFERS_COLOR_SCHEME_DARK:
return Some(StylePrefersColorScheme::Dark);
case PREFERS_COLOR_SCHEME_NO_PREFERENCE:
return Some(StylePrefersColorScheme::NoPreference);
case PREFERS_COLOR_SCHEME_NONE:
return Nothing();
default:

View File

@ -10,9 +10,6 @@
@media (prefers-color-scheme: dark) {
#test { color: rgb(0, 2, 0); }
}
@media (prefers-color-scheme: no-preference) {
#test { color: rgb(0, 3, 0); }
}
</style>
<div id="test"></div>
<script>
@ -36,9 +33,6 @@ function colorId() {
cv.emulatePrefersColorScheme(cv.PREFERS_COLOR_SCHEME_DARK);
is(colorId(), 2, "Dark emulation works");
cv.emulatePrefersColorScheme(cv.PREFERS_COLOR_SCHEME_NO_PREFERENCE);
is(colorId(), 3, "No preference emulation works");
cv.emulatePrefersColorScheme(cv.PREFERS_COLOR_SCHEME_NONE);
is(colorId(), originalColor, "Clearing the override works");
}

View File

@ -14,9 +14,6 @@ div {
@media (prefers-color-scheme: light) {
div { background-color: red; }
}
@media (prefers-color-scheme: no-preference) {
div { background-color: red; }
}
</style>
<div></div>
</html>

View File

@ -14,9 +14,6 @@ div {
@media (prefers-color-scheme: dark) {
div { background-color: red; }
}
@media (prefers-color-scheme: no-preference) {
div { background-color: red; }
}
</style>
<div></div>
</html>

View File

@ -1,22 +0,0 @@
<!doctype html>
<meta charset="utf-8">
<html>
<title>prefers-color-scheme: no-preference</title>
<style>
div {
width: 100px;
height: 100px;
}
@media (prefers-color-scheme: no-preference) {
div { background-color: green; }
}
@media (prefers-color-scheme: light) {
div { background-color: red; }
}
@media (prefers-color-scheme: dark) {
div { background-color: red; }
}
</style>
<div></div>
</html>

View File

@ -14,9 +14,6 @@ div {
@media (prefers-color-scheme: dark) {
div { background-color: red; }
}
@media (prefers-color-scheme: no-preference) {
div { background-color: red; }
}
</style>
<div></div>
</html>

View File

@ -32,4 +32,3 @@ test-pref(privacy.resistFingerprinting,true) == mq_prefers_color_scheme_light.ht
== mq_prefers_color_scheme_print.html greenbox-print.html
test-pref(ui.systemUsesDarkTheme,0) == mq_prefers_color_scheme_light.html greenbox.html
test-pref(ui.systemUsesDarkTheme,1) == mq_prefers_color_scheme_dark.html greenbox.html
test-pref(ui.systemUsesDarkTheme,2) == mq_prefers_color_scheme_no_preference.html greenbox.html

View File

@ -5611,6 +5611,15 @@
mirror: always
rust: true
# Whether the `no-preference` value for `prefers-color-scheme` is parsed.
#
# It never matches regardless.
- name: layout.css.prefers-color-scheme-no-preference.enabled
type: RelaxedAtomicBool
value: false
mirror: always
rust: true
# Whether the `:focus-visible` pseudo-class is enabled.
#
# TODO: There are various ambiguities in the spec about this, so we shouldn't

View File

@ -1341,8 +1341,6 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
// → true
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
// → false
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
// → false
await page.emulateMediaFeatures([{ name: 'prefers-reduced-motion', value: 'reduce' }]);
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches);
@ -1358,8 +1356,6 @@ await page.evaluate(() => matchMedia('(prefers-color-scheme: dark)').matches);
// → true
await page.evaluate(() => matchMedia('(prefers-color-scheme: light)').matches);
// → false
await page.evaluate(() => matchMedia('(prefers-color-scheme: no-preference)').matches);
// → false
await page.evaluate(() => matchMedia('(prefers-reduced-motion: reduce)').matches);
// → true
await page.evaluate(() => matchMedia('(prefers-reduced-motion: no-preference)').matches);

View File

@ -246,11 +246,6 @@ describe('Emulation', () => {
() => matchMedia('(prefers-color-scheme: dark)').matches
)
).toBe(false);
expect(
await page.evaluate(
() => matchMedia('(prefers-color-scheme: no-preference)').matches
)
).toBe(false);
await page.emulateMediaFeatures([
{ name: 'prefers-color-scheme', value: 'dark' },
]);
@ -264,11 +259,6 @@ describe('Emulation', () => {
() => matchMedia('(prefers-color-scheme: light)').matches
)
).toBe(false);
expect(
await page.evaluate(
() => matchMedia('(prefers-color-scheme: no-preference)').matches
)
).toBe(false);
await page.emulateMediaFeatures([
{ name: 'prefers-reduced-motion', value: 'reduce' },
{ name: 'prefers-color-scheme', value: 'light' },
@ -293,11 +283,6 @@ describe('Emulation', () => {
() => matchMedia('(prefers-color-scheme: dark)').matches
)
).toBe(false);
expect(
await page.evaluate(
() => matchMedia('(prefers-color-scheme: no-preference)').matches
)
).toBe(false);
});
it('should throw in case of bad argument', async () => {
const { page } = getTestState();

View File

@ -278,6 +278,10 @@ enum PrefersReducedMotion {
Reduce,
}
fn color_scheme_no_preference_enabled(_: &crate::parser::ParserContext) -> bool {
static_prefs::pref!("layout.css.prefers-color-scheme-no-preference.enabled")
}
/// Values for the prefers-color-scheme media feature.
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, PartialEq, ToCss)]
#[repr(u8)]
@ -285,6 +289,7 @@ enum PrefersReducedMotion {
pub enum PrefersColorScheme {
Light,
Dark,
#[parse(condition = "color_scheme_no_preference_enabled")]
NoPreference,
}

View File

@ -1,11 +0,0 @@
[prefers-color-scheme.html]
[Should not be parseable in JS: '(prefers-color-scheme: no-preference)']
expected: FAIL
[Check that prefer-color-scheme evaluates to true in the boolean context]
expected:
if (os == "win") and (processor == "x86_64"): FAIL
[Should not be parseable in a CSS stylesheet: '(prefers-color-scheme: no-preference)']
expected: FAIL