My first Firefox contribution

When I started ImageTweak a few years ago, the decision of building an extensions was mostly due to the fact that the Firefox codebase looked, frankly, quite scaring. Even only attempting to compile Firefox on Windows looked like an impossible endeavor, let alone building a modified version.

Compared to this, writing an extensions looked like a piece of cake (looking back, this was a rather naïve evaluation, but that’s another story…).

Fast forward a few years: ImageTweak has gotten pretty mature, so the question pops up again. Wouldn’t it be better to tackle the source of all problems (pun intended) and bring at least a subset of ImageTweak to all Firefox users? And so, on a fine spring day, while working on my MSc thesis, I finally found the courage to make a real attempt at producing a patch that would at least bring feature parity with ImageTweak 0.9, i.e. centering stand-alone images on a dark background.

After a few rounds of patches, I finally managed to produce a working patch that had a single, HUGE, issue. It produced an awful lot of failed tests in the regression tests. If you add to this that, by the time the working patch was ready, I was on the eve of my dissertation (that would be followed by a fair amount of AFK holidays and by a close-to-immediate hiring for a consultancy firm) the amount of time I could devote to Mozilla-related tasks dropped rather quickly to nil.

Luckily, my (clumsy) attempt at a patch had the effect of setting the proverbial ball rolling: somebody (Jared Wein) over at BMO picked up where I left off and fixed all regression tests. And, just like that, a couple of weeks ago, I received a notification about the fact that my patch had been pushed to mozilla-central and that it will be part of Firefox 11. Proudness ensued.

Obviously, as with any other user-facing change, this is prone to (hopefully constructive) discussion. And that’s good, I guess, because those are yet more proverbially rolling balls.

update: Unlike Daniel Glazman, Jared Wein seems to like it: Blinded by the light! – An improved image viewing experience in Firefox

FancyText – or emulating text-rendering:geometricPrecision in Firefox 4

I just wrote FancyText, a tiny addon for Firefox 4 that emulates the text-rendering:geometricPrecision CSS directive.

It’s a bit of an hack because it does its thing by asking Firefox to rotate all pages by a fraction of degree. This rotation is not really visible but it’s enough to make Firefox stop using the hinting of the font, therefore yielding antialiased text with no hinting (i.e. geometricPrecision).

It’s worth noting that this method can be used also in normal webpages, because all it takes is adding -moz-transform:rotate(0.000575deg); where you would normally apply text-rendering:geometricPrecision;

If you’re on Firefox 4 on windows, you can see the effect of this method (and of FancyText) in this example. In each pair of lines, the top one is the normal Firefox rendering whereas the bottom one is as it appears with FancyText.

The quick brown fox jumps over the lazy dog 0123456789

The quick brown fox jumps over the lazy dog 0123456789

The quick brown fox jumps over the lazy dog 0123456789

The quick brown fox jumps over the lazy dog 0123456789

The quick brown fox jumps over the lazy dog 0123456789

The quick brown fox jumps over the lazy dog 0123456789

Bear in mind that this likely increase the CPU and GPU loads and that I tested it only on computers running Windows 7 with hardware acceleration enabled.

FancyText is available on AMO.

ImageTweak development moved to GitHub

I finally resolved to move the trunk code of ImageTweak to GitHub. Up to now I never used any VCS for ImageTweak because I felt it was kind of overkill. Unfortunately, this is no longer true because – apart from the coaasional trivial fixes – all new features will likely require extensive rewrites and testing.

In the repository linked above you will always find the latest source of ImageTweak (modulo local changes not yet pushed to GitHub) with the added bonus that, by leveraging the GitHub infrastructure, you can fork ImageTweak with a single click, make changes to the source and send me pull requests to have them included in the official tree.

Google cruft

Am I the only one in the world wondering the hell why can’t Google merge Analytics, Webmaster Tools, Adwords and maybe even AdSense in a single, centralized control panel?
In this way they could possibly also improve the display of the data (the usage data reported by Analytics, Webmaster Tools and Adwords are all different – for good reasons, I know – yet comparing them on three different websites is a pain in the butt!) greatly simplifying the life of users in the process… Sure, we don’t pay for the service (as far as cold hard cash is concerned, but we pay in countless other ways) but still…

Netbook browsing tips for Firefox

Having recently bought a netbook (MSI U123) I had to readjust my browsing habits since normally I work on a 24″ Dell 2407WFP with a resolution of 1920×1200, whereas the MSI has a meager 10.1″ at 1024×600.

