Bug 1733413 - Force light color-scheme for non-native-theme docs for now. r=mstange, a=RyanVM
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 04 Oct 2021 18:39:37 +0000
changeset 663175 e9187d67b698a2e02569ada391d2a7a0c2bcdff0
parent 663174 9d89d049f062ddc0787b8693f980690b7ebae66d
child 663176 200db645dbbedf465e873d3695d77e4d0d02caea
push id15895
push userryanvm@gmail.com
push dateTue, 05 Oct 2021 17:04:54 +0000
treeherdermozilla-beta@e9187d67b698 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, RyanVM
bugs1733413
milestone94.0
Bug 1733413 - Force light color-scheme for non-native-theme docs for now. r=mstange, a=RyanVM In the future we need to remove this patch, implement dark form controls, and probably make those tests pass some other way (like forcing the chrome color-scheme to match content for those tests or something). Otherwise they are really expected to fail on a Firefox dark theme. But this is a somewhat-easy fix for now. Differential Revision: https://phabricator.services.mozilla.com/D127473
widget/nsXPLookAndFeel.cpp
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -1067,16 +1067,22 @@ LookAndFeel::ColorScheme LookAndFeel::Co
   if (ShouldRespectSystemColorSchemeForChromeDoc()) {
     return SystemColorScheme();
   }
   return ColorScheme::Light;
 }
 
 static LookAndFeel::ColorScheme ColorSchemeForDocument(
     const dom::Document& aDoc, bool aContentSupportsDark) {
+  if (aDoc.ShouldAvoidNativeTheme()) {
+    // The non-native theme doesn't know how to draw dark form controls yet, so
+    // let's force light colors for now.
+    return LookAndFeel::ColorScheme::Light;
+  }
+
   if (nsContentUtils::IsChromeDoc(&aDoc)) {
     return LookAndFeel::ColorSchemeForChrome();
   }
 #ifdef MOZ_WIDGET_GTK
   if (StaticPrefs::widget_content_allow_gtk_dark_theme()) {
     // If users manually tweak allow-gtk-dark-theme, allow content to use the
     // system color scheme rather than forcing it to light.
     return LookAndFeel::SystemColorScheme();