Last week in WebKit:
simplifying everything
Last week, everyone became crazy about refactoring. Some have taken “spring cleaning” very literally and many patches landed to make WebKit simpler and cleaner.
A nice change ties to the way Objective-C objects are adopted by RetainPtr. Previously, there were 3 ways to adopt a pointer:
RetainPtr<id> foo = adoptNS([...]);
RetainPtr<id> bar(AdoptNS, [...]);
RetainPtr<id> baz;
baz.adoptNS([...]);
Darin Adler and Anders Carlsson wrote a few patches to unify all the code behind the adoptNS([…]) syntax. Some bugs were also discovered and fixed on the way.
Another great refactoring by Darin and Anders was switching from manual management of memory to smart pointers when possible. In particular, they hunted the use of deleteAllValues() on various data structure and updated their storage to use WTF’s OwnPtr. The new code is easier to reason about, and it becomes hard to accidentally leak memory on those structures.
There were also some nice cleaning of headers to rationalize where everything is defined in WTF.
New behaviors:
As usual, there were a lot of bug fixes. Some visible changes:
- Zalan Bujtas has to remove the performance.now() API he had just enabled last week :(. Some websites use that function to do feature detection of Navigation Timing API. The JavaScript code in the wild will force WebKit to enable everything at once.
- A nice fix by Enrica Casucci is recomputing the style dynamically when the system style parameters are updated.
- Christophe Dumez removed [NoInterfaceObject] on many interface definitions, making the interface objects visible on the Window object as defined by the specifications.
- Dongseong Hwang fixed the definition of a few canvas context functions. Previously, scale(), rotate(), translate(), transform(), setTransform(), createLinearGradient() and createRadialGradient() were incorrectly defined with optional arguments.
Talking about canvas, I spent a little time improving fillStyle and strokeStyle on Canvas2D’s context. A pattern I have seen is code recreating a CanvasPattern or CanvasGradient with every frame. For example:
function draw() { // Bad idea: don't do that for every frame. var gradient = context.createRadialGradient(...); gradient.addColorStop(...); context.strokeStyle = gradient; context.lineTo(...) }
When the Gradient/Pattern is constant from frame to frame, it’s much better to initialize the objects at the beginning and reuse them with every frame. Unfortunately, many tutorials fall into the trap of trashing the objects.
Engine engineering
- Simon Fraser is fixing every compositing bug he can find.
- Andreas Kling created a way to close web processes faster when their last page is closed, making the UI process more responsive.
- Christophe Dumez fixed the coding style of the generated code, improved testing of the exposed constructor objects, added support for NoInterfaceObject and removed support for TransferList from the binding generator.
- Anders Carlsson did not sleep. In addition to all the cleaning and bug fixes he did, he finished and enabled the UI Process Storage feature of WebKit2. With this, the various Web Storage API’s have a consistent state between multiple Web processes.
The WebKitten of the week is Anders Carlsson for making this blog difficult with over 50 patches. Half of them refactoring and cleaning the code, the other half adding features to WebKit2.
Things to look forward to:
- Michael Saboff started a Thumb2 disassembler for the ARM tooling of JavaScriptCore. This is awesome work and I cannot wait to try that.
- Sergio Villar Senin made a fix to CSS Variables, bringing hope that someone is interested in developing that feature 🙂