Bug 1355771 - Automatically enable Firefox touch mode in Windows Tablet mode.
MozReview-Commit-ID: 1KLFdsNlib1
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -235,16 +235,23 @@ pref("general.smoothScroll", true);
pref("general.autoScroll", false);
#else
pref("general.autoScroll", true);
#endif
// UI density of the browser chrome. This mostly affects toolbarbutton
// and urlbar spacing. The possible values are 0=normal, 1=compact, 2=touch.
pref("browser.uidensity", 0);
+// Whether Firefox will automatically override the uidensity to "touch"
+// while the user is in a touch environment (such as Windows tablet mode).
+#ifdef MOZ_PHOTON_THEME
+pref("browser.touchmode.auto", true);
+#else
+pref("browser.touchmode.auto", false);
+#endif
// At startup, check if we're the default browser and prompt user if not.
pref("browser.shell.checkDefaultBrowser", true);
pref("browser.shell.shortcutFavicons",true);
pref("browser.shell.mostRecentDateSetAsDefault", "");
pref("browser.shell.skipDefaultBrowserCheckOnFirstRun", true);
pref("browser.shell.didSkipDefaultBrowserCheckOnFirstRun", false);
pref("browser.shell.defaultBrowserCheckCount", 0);
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5402,16 +5402,17 @@ var TabletModeUpdater = {
update(isInTabletMode) {
let wasInTabletMode = document.documentElement.hasAttribute("tabletmode");
if (isInTabletMode) {
document.documentElement.setAttribute("tabletmode", "true");
} else {
document.documentElement.removeAttribute("tabletmode");
}
if (wasInTabletMode != isInTabletMode) {
+ gUIDensity.update();
TabsInTitlebar.updateAppearance(true);
}
},
};
var gTabletModePageCounter = {
enabled: false,
inc() {
@@ -5441,31 +5442,44 @@ var gTabletModePageCounter = {
};
function displaySecurityInfo() {
BrowserPageInfo(null, "securityTab");
}
// Updates the UI density (for touch and compact mode) based on the uidensity pref.
var gUIDensity = {
+ MODE_COMPACT: 1,
+ MODE_TOUCH: 2,
prefDomain: "browser.uidensity",
+
observe(aSubject, aTopic, aPrefName) {
if (aTopic != "nsPref:changed" || aPrefName != this.prefDomain)
return;
this.update();
},
update() {
+ let mode;
+ // Automatically override the uidensity to touch in Windows tablet mode.
+ if (AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
+ WindowsUIUtils.inTabletMode &&
+ gPrefService.getBoolPref("browser.touchmode.auto")) {
+ mode = this.MODE_TOUCH;
+ } else {
+ mode = gPrefService.getIntPref(this.prefDomain);
+ }
+
let doc = document.documentElement;
- switch (gPrefService.getIntPref(this.prefDomain)) {
- case 1:
+ switch (mode) {
+ case this.MODE_COMPACT:
doc.setAttribute("uidensity", "compact");
break;
- case 2:
+ case this.MODE_TOUCH:
doc.setAttribute("uidensity", "touch");
break;
default:
doc.removeAttribute("uidensity");
break;
}
},
};