November 19, 2009

WebKit nightlies support HTML5 noreferrer link relation

Surfin’ Safari

WebKit nightlies now support the HTML5 noreferrer link relation, a neat little feature that allows web developers to prevent browsers from sending the Referrer: header when navigating either <a> or <area> elements.  Just add noreferrer in the rel attribute of a link like so:

<a href="www.example.com" rel="noreferrer">noreferrer!</a>

When example.com receives the HTTP request generated by clicking this link, the HTTP Referer field will be empty, as if the user had navigated from about:blank.

When rel=”noreferrer” is used in conjunction with target=”_blank”, WebKit will also set the window.opener attribute to null.  This usage is interpreted as a request from the web page author that any scripts on the destination page should be run in a new context, even if the destination page would normally be considered to be of the same origin.

The noreferrer link relation is one of many link relations defined in the HTML5 spec, and the first to be implemented in WebKit.  We hope it will make life a little easier for web developers who have concerns about user privacy and security.

By Nate Chapin at November 19, 2009 05:18 PM

November 18, 2009

Updated WebKit SDK (@r51062)

Brent Fulgham

I have updated the WebKitSDK to correspond to SVN revision r51062.
Edit: I stupidly wrote "-webkit-block-shadow", when I meant "-webkit-box-shadow". Thanks to Brad K. for catching this!
Major changes in this revision:
* Support for -webkit-box-shadow.
* General support for Canvas and SVG shadows in Cairo.
* New SVG filter effects: feComposite, feDisplacementMap, feGaussianBlur, feMorphology
* Many SVG rendering improvements, including support for SourceAlpha.
* Support for CSS in Text Kerning and ligature.
* Ability to specify the number of visible lines in -webkit-line-clamp.
* Implement DOM Level 3 composition events.
* Implement CSSOM Range.getClientRects/getBoundingClientRect.
* @import now works in user stylesheets.
* Protect Canvas methods from NaN and Infinity.
* Web Inspector improvements (see this blog entry for details), but many cool new features!
* Some support for -webkit-color-correction (needs further testing on this platform).
* JavaScript engine speed-ups.
* Initial <ruby> support (see this blog entry for details)
* Accessibility improvements.

Clearly this is a significant amount of new logic, so there may be some regressions. Please let me know if you encounter any problems with this new version.

Unfortunately I have not been able to complete work on 3D CSS or WebGL, but stay tuned!

By Brent (bfulgham@gmail.com) at November 18, 2009 09:11 AM

November 16, 2009

WebKit-Box-Shadows At Last!

Brent Fulgham


With the landing of Bug 26102, all Cairo ports of WebKit can now enjoy full webkit-box-shadow support. Even the multi-line wrapped bordered text show shadows, and the geometric primitives in the "border-radius-big.html" test work.

It took a long time, but the results are definitely worth it!

By Brent (bfulgham@gmail.com) at November 16, 2009 01:10 PM

November 15, 2009

WebKit's week - #10

Anthony Ricaud

Week from May 25 to June 7 (before r44490). To test those changes, you'll need a WebKit nightly.

Smarter border-radius (44235)

You all know border-radius. And you enjoy using it. Before this change, if the radius was longer than some metrics (eg. half the width of the element), then it's set to zero and there are no rounded corners. Since then, WebKit follow the latest rules of the spec and will reduce the radius to the max possible value.

Multiple corrections according to specs (44293, 44298, 44301, 44302, 44360, 44475, 44481)

A lot of events weren't dispatched to the window object, unlike what the spec says. Zou, fixed. In addition, some storage events needed a storageArea event giving access to the modified storage area. Those are small but necessary fixes.

Locking the anchor in view while loading

Between the moment when a page starts to render and when it's fully loaded, a lot of resources can modify the layout of a page. Therefore, the position of an anchor can change. Before this change, the browser stayed at the initial position of the anchor. Now, if the user doesn't scroll, the anchor will stay in the view.

Web Inspector's panel activation

The Resources, Network and Profiles panels all have an activation page. This activation page are here to not affect the performances of the pages when they are not needed.


This is everything for this week. Of course, this is just a selection I've made. If you've noticed any other interesting changes, please let me know. Same thing if I got something wrong.

By Anthony Ricaud at November 15, 2009 10:37 PM

Functioning Box-Shadow

Brent Fulgham


It's taken a couple of weeks to get everything put together and landed in the archive, but tonight I finally got webkit-box-shadow functioning in the Cairo build.

This original work was done by Dirk Schulze, who put together most of the shadow logic. There were a few dark corners that had to be examined and resolved before the feature worked properly.

The main problem boiled down to a very simple coding error:


===================================================================
--- GraphicsContextCairo.cpp (revision 50998)
+++ GraphicsContextCairo.cpp (working copy)
@@ -1113,7 +1155,7 @@
cairo_t* cr = m_data->cr;
double x1, y1, x2, y2;
cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
- cairo_rectangle(cr, x1, x2, x2 - x1, y2 - y1);
+ cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
cairo_rectangle(cr, r.x(), r.y(), r.width(), r.height());
cairo_fill_rule_t savedFillRule = cairo_get_fill_rule(cr);
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);


The clipping rectangle was being computed with the right-hand x-position of the current clipping bounds, rather than the y-position per the signature. This was causing the wrong regions of the screen to be clipped out, yielding bizarrely inverted shadow effects (see my last post for an example.)

The final results look pretty good. They generally match the reference implementation (Safari), at least as closely as WinCairo does in other respects (e.g., fonts), as shown in the following overlay:


Once this patch lands, both the Linux and Windows builds of WebKit (Cairo) should begin enjoying most of the cool features provided by webkit-box-shadow. There are still several missing bits of functionality:


Shadows on various geometries don't seem to work (see the "border-radius-big.html" test).



Multi-line shadow effects (see the first series in "basic-shadows.html".)


Strangely, this effect works properly when the shadow is inset in the image.

By Brent (bfulgham@gmail.com) at November 15, 2009 10:31 PM

November 13, 2009

WebKit adds support for the HTML5 <ruby> element

Michael(tm) Smith

If you don’t know what the HTML5 ruby element is, you might want to take a minute to first read the section about the ruby element in the HTML5 specification and/or the Wikipedia article on ruby characters. To quote from the HTML5 description of the ruby element:

The ruby element allows one or more spans of phrasing content to be marked with ruby annotations. Ruby annotations are short runs of text presented alongside base text, primarily used in East Asian typography as a guide for pronunciation or to include other annotations. In Japanese, this form of typography is also known as furigana.

I give a specific example further down, but for now I want to first say that the really great news about the ruby element is that last week Google Chrome developer Roland Steiner checked in a change (r50495, and see also related bug 28420) that adds ruby support to the trunk of the WebKit source repository, thus making the ruby feature available in WebKit nightlies and Chrome dev-channel releases.

A simple example

The following is a simple example of what you can do with the ruby element; make sure to view it in a recent nightly or dev-channel release. Note that the text is an excerpt from the source of a ruby-annotated online copy of the short story Run, Melos, Run by the writer Osamu Dazai, which I came across by way of Piro’s info page for his XHTML Ruby add-on for Firefox (and which I mention a bit more about further below).

きのうの豪雨で山の水源地は<ruby>氾濫<rp>(</rp>
<rt>はんらん</rt><rp>)</rp></ruby>し、濁流
<ruby>滔々<rp>(</rp><rt>とうとう</rt><rp>)</rp>
</ruby>と下流に 集り、猛勢一挙に橋を破壊し、どうどうと
響きをあげる激流が、<ruby>木葉微塵<rp>(</rp>
<rt>こっぱみじん</rt><rp>)</rp></ruby>に<ruby>橋桁
<rp>(</rp><rt>はしげた</rt><rp>)</rp></ruby>
を跳ね飛ばしていた。

If you don’t happen to have Japanese fonts installed, here’s a screenshot of the source for reference:

ruby source markup

Notice that the actual annotative ruby text (which I’ve highlighted in yellow in the source just for the sake of emphasis) is marked up using the rt element as a child of the ruby element, and the text being annotated is the node that’s a previous sibling to that rt content as a child of the ruby element. The final new element in the mix is the rp element, which is simply a way to mark up the annotative ruby text with parenthesis, for graceful fallback in browsers that don’t support ruby.

So here’s the rendered view of that same text:

見よ、前方の川を。きのうの豪雨で山の水源地は氾濫(はんらん)し、濁流滔々(とうとう)と下流に集り、猛勢一挙に橋を破壊し、どうどうと響きをあげる激流が、木葉微塵(こっぱみじん)に橋桁(はしげた)を跳ね飛ばしていた。

