зеркало из https://github.com/mozilla/gecko-dev.git
Bug 680077 - Use Util.isTablet() everywhere to check if tablet mode is on (r=mbrubeck)
Use it instead of checking for a 'tablet' attribute in Elements.urlbarState everywhere.
This commit is contained in:
Родитель
6fc0ee69ae
Коммит
b750fd666f
|
@ -161,15 +161,29 @@ let Util = {
|
||||||
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
|
||||||
},
|
},
|
||||||
|
|
||||||
isTablet: function isTablet() {
|
isTablet: function isTablet(options) {
|
||||||
|
let forceUpdate = options && 'forceUpdate' in options && options.forceUpdate;
|
||||||
|
|
||||||
|
if ('_isTablet' in this && !forceUpdate)
|
||||||
|
return this._isTablet;
|
||||||
|
|
||||||
|
let tabletPref = Services.prefs.getIntPref("browser.ui.layout.tablet");
|
||||||
|
|
||||||
|
// Act according to user prefs if tablet mode has been
|
||||||
|
// explicitly disabled or enabled.
|
||||||
|
if (tabletPref == 0)
|
||||||
|
return this._isTablet = false;
|
||||||
|
else if (tabletPref == 1)
|
||||||
|
return this._isTablet = true;
|
||||||
|
|
||||||
let dpi = this.displayDPI;
|
let dpi = this.displayDPI;
|
||||||
if (dpi <= 96)
|
if (dpi <= 96)
|
||||||
return (window.innerWidth > 1024);
|
return this._isTablet = (window.innerWidth > 1024);
|
||||||
|
|
||||||
// See the tablet_panel_minwidth from mobile/themes/core/defines.inc
|
// See the tablet_panel_minwidth from mobile/themes/core/defines.inc
|
||||||
let tablet_panel_minwidth = 124;
|
let tablet_panel_minwidth = 124;
|
||||||
let dpmm = 25.4 * window.innerWidth / dpi;
|
let dpmm = 25.4 * window.innerWidth / dpi;
|
||||||
return (dpmm >= tablet_panel_minwidth);
|
return this._isTablet = (dpmm >= tablet_panel_minwidth);
|
||||||
},
|
},
|
||||||
|
|
||||||
isPortrait: function isPortrait() {
|
isPortrait: function isPortrait() {
|
||||||
|
|
|
@ -186,7 +186,7 @@ var BrowserUI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
lockToolbar: function lockToolbar() {
|
lockToolbar: function lockToolbar() {
|
||||||
if (Elements.urlbarState.getAttribute("tablet"))
|
if (Util.isTablet())
|
||||||
return;
|
return;
|
||||||
this._toolbarLocked++;
|
this._toolbarLocked++;
|
||||||
document.getElementById("toolbar-moveable-container").top = "0";
|
document.getElementById("toolbar-moveable-container").top = "0";
|
||||||
|
@ -549,8 +549,7 @@ var BrowserUI = {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTabletLayout: function updateTabletLayout() {
|
updateTabletLayout: function updateTabletLayout() {
|
||||||
let tabletPref = Services.prefs.getIntPref("browser.ui.layout.tablet");
|
if (Util.isTablet({ forceUpdate: true })) {
|
||||||
if (tabletPref == 1 || (tabletPref == -1 && Util.isTablet())) {
|
|
||||||
this.unlockToolbar();
|
this.unlockToolbar();
|
||||||
Elements.urlbarState.setAttribute("tablet", "true");
|
Elements.urlbarState.setAttribute("tablet", "true");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ var Browser = {
|
||||||
},
|
},
|
||||||
|
|
||||||
tryFloatToolbar: function tryFloatToolbar(dx, dy) {
|
tryFloatToolbar: function tryFloatToolbar(dx, dy) {
|
||||||
if (this.floatedWhileDragging || Elements.urlbarState.getAttribute("tablet"))
|
if (this.floatedWhileDragging || Util.isTablet())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility(dx, dy);
|
let [leftvis, ritevis, leftw, ritew] = Browser.computeSidebarVisibility(dx, dy);
|
||||||
|
@ -1289,7 +1289,7 @@ Browser.MainDragger.prototype = {
|
||||||
let bcr = browser.getBoundingClientRect();
|
let bcr = browser.getBoundingClientRect();
|
||||||
this._contentView = browser.getViewAt(clientX - bcr.left, clientY - bcr.top);
|
this._contentView = browser.getViewAt(clientX - bcr.left, clientY - bcr.top);
|
||||||
this._stopAtSidebar = 0;
|
this._stopAtSidebar = 0;
|
||||||
this._panToolbars = !Elements.urlbarState.getAttribute("tablet");
|
this._panToolbars = !Util.isTablet();
|
||||||
if (this._sidebarTimeout) {
|
if (this._sidebarTimeout) {
|
||||||
clearTimeout(this._sidebarTimeout);
|
clearTimeout(this._sidebarTimeout);
|
||||||
this._sidebarTimeout = null;
|
this._sidebarTimeout = null;
|
||||||
|
@ -1908,7 +1908,7 @@ const ContentTouchHandler = {
|
||||||
// or if the urlbar is showing
|
// or if the urlbar is showing
|
||||||
this.canCancelPan = (aX >= rect.left + kSafetyX) && (aX <= rect.right - kSafetyX) &&
|
this.canCancelPan = (aX >= rect.left + kSafetyX) && (aX <= rect.right - kSafetyX) &&
|
||||||
(aY >= rect.top + kSafetyY) &&
|
(aY >= rect.top + kSafetyY) &&
|
||||||
(bcr.top == 0 || Elements.urlbarState.getAttribute("tablet"));
|
(bcr.top == 0 || Util.isTablet());
|
||||||
},
|
},
|
||||||
|
|
||||||
tapDown: function tapDown(aX, aY) {
|
tapDown: function tapDown(aX, aY) {
|
||||||
|
@ -3155,7 +3155,7 @@ function rendererFactory(aBrowser, aCanvas) {
|
||||||
var ViewableAreaObserver = {
|
var ViewableAreaObserver = {
|
||||||
get width() {
|
get width() {
|
||||||
let width = this._width || window.innerWidth;
|
let width = this._width || window.innerWidth;
|
||||||
if (Elements.urlbarState.getAttribute("tablet")) {
|
if (Util.isTablet()) {
|
||||||
let sidebarWidth = Math.round(Elements.tabs.getBoundingClientRect().width);
|
let sidebarWidth = Math.round(Elements.tabs.getBoundingClientRect().width);
|
||||||
width -= sidebarWidth;
|
width -= sidebarWidth;
|
||||||
}
|
}
|
||||||
|
@ -3164,7 +3164,7 @@ var ViewableAreaObserver = {
|
||||||
|
|
||||||
get height() {
|
get height() {
|
||||||
let height = (this._height || window.innerHeight);
|
let height = (this._height || window.innerHeight);
|
||||||
if (Elements.urlbarState.getAttribute("tablet"))
|
if (Util.isTablet())
|
||||||
height -= BrowserUI.toolbarH;
|
height -= BrowserUI.toolbarH;
|
||||||
return height;
|
return height;
|
||||||
},
|
},
|
||||||
|
|
Загрузка…
Ссылка в новой задаче