My new opensource project: Flying Saucer, an all Java XHTML renderer.

I normally try to be even handed, un-biased, and bi-partisan; but today I'm going to shamelessly use my muchly vaunted position as a highly skilled blogologist in field of to plug my new project: Flying Saucer, an all Java XHTML + CSS renderer.

When I was doing research for my two part series on HTML renderers for Swing (pts 1 & 2) I got to thinking Why are there so few renderers, and almost none that are opensource? Is it really that hard?. Initially I tried to fix some of the bugs in the HTMLEditorKit that comes with Swing, but found a slew of private methods that prevented me from improving it through subclassing. I also tried editing the Swing code itself during a four hour cross country flight, but to no avail. And even if I had made the changes I couldn't have released them with the current Swing license. With so little to go on I struck out on my own. I mean, really, how hard could it be? :)

Two months of hacking an hour here and there I found out how hard. It was both easier and harder than I expected.. To make life easier on me I decided to leave out everything that didn't directly have to do with rendering HTML on the screen. I dropped the idea of making a complete browser with a UI, javascript, debugging, bookmarks, history, etc. Those are all important but not the hard part. Since CSS and XML parsing are already provided by other libraries I reused them instead of reinventing the wheel. It's not that I dislike wheel inventing, it just that I have to be realistic about what one programmer can do in his spare time.

With that out of the way it was still too big. The core renderer of Mozilla took years to develop and the full time work of several top notch programmers. Gotta cut it down. Thinking about it, though, I don't need a complete webbrowser like IE or Mozilla. Since this is for embedding in my own programs most of the content will be generated by my own code. I don't need to deal with every browser bug and every malformed webpage out there. I could get by with strictly compliant pages and worry about quirks handling in a compatibility library. (to be built later, of course. :)

Now, if I'm going to write a new renderer from scratch I should go for the gold, ie: complete XHTML + CSS 2.0 (now 2.1). It's actually not as hard as I thought. The W3C makes some completely exhaustive specifications. The CSS 2 spec in particular is huge, but it does describe in great and explicit detail how each feature should behave (giving Internet Explorer no excuse for it's bugs).

So what do we have. I've written a renderer that takes a org.w3c.dom.Document object with inline styles and renders it into a scrollable JPanel. Most of plain HTML is supported, as are the full box model, tables, and images. Parts of relative, absolute, and fixed positioning work. The main issue is the bugs in float/clear, and the lack of forms support. Oh yeah, and it's really, really, really slow (Need some help with that. I used regexs for the text parsing). But it works and the supported features are pretty compliant.

I was actually surprised at how much I've done by myself. Still, I know the limits of one programmer, which is why I'm launching it as an open source project right here on And I need your help!

This is a challenging project that needs some top-notch people. If you feel you are up to it then sign on to the project and join the dev mailing list. In particular I want to start breaking it up into modules and find owners for each:

  • Rendering compliance (research the latest standards, build it, test it)

  • CSS (parsing, converting, optimizing, rendering new features)

  • HTML->XHTML converter (support for HTML 3/4.0 pages)

  • Browser component (a standalone webbrowser based on Flying Saucer)

  • Javascript support (how do we plug in rhino?)

  • I18N efforts (how do we make sure the whole thing is i18n-able)

  • forms (input, select, text area, etc)

  • object and plugin support (SVG, xforms, flash, pdf)

  • printing module (we can't print anything yet!)

  • network module (ssl, redirects, image loading, etc.)

  • performance and memory optimization (how do we make the whole thing as fast and light as possible)
  • I really think that a complete XHTML renderer is a vital component of any modern programming toolkit, and I'd like to see Flying Saucer become the best of breed implementation for Java. It's a lot of work but it's going to be rewarding. Come on in. The water's fine!

    Oh, to just play with it quickly check the source out of cvs or download this zipfile. You only need Ant and the 1.4 JDK. Run ant test to launch the test program. Select different tests from the Test menu.

    Update: I forgot some links. the project is here and the mailing list is here.

    Talk to me about it on Twitter

    Posted June 18th, 2004