As a result I had to tweak my browser of choice to be able to work nicely on such a small screen. Fortunately enough, Firefox allows you to tailor almost exactly as you want, and to reclaim much of the needed vertical screen space.

So, let’s get started. Continue reading

HTML5 Web Sockets API reloaded

One of the most exciting upcoming features of HTML5 is the ability to open persistent bidirectional sockets to a remote host.

As far as I know, one of the early proposals was about allowing web applications almost complete control over sockets, including the ability to create raw sockets and to listen for incoming connections exactly like a typical network daemon/server, but this proposal was later scraped because of security implications.

Fast forward to today and the Web Sockets API, even if still under development, are starting to get a stable shape and they will probably be implemented soon by the most forward-looking browser vendors.

The problem is, though, that the original proposal got crampled along the way and therefore there won’t be any means to create peer-to-peer connections between users, something that could enable all kinds of cool distributed systems.

That is, unless someone does something: what I’m thinking about right now is a kind of wrapper/extension around the Web Sockets API that does simply a few things:

  1. allows a web application to register for incoming connections
  2. opens up the required ports on the firewall/NAT
  3. when a connection arrives, perform the handshaking required by the ws:// protocol and forwards a WebSocket object representing the connection to the application

Talking IDL, that would mean (the WebSocket interface is the current WHATWG proposal, while WebSocketListener is my addition):

[Constructor(in DOMString url, optional in DOMString protocol)]
interface WebSocket {
  readonly attribute DOMString URL;

  // ready state
  const unsigned short CONNECTING = 0;
  const unsigned short OPEN = 1;
  const unsigned short CLOSED = 2;
  readonly attribute unsigned short readyState;
  readonly attribute unsigned long bufferedAmount;

  // networking
           attribute Function onopen;
           attribute Function onmessage;
           attribute Function onclose;
  boolean send(in DOMString data);
  void close();

[Constructor(optional in short port, optional in DOMString protocol)]
interface WebSocketListener {
  readonly attribute short port;

  // ready state
  const unsigned short OPENING = 0;
  const unsigned short LISTENING = 1;
  const unsigned short CLOSED = 2;
  readonly attribute unsigned short readyState;

  // networking
           attribute Function onconnection;
  void close();

Talking about the Mozilla platform, points 1 and 3 are straightforward (once the Web Sockets API has been implemented), whereas point 2 will be platform-dependent and, therefore, trickier. Nevertheless, I think that all of this can be handled (with some work) by a Firefox extension.

Once Firefox will gain Web Sockets support I’ll definitely try to see if it is possible to add it.

Open letter to the European Parlament about the amendment 46 (ex-138) to the Telecom Package

Prompted by La Quadrature du Net, this is the letter I just sent to all Italian MEPs seating in the ITRE – you can find their mail addresses here. If you want to do the same, remember that the vote is expected to start today at 20:00 CET.


mi chiamo Carlo Alberto Ferraris e sono uno studente di ingegneria delle Telecomunicazioni presso il Politecnico di Torino.

Le scrivo per attirare la Sua attenzione sull’emendamento 46 (ex-138) del “Telecom package” in discussione in questo periodo presso il Parlamento Europeo.

Come certamente saprà, Internet è nata con il preciso scopo di favorire e permettere gli scambi di conoscenza, conoscenza che è alla base stessa della pacifica e civile convivenza dell’intera società umana come sottolineato sin dai preamboli della Costituzione Europea1 e negli articoli 12, 19, 26 e 27 della Dichiarazione Universale dei Diritti dell’Uomo.

Quanto in discussione in questo momento presso il Parlamento Europeo ha, a mio avviso, le potenzialità per minare gravemente alcune libertà che la stessa Unione Europea dichiara proprie. Per questo motivo, in primis come persona, come giovane e come italiano, spero voterà questo emendamento in piena coscienza e senza voler scendere a compromessi con essa.

La ringrazio per l’attenzione dedicatami, e porgo cordiali saluti.

Carlo Alberto Ferraris

1 “CONVINTI che l’Europa, ormai riunificata dopo esperienze dolorose, intende avanzare sulla via della civiltà, del progresso e della prosperità per il bene di tutti i suoi abitanti, compresi i più deboli e bisognosi; che vuole restare un continente aperto alla cultura, al sapere e al progresso sociale; che desidera approfondire il carattere democratico e trasparente della vita pubblica e operare a favore della pace, della giustizia e della solidarietà nel mondo;”

Update: it looks like it worked.