Bespin, canvas, SVG, DOM and other thoughts

A person named "LaC" left a rather strong comment on Ben Galbraith's blog. Since Ben's original article partly explains why canvas was chosen for Bespin, let me give you my personal view of the thing...

Diavolo, my source view editor, uses the editor in Gecko. So I had to deal with DOM nodes. Colorizing a word needs an element. Placing the caret in the middle of an element and typing a char needs expensive DOM operations to split the node in two if the grammar says the parsing was modified by the char. And if you're unlucky and it affects drastically the parsing of the rest of the document, well, you're doomed... All in all, dealing with a DOM here is so expensive that the performance is still poor on large files. The original parsing/rendering of a large file is too long. Ok, it's much better than it used to be, and my first attempt at a JS-based source editor in 2001 ended up nowhere because of Gecko itself.

So dealing with canvas - part of the HTML 5 standard - with good performance because there's no need to act on a DOM instead of contenteditable - part of the HTML 5 standard - with poor performance because you must deal with a DOM seems to me a natural choice, and a good choice. A markup-based editor for source is a workable solution if you don't want to implement complex features like rich syntax highlight, auto-completion, folding, exceptions allowing to put an instance conforming to one grammar inside another instance conforming to a different grammar (think for instance CSS embedded in HTML) and so on.

Last but not least, last time I checked Mozilla Labs' name contained the word "Labs". In general, labs are here to make experiments, things that don't seem ordinary or even reasonable, labs are here to pave the future, not do what all others are doing too.


1. On Thursday 19 February 2009, 11:53 by me

When you ask for comments, you may receive criticism. In this case, the criticism was valid, not using insulting or foul language and not an ad-hominem attack. Quite a rarity on the internet, actually. I'm sure Ben can deal with that, as is evidenced by his reply.

(and no, I'm not 'LaC' whoever that may be).

2. On Thursday 19 February 2009, 12:40 by Riccardo Galli

I think too that the critic from LaC was a valid one. Listening from an employer of Mozilla that they didn't use SVG for fear of incompatibilities beetween browsers, while comprehensible it makes one think "why bother with SVG at all if Mozilla too doesn't trust it ?".
(I'm not saying not to use SVG here, I just want to say what impression I had reading the other article)

3. On Thursday 19 February 2009, 17:37 by Olly Hodgson

Riccardo - It's not just because they don't trust their own SVG implementation. It's because they don't trust *anybody's* SVG implementation. This work isn't just intended for Firefox, but rather for any modern browser that supports the standards they're targeting.

4. On Monday 2 March 2009, 13:08 by Tim

I have found a good guide on the issue by http://rapid4me.com/ - something like step-by-step instruction