My first real WebKit patch

October 13, 2009

That previous post on unforking was in part setting the stage for this: For me, I didn't work much on WebKit before we went public and have continued mostly working on the other half of the browser, the parts that don't really touch WebKit. But I've been meaning to get more involved because I like the project; more exposure to code reviews from a different set of smart engineers with a different background is sure to be a good learning experience. So the past couple of weeks I've been doing a couple of WebKit patches -- mostly trivial stuff like adding tests or fixing Chrome-specific bugs.

But recently I (with a huge amount of help from Darin Adler) landed my first "real" change: it improves WebKit (albeit in a minor way) on all platforms, and is of particular importance to people who use WebKit from European locales where LC_NUMERIC screws up printf.

For background: when you stringify a float in CSS, as in

var x = document.getElementById('foobar').opacity;

the CSS spec requires it to output as '.' ; no exponential notation allowed, and '.' must be the decimal separator even if in your language you use ',', like in German and Polish. (This is in part necessary if you then want to copy x's value back in to a CSS propery elsewhere.) WebKit got both of those wrong. The fix was to manually stringify floats from CSS, but it took me a ton of work to figure out the right place and way to do that without breaking tests or performance.

And, as anticipated, I learned a bunch from reading the WebKit code and from Darin's careful review. I especially appreciate even more the value of their test-first and test-heavy culture.