Bug 1593390 - Use NSApp.effectiveAppearance to detect system dark mode. r=mac-reviewers,harry

Differential Revision: https://phabricator.services.mozilla.com/D110499
This commit is contained in:
Markus Stange 2021-04-01 16:42:04 +00:00
parent 1ebb0b4ffa
commit 6d3a6fbf56

View File

@ -639,10 +639,12 @@ bool nsLookAndFeel::AllowOverlayScrollbarsOverlap() { return (UseOverlayScrollba
bool nsLookAndFeel::SystemWantsDarkTheme() {
// This returns true if the macOS system appearance is set to dark mode on
// 10.14+, false otherwise.
if (!nsCocoaFeatures::OnMojaveOrLater()) {
return false;
if (@available(macOS 10.14, *)) {
NSAppearanceName aquaOrDarkAqua = [NSApp.effectiveAppearance
bestMatchFromAppearancesWithNames:@[ NSAppearanceNameAqua, @"NSAppearanceNameDarkAqua" ]];
return [aquaOrDarkAqua isEqualToString:@"NSAppearanceNameDarkAqua"];
}
return !![[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
return false;
}
bool nsLookAndFeel::NativeGetFont(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle) {