Sunday, September 30, 2007

View->Text Size->Increase (cmd+)

On my mbp, I increase the size of my font via the shortcut key (cmd+... applekey with plus key). How is this feature implemented?

1. search mxr for "Text Size"


* line 30 -- <!--ENTITY textSizePlus.label "Text Size +"-->
* line 31 -- <!--ENTITY textSizeMinus.label "Text Size -"-->
2. search for textSizePlus.label


* line 329 -- label="&textSizePlus.label;"
3. open up the minimo.xul to see if I can find a function
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"

* line 292 -- <!--ENTITY textSize.label "Text Size"-->
2. search for textSize.label

* line 174 -- <menu id="viewTextZoomMenu" label="&textSize.label;" accesskey="&textSize.accesskey;" observes="isImage">
3. open the source and look for a function
174                 <menu id="viewTextZoomMenu" label="&textSize.label;" accesskey="&textSize.accesskey;" observes="isImage">
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>
4. command="cmd_textZoomEnlarge" ??? look for that

* line 105 -- <command id="cmd_textZoomEnlarge" oncommand="TextZoom.enlarge()">
5. TextZoom looks like a class, lets do an Identifier Search
 73   __zoomManager: null,
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 },
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?

6. Search for ZoomManager
  49 function ZoomManager() {
50 this.bundle = document.getElementById("bundle_viewZoom");
52 // factorAnchor starts on factorOther
53 this.factorOther = parseInt(this.bundle.getString("valueOther"));
54 this.factorAnchor = this.factorOther;
55 }
enlarge method
 102   enlarge : function() {
103 this.jump(1);
104 },
jump method
 153   jump : function(aDirection) {
154 if (aDirection != -1 && aDirection != 1)
155 throw Components.results.NS_ERROR_INVALID_ARG;
157 this.ensureZoomFactors();
159 var currentZoom = this.textZoom;
160 var insertIndex = -1;
161 var stepFactor = parseFloat(this.bundle.getString("stepFactor"));
163 // temporarily add factorOther to list
164 if (this.isZoomInRange(this.factorOther)) {
165 insertIndex = 0;
166 while (this.zoomFactors[insertIndex] < this.factorOther)
167 ++insertIndex;
169 if (this.zoomFactors[insertIndex] != this.factorOther)
170 this.zoomFactors.splice(insertIndex, 0, this.factorOther);
171 }
173 var factor;
174 var done = false;
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 }
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 }
202 if (insertIndex != -1)
203 this.zoomFactors.splice(insertIndex, 1);
205 this.textZoom = factor;
206 },
Well this is where the code is... ZoomManager.jump. The browser is defined in the, which is an include file for the browser.xul . Browser.xul is the user interface definition for the firefox browser.

Bug 364713 - Project

I have accepted the Mozilla bug relating to Non-styled fonts not displaying bold and italic, (364713). I want to have my first patch ready for Oct 19 2007.

Friday, September 21, 2007

Setting up Debugging with xCode

I followed this manual and everything worked as it should.

Some notes:
I ran with a debug build, I was able to set a breakpoint in a cfile in the GFX library and the execution stopped at the set-breakpoint just as it should.

I've set up some scripts to make it easy to run optimized builds and debug builds.

Tuesday, September 18, 2007

My experiences with "Shark"

Stuart suggested I learn a bit about "Shark" an optimizing tool for OSX.  Here are my experiences.  I followed along with this tutorial: Optimizing Noble Ape with Shark


Needed to reinstall (with my osx disk 1) Xcode.  Clicked the option to install CHUD

Compile - Pre Analysis

Need to compile the NobleApe Application... load up the project file and "build & Run"
Neat little program I guess, I left it running.


I opened shark, and clicked "Start" and let it do its thing

You do this "Run Program, run Shark Analysis" a few times with the tutorial explaining how the code of a certain function would change.


Shark helps you determine what parts of your code take the longest to run

Backend GFX debugging for Mozilla

So I have signed up to the Backend GFX debugging project for Mozilla as a team lead.  I think this project will really introduce me to the Mozilla source code.  I will do my best to help get this GFX system "out the door" by shipdate.

Monday, September 17, 2007

nled Makefile : PLEASE COPY MY WORK

Hi All... I tried to be REALLY REALLY generic.  Im looking for others to help me out with Windows and/or Linux/AIX porting

To run type
make -f

Here are my Makefiles
ALLOBJ=qkdisp.o nledshwr.o nledmisc.o nledit.o nledisp.o nledio.o nledata.o nled.o

# 1) in nled.h remove the lines which define the target system
# 2) in qkdisp.c remove the lines which define the target system
# 3) around the function beep(int n) in nledio.c wrap the entire function in a
# #if MACOSX == 0 ... #endif

all: nled cleanobj

compile: nled


$(DEL) nled

clean: cleanobj cleanexe

nled: $(ALLOBJ)
$(CC) $(ALLOBJ) $(LIBS) $(LDFLAGS) $(TOOBJ) nled

qkdisp.$(OBJ): qkdisp.c nledkeys.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) qkdisp.c $(TOOBJ) qkdisp.$(OBJ)

nledshwr.$(OBJ): nledshwr.c nled.h nledvdef.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledshwr.c $(TOOBJ) nledshwr.$(OBJ)

nledmisc.$(OBJ): nledmisc.c nled.h nledkeys.h nledvdef.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledmisc.c $(TOOBJ) nledmisc.$(OBJ)

nledit.$(OBJ): nledit.c nled.h nledkeys.h nledvdef.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledit.c $(TOOBJ) nledit.$(OBJ)

nledisp.$(OBJ): nledisp.c nled.h nledkeys.h nledvdef.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledisp.c $(TOOBJ) nledisp.$(OBJ)

nledio.$(OBJ): nledio.c nled.h nledkeys.h nledvdef.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledio.c $(TOOBJ) nledio.$(OBJ)

nledata.$(OBJ): nledata.c nled.h nledkeys.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nledata.c $(TOOBJ) nledata.$(OBJ)

nled.$(OBJ): nled.c nled.h nledkeys.h nledfdef.h
$(CC) $(CFLAGS) $(DEFINES) $(NOLINK) nled.c $(TOOBJ) nled.$(OBJ)

Mozilla Trunk from CVS : firefox : Mac OS X

Here are my experiences building firefox from the mozilla trunk from CVS for Mac OS X.

From start to finish. I posted my findings in our wiki

Friday, September 14, 2007

RIM has offered me a JOB!!!!!

YEAH, I will be employed (so long as I sign the paper and graduate!)

Im very glad I got a job at RIM.  The financial compensation is far more than I expect (can't take it back now RIM!), I love the city of Ottawa, I enjoy being around my old co-workers, and working on those devices is KICK-ASS.  Not only these things, but we play lunchtime road hockey in the springtime!  So long as everything goes well this year at school, I'll be starting my employment on May 5, 2008 (2008-05-05).

Oh man, I can't wait for the winter of '08 when I can skate the Rideau again.

Serious Linux Based Employment

Key job responsibility
- Port Windows based games to Linux Platform

Valve makes the HalfLife games, and has some deep pockets.  It looks like they want to start getting into Linux.

Wednesday, September 12, 2007

Moz Compiling

I want to compile the firefox browser.  here are my experiences doing so

1) downloaded the source... easy enough to download
2) configured my mozilla/browser/config/mozconfig file... easy enough
3) export mozilla/browser/config/mozconfig... easy enough
4) make -f build... doh error, I need libIDL
  a) install Fink  ... easy enough (reload, re export)
  b) use apt-get to install libIDL ... easy enough
5) make again
6) watch compiling
7) 25-30 min later run the ... voila :)

The Eternal Question

How do I get paid?

As we dive into our last year at school, Its on my mind: how do I get paid?  Can Open Source/Free Software pay the bills?  Can I live as nicely as the Jones'? Do I deserve to live as nicely as the Jones'?

Its nice for academics and long haired hippies to expose how wonderful open source is towards society, but they shop at the A&P whether people pay developers for the software or not... they train people afterall, they do not feed their kids on emails saying "hey man, thanks for the cool browser."

I suppose I could live on welfare and charity, surf off my neighbours insecure 802.11, and code all day long, but I am greedy for more.

Open Source: What's in it for me?  I want things; and by things I do mean things. I want big TVs, a nice house, a dog, a super powerful washing machine, a kick ass computer, video games, and I want not to steal wifi (gadgets fill the void of being a fat nerd sitting on a computer in the basement and unable to score with girls, lol).  How can Open Source pay for those things?

Does anyone want to give me a job to do some code in Mozilla?  (like seriously, some cash would be nice right now)

Thoughts on Revolution OS

I thought this was going to be a poorly produced documentary, and I wasn't looking forward to watching this at all.  However after watching for the first 5 minutes I was engrossed.

I don't really have many thoughts on the movie other than I thought it was a nice history lesson.  I myself am a linux user (I used to be rabid and used it as my desktop and server, but now that I've found mac OSX...).  The movie could have used some controversy (perhaps talk about Hans Reiser) and Michael Moore would have done well to produce this flick.

Tuesday, September 11, 2007

Thoughts on Eric S. Raymonds piece "The Cathedral and the Bazaar"

I was about to simply read "The Cathedral and the Bazaar" and post my thoughts afterwards when I came to this quote, "Plan to throw one away; you will, anyhow." I think its a great line and had to immediately say that I totally agree.

I agree with points 2-6 in "The Mail Must Get Through" section, but I am somewhat iffy on point 1.  I think quite a few pieces of software started off to get someone rich (perhaps wealth is a personal itch?)

In section "The Importance of Having Users" I disagree with the idea of having users being the guinea pigs for debugging.  This seems to put the idea that 'the software organism' is what is important, and that perfecting it should be our pinnacle of success; I believe that user satisfaction should be the pinnacle of success.  Now having perfect software will make people happy, but if our non-hacker-but-still-users have had to put up with several iterations of buggy software , they will not be happy.  There is a place for beta-testing, however in house testing should be done thoroughly before software is released for serious products.

I only half believe the statement "release early. release often."  I think it should be "release carefully. then release often."  Release the software after through testing, but after this initial release phase the maintenance patches should be rapidly implemented and deployed.

I agree with his section about throwing away features.

I think the idea of "harnessing" communities more than solitary brains is cute, but not necessarily true.  Sometimes great ideas come from only one head.

The rest of the article is interesting and informative, but simply based on the authors desire to defend the Bazaar style.  The author then demonstrates the successful stories of the bazaar and seems to ignore the unsuccessful stories, or the bad sides to bazaar style development.

Friday, September 7, 2007

Start of Class - First Ideas

Yesterday (2007-09-06), we had our first DPS909 class.

We discussed what the purpose of the class was (introduce us to Open Source development methodologies).  I've got a few ideas about what project I want to do during this class.  Unfortunately my ideas seem a little bit big to me... comment if you think so (or not).

1) Mozilla Scriptability
- The ability to use the Mozilla browser statefully in a scripting language (such as perl). eg. Scripting language looks something like this (forgive me for using java... its easiest to psudocode in for me... the final product probably wont be a java thing, but a commandline thing for scripting langs like PERL PHP etc)

MozBrowser m = new MozBrowser();
m.setTextBox( "masmullin", 0 ); // put my username in box 1
m.setTextBox( "hahanicetry", 1 ); // put my pword in box 2
m.clickSubmit( 0 ); // click the submit button
String s = m.getHtmlAsString();

Now Gmail is actually an incredibly bad example now that I look at the page... because its AJAXy (view the source for gmail once you log in... you'll notice a lack of HTML code).  But the example is just to give you an idea.

2) Firefox logging
- An extension to log what a person does in firefox to give the ability to easily "record" steps taken during a browsing section.  
This idea is the "opposite" of my first idea, and is complementary to the scriptability idea.  They logging + scripting would allow a non-power user to automate tasks they regularly perform in firefox. eg.

A user regularly logs into their bank site to see their balance.  The user can switch on "logging" and perform the necessary tasks to get to the page which contains their balance.  The output can then be used the scripting idea (idea 1) to gather the text displayed on the balance page... pipe to a regular expression and bam, they can easily automate a little task to grab their bank balance.