!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 42 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/toolkit/content/viewZoomOverlay.js"
2
3 /** Document Zoom Management Code
4 *
5 * To use this, you'll need to have a getBrowser() function.
6 **/
7
8 var ZoomManager = {
ZoomManager_get__prefBranch
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
9 get _prefBranch ZoomManager_get__prefBranch() {
10 delete this._prefBranch;
11 return this._prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
12 .getService(Components.interfaces.nsIPrefBranch);
13 },
14
ZoomManager_get_MIN
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
15 get MIN ZoomManager_get_MIN() {
16 delete this.MIN;
17 return this.MIN = this._prefBranch.getIntPref("zoom.minPercent") / 100;
18 },
19
ZoomManager_get_MAX
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
20 get MAX ZoomManager_get_MAX() {
21 delete this.MAX;
22 return this.MAX = this._prefBranch.getIntPref("zoom.maxPercent") / 100;
23 },
24
ZoomManager_get_useFullZoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
25 get useFullZoom ZoomManager_get_useFullZoom() {
26 return this._prefBranch.getBoolPref("browser.zoom.full");
27 },
28
ZoomManager_set_useFullZoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
29 set useFullZoom ZoomManager_set_useFullZoom(aVal) {
30 this._prefBranch.setBoolPref("browser.zoom.full", aVal);
31 return aVal;
32 },
33
ZoomManager_get_zoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
34 get zoom ZoomManager_get_zoom() {
35 var markupDocumentViewer = getBrowser().markupDocumentViewer;
36
37 return this.useFullZoom ? markupDocumentViewer.fullZoom
38 : markupDocumentViewer.textZoom;
39 },
40
ZoomManager_set_zoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
41 set zoom ZoomManager_set_zoom(aVal) {
42 if (aVal < this.MIN || aVal > this.MAX)
43 throw Components.results.NS_ERROR_INVALID_ARG;
44
45 var markupDocumentViewer = getBrowser().markupDocumentViewer;
46
47 if (this.useFullZoom) {
48 markupDocumentViewer.textZoom = 1;
49 markupDocumentViewer.fullZoom = aVal;
50 } else {
51 markupDocumentViewer.textZoom = aVal;
52 markupDocumentViewer.fullZoom = 1;
53 }
54
55 return aVal;
56 },
57
ZoomManager_get_zoomValues
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
58 get zoomValues ZoomManager_get_zoomValues() {
59 var zoomValues = this._prefBranch.getCharPref("toolkit.zoomManager.zoomValues")
60 .split(",").map(parseFloat);
61 zoomValues.sort();
62
63 while (zoomValues[0] < this.MIN)
64 zoomValues.shift();
65
66 while (zoomValues[zoomValues.length - 1] > this.MAX)
67 zoomValues.pop();
68
69 delete this.zoomValues;
70 return this.zoomValues = zoomValues;
71 },
72
ZoomManager_enlarge
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
73 enlarge: function ZoomManager_enlarge() {
74 var i = this.zoomValues.indexOf(this.snap(this.zoom)) + 1;
75 if (i < this.zoomValues.length)
76 this.zoom = this.zoomValues[i];
77 },
78
ZoomManager_reduce
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
79 reduce: function ZoomManager_reduce() {
80 var i = this.zoomValues.indexOf(this.snap(this.zoom)) - 1;
81 if (i >= 0)
82 this.zoom = this.zoomValues[i];
83 },
84
ZoomManager_reset
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
85 reset: function ZoomManager_reset() {
86 this.zoom = 1;
87 },
88
ZoomManager_toggleZoom
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
89 toggleZoom: function ZoomManager_toggleZoom() {
90 var zoomLevel = this.zoom;
91
92 this.useFullZoom = !this.useFullZoom;
93 this.zoom = zoomLevel;
94 },
95
ZoomManager_snap
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
96 snap: function ZoomManager_snap(aVal) {
97 var values = this.zoomValues;
98 for (var i = 0; i < values.length; i++) {
99 if (values[i] >= aVal) {
100 if (i > 0 && aVal - values[i - 1] < values[i] - aVal)
101 i--;
102 return values[i];
103 }
104 }
105 return values[i - 1];
106 }
107 }