diff --git a/widget/gtk/nsNativeBasicThemeGTK.cpp b/widget/gtk/nsNativeBasicThemeGTK.cpp index 51297cf9fc64..f9ecb9e8c0d2 100644 --- a/widget/gtk/nsNativeBasicThemeGTK.cpp +++ b/widget/gtk/nsNativeBasicThemeGTK.cpp @@ -30,7 +30,7 @@ nsITheme::Transparency nsNativeBasicThemeGTK::GetWidgetTransparency( aAppearance == StyleAppearance::ScrollbarHorizontal) { nsPresContext* pc = aFrame->PresContext(); auto docState = pc->Document()->GetDocumentState(); - const auto useSystemColors = ShouldUseSystemColors(*pc->Document()); + const auto useSystemColors = ShouldUseSystemColors(*pc); const auto* style = nsLayoutUtils::StyleForScrollbar(aFrame); auto trackColor = ComputeScrollbarTrackColor(aFrame, *style, docState, useSystemColors); diff --git a/widget/nsNativeBasicTheme.cpp b/widget/nsNativeBasicTheme.cpp index 1e427294b9df..95f59f4b66b2 100644 --- a/widget/nsNativeBasicTheme.cpp +++ b/widget/nsNativeBasicTheme.cpp @@ -1776,12 +1776,14 @@ static LayoutDeviceRect ToSnappedRect( return LayoutDeviceRect::FromAppUnits(aRect, aTwipsPerPixel); } -auto nsNativeBasicTheme::ShouldUseSystemColors(const dom::Document& aDoc) +auto nsNativeBasicTheme::ShouldUseSystemColors(const nsPresContext& aPc) -> UseSystemColors { - // TODO: Do we really want to use system colors even when the page can - // override the high contrast theme? (mUseDocumentColors = true?). - return UseSystemColors( - PreferenceSheet::PrefsFor(aDoc).NonNativeThemeShouldUseSystemColors()); + // We make sure that we're drawing backgrounds, since otherwise layout will + // darken our used text colors etc anyways, and that can cause contrast issues + // with dark high-contrast themes. + return UseSystemColors(aPc.GetBackgroundColorDraw() && + PreferenceSheet::PrefsFor(*aPc.Document()) + .NonNativeThemeShouldUseSystemColors()); } template @@ -1798,7 +1800,7 @@ bool nsNativeBasicTheme::DoDrawWidgetBackground(PaintBackendData& aPaintData, const auto devPxRect = ToSnappedRect(aRect, twipsPerPixel, aPaintData); const EventStates docState = pc->Document()->GetDocumentState(); - const auto useSystemColors = ShouldUseSystemColors(*pc->Document()); + const auto useSystemColors = ShouldUseSystemColors(*pc); EventStates eventState = GetContentState(aFrame, aAppearance); if (aAppearance == StyleAppearance::MozMenulistArrowButton) { bool isHTML = IsHTMLContent(aFrame); diff --git a/widget/nsNativeBasicTheme.h b/widget/nsNativeBasicTheme.h index 09d8c1e4939e..3ac993331353 100644 --- a/widget/nsNativeBasicTheme.h +++ b/widget/nsNativeBasicTheme.h @@ -184,7 +184,7 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme { // Whether we should use system colors (for high contrast mode). enum class UseSystemColors : bool { No, Yes }; - static UseSystemColors ShouldUseSystemColors(const mozilla::dom::Document&); + static UseSystemColors ShouldUseSystemColors(const nsPresContext&); std::pair ComputeCheckboxColors(const EventStates&, StyleAppearance,