зеркало из https://github.com/mozilla/gecko-dev.git
Bug 663023 - Cache getDPI calls. r=mbrubeck
This commit is contained in:
Родитель
9efa89af2a
Коммит
145c0b17cf
|
@ -162,7 +162,7 @@ let Util = {
|
|||
},
|
||||
|
||||
isTablet: function isTablet() {
|
||||
let dpi = Util.getWindowUtils(window).displayDPI;
|
||||
let dpi = this.displayDPI;
|
||||
if (dpi <= 96)
|
||||
return (window.innerWidth > 1024);
|
||||
|
||||
|
@ -188,6 +188,11 @@ let Util = {
|
|||
return ViewableAreaObserver.isKeyboardOpened;
|
||||
|
||||
return (sendSyncMessage("Content:IsKeyboardOpened", {}))[0];
|
||||
},
|
||||
|
||||
get displayDPI() {
|
||||
delete this.displayDPI;
|
||||
return this.displayDPI = this.getWindowUtils(window).displayDPI;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ var BrowserUI = {
|
|||
return true;
|
||||
case -1: {
|
||||
let threshold = Services.prefs.getIntPref("widget.ime.android.fullscreen_threshold");
|
||||
let dpi = Util.getWindowUtils(window).displayDPI;
|
||||
let dpi = Util.displayDPI;
|
||||
return (window.innerHeight * 100 < threshold * dpi);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1112,7 +1112,7 @@ var Browser = {
|
|||
if (prefValue > 0)
|
||||
return prefValue / 100;
|
||||
|
||||
let dpi = this.windowUtils.displayDPI;
|
||||
let dpi = Util.displayDPI;
|
||||
if (dpi < 200) // Includes desktop displays, and LDPI and MDPI Android devices
|
||||
return 1;
|
||||
else if (dpi < 300) // Includes Nokia N900, and HDPI Android devices
|
||||
|
@ -1809,7 +1809,7 @@ const ContentTouchHandler = {
|
|||
panningPrevented: false,
|
||||
|
||||
updateCanCancel: function(aX, aY) {
|
||||
let dpi = Browser.windowUtils.displayDPI;
|
||||
let dpi = Util.displayDPI;
|
||||
|
||||
const kSafetyX = Services.prefs.getIntPref("dom.w3c_touch_events.safetyX") / 240 * dpi;
|
||||
const kSafetyY = Services.prefs.getIntPref("dom.w3c_touch_events.safetyY") / 240 * dpi;
|
||||
|
|
|
@ -68,7 +68,10 @@ const ElementTouchHelper = {
|
|||
|
||||
/* Retrieve the closest element to a point by looking at borders position */
|
||||
getClosest: function getClosest(aWindowUtils, aX, aY) {
|
||||
let dpiRatio = aWindowUtils.displayDPI / kReferenceDpi;
|
||||
if (!this.dpiRatio)
|
||||
this.dpiRatio = aWindowUtils.displayDPI / kReferenceDpi;
|
||||
|
||||
let dpiRatio = this.dpiRatio;
|
||||
|
||||
let target = aWindowUtils.elementFromPoint(aX, aY,
|
||||
true, /* ignore root scroll frame*/
|
||||
|
|
|
@ -118,7 +118,7 @@ function MouseModule() {
|
|||
this._mouseOverTimeout = new Util.Timeout(this._doMouseOver.bind(this));
|
||||
this._longClickTimeout = new Util.Timeout(this._doLongClick.bind(this));
|
||||
|
||||
this._doubleClickRadius = Util.getWindowUtils(window).displayDPI * kDoubleClickRadius;
|
||||
this._doubleClickRadius = Util.displayDPI * kDoubleClickRadius;
|
||||
|
||||
window.addEventListener("mousedown", this, true);
|
||||
window.addEventListener("mouseup", this, true);
|
||||
|
@ -570,7 +570,7 @@ MouseModule.prototype = {
|
|||
var ScrollUtils = {
|
||||
// threshold in pixels for sensing a tap as opposed to a pan
|
||||
get tapRadius() {
|
||||
let dpi = Util.getWindowUtils(window).displayDPI;
|
||||
let dpi = Util.displayDPI;
|
||||
|
||||
delete this.tapRadius;
|
||||
return this.tapRadius = Services.prefs.getIntPref("ui.dragThresholdX") / 240 * dpi;
|
||||
|
@ -686,7 +686,7 @@ var ScrollUtils = {
|
|||
*/
|
||||
function DragData() {
|
||||
this._domUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
|
||||
this._lockRevertThreshold = Util.getWindowUtils(window).displayDPI * kAxisLockRevertThreshold;
|
||||
this._lockRevertThreshold = Util.displayDPI * kAxisLockRevertThreshold;
|
||||
this.reset();
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче