From ebdc13da8f29d8d24abc2444ac224621ba4f622a Mon Sep 17 00:00:00 2001 From: Iulian Moraru Date: Sat, 11 Sep 2021 04:08:21 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1728187) for causing reftest failures on backplate-select-001.html. CLOSED TREE Backed out changeset 3a8197599a5c (bug 1728187) Backed out changeset d26328903485 (bug 1728187) --- .../prefers-contrast-black-ref.html | 24 +++++++++++------ layout/reftests/high-contrast/reftest.list | 4 +-- layout/style/PreferenceSheet.h | 8 +++--- layout/style/nsMediaFeatures.cpp | 8 ++---- .../test/test_dont_use_document_colors.html | 27 ++++++++++--------- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/layout/reftests/high-contrast/prefers-contrast-black-ref.html b/layout/reftests/high-contrast/prefers-contrast-black-ref.html index 67385886f51f..470f66fa8373 100644 --- a/layout/reftests/high-contrast/prefers-contrast-black-ref.html +++ b/layout/reftests/high-contrast/prefers-contrast-black-ref.html @@ -1,11 +1,19 @@ + + -reference: a black box to test the prefers-contrast media query - -
+ + +
+ + diff --git a/layout/reftests/high-contrast/reftest.list b/layout/reftests/high-contrast/reftest.list index 4ccb43d87202..50a1c798736d 100644 --- a/layout/reftests/high-contrast/reftest.list +++ b/layout/reftests/high-contrast/reftest.list @@ -49,8 +49,8 @@ pref(browser.display.document_color_use,2) == background-transparent-form-contro # prefers-contrast media query: -# Forced colors affects prefers-contrast. -== prefers-contrast-001.html prefers-contrast-black-ref.html +# Forced colors doesn't affect prefers-contrast. +!= prefers-contrast-001.html prefers-contrast-black-ref.html # high should match when an accessibility theme is used test-pref(ui.windowForeground,"black") test-pref(ui.windowBackground,"white") test-pref(ui.useAccessibilityTheme,1) == prefers-contrast-001.html prefers-contrast-black-ref.html diff --git a/layout/style/PreferenceSheet.h b/layout/style/PreferenceSheet.h index c9fcf4e820e9..02241e232fae 100644 --- a/layout/style/PreferenceSheet.h +++ b/layout/style/PreferenceSheet.h @@ -37,11 +37,11 @@ struct PreferenceSheet { bool mUseDocumentColors = true; // Whether the non-native theme should use system colors for widgets. - // We only do that if we are overriding the document colors. Otherwise it - // causes issues when pages only override some of the system colors, - // specially in dark themes mode. + // We only do that if we have a high-contrast theme _and_ we are overriding + // the document colors. Otherwise it causes issues when pages only override + // some of the system colors, specially in dark themes mode. bool NonNativeThemeShouldUseSystemColors() const { - return !mUseDocumentColors; + return mUseAccessibilityTheme && !mUseDocumentColors; } void Load(bool aIsChrome); diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index 4b43da16e96d..fffe37c359c5 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -257,20 +257,16 @@ StylePrefersColorScheme Gecko_MediaFeatures_PrefersColorScheme( return aDocument->PrefersColorScheme(); } -// Neither Linux, Windows, nor Mac have a way to indicate that low contrast is -// preferred so we use the presence of an accessibility theme or forced colors -// as a signal. StylePrefersContrast Gecko_MediaFeatures_PrefersContrast( const Document* aDocument) { if (nsContentUtils::ShouldResistFingerprinting(aDocument)) { return StylePrefersContrast::NoPreference; } + // Neither Linux, Windows, nor Mac have a way to indicate that low contrast is + // preferred so we use the presence of an accessibility theme as a signal. if (!!LookAndFeel::GetInt(LookAndFeel::IntID::UseAccessibilityTheme, 0)) { return StylePrefersContrast::More; } - if (!PreferenceSheet::PrefsFor(*aDocument).mUseDocumentColors) { - return StylePrefersContrast::More; - } return StylePrefersContrast::NoPreference; } diff --git a/layout/style/test/test_dont_use_document_colors.html b/layout/style/test/test_dont_use_document_colors.html index 7148d950b19e..401f66d2442e 100644 --- a/layout/style/test/test_dont_use_document_colors.html +++ b/layout/style/test/test_dont_use_document_colors.html @@ -70,6 +70,8 @@ function pushPrefEnvAndWait(args, cb) { pushPrefEnvAndWait({'set': [['browser.display.document_color_use', 1]]}, part1); var transparentBackgroundColor; +var inputBackgroundColor, inputColor, inputBorderTopColor; +var inputBorderRightColor, inputBorderLeftColor, inputBorderBottomColor; function part1() { @@ -104,7 +106,7 @@ function part1() isnot(cs5.borderRightColor, cs2.borderRightColor, "border-inline-end-color applies"); isnot(cs5.borderLeftColor, cs2.borderLeftColor, - "border-inline-start-color applies"); + "border-inline-start-color applies"); isnot(cs6.borderRightColor, cs2.borderRightColor, "border-inline-start-color applies"); isnot(cs6.borderLeftColor, cs2.borderLeftColor, @@ -122,14 +124,15 @@ function part1() "border-bottom-color applies"); isnot(cs8.borderImageSource, cs9.borderImageSource, "border-image-source applies"); transparentBackgroundColor = cs2.backgroundColor; + inputBackgroundColor = cs4.backgroundColor; + inputColor = cs4.color; + inputBorderTopColor = cs4.borderTopColor; + inputBorderRightColor = cs4.borderRightColor; + inputBorderLeftColor = cs4.borderLeftColor; + inputBorderBottomColor = cs4.borderBottomColor; pushPrefEnvAndWait({'set': [['browser.display.document_color_use', 2]]}, part2); } -function systemColor(c) { - let {r, g, b, a} = SpecialPowers.wrap(window).InspectorUtils.colorToRGBA(c, document); - return a != 1 ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`; -} - function part2() { isnot(cs1.backgroundColor, cs2.backgroundColor, "background-color transparency preserved (opaque)"); @@ -165,14 +168,14 @@ function part2() "border-left-color is blocked"); is(cs3.borderBottomColor, cs4.borderBottomColor, "border-bottom-color is blocked"); - is(cs4.backgroundColor, systemColor("ButtonFace"), "background-color not broken on inputs"); - is(cs4.color, systemColor("ButtonText"), "color not broken on inputs"); - is(cs4.borderTopColor, systemColor("ThreeDLightShadow"), "border-top-color not broken on inputs"); - is(cs4.borderRightColor, systemColor("ThreeDLightShadow"), + is(cs4.backgroundColor, inputBackgroundColor, "background-color not broken on inputs"); + is(cs4.color, inputColor, "color not broken on inputs"); + is(cs4.borderTopColor, inputBorderTopColor, "border-top-color not broken on inputs"); + is(cs4.borderRightColor, inputBorderRightColor, "border-right-color not broken on inputs"); - is(cs4.borderLeftColor, systemColor("ThreeDLightShadow"), + is(cs4.borderLeftColor, inputBorderLeftColor, "border-left-color not broken on inputs"); - is(cs4.borderBottomColor, systemColor("ThreeDLightShadow"), + is(cs4.borderBottomColor, inputBorderBottomColor, "border-bottom-color not broken on inputs"); is(cs8.borderImageSource, cs9.borderImageSource, "border-image-source is blocked");