Bug 1044066 - Browser API for zoom-in/zoom-out. r=fabrice.

This commit is contained in:
Shih-Chiang Chien 2014-07-26 21:57:37 +08:00
parent fb041fea04
commit f5097f162b
2 changed files with 16 additions and 0 deletions

View File

@ -231,6 +231,7 @@ BrowserElementChild.prototype = {
"go-forward": this._recvGoForward,
"reload": this._recvReload,
"stop": this._recvStop,
"zoom": this._recvZoom,
"unblock-modal-prompt": this._recvStopWaiting,
"fire-ctx-callback": this._recvFireCtxCallback,
"owner-visibility-change": this._recvOwnerVisibilityChange,
@ -1031,6 +1032,10 @@ BrowserElementChild.prototype = {
webNav.stop(webNav.STOP_NETWORK);
},
_recvZoom: function(data) {
docShell.contentViewer.fullZoom = data.json.zoom;
},
_recvSetInputMethodActive: function(data) {
let msgData = { id: data.json.id };
if (!this._isContentWindowCreated) {

View File

@ -126,6 +126,7 @@ function BrowserElementParent(frameLoader, hasRemoteFrame, isPendingFrame) {
defineNoReturnMethod('goForward', this._goForward);
defineNoReturnMethod('reload', this._reload);
defineNoReturnMethod('stop', this._stop);
defineNoReturnMethod('zoom', this._zoom);
defineMethod('download', this._download);
defineDOMRequestMethod('purgeHistory', 'purge-history');
defineMethod('getScreenshot', this._getScreenshot);
@ -591,6 +592,16 @@ BrowserElementParent.prototype = {
this._sendAsyncMsg('stop');
},
/*
* The valid range of zoom scale is defined in preference "zoom.maxPercent" and "zoom.minPercent".
*/
_zoom: function(zoom) {
zoom *= 100;
zoom = Math.min(getIntPref("zoom.maxPercent", 300), zoom);
zoom = Math.max(getIntPref("zoom.minPercent", 50), zoom);
this._sendAsyncMsg('zoom', {zoom: zoom / 100.0});
},
_download: function(_url, _options) {
let ioService =
Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);