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.

Preliminary support for videos in ImageTweak

Today I finally had a couple of hours available to work on ImageTweak and I decided to start by adding some new feature (way more interesting than fixing bugs!). The result is that now ImageTweak can work its magic (this word is severely abused lately) on videos as well. Mind you, only for native video (i.e. those supported by the HTML5 <video> element) and not for plugin videos (flash-based as well).

ImageTweak preliminary support for video

ImageTweak preliminary support for video

Right now it’s nowhere near an usable state because the user controls where thought for images and obviously video has different needs. I’ll need to try to figure this out well before pushing a beta. The good news is that most of the functionalities work out of the box just by adding a couple of abstractions. For example, zooming and rotations work already, and so does resizing.

Preliminary support for videos in ImageTweak

Zoom and rotation work already

Now a new problem arises… since it won’t work on just images anymore, should I change the name ImageTweak? If yes, how should I call it?

Drag&drop not really working properly in ImageTweak

When I released ImageTweak 0.19 I wrote in the changelog that the main change was the support for proper image drag&drop.

It actually works correctly but this change had the side effect of changing the normal mouse pointer used by ImageTweak to indicate that you’re moving an image around the window. I noticed this before releasing the update, but it seemed like a minor annoyance worth the additional functionality. I actually tried to fix it but found no way, and since there were a lot of people writing negative reviews on AMO for the lack of drag&drop support I decided to release it without fixing it.

Fast forward some weeks, and it turns out that actually the new behaviour is quite confusing and many are complaining about the mouse pointer showing the “forbidden” shape while moving the image. Fewer than they were complaining before about the lack of drag&drop, but still…

So I set out to find a solution for this problem but apparently there’s no way to freely control the mouse pointer shape during a drap&drop operation. The only thing that comes closer is setting the mozCursor property of the DOMDataTransfer interface to “default”, but that works only on win32 and simply switch the cursor from “forbidden” to the default arrow.

I’m therefore pretty much stuck in a fix: I have to fix this problem but I have no idea of how. If you know how to do this, or know somebody that might help me in fixing this, please let me know.

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

ImageTweak 0.19: proper drag&drop

A few months and a complete change of location (I’m in Helsinki right now!) later, ImageTweak is going to reach version 0.19.

I had to scrape all the work I already did for 0.19 because I hit a few roadblocks, and so I had to start over with a minor but longstanding bug: proper drag&drop support. What it means is that you won’t have to hold CTRL anymore when performing drag&drop. The price is that I had to drop support for firefox 2.x and 3.0.x.

I just added it on AMO. As soon as it gets reviewed it will be available for download.

p.s. I also enabled donations on AMO, so if you feel like it please support the development of ImageTweak.

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.