Skip to content
This repository was archived by the owner on Jul 30, 2022. It is now read-only.

Commit 1f69a14

Browse files
committed
Bug 1658780 - Update the prefers-contrast media query to use the new more/less keywords r=emilio
Per the resolution here: w3c/csswg-drafts#2943 (comment) Differential Revision: https://phabricator.services.mozilla.com/D86848
1 parent 7f61fd9 commit 1f69a14

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

layout/reftests/high-contrast/prefers-contrast-002.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
width: 100px;
1010
height: 100px;
1111
}
12-
@media (prefers-contrast: high) {
12+
@media (prefers-contrast: more) {
1313
div {
1414
outline: 2px solid #000000;
1515
}

layout/style/nsMediaFeatures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ StyleContrastPref Gecko_MediaFeatures_PrefersContrast(
281281
// https://github.com/w3c/csswg-drafts/issues/3856#issuecomment-642313572
282282
// https://github.com/w3c/csswg-drafts/issues/2943
283283
if (!!LookAndFeel::GetInt(LookAndFeel::IntID::UseAccessibilityTheme, 0)) {
284-
return StyleContrastPref::High;
284+
return StyleContrastPref::More;
285285
}
286286
return StyleContrastPref::NoPreference;
287287
}

layout/style/test/chrome/test_chrome_only_media_queries.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
expectParseable("(-moz-os-version: windows-win10)");
7575
expectNonParseable("(-moz-os-version: )");
7676

77-
expectParseable("(prefers-contrast: low)")
77+
expectParseable("(prefers-contrast: more)")
7878
expectParseable("(prefers-contrast: forced)")
7979
expectParseable("(prefers-contrast: no-preference)")
80-
expectParseable("(prefers-contrast: high)");
80+
expectParseable("(prefers-contrast: less)");
8181
expectParseable("(prefers-contrast)")
8282
script>

servo/components/style/gecko/media_features.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ fn eval_prefers_reduced_motion(device: &Device, query_value: Option
313313
#[repr(u8)]
314314
#[allow(missing_docs)]
315315
enum PrefersContrast {
316-
High,
317-
Low,
316+
More,
317+
Less,
318318
NoPreference,
319319
Forced,
320320
}
@@ -326,12 +326,11 @@ enum PrefersContrast {
326326
#[derive(Clone, Copy, Debug, FromPrimitive, PartialEq)]
327327
#[repr(u8)]
328328
pub enum ContrastPref {
329-
/// High contrast is prefered. Corresponds to an accessibility theme
329+
/// More contrast is prefered. Corresponds to an accessibility theme
330330
/// being enabled or firefox forcing high contrast colors.
331-
High,
332-
/// Low contrast is prefered. Corresponds to the
333-
/// browser.display.prefers_low_contrast pref being true.
334-
Low,
331+
More,
332+
/// Low contrast is prefered.
333+
Less,
335334
/// The default value if neither high or low contrast is enabled.
336335
NoPreference,
337336
}
@@ -344,8 +343,8 @@ fn eval_prefers_contrast(device: &Device, query_value: Option)
344343
if let Some(query_value) = query_value {
345344
match query_value {
346345
PrefersContrast::Forced => forced_colors,
347-
PrefersContrast::High => contrast_pref == ContrastPref::High,
348-
PrefersContrast::Low => contrast_pref == ContrastPref::Low,
346+
PrefersContrast::More => contrast_pref == ContrastPref::More,
347+
PrefersContrast::Less => contrast_pref == ContrastPref::Less,
349348
PrefersContrast::NoPreference => contrast_pref == ContrastPref::NoPreference,
350349
}
351350
} else {

testing/web-platform/tests/css/mediaqueries/prefers-contrast.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<script>
88
query_should_be_css_parseable("(prefers-contrast)");
99
query_should_be_css_parseable("(prefers-contrast: no-preference)");
10-
query_should_be_css_parseable("(prefers-contrast: high)");
11-
query_should_be_css_parseable("(prefers-contrast: low)");
10+
query_should_be_css_parseable("(prefers-contrast: more)");
11+
query_should_be_css_parseable("(prefers-contrast: less)");
1212
query_should_be_css_parseable("(prefers-contrast: forced)");
1313

1414
query_should_not_be_css_parseable("(prefers-contrast: increase)");
@@ -18,11 +18,13 @@
1818
query_should_not_be_css_parseable("(prefers-contrast > increase)");
1919
query_should_not_be_css_parseable("(prefers-increased-contrast)");
2020
query_should_not_be_css_parseable("(prefers-decreased-contrast)");
21+
query_should_not_be_css_parseable("(prefers-contrast: high)");
22+
query_should_not_be_css_parseable("(prefers-contrast: low)");
2123

2224
query_should_be_js_parseable("(prefers-contrast)");
2325
query_should_be_js_parseable("(prefers-contrast: no-preference)");
24-
query_should_be_js_parseable("(prefers-contrast: high)");
25-
query_should_be_js_parseable("(prefers-contrast: low)");
26+
query_should_be_js_parseable("(prefers-contrast: more)");
27+
query_should_be_js_parseable("(prefers-contrast: less)");
2628
query_should_be_js_parseable("(prefers-contrast: forced)");
2729

2830
query_should_not_be_js_parseable("(prefers-contrast: increase)");
@@ -32,6 +34,8 @@
3234
query_should_not_be_js_parseable("(prefers-contrast > increase)");
3335
query_should_not_be_js_parseable("(prefers-increased-contrast)");
3436
query_should_not_be_js_parseable("(prefers-decreased-contrast)");
37+
query_should_not_be_js_parseable("(prefers-contrast: high)");
38+
query_should_not_be_js_parseable("(prefers-contrast: low)");
3539

3640
test(() => {
3741
// no-preference is the default and all other values evaluate to

0 commit comments

Comments
 (0)