Bug 1704853 - Disable skeleton UI on non-default density r=emalysz

This is a little more than we need to disable it, but I figure we'll want to
support different UI densities in the skeleton UI long term.

Differential Revision: https://phabricator.services.mozilla.com/D111906
This commit is contained in:
Doug Thayer 2021-04-15 22:10:43 +00:00
parent c87c9a4350
commit c632b8a57d
3 changed files with 52 additions and 0 deletions

View File

@ -1960,6 +1960,11 @@ static Result<Ok, PreXULSkeletonUIError> CreateAndStorePreXULSkeletonUIImpl(
sFlagsRegSuffix)));
flags.deserialize(flagsUint);
if (flags.contains(SkeletonUIFlag::TouchDensity) ||
flags.contains(SkeletonUIFlag::CompactDensity)) {
return Err(PreXULSkeletonUIError::BadUIDensity);
}
uint32_t theme;
MOZ_TRY_VAR(theme, ReadRegUint(regKey, GetRegValueName(binPath.get(),
sThemeRegSuffix)));
@ -2124,6 +2129,13 @@ Result<Ok, PreXULSkeletonUIError> PersistPreXULSkeletonUIValues(
if (settings.rtlEnabled) {
flags += SkeletonUIFlag::RtlEnabled;
}
if (settings.uiDensity == SkeletonUIDensity::Touch) {
flags += SkeletonUIFlag::TouchDensity;
}
if (settings.uiDensity == SkeletonUIDensity::Compact) {
flags += SkeletonUIFlag::CompactDensity;
}
uint32_t flagsUint = flags.serialize();
MOZ_TRY(WriteRegUint(regKey, GetRegValueName(binPath.get(), sFlagsRegSuffix),
flagsUint));

View File

@ -35,6 +35,8 @@ struct DevPixelSpan {
int end;
};
enum class SkeletonUIDensity { Default, Touch, Compact };
struct SkeletonUISettings {
uint32_t screenX;
uint32_t screenY;
@ -48,6 +50,7 @@ struct SkeletonUISettings {
bool menubarShown;
bool bookmarksToolbarShown;
bool rtlEnabled;
SkeletonUIDensity uiDensity;
};
enum class ThemeMode : uint32_t { Invalid, Default, Dark, Light };
@ -56,6 +59,8 @@ enum class SkeletonUIFlag : uint8_t {
MenubarShown,
BookmarksToolbarShown,
RtlEnabled,
TouchDensity,
CompactDensity,
};
struct ThemeColors {
@ -93,6 +98,7 @@ enum class PreXULSkeletonUIError : uint32_t {
FailedBlitting,
FailedFillingBottomRect,
CrashedOnce,
BadUIDensity,
Unknown,
};
@ -143,6 +149,8 @@ inline const wchar_t* GetPreXULSkeletonUIErrorString(
return L"FailedFillingBottomRect";
case PreXULSkeletonUIError::CrashedOnce:
return L"CrashedOnce";
case PreXULSkeletonUIError::BadUIDensity:
return L"BadUIDensity";
case PreXULSkeletonUIError::Unknown:
return L"Unknown";
}

View File

@ -38,6 +38,7 @@
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsIWindowWatcher.h"
#include "nsIWindowsUIUtils.h"
#include "nsIURI.h"
#include "nsAppShellCID.h"
#include "nsReadableUtils.h"
@ -1916,6 +1917,37 @@ nsresult AppWindow::MaybeSaveEarlyWindowPersistentValues(
settings.rtlEnabled = intl::LocaleService::GetInstance()->IsAppLocaleRTL();
bool isInTabletMode = false;
bool autoTouchModePref =
Preferences::GetBool("browser.touchmode.auto", false);
if (autoTouchModePref) {
nsCOMPtr<nsIWindowsUIUtils> uiUtils(
do_GetService("@mozilla.org/windows-ui-utils;1"));
if (!NS_WARN_IF(!uiUtils)) {
uiUtils->GetInTabletMode(&isInTabletMode);
}
}
if (isInTabletMode) {
settings.uiDensity = SkeletonUIDensity::Touch;
} else {
int uiDensityPref = Preferences::GetInt("browser.uidensity", 0);
switch (uiDensityPref) {
case 0: {
settings.uiDensity = SkeletonUIDensity::Default;
break;
}
case 1: {
settings.uiDensity = SkeletonUIDensity::Compact;
break;
}
case 2: {
settings.uiDensity = SkeletonUIDensity::Touch;
break;
}
}
}
Unused << PersistPreXULSkeletonUIValues(settings);
#endif