Archive for April, 2009

A brief history of XPConnect

April 23rd, 2009 | Category: Uncategorized

XPConnect has been around since the beginning of Gecko. However, at the beginning, it was only the bridge between JavaScript chrome code (chrome code is the code running in the browser itself, as opposed to content, web page code). In those early days, XPConnect-using JavaScript code looked a lot different. Because XPConnect didn’t know about nsIClassInfo properties had to be addressed through their interfaces. So instead of saying docShell.QueryInterface(Ci.nsIWebNavigation).canGoBack one might say docShell.nsIWebNavigation.canGoBack. Obviously, this wouldn’t work for web pages, so there had to be another solution.

That other solution was midl.exe. This was a Windows-only program that generated gobs and gobs of C++ glue to connect DOM-facing objects to JavaScript from the IDL. The generated stub code was put in dom/src/* and weighed in at over a megabyte. Because midl only ran on Windows, every time a developer wanted to change an IDL file, he would have to find a developer who ran on Windows to generate new stubs for the affected interfaces before proceeding.

In 2001, John Bandhauer (jband) and Johnny Stenback (jst) started working to teach XPConnect about nsIClassInfo and to replace the midl generated code by simply calling functions through xptcall. This resulted in a significant codesize reduction and allowed people to change idl files, even if they didn’t run Windows. Furthermore, in order to support some of the weirder aspects of the DOM (such as setting window.location changing the currently shown page) the nsIXPCScriptable interface was fleshed out, allowing any C++ code to interact nicely with JavaScript code, instead of just the DOM code. For example, the storage code in Gecko now provides a nice enumeration API for JS to use for-in loops to iterate over query results. Without the magic of nsIXPCScriptable, JS would be forced to use uglier function calls.

Comments are off for this post

Hello from the bowels of Gecko

April 03rd, 2009 | Category: Uncategorized

Hello and welcome to another blog about the deep innards of Gecko. I’m Blake (known to many as mrbkap, pronounced Mr. Bee Kap) and I’ve been down here for about three years now. I’m look forward to joining the blogging ranks and all of the fame and fortune that obviously follows.

What do I mean by bowels, exactly? When I started contributing to Mozilla (not yet FIrefox!), I started hacking on the HTML parser and in particular, fixing view source to property display the HTML source code of web pages. Now, I mostly leave that code alone and work on the JavaScript Engine and the bridge between JavaScript and C++. My work in these areas has led me to work on security bugs, in particular XSS and privilege escalation bugs. At times, I also like to jump in and fix the hot new security bugs, though I prefer doing so before they’re made public.

My work on XPConnect has given me an association with wrappers, which is a topic that I hope to expand on in this very blog. Being extremely new to blogging, I don’t know what to expect from this, but jumping feet first into the cloud the way I am makes me want to put on my rain jacket. Although, this being the internet, I suppose I’d really want my flame jacket.

3 comments