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 6d0ed60fa1
commit daecb46ab3
3 changed files with 52 additions and 0 deletions

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