1. search mxr for "Text Size"
Results:
2. search for textSizePlus.label
/minimo/chrome/locale/en-US/minimo.dtd,
* line 30 -- <!--ENTITY textSizePlus.label "Text Size +"-->
* line 31 -- <!--ENTITY textSizeMinus.label "Text Size -"-->
3. open up the minimo.xul to see if I can find a function
/minimo/chrome/content/minimo.xul,
* line 329 -- label="&textSizePlus.label;"
Side Question: What is minimo? it looks important, like it defines the main menu for firefox browser.
Minimo is the windows mobile browser... DOH, Im sure Dave told us about that in class too
Ok Restart
1. search mxr for "Text Size"
Results:
/browser/locales/en-US/chrome/browser/browser.dtd,2. search for textSize.label
* line 292 -- <!--ENTITY textSize.label "Text Size"-->
Results:
/browser/base/content/browser-menubar.inc,3. open the source and look for a function
* line 174 -- <menu id="viewTextZoomMenu" label="&textSize.label;" accesskey="&textSize.accesskey;" observes="isImage">
</menu>
Results:
174 <menu id="viewTextZoomMenu" label="&textSize.label;" accesskey="&textSize.accesskey;" observes="isImage">4. command="cmd_textZoomEnlarge" ??? look for that
175 <menupopup>
176 <menuitem key="key_textZoomEnlarge" label="&textZoomEnlargeCmd.label;" accesskey="&textZoomEnlargeCmd.accesskey;" 177="" command="cmd_textZoomEnlarge">
178 <menuitem key="key_textZoomReduce" label="&textZoomReduceCmd.label;" accesskey="&textZoomReduceCmd.accesskey;" 179="" command="cmd_textZoomReduce">
180 <menuseparator>
181 <menuitem key="key_textZoomReset" label="&textZoomResetCmd.label;" accesskey="&textZoomResetCmd.accesskey;" 182="" command="cmd_textZoomReset">
183 </menuitem>
184
</menuseparator></menuitem></menuitem></menupopup>
Results:
/browser/base/content/browser-sets.inc,5. TextZoom looks like a class, lets do an Identifier Search
* line 105 -- <command id="cmd_textZoomEnlarge" oncommand="TextZoom.enlarge()">
</command>
73 __zoomManager: null,So basically when a textZoomEnlargeCmd.label or a textZoomEnlargeCmd.accesskey occurs the TextZoom.enlarge function is ran... this in turn asks the ZoomManager to run things for it. What is the ZoomManager (obviously a singleton), What does it do?
74 get _zoomManager() {
75 if (!this.__zoomManager)
76 this.__zoomManager = ZoomManager.prototype.getInstance();
77 return this.__zoomManager;
78 },
236 enlarge: function TextZoom_enlarge() {
237 this._zoomManager.enlarge();
238 this._applySettingToPref();
239 },
6. Search for ZoomManager
Constructor
49 function ZoomManager() {enlarge method
50 this.bundle = document.getElementById("bundle_viewZoom");
51
52 // factorAnchor starts on factorOther
53 this.factorOther = parseInt(this.bundle.getString("valueOther"));
54 this.factorAnchor = this.factorOther;
55 }
102 enlarge : function() {jump method
103 this.jump(1);
104 },
153 jump : function(aDirection) {Well this is where the code is... ZoomManager.jump. The browser is defined in the browser-menubar.inc, which is an include file for the browser.xul . Browser.xul is the user interface definition for the firefox browser.
154 if (aDirection != -1 && aDirection != 1)
155 throw Components.results.NS_ERROR_INVALID_ARG;
156
157 this.ensureZoomFactors();
158
159 var currentZoom = this.textZoom;
160 var insertIndex = -1;
161 var stepFactor = parseFloat(this.bundle.getString("stepFactor"));
162
163 // temporarily add factorOther to list
164 if (this.isZoomInRange(this.factorOther)) {
165 insertIndex = 0;
166 while (this.zoomFactors[insertIndex] < this.factorOther)
167 ++insertIndex;
168
169 if (this.zoomFactors[insertIndex] != this.factorOther)
170 this.zoomFactors.splice(insertIndex, 0, this.factorOther);
171 }
172
173 var factor;
174 var done = false;
175
176 if (this.isZoomInRange(currentZoom)) {
177 var index = this.indexOf(currentZoom);
178 if (aDirection == -1 && index == 0 ||
179 aDirection == 1 && index == this.zoomFactors.length - 1) {
180 this.steps = 0;
181 this.factorAnchor = this.zoomFactors[index];
182 } else {
183 factor = this.zoomFactors[index + aDirection];
184 done = true;
185 }
186 }
187
188 if (!done) {
189 this.steps += aDirection;
190 factor = this.factorAnchor * Math.pow(stepFactor, this.steps);
191 if (factor < this.MIN || factor > this.MAX) {
192 this.steps -= aDirection;
193 factor = this.factorAnchor * Math.pow(stepFactor, this.steps);
194 }
195 factor = Math.round(factor);
196 if (this.isZoomInRange(factor))
197 factor = this.snap(factor);
198 else
199 this.factorOther = factor;
200 }
201
202 if (insertIndex != -1)
203 this.zoomFactors.splice(insertIndex, 1);
204
205 this.textZoom = factor;
206 },
No comments:
Post a Comment