Bug 1953907 - Avoid reading from uninitialized mHighContrastInfo.
MANUAL PUSH: UBSan fix CLOSED TREE
This commit is contained in:
@@ -157,10 +157,10 @@ sRGBColor ThemeAccentColor::GetDarker() const {
|
||||
return sRGBColor::FromABGR(ColorPalette::GetDarker(*mAccentColor));
|
||||
}
|
||||
|
||||
auto ThemeColors::ShouldBeHighContrast(const nsPresContext& aPc,
|
||||
bool aCustomAccentColor)
|
||||
auto ThemeColors::ShouldBeHighContrast(const nsIFrame* aFrame)
|
||||
-> HighContrastInfo {
|
||||
if (!aPc.GetBackgroundColorDraw()) {
|
||||
auto* pc = aFrame->PresContext();
|
||||
if (!pc->GetBackgroundColorDraw()) {
|
||||
// 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.
|
||||
@@ -177,18 +177,18 @@ auto ThemeColors::ShouldBeHighContrast(const nsPresContext& aPc,
|
||||
// or in "requested" mode (chrome-only) with no custom accent color.
|
||||
// Otherwise it causes issues when pages only override some of the system
|
||||
// colors, specially in dark themes.
|
||||
switch (aPc.ForcedColors()) {
|
||||
switch (pc->ForcedColors()) {
|
||||
case StyleForcedColors::None:
|
||||
break;
|
||||
case StyleForcedColors::Requested:
|
||||
return !aCustomAccentColor;
|
||||
return aFrame->StyleUI()->mAccentColor.IsAuto();
|
||||
case StyleForcedColors::Active:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
const bool mustUseLight =
|
||||
PreferenceSheet::PrefsFor(*aPc.Document()).mMustUseLightSystemColors;
|
||||
PreferenceSheet::PrefsFor(*pc->Document()).mMustUseLightSystemColors;
|
||||
return {highContrast, mustUseLight};
|
||||
}
|
||||
|
||||
|
||||
@@ -55,18 +55,17 @@ class ThemeColors {
|
||||
};
|
||||
|
||||
const Document& mDoc;
|
||||
const HighContrastInfo mHighContrastInfo;
|
||||
const ColorScheme mColorScheme;
|
||||
const AccentColor mAccentColor;
|
||||
const HighContrastInfo mHighContrastInfo;
|
||||
|
||||
public:
|
||||
explicit ThemeColors(const nsIFrame* aFrame, StyleAppearance aAppearance)
|
||||
: mDoc(*aFrame->PresContext()->Document()),
|
||||
mHighContrastInfo(ShouldBeHighContrast(aFrame)),
|
||||
mColorScheme(
|
||||
ColorSchemeForWidget(aFrame, aAppearance, mHighContrastInfo)),
|
||||
mAccentColor(*aFrame->Style(), mColorScheme),
|
||||
mHighContrastInfo(ShouldBeHighContrast(*aFrame->PresContext(),
|
||||
mAccentColor.IsCustom())) {}
|
||||
mAccentColor(*aFrame->Style(), mColorScheme) {}
|
||||
virtual ~ThemeColors() = default;
|
||||
|
||||
[[nodiscard]] static float ScaleLuminanceBy(float aLuminance, float aFactor) {
|
||||
@@ -102,8 +101,8 @@ class ThemeColors {
|
||||
}
|
||||
|
||||
// Whether we should use system colors (for high contrast mode).
|
||||
static HighContrastInfo ShouldBeHighContrast(const nsPresContext&,
|
||||
bool aCustomAccentColor);
|
||||
static HighContrastInfo ShouldBeHighContrast(const nsIFrame*);
|
||||
|
||||
static ColorScheme ColorSchemeForWidget(const nsIFrame*, StyleAppearance,
|
||||
const HighContrastInfo&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user