And here is a screenshot of how it should look in a recent nightly or dev-channel release:

ruby rendered view

Notice that the annotative ruby text is displayed above the ruby base it annotates. If you instead view this page in a browser that doesn’t support the ruby feature, you’ll see that the ruby text is just shown inline, in parenthesis following the ruby base it annotates. So the feature falls back gracefully in older browsers.

If you’re not accustomed to reading printed books and magazines and such in Japanese, you may be feeling underwhelmed by the example above. But for authors and developers and content providers in Japan who want to finally be able to use on the Web this very common feature of Japanese page layout from the print world, getting ruby support into WebKit is a huge win, and something to be very excited about.

Support in other browsers

Current versions of Microsoft Internet Explorer also have native support for ruby, and you can also get ruby support in Firefox by installing Piro’s XHTML Ruby add-on (and for more details, see his XHTML ruby add-on info page) — so we are well on the way to seeing the HTML5 ruby feature supported across a range of browsers.

By Michael(tm)Smith (mike@w3.org) at November 13, 2009 02:36 AM

November 11, 2009

Kenneth Rohde Christiansen is now a WebKit reviewer!

Surfin’ Safari

Kenneth has been participating in WebKit development since late 2008, when he started the initial EFL port. Since early 2009 he has contributed a great deal on all fronts of the Qt port, including WebCore integration and API. He has also played an important role in making sure the GTK+ and Qt ports work together wherever possible.

Please join me in congratulating Kenneth on his reviewer status!

By Gustavo Noronha at November 11, 2009 05:59 PM

Compiling WebKitGTK+ on Scratchbox for ARM platform

University of Szeged

If we would like to build WebKitGTK+ for ARM platform, Scratchbox could be a good choice. In this post I will show, how we can install and setup Scratchbox to build WebKitGTK+. First, we have to install the Scratchbox and its ARM target. Next, we install some libraries to WebKitGTK+.
Let's see how we can do that.

read more

By gabor.rapcsanyi at November 11, 2009 02:25 PM

November 09, 2009

About Dynamic UI, Web-Apps, Performance, and State-Machines

Trolltech Labs

Lately I’ve been working on a couple of exciting customer projects, involving HTML5-based UIs on embedded (TV) platforms. Due to the fabulous work some of my colleagues put into QtWebkit and QtDirectFB, and the ongoing work from MIPS Technologies on their Webkit JIT, the paint performance is very good, and Javascript is getting faster and faster.
However, while working on these projects, I’ve ran into a few issues that were not solvable by JIT-accelerated JavaScript or by hardware accelerated painting.

The main problem was that when you write a dynamic UI for a full application, the complexity starts to be difficult to manage. I started by dividing the app to a few HTML pages, but that of course created unacceptable delays when switching between the pages. So I looked online for dynamic web-app solutions. Those include the amazing Javascript libraries Dojo and JQuery. The problem with those is that they manage the complexity by selecting elements with custom-built CSS-like selectors (which are slow) and by modifying the HTML DOM tree in runtime (which is slower).

An alternate way to handle HTML performance is with the HTML5 canvas element (which is nicely accelerated) - the problem is that canvas API is currently too low level, and the widget libraries on top of it are not mature yet, definitely not in time for my customer projects.

So I asked myself: what components are really needed in order to make a dynamic UI?
Looking at the Qt Kinetic project, I need 4 main elements:

  • Animations
  • State Machine
  • Graphic effects
  • Declarative Syntax

Now HTML and CSS are already a declarative syntax, and CSS3 (supported in webkit) contains all the animations and graphic effects I currently need. The missing element, which is also my personal favorite, is the State Machine.

Why do I keep going on and on about state-machines?
If you think about it, both CSS, HTML, and Qt widgets are optimized to handle complexity in space. State machines, however, are optimized to handle complexity in time. An application can be dynamic only if it’s rich both in space and in time. That’s why to me state-machines are of outmost importance for dynamic UIs.

Enough philosophy, what’s this about?
Now I’ve had the pleasure to work with the SCXML standard in the last year, both by prototyping the Qt-SCXML library (which later helped with the evolution of the Qt State Machine Framework), and by joining the w3c group that defines the SCXML standard.
While working on my latest HTML-based project, I was thinking - what if I could define the flow of my web-app with an SCXML statechart? Wouldn’t that allow for managing the complexity of my web app, without incurring the performance overhead of modifying and re-modifying the DOM?

Introducing Statechartz
So I took the time to write an SCXML library for Javascript. I basically had to copy the SCXML algorithm to Javascript syntax, which took a while, but has already saved me hours of work by having the code of my web-apps cleaner and smaller.
The result can be found at the statechartz branch on the SCXML lab GIT repo., and the demo can be viewed online. Note that the library is currently only tested on webkit-based browsers (QtWebkit/Arora, Safari, Chrome), but porting it to other browsers shouldn’t be too difficult.

Looking a bit at the HTML code of the demo, you’ll notice the following:

<link rel="statechart" href="flow.scxml" />

This is the line that connects an HTML page with an SCXML statechart, defining the page’s flow. The state-machine would start running as soon as the page is loaded.
But hey! rel=”statechart” isn’t standard!

Well, I was surprised to learn that HTML5 allows you to add your own link types, which become legal if you register them in the WHATWG Wiki, which I did; so now <link rel=”statechart” href=”somefile.scxml” /> is completely standard :)
Though using the link tag would cover most cases, it’s completely optional and the Statechartz library can be used more dynamically, either by loading an SCXML file whenever wanted:

var myStateMachine = Statechartz.loadScxml(someURL);

or by using a dynamic javascript syntax that looks like this:

var myStateMachine;
with (Statechartz) {
  myStateMachine = build(
    State("root",
        Entry(function() { doSomething(); }),
        Parallel("s1",Initial,
             Exit(function()(doSomethingElse(); }),
             Transition(Event("EVENT.QUIT"), Target("exit"))
        ),
        Final("exit")
    )
  );
}

Another thing to look at, is the DOM:

<div id="screen_weather" class="screen">
      <script type="text/javascript" src="..."></script>
</div>
<div id="screen_shopping" class="screen">
    <iframe src="..." height="240" width="320" scrolling="no" style="overflow:hidden" frameborderwidth="0"></iframe>
</div>
<div id="screen_calc" class="screen">...</div>

Even though screen_weather, screen_shopping and screen_calc exist in the DOM to begin with, only one of them is shown at a time. Also, there’s no particular Javascript code that shows and hides them. That’s done by a trick I added to the Statechartz library: the CSS class of the document BODY element changes when the state changes. So, if I’m in a state with ID “calc”, the body would have a CSS class “state_calc”, and now all it takes is adding this to the CSS (it’s a little different in the actual CSS, but I’m trying to make a point):

#screen_calc {
  left: -350px;
  -webkit-transition-duration: 600ms;
  opacity: 0.5;
}
.state_calc #screen_calc {
  left: 0px;
  -webkit-transform: rotate(360deg) scale(1);
  opacity: 1;
}

This code, like states and transitions in Qt 4.6, would animate the opacity and geometry of my calculator screen, and would create an animated transition when the calculator is entered to / exited from.

The Demo, and performance
The

demo that comes with the statechartz library demonstrates 3 uses of the Statechartz library:
  • Dynamic UIs with states and transitions (switching between the 3 widgets)
  • Managing UI complexity (e.g. the instructions popup)
  • Business logic (the calculator ‘engine’)

Note that the demo specifically is too animation-heavy to run well on embedded platforms, and of course webkit could use some more optimizations. but the concepts (don’t mess with the DOM, use Statecharts to manage time) are the same, and are working on other webkit-based projects with a cvery nice performance gain.

The next step on the SCXML path
After this project, SCXML is now supported in 3 implementations: Qt C++ (with scc), QtScript (with QScxml), and web (with Statechartz). The next natural step is a statechart graphical tool (Creator plugin) that can help author SCXML files for all of those 3 implementations. Though it’s not on our roadmap, some of us (including the undersigned) were working on prototypes, and any help from the community would be appreciated!

Links
The code: http://qt.gitorious.org/qt-labs/scxml/trees/statechartz
The live demo (webkit browsers only): http://labs.trolltech.com/blogs/wp-content/uploads/2009/11/demo.html
Video capture of the live demo: http://labs.trolltech.com/blogs/wp-content/uploads/2009/11/statechartz-capture_0001.wmv

By No'am Rosenthal at November 09, 2009 04:21 AM