Bug 1546075 - Fork viewZoomOverlay.js to common/ to fix zooming bug. r=darktrojan DONTBUILD
This commit is contained in:
Родитель
87b2271696
Коммит
5ed7fbb063
|
@ -40,7 +40,7 @@
|
||||||
<script src="chrome://messenger/content/mailCore.js"/>
|
<script src="chrome://messenger/content/mailCore.js"/>
|
||||||
#endif
|
#endif
|
||||||
<script src="chrome://messenger/content/viewSource.js"/>
|
<script src="chrome://messenger/content/viewSource.js"/>
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
<script src="chrome://global/content/contentAreaUtils.js"/>
|
<script src="chrome://global/content/contentAreaUtils.js"/>
|
||||||
<script src="chrome://global/content/editMenuOverlay.js"/>
|
<script src="chrome://global/content/editMenuOverlay.js"/>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
|
||||||
|
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
/* globals getBrowser */
|
||||||
|
|
||||||
|
/** Document Zoom Management Code
|
||||||
|
*
|
||||||
|
* Forked from M-C since we don't provide a global gBrowser variable.
|
||||||
|
**/
|
||||||
|
|
||||||
|
var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
var ZoomManager = {
|
||||||
|
get MIN() {
|
||||||
|
delete this.MIN;
|
||||||
|
return this.MIN = Services.prefs.getIntPref("zoom.minPercent") / 100;
|
||||||
|
},
|
||||||
|
|
||||||
|
get MAX() {
|
||||||
|
delete this.MAX;
|
||||||
|
return this.MAX = Services.prefs.getIntPref("zoom.maxPercent") / 100;
|
||||||
|
},
|
||||||
|
|
||||||
|
get useFullZoom() {
|
||||||
|
return Services.prefs.getBoolPref("browser.zoom.full");
|
||||||
|
},
|
||||||
|
|
||||||
|
set useFullZoom(aVal) {
|
||||||
|
Services.prefs.setBoolPref("browser.zoom.full", aVal);
|
||||||
|
return aVal;
|
||||||
|
},
|
||||||
|
|
||||||
|
get zoom() {
|
||||||
|
return this.getZoomForBrowser(getBrowser());
|
||||||
|
},
|
||||||
|
|
||||||
|
getZoomForBrowser(aBrowser) {
|
||||||
|
let zoom = (this.useFullZoom || aBrowser.isSyntheticDocument)
|
||||||
|
? aBrowser.fullZoom : aBrowser.textZoom;
|
||||||
|
// Round to remove any floating-point error.
|
||||||
|
return Number(zoom ? zoom.toFixed(2) : 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
set zoom(aVal) {
|
||||||
|
this.setZoomForBrowser(getBrowser(), aVal);
|
||||||
|
return aVal;
|
||||||
|
},
|
||||||
|
|
||||||
|
setZoomForBrowser(aBrowser, aVal) {
|
||||||
|
if (aVal < this.MIN || aVal > this.MAX)
|
||||||
|
throw Cr.NS_ERROR_INVALID_ARG;
|
||||||
|
|
||||||
|
if (this.useFullZoom || aBrowser.isSyntheticDocument) {
|
||||||
|
aBrowser.textZoom = 1;
|
||||||
|
aBrowser.fullZoom = aVal;
|
||||||
|
} else {
|
||||||
|
aBrowser.textZoom = aVal;
|
||||||
|
aBrowser.fullZoom = 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
get zoomValues() {
|
||||||
|
var zoomValues = Services.prefs.getCharPref("toolkit.zoomManager.zoomValues")
|
||||||
|
.split(",").map(parseFloat);
|
||||||
|
zoomValues.sort((a, b) => a - b);
|
||||||
|
|
||||||
|
while (zoomValues[0] < this.MIN)
|
||||||
|
zoomValues.shift();
|
||||||
|
|
||||||
|
while (zoomValues[zoomValues.length - 1] > this.MAX)
|
||||||
|
zoomValues.pop();
|
||||||
|
|
||||||
|
delete this.zoomValues;
|
||||||
|
return this.zoomValues = zoomValues;
|
||||||
|
},
|
||||||
|
|
||||||
|
enlarge() {
|
||||||
|
var i = this.zoomValues.indexOf(this.snap(this.zoom)) + 1;
|
||||||
|
if (i < this.zoomValues.length)
|
||||||
|
this.zoom = this.zoomValues[i];
|
||||||
|
},
|
||||||
|
|
||||||
|
reduce() {
|
||||||
|
var i = this.zoomValues.indexOf(this.snap(this.zoom)) - 1;
|
||||||
|
if (i >= 0)
|
||||||
|
this.zoom = this.zoomValues[i];
|
||||||
|
},
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.zoom = 1;
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleZoom() {
|
||||||
|
var zoomLevel = this.zoom;
|
||||||
|
|
||||||
|
this.useFullZoom = !this.useFullZoom;
|
||||||
|
this.zoom = zoomLevel;
|
||||||
|
},
|
||||||
|
|
||||||
|
snap(aVal) {
|
||||||
|
var values = this.zoomValues;
|
||||||
|
for (var i = 0; i < values.length; i++) {
|
||||||
|
if (values[i] >= aVal) {
|
||||||
|
if (i > 0 && aVal - values[i - 1] < values[i] - aVal)
|
||||||
|
i--;
|
||||||
|
return values[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values[i - 1];
|
||||||
|
},
|
||||||
|
};
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||||
<window id="window" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
|
<window id="window" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
<script><![CDATA[
|
<script><![CDATA[
|
||||||
function getBrowser() {
|
function getBrowser() {
|
||||||
return document.getElementById('browser');
|
return document.getElementById('browser');
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
<script src="chrome://messenger/content/mail-offline.js"/>
|
<script src="chrome://messenger/content/mail-offline.js"/>
|
||||||
<script src="chrome://global/content/printUtils.js"/>
|
<script src="chrome://global/content/printUtils.js"/>
|
||||||
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
||||||
<script src="chrome://messenger/content/mailCore.js"/>
|
<script src="chrome://messenger/content/mailCore.js"/>
|
||||||
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
<script src="chrome://messenger/content/mail-offline.js"/>
|
<script src="chrome://messenger/content/mail-offline.js"/>
|
||||||
<script src="chrome://global/content/printUtils.js"/>
|
<script src="chrome://global/content/printUtils.js"/>
|
||||||
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
||||||
<script src="chrome://messenger/content/mailCore.js"/>
|
<script src="chrome://messenger/content/mailCore.js"/>
|
||||||
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
||||||
|
|
|
@ -142,7 +142,7 @@
|
||||||
<script src="chrome://messenger/content/mail-offline.js"/>
|
<script src="chrome://messenger/content/mail-offline.js"/>
|
||||||
<script src="chrome://global/content/printUtils.js"/>
|
<script src="chrome://global/content/printUtils.js"/>
|
||||||
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
<script src="chrome://messenger/content/msgViewPickerOverlay.js"/>
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
<script src="chrome://communicator/content/utilityOverlay.js"/>
|
||||||
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
<script src="chrome://messenger/content/quickFilterBar.js"/>
|
||||||
<script src="chrome://messenger/content/newmailaccount/uriListener.js"/>
|
<script src="chrome://messenger/content/newmailaccount/uriListener.js"/>
|
||||||
|
|
|
@ -34,6 +34,7 @@ messenger.jar:
|
||||||
* content/messenger/customizeToolbar.xul (../../common/src/customizeToolbar.xul)
|
* content/messenger/customizeToolbar.xul (../../common/src/customizeToolbar.xul)
|
||||||
content/messenger/viewSource.js (../../common/src/viewSource.js)
|
content/messenger/viewSource.js (../../common/src/viewSource.js)
|
||||||
* content/messenger/viewSource.xul (../../common/src/viewSource.xul)
|
* content/messenger/viewSource.xul (../../common/src/viewSource.xul)
|
||||||
|
content/messenger/viewZoomOverlay.js (../../common/src/viewZoomOverlay.js)
|
||||||
content/messenger/generalBindings.xml (../../common/bindings/generalBindings.xml)
|
content/messenger/generalBindings.xml (../../common/bindings/generalBindings.xml)
|
||||||
content/messenger/generalBindings.js (../../common/bindings/generalBindings.js)
|
content/messenger/generalBindings.js (../../common/bindings/generalBindings.js)
|
||||||
content/messenger/menubutton.xml (../../common/bindings/menubutton.xml)
|
content/messenger/menubutton.xml (../../common/bindings/menubutton.xml)
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
|
<script src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
|
||||||
<script src="chrome://global/content/globalOverlay.js"/>
|
<script src="chrome://global/content/globalOverlay.js"/>
|
||||||
<script src="chrome://global/content/contentAreaUtils.js"/>
|
<script src="chrome://global/content/contentAreaUtils.js"/>
|
||||||
<script src="chrome://global/content/viewZoomOverlay.js"/>
|
<script src="chrome://messenger/content/viewZoomOverlay.js"/>
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
<script src="chrome://global/content/macWindowMenu.js"/>
|
<script src="chrome://global/content/macWindowMenu.js"/>
|
||||||
#endif
|
#endif
|
||||||
|
|
Загрузка…
Ссылка в новой задаче