<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web Platform Team Blog &#187; WebKit</title>
	<atom:link href="http://blogs.adobe.com/webplatform/tag/webkit/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.adobe.com/webplatform</link>
	<description>Making the web awesome</description>
	<lastBuildDate>Tue, 21 May 2013 06:02:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Freeing the Floats of the Future From the Tyranny of the Rectangle</title>
		<link>http://blogs.adobe.com/webplatform/2013/03/27/freeing-the-floats-of-the-future-from-the-tyranny-of-the-rectangle/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/03/27/freeing-the-floats-of-the-future-from-the-tyranny-of-the-rectangle/#comments</comments>
		<pubDate>Wed, 27 Mar 2013 17:10:41 +0000</pubDate>
		<dc:creator>Bem Jones-Bey</dc:creator>
				<category><![CDATA[Exclusions]]></category>
		<category><![CDATA[Web Platform Features]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[exclusions]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=3287</guid>
		<description><![CDATA[With modern web layout you can have your content laid out in whatever shape you want as long as it&#8217;s a rectangle. Designers in other media have long been able to have text and other content lay out inside and around arbitrarily complex shapes. The CSS Exclusions and Shapes specification aims to bring this capability...]]></description>
				<content:encoded><![CDATA[<p>With modern web layout you can have your content laid out in whatever shape you want as long as it&#8217;s a rectangle. Designers in other media have long been able to have text and other content lay out inside and around arbitrarily complex shapes. The <a href="http://dev.w3.org/csswg/css3-exclusions/">CSS Exclusions and Shapes specification</a> aims to bring this capability to the web.</p>
<p>While these features aren&#8217;t widely available yet, implementation is progressing and it&#8217;s already possible to try out some of the features yourself. Internet Explorer 10 has an implementation of the exclusions processing model, so you can try out <a href="http://msdn.microsoft.com/en-us/library/ie/hh673558(v=vs.85).aspx">exclusions in IE 10</a> today.</p>
<p>At Adobe we have been focusing on implementing the shapes portion of the specification. We began with an <a href="http://blogs.adobe.com/webplatform/2012/10/17/css-exclusions-now-available-under-flag-in-chrome-canary/">implementation of shape-inside</a> and now have a working implementation of the <a href="http://dev.w3.org/csswg/css3-exclusions/#shape-outside-property">shape-outside property</a> on floats. We have been building our implementation in WebKit, so the easiest way to try it out yourself is to <a href="https://www.google.com/intl/en/chrome/browser/canary.html">download a copy of Chrome Canary</a>. Once you have Canary, <a href="http://adobe.github.com/web-platform/samples/css-exclusions/index.html#browser-support">enable Experimental WebKit Features</a> and go wild!</p>
<h2>What is shape-outside?</h2>
<p>&#8220;Now hold up there,&#8221; you may be thinking, &#8220;I don&#8217;t even know what a <code>shape-outside</code> is and you want me to read this crazy incomprehensible specification thing to know what it is!?!&#8221;</p>
<p>Well you&#8217;ll be happy to know that it really isn&#8217;t that complex, especially in the case of floats. When an element is floated, inline content avoids the floated element. Content flows around the margin box of the element as defined by the <a href="http://www.w3.org/TR/CSS2/box.html">CSS box model</a>. The <code>shape-outside</code> CSS property allows you to tell the browser to use a specified shape instead of the margin box when wrapping content around the floating element.</p>
<p><center><img src="http://blogs.adobe.com/webplatform/files/2013/03/grid_cssexclusions.png" alt="CSS Exclusions" width="450" class="aligncenter size-medium wp-image-3361" /></center></p>
<p>The current implementation allows for rectangles, rounded rectangles, circles, ellipses, and polygons. While this gives a lot of flexibility, eventually you will be able to use a SVG path or the alpha channel of an image to make it easier to create complex shapes.</p>
<h2>How do I use it?</h2>
<p>First, you need to get a copy of <a href="https://www.google.com/intl/en/chrome/browser/canary.html">Chrome Canary</a> and then <a href="http://adobe.github.com/web-platform/samples/css-exclusions/index.html#browser-support">enable Experimental WebKit features</a>. Once you have that, load up this post in Chrome Canary so that you can click on the images below to see a live example of the code. Even better, the examples are on <a href="http://codepen.io/">Codepen</a>, so you can and should play with them yourself and see what interesting things you can come up with.</p>
<p>Note that in this post and the examples I use the unprefixed <code>shape-outside</code> property.<br />
If you want to test these examples outside of my <a href="http://codepen.io/">Codepen</a> then you will need to use the prefixed <code>-webkit-shape-outside</code> property or use <a href="http://leaverou.github.com/prefixfree/".Prefix Free</a> (which is a built in option in Codepen).</p>
<p>We&#8217;ll start with a <a href="http://codepen.io/adobe/pen/xjkyE">HTML document with some content and a float</a>. Currently <code>shape-outside</code> only works on floating elements, so those are the ones to concentrate on. For example: (click on the image to see the code)</p>
<p><center><a href="http://codepen.io/adobe/pen/xjkyE"><img class="aligncenter size-full wp-image-3290" alt="HTML without shape-outside" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-html-template1.png" /></a></center></p>
<p>You can now add the <code>shape-outside</code> property to the style for your floats.</p>
<pre class="brush: css; title: ; notranslate">
.float {
  shape-outside: circle(50%, 50%, 50%);
}
</pre>
<p>A circle is much more interesting than a standard rectangle, don&#8217;t you think? This circle is centered in the middle of the float and has a radius that is half the width of the float. The effect on the layout is something like this:</p>
<p><center><a href="http://codepen.io/adobe/pen/HEGna"><img class="aligncenter size-full wp-image-3295" alt="shape-outside circle" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-circle1.png"/></a></center></p>
<p>While percentages were used for this circle, you can use any CSS unit you like to specify the shape. All of the relative units are relative to the dimensions of element where the <code>shape-outside</code> is specified.</p>
<h3>Supported shapes</h3>
<p>Circles are cool and all, but I promised you other shapes, and I will deliver. There are four types of shapes that are supported by the current <code>shape-outside</code> implementation: rectangle, circle, ellipse, and polygon.</p>
<h4>rectangle</h4>
<p>You have the ability to specify a <code>shape-outside</code> that is a fairly standard rectangle:</p>
<pre class="brush: css; title: ; notranslate">
shape-outside: rectangle(x, y, width, height);
</pre>
<p>The <code>x</code> and <code>y</code> parameters specify the coordinates of the top-left corner of the rectangle. This coordinate is in relation to the top-left corner of the floating element&#8217;s content box. Because of the way this interacts with the rules of float positioning, setting these to anything other than 0 causes an effect that is similar to relatively positioning the float&#8217;s content. (Explaining this is beyond the scope of this post.)</p>
<p>The <code>width</code> and <code>height</code> parameters should be self-explanatory: they are the width and height of the resulting rectangle.</p>
<p>Where things get interesting is with the six-argument form of <code>rectangle</code>:</p>
<pre class="brush: css; title: ; notranslate">
shape-outside: rectangle(x, y, width, height, rx, ry);
</pre>
<p>The first four arguments are the same as explained above, but the last two specify corner radii in the horizontal (<code>rx</code>) and vertical (<code>ry</code>) directions. This not only allows the creation of rounded rectangles, you can create circles and ellipses as well. (Just like with [border-radius][border-radius].)</p>
<p>Here&#8217;s an <a href="http://codepen.io/adobe/pen/kuCGd">example of a rectangle, a rounded rectangle, a circle, and an ellipse using just rectangle syntax</a>:</p>
<p><center><a href="http://codepen.io/adobe/pen/kuCGd"><img class="aligncenter size-full wp-image-3296" alt="shape-outside rectangle" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-rectangle1.png"/></a></center></p>
<p>If you&#8217;re reading this in Chrome Canary with exclusions turned on, play around with this demo and see what other things you can do with the rectangles.</p>
<h4>circle</h4>
<p>I already showed you a <a href="http://codepen.io/adobe/pen/HEGna">simple circle demo</a> and you&#8217;ll be happy to know that&#8217;s pretty much all there is to know about circles:</p>
<pre class="brush: css; title: ; notranslate">
shape-outside: circle(cx, cy, radius);
</pre>
<p>The <code>cx</code> and <code>cy</code> parameters specify the coordinates of the center of the circle. In most situations you&#8217;ll want to put them at the center of your box. Just like with rectangles moving this around can be useful, but it behaves similarly to relatively positioning the float&#8217;s content with respect to the shape.</p>
<p>The <code>radius</code> parameter is the radius of the resulting circle.</p>
<p>In case you&#8217;d like to see it again, here&#8217;s what a circle looks like:</p>
<p><center><a href="http://codepen.io/adobe/pen/HEGna"><img class="aligncenter size-full wp-image-3295" alt="shape-outside circle" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-circle1.png" /></a></center></p>
<p>While it is possible to create circles with rounded rectangles as described above, having a dedicated circle shape is much more convenient.</p>
<h4>ellipse</h4>
<p>Sometimes, you need to squish your circles and that&#8217;s where the ellipse comes in handy.</p>
<pre class="brush: css; title: ; notranslate">
shape-outside: ellipse(cx, cy, rx, ry);
</pre>
<p>Just like a circle, an ellipse has <code>cx</code> and <code>cy</code> to specify the coordinates of its center and you will likely want to have them at the center of your float. And just like all the previous shapes, changing these around will cause the float&#8217;s content to position relative to your shape.</p>
<p>The <code>rx</code> and <code>ry</code> parameters will look familiar from the rounded rectangle case and they are exactly what you would expect: the horizontal and vertical radii of the ellipse.</p>
<p>Ellipses can be used to create circles (<code>rx</code> = <code>ry</code>) and rounded rectangles can be used to create ellipses, but it&#8217;s best to use the shape that directly suits your purpose. It&#8217;s much easier to read and maintain that way.</p>
<p>Here&#8217;s an <a href="http://codepen.io/adobe/pen/BGsEu">example of using an ellipse shape</a>:</p>
<p><center><a href="http://codepen.io/adobe/pen/BGsEu"><img class="aligncenter size-full wp-image-3297" alt="shape-outside ellipse" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-ellipse1.png" /></a></center></p>
<h4>polygon</h4>
<p>Now here&#8217;s where things get really interesting. The polygon `shape-outside` allows you to specify an arbitrary polygonal shape for your float:</p>
<pre class="brush: css; title: ; notranslate">
shape-outside: polygon(x1 y1, x2 y2, ... , xn yn);
</pre>
<p>The parameters of the polygon are the x and y coordinates of each vertex of the shape. You can have as many vertices as you would like.</p>
<p>Here&#8217;s an <a href="http://codepen.io/adobe/pen/ckvas">example of a simple polygon</a>:</p>
<p><center><a href="http://codepen.io/adobe/pen/ckvas"><img class="aligncenter size-full wp-image-3298" alt="shape-outside triangle" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-triangle1.png" /></a></center></p>
<p>Feel free to play with this and see what happens if you create more interesting shapes!</p>
<h3>Putting content in the float</h3>
<p>The previous examples all had divs without any content just to make it easier to read and understand the code, but a big motivation for <code>shape-outside</code> is to wrap around other content. Interesting layouts often involve wrapping text around images as this final example shows:</p>
<p><center><a href="http://codepen.io/adobe/pen/FnkvC"><img class="aligncenter size-full wp-image-3299" alt="shape-outside with images" src="http://blogs.adobe.com/webplatform/files/2013/03/shape-outside-with-images.png" width="619" height="529" /></a></center></p>
<p>As usual, you should take a look and play with the <a href="http://codepen.io/adobe/pen/FnkvC">code for this example of text wrapping around floated images</a>. This is just the beginning of the possibilities, as you can put a shape outside on any floating element with any content you want inside.</p>
<h2>Next steps</h2>
<p>We are still hard at work on fixing bugs in the current implementation and implementing the rest of the features in the <a href="http://dev.w3.org/csswg/css3-exclusions/">CSS Exclusions and Shapes specification</a>. We welcome your feedback on what is already implemented and also on the spec itself. If you are interested in becoming part of the process, you can raise issues with the current WebKit implementation by filing bugs in <a href="http://bugs.webkit.org/">the WebKit bugzilla</a>. If you have issues with the spec, those are best raised on the <a href="http://lists.w3.org/Archives/Public/www-style/">www-style mailing list</a>. And of course, you can leave your feedback as comments on this post.</p>
<p>I hope that you enjoy experimenting with <code>shape-outside</code> and the other features we are currently working on.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/03/27/freeing-the-floats-of-the-future-from-the-tyranny-of-the-rectangle/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>CSS Fragmentation In WebKit</title>
		<link>http://blogs.adobe.com/webplatform/2013/03/05/css-fragmentation-in-webkit/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/03/05/css-fragmentation-in-webkit/#comments</comments>
		<pubDate>Tue, 05 Mar 2013 17:45:01 +0000</pubDate>
		<dc:creator>Andrei Bucur</dc:creator>
				<category><![CDATA[Regions]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2976</guid>
		<description><![CDATA[What is fragmentation? The CSS 2.1 specification defines a box model to represent the layout of a document and pretty much everything is a box. Normal flow nodes (e.g. not absolutely positioned) are laid out child by child starting at the top of their parent element box. If an element’s box is too small to fit all the content,...]]></description>
				<content:encoded><![CDATA[<h2>What is fragmentation?</h2>
<p>The <a title="CSS 2.1 Specification" href="http://www.w3.org/TR/CSS21/" target="_blank">CSS 2.1</a> specification defines a box model to represent the layout of a document and pretty much everything is a box. <a title="Normal flow definition" href="http://www.w3.org/TR/CSS21/visuren.html#normal-flow" target="_blank">Normal flow</a> nodes (e.g. not absolutely positioned) are laid out child by child starting at the top of their parent element box. If an element’s box is too small to fit all the content, the content is said to overflow and this overflow can either be visible or get clipped.</p>
<p>Fragmentation is different from overflow because it allows flowing the content through multiple boxes called fragmentation containers &#8211; fragmentainers for short. When the end of the current fragmentainer is reached a break occurs and the layout continues within the next fragmentainer. Using CSS, authors can also force breaks to occur after or before an element and even avoid them altogether.</p>
<p>The important detail to remember is that fragmentation doesn’t mean taking the overflow of a box and visually moving it to another one. Fragmentation happens during the layout and affects the dimensions of the content boxes.</p>
<p>There are a few specifications in CSS based on fragmentation:</p>
<ul>
<li><a title="CSS3 Page Specification" href="http://dev.w3.org/csswg/css3-page/" target="_blank">CSS3 Pagination</a> - the document is laid out so it can fit on pages; the pages act as fragmentainers.</li>
<li><a title="CSS3 Multi-column Specification" href="http://dev.w3.org/csswg/css3-multicol/" target="_blank">CSS3 Multi-column</a> - the element defines a number of columns that fill its box and where the content is laid out; the columns act as fragmentainers.</li>
<li><a title="CSS3 Regions Specification" href="http://dev.w3.org/csswg/css3-regions/" target="_blank">CSS3 Regions</a> - selected content forms a flow that’s laid out inside boxes called regions; the regions act as fragmentainers.</li>
</ul>
<p>All of these specifications share common concepts covered by the <a title="CSS3 Fragmentation Specification" href="http://dev.w3.org/csswg/css3-break/" target="_blank">CSS3 Fragmentation</a> specification.</p>
<div id="attachment_2978" class="wp-caption aligncenter" style="width: 660px"><a href="http://blogs.adobe.com/webplatform/files/2013/02/pic1.png"><img class="size-full wp-image-2978" alt="Paragraph in regions." src="http://blogs.adobe.com/webplatform/files/2013/02/pic1.png" width="650" height="264" /></a><p class="wp-caption-text">Example of a paragraph flown in two regions.</p></div>
<h2>Fragmentation in WebKit</h2>
<h3>The Layout Process</h3>
<p>To fully understand the concepts presented here you should know a bit about how layout works in WebKit. There are some nice articles on the Web covering the basics such as <a title="Bem's Article" href="http://blogs.adobe.com/webplatform/2013/01/21/getting-started-with-the-webkit-layout-code/" target="_blank">Bem’s article</a>.</p>
<p>Long story short, the DOM tree is internally mapped to a render tree that is used to build up the box properties for every node. The render tree is made up from objects like <code>RenderBox</code>, <code>RenderBlock</code>, <code>RenderInline</code> etc. that represent the concepts defined in CSS2.1. During layout this tree is traversed and the various geometrical properties of the renderers are computed based on the style values. In the end all the elements have their box information computed.</p>
<p>As a side note, you’ll notice the symbols inside WebKit are usually named using the “pagination” or “page” <a title="Example" href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlock.h?rev=144561#L1084" target="_blank">terminology</a>. This is for historical reasons, but most of the time the pagination concepts map to the fragmentation ones &#8211; pages, columns or regions.</p>
<p>There were a couple of ways the fragmentation behavior could have been implemented in WebKit. One of them was to have a renderer for each element fragment. For instance a simple paragraph with ten lines where there’s a break after the fourth one, we would have had one renderer with four lines in the first fragmentainer and a second renderer with six lines in the second fragmentainer. Both of the renderers would belong to the initial element. This approach is difficult to implement correctly and maintain because of the complexity it brings to the codebase. Additionally, it is also very risky from a security standpoint as it can introduce many subtle memory management bugs.</p>
<p>A rule of maximum one renderer per DOM node was created because of these concerns. Fragmentation is implemented by shifting the monolithic boxes (boxes that can’t be fragmented, such as line boxes &#8211; rectangles wrapping each line of text) so that they don’t overlap with the breaks. The correct rendering is obtained during the painting phase by placing each fragment exactly where it is supposed to appear in the fragmentainer. More about this topic in the next section.</p>
<p>In the case of unforced breaks, a position adjustment, called pagination strut in the codebase, is attached to the boxes during layout. This value represents a shift offset from the default layout position to the next fragmentainer in case the box doesn’t fit the current one. This offset needs to be stored separately on each box, not as a part of the top position because it’s not an attribute of the renderer. It’s a layout artifice that helps measuring the fragmented boxes. For example, if a block is collapsing at the top margin with its container (e.g. it’s the first child) and it also has a pagination strut, that offset will be transferred to the container. This makes sense because both the block and the container need to be placed in the next fragmentainer even though it’s the child that won’t fit. </p>
<p>The same rule applies to the first line box of a block. Also, during subsequent layouts it’s possible for an element to shift in the block-flow direction. The line boxes pagination struts need to be recomputed because the shift offsets are most likely different after the element changed position.</p>
<div id="attachment_2984" class="wp-caption aligncenter" style="width: 553px"><a href="http://blogs.adobe.com/webplatform/files/2013/02/pic2.png"><img class="size-full wp-image-2984" alt="When a line doesn't fit the current fragmentainer it is shifted using the pagination strut." src="http://blogs.adobe.com/webplatform/files/2013/02/pic2.png" width="543" height="321" /></a><p class="wp-caption-text">When a line doesn&#8217;t fit the current fragmentainer it is shifted using the pagination strut.</p></div>
<p>As an example, in the case of the example above, the first four line boxes would be positioned normally in the first fragmentainer. The fifth line box may need to have a pagination strut defined if it fits only partially in the first fragmentainer. This pagination strut would logically shift the line inside the next fragmentainer. The rest of the lines are all placed normally in the second fragmentainer.</p>
<p>In the case of forced breaks, the pagination strut is no longer used because the authors directly specify where the breaks occur. The boxes are positioned inside their container so they respect the break condition.</p>
<p>Each type of fragmentation layout has its own specialized behavior. The multi-column elements have the <code>ColumnInfo</code> object attached to them. It contains information about the number and the width of the columns, the distance between breaks (used to balance the columns if they have auto-height) etc. This object is also pushed on the layout state stack so it can be accessed from any point inside the render tree.</p>
<p>The regions implementation is currently the most complex type of layout that makes use of fragmentation. The content node renderers are not attached to their DOM parent renderer. Instead, they are moved to a special object, <code>RenderFlowThread</code>, that sets up a pagination context when it is laid out. These renderers need to hold and use various information about the<a title="Flow Thread Definition" href="http://dev.w3.org/csswg/css3-regions/#named-flow" target="_blank"> flow thread</a>: the regions size, how the descendant boxes change width in every region they are flowing into etc. Because the concept of the flow thread is so generic there are plans to port the multi-column implementation on top of it.</p>
<h3>The Layout Performance</h3>
<p>From a performance perspective, the layout process will always be slower for fragmented content because the engine can’t apply the same optimizations that are made for continuous vertical content. For example, without the possibility of fragmentation, updating the top margin of an element can shift it on the vertical axis but no relayout may be needed. If the element is enclosed in a fragmentation context, by shifting the element it’s possible it won’t fit any more inside the fragmentainer, triggering a break. To cover this case, a relayout of the element is always required.</p>
<p>The layout engine is usually optimized for both speed and memory consumption. This means fragmentation code is used only when necessary: if there is a printing context, if the node being laid out is a part of a multi-column element or if the renderer belongs to a flow thread. The logic for enabling the fragmentation code can be found inside the <code>LayoutState</code> class. During layout, a stack of <code>LayoutState</code> objects is created and stored on the root of the render tree, the <code>RenderView</code>. Any renderer can query the top of this stack to determine if the content can be fragmented or not.</p>
<h3>The Painting Phase</h3>
<p>The painting of the renderers in WebKit is handled by the <code>RenderLayer</code> tree. For some renderers the engine creates layers that are used to paint the document in the <a title="The Painting Order Specification" href="http://www.w3.org/TR/CSS21/zindex.html#painting-order" target="_blank">correct order</a> (e.g. with respect the z-index restrictions). Layers are always created for the renderers that fragment, such as multi-column blocks or <code>RenderFlowThread</code> objects. Because of this, multi-column elements and regions create stacking contexts and are painted as a single item.</p>
<p>For regions, when the painting operation occurs, the engine takes into account the fragmentation properties of the renderer and shifts the layer to the correct position so the painting is always executed inside the correct fragmentainer. The content not belonging to the current fragmentainer is clipped so the engine always paints only the content that should be displayed in a certain area. The mechanism is in some ways similar to how sprites (e.g. <a title="CSS Sprites" href="http://css-tricks.com/css-sprites/" target="_blank">CSS Sprites</a>) work.</p>
<div id="attachment_2986" class="wp-caption aligncenter" style="width: 659px"><a href="http://blogs.adobe.com/webplatform/files/2013/02/pic3.png"><img class="size-full wp-image-2986" alt="The RenderFlowThread is painted in the two regions at the offsets corresponding to each content fragment." src="http://blogs.adobe.com/webplatform/files/2013/02/pic3.png" width="649" height="410" /></a><p class="wp-caption-text">The RenderFlowThread is painted in the two regions at the offsets corresponding to each content fragment.</p></div>
<p>For example, let’s say the paragraph above is flown into regions A and B. When region A is painted, the flow thread layer is called to paint in the fragmentainer box. It will paint the first four lines and then blank space until the bottom of the fragmentainer because the fifth line was shifted at layout-time using the pagination strut. When region B is painted, the flow thread layer is called again to paint inside the fragmentainer box, but at a new offset, where the region B fragment starts (top of the fifth line). The last six lines of the paragraph are painted.</p>
<p>Something similar happens with the multi-column blocks. However, the main difference is the fragmentainers for multi-column blocks don’t have their own layers. By using the same layer as the multi-column block the content is able to use advanced graphics features such as 3D transforms and video tags (see <a title="WebKit Compositing" href="http://www.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome" target="_blank">WebKit Compositing</a> for more details about how accelerated layers work).</p>
<p>In the case of a flow thread, making its layer work with the region layers is one of the major challenges that need to be solved. As a consequence of this problem, content layers that require accelerated compositing (e.g. video layers) will not work correctly inside flow threads.</p>
<h2>Conclusions</h2>
<p>The modern fragmentation concepts are not yet fully implemented inside WebKit. There are some issues with the handling of forced breaks and the <a title="Avoid values" href="http://dev.w3.org/csswg/css3-break/#break-between"><code>avoid</code></a> value is implemented only for the <code><a title="The break-inside property" href="http://dev.w3.org/csswg/css3-break/#break-inside">break-inside</a></code> property. The <a title="Windows and Orphans Specification" href="http://dev.w3.org/csswg/css3-break/#widows-orphans" target="_blank"><code>widows</code> and <code>orphans</code></a> properties were just recently <a title="Widows and Orphans Patch" href="http://trac.webkit.org/changeset/137200" target="_blank">fully enabled</a>.</p>
<p>On the CSS Regions side there’s some work left to do to achieve a smooth integration with the layers and compositing subsystem. Testing is also much needed to ensure good integration with other Web features.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/03/05/css-fragmentation-in-webkit/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>A look into Custom Filters reference implementation</title>
		<link>http://blogs.adobe.com/webplatform/2013/02/07/a-look-into-custom-filters-reference-implementation/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/02/07/a-look-into-custom-filters-reference-implementation/#comments</comments>
		<pubDate>Thu, 07 Feb 2013 17:00:24 +0000</pubDate>
		<dc:creator>Michelangelo De Simone</dc:creator>
				<category><![CDATA[Custom Filters]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2742</guid>
		<description><![CDATA[Over the past two years, my team in Adobe has been actively working on the CSS Custom Filters specification (formerly CSS Shaders), which is just one part of the greater CSS Filters specification. Alongside the spec work, we have been working on the CSS Custom Filters WebKit implementation, so I’ve decided to write this blog...]]></description>
				<content:encoded><![CDATA[<p><img class="size-full wp-image-2746 aligncenter" alt="A shader example" src="http://blogs.adobe.com/webplatform/files/2013/01/shader_header.png" width="450" height="429" /></p>
<p dir="ltr">Over the past two years, my team in Adobe has been actively working on the <a href="http://www.w3.org/TR/filter-effects/">CSS Custom Filters specification</a> (formerly CSS Shaders), which is just one part of the greater CSS Filters specification. Alongside the spec work, we have been working on the CSS Custom Filters WebKit implementation, so I’ve decided to write this blog post to explain how this is all being implemented in WebKit, giving an high-level conceptual overview of the game.</p>
<p dir="ltr">Support for OpenGL shaders on general DOM content has been one of the noted features for the <a href="http://www.webmonkey.com/2013/01/google-chrome-now-with-cinema-style-3d-effects/">latest Chrome releases</a>. Users and web developers are excited about the ability to apply cinematic effects on their pages.</p>
<h3>Shaders, Shaders, Shaders</h3>
<p dir="ltr">I’ve often been asked “what is a shader?”; well, shaders are short programs that run on the <a href="http://en.wikipedia.org/wiki/Graphics_processing_unit">GPU</a> that &#8211; unlike regular programs &#8211; solely deal with bitmaps (textures) and 3D meshes, performing specific operations on pixels (called fragments) and vertices. You can get a more in-depth explanation of shaders <a href="http://en.wikipedia.org/wiki/Shader">on Wikipedia</a>.</p>
<p dir="ltr">Roughly speaking, the reason why these small programs run on the your graphic card’s processor (the GPU) instead of the regular CPU is that GPUs are very good at performing ad hoc math operations in parallel. While the GPU is busy performing graphical operations, your CPU is idle and ready to perform other tasks. Everything is faster and snappier.</p>
<p dir="ltr">In our case, the texture passed to the graphic pipeline is styled DOM content, <em>your</em> page content. This means that with one line of CSS and a shader, you can get splendid and astonishing results, just take a look at the image at the beginning of this post.</p>
<p dir="ltr">HTML5Rocks has a <a href="http://updates.html5rocks.com/2012/09/Interactive-Globe-with-CSS-shaders-Google-Maps">great post</a> covering the whole idea behind CSS Custom Filters with an example of their capabilities so I won’t spend too many words on how to <em>use</em> them, instead I’ll be focusing on what is the general idea behind the implementation. Let’s start!</p>
<h3>Parsing and Style Resolution</h3>
<p>The life of a CSS Shader Custom Filter starts with the CSS Custom Filter declaration. With the currently implemented WebKit syntax, it might look like the following:</p>
<pre>#myElement {
    -webkit-filter: custom(url(vertex.vs) none)
}</pre>
<p>This CSS is firstly encountered by WebKit’s <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/css/CSSParser.h">CSSParser</a></tt>, which – as the name might suggest – is the component within WebKit responsible for CSS parsing. Raw text data gathered from this object is then computed by WebKit’s <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/css/StyleResolver.h">StyleResolver</a></tt> and from there, a <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/filters/CustomFilterOperation.h">CustomFilterOperation</a></tt> is created. This class will contain all the major information about the Custom Filter you’ve asked to use, such as its parameters. It also references the program, a <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/filters/CustomFilterProgram.h">CustomFilterProgram</a></tt>, which is a vertex shader and fragment shader pair, that will be applied to the texture (your styled DOM content).</p>
<p>Here&#8217;s a picture of the happy event:</p>
<pre>PassRefPtr StyleResolver::createCustomFilterOperation(WebKitCSSFilterValue* filterValue)
{
    // ...snip...
    RefPtr program = StyleCustomFilterProgram::create(vertexShader.release(), fragmentShader.release(), programType, mixSettings, meshType);
    return CustomFilterOperation::create(program.release(), parameterList, meshRows, meshColumns, meshType);
}</pre>
<h3>Computing and Rendering</h3>
<p>The <tt>RenderLayer</tt> tree is one of the many trees in WebKit and it’s currently being used, among other things, to deal with group operations such as opacity, stacking contexts, transforms and to do things like scrolling and accelerated compositing: it’s a huge huge piece of code that defines the word “complexity”.:-)</p>
<p>What happens after the parsing and the style resolution is most interesting: when a DOM element has a filter associated with it, it receives its own <tt>RenderLayer</tt>. When this happens, the relevant DOM content is painted in an image buffer and then sent to the GPU for the “shading treatment” as a regular texture. All this starts to take place thanks to <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderLayerFilterInfo.h">RenderLayerFilterInfo</a></tt> which, among other things, downloads the shaders as external resources and calls the <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderLayer.h">RenderLayer</a></tt> back to notify it that everything’s ready to repaint.</p>
<p>The computing magic begins when a <tt>RenderLayer</tt> starts to iterate on all the filters associated with it:</p>
<pre>FilterOperations RenderLayer::computeFilterOperations(const RenderStyle* style)
{
	// ...snip...
        for (size_t i = 0; i < filters.size(); ++i) {
        RefPtr<FilterOperation> filterOperation = filters.operations().at(i);
        if (filterOperation->getOperationType() == FilterOperation::CUSTOM) {
	// ...snip...
            CustomFilterGlobalContext* globalContext = renderer()->view()->customFilterGlobalContext();
            RefPtr<CustomFilterValidatedProgram> validatedProgram = globalContext->getValidatedProgram(program->programInfo());
	// ...snip...
}</pre>
<p>For every custom filter, a <em>validated</em> version of the program (see next paragraph) is requested; this is then appended to the list of the associated filter operations.</p>
<p>The actual rendering will take place in the <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/FilterEffectRenderer.h">FilterEffectRenderer</a></tt> class where the “filter building” operation will start in a surprisingly straightforward manner:</p>
<pre>
bool FilterEffectRenderer::build(RenderObject* renderer, const FilterOperations&#038; operations)
{
	// ...snip...
        effect = createCustomFilterEffect(this, document, customFilterOperation);
	// ...snip...
}</pre>
<p><tt>FilterEffectRenderer::createCustomFilterEffect</tt> is the method that will rule them all. Take a look at it, it’s just gorgeous! <img src='http://blogs.adobe.com/webplatform/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>A word about security</h3>
<p>Among the other things, shaders deal with pixels which means that a texture can be <em>sampled</em> (read). This translates into a potential security risk: we don’t really like the idea of malicious shaders reading your page content. Imagine to what would happen if anyone was able to push a shader capable of making a screenshot of your private messages on some social network.</p>
<p>In light of this we do  enforce restrictions on shader code before it’s sent to the GPU. We do this by validating and rewriting the shaders in a controlled and secure fashion, and <tt><a href="http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/filters/CustomFilterValidatedProgram.h">CustomFilterValidatedProgram</a></tt> serves just this purpose, one of its goals is to avoid texture sampling, meaning that the shaders cannot read pixels from your page content anymore. Most of the validation work actually relies on <a href="http://code.google.com/p/angleproject/">ANGLE</a>, an open source library used by many other projects, including WebKit and Gecko, for WebGL validation and portability.</p>
<p>If you want to have an idea of the kind of validation we perform, pay attention to <tt>CustomFilterValidatedProgram</tt>: it might prove a very learning reading.</p>
<h3>Wrapping up</h3>
<p>Currently, we’re working with the CSS Working Group to make the CSS Custom Filters syntax  more elegant and future-proof. As with any new web feature, you can expect changes. Stay tuned for more information on upcoming improvements!</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/02/07/a-look-into-custom-filters-reference-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Visual Method for Understanding WebKit Layout</title>
		<link>http://blogs.adobe.com/webplatform/2013/02/05/a-visual-method-for-understanding-webkit-layout/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/02/05/a-visual-method-for-understanding-webkit-layout/#comments</comments>
		<pubDate>Tue, 05 Feb 2013 17:14:21 +0000</pubDate>
		<dc:creator>Bem Jones-Bey</dc:creator>
				<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2725</guid>
		<description><![CDATA[My last post was an introduction to the WebKit layout code. It was pretty high level, with a focus on documentation. This post is much more hands on: I will explain some changes that you can make to WebKit&#8217;s C++ rendering code to be able to see which classes handle which parts of a web...]]></description>
				<content:encoded><![CDATA[<p>My last post was an <a href="http://blogs.adobe.com/webplatform/2013/01/21/getting-started-with-the-webkit-layout-code/">introduction to the WebKit layout code</a>. It was pretty high level, with a focus on documentation. This post is much more hands on: I will explain some changes that you can make to WebKit&#8217;s C++ rendering code to be able to see which classes handle which parts of a web page.</p>
<h2>Getting and building the code</h2>
<p>This is entirely optional, so if you don&#8217;t feel like setting this up or don&#8217;t have a machine powerful enough to do the build, feel free to skip to the next section. I will put in links to all of the code that I reference throughout the document, so you should be able to follow along with nothing more than the web browser you are using to read this.</p>
<p>Note that this section does not attempt to be a complete guide to setting up a build environment and getting a working build. That would be an entire blog series of its own!</p>
<h3>Getting the code</h3>
<p>If you&#8217;re still with me, before you build anything, you&#8217;ll need to get a copy of the source code. WebKit uses <a href="//subversion.apache.org/">Subversion</a> for source control; however, most developers work with the <a href="http://git-scm.com/">Git</a> mirror. If you&#8217;re on Windows, you should jump directly to the <strong>Building the code</strong> section below, as you need to have the code checked out to a specific location in order for the code to build. Otherwise, you can continue with this section.</p>
<h4>Installing Git on Linux and Mac OS X</h4>
<p>Installing Git is pretty straightforward on Linux and Mac OS X. On Linux, I&#8217;d suggest that you use your distribution&#8217;s package manager, but if you can&#8217;t do that for some reason, you can download Git from the <a href="http://git-scm.com/">Git Homepage</a>.</p>
<p>For recent versions of Mac OS X, it is included in the Xcode developer tools, and you will need them to build the code anyways. Once you&#8217;ve installed Xcode, you will need to install the command line tools, which is located under Xcode -&gt; Preferences -&gt; Downloads in Xcode 4.5.2, and in a similar location in earlier versions.</p>
<h4>Downloading the source</h4>
<p>Once you have Git installed, grabbing the source is pretty straightforward. First, make sure you have at least 4 gigs of free space. Then, open a terminal, find a suitable directory, and run the following command:</p>
<pre class="brush: bash; title: ; notranslate">
git clone git://git.webkit.org/WebKit.git WebKit
</pre>
<p>This will take awhile, but when it&#8217;s done, you&#8217;ll have your very own copy of the WebKit source code.</p>
<h4>That&#8217;s great, but I still don&#8217;t get this Git thing</h4>
<p>Explaining how to use Git is beyond the scope of this post, but here are a couple of resources:</p>
<ul>
<li><a href="https://trac.webkit.org/wiki/UsingGitWithWebKit">Using Git With WebKit</a>: Documentation on using Git with WebKit</li>
<li><a href="http://progit.org/">Pro Git</a>: Free, professionally written book on Git</li>
</ul>
<h3>Building the code</h3>
<p>WebKit is designed to be able to run on many different platforms. To facilitate this, functions like graphics and networking have abstraction layers that allow an implementation for a specific platform to be plugged in. This combination of the platform independent part of WebKit with the low level bindings for a specific platform is called a port.</p>
<p style="text-align: center">
<img src="http://blogs.adobe.com/webplatform/files/2013/02/port-diagram.png" alt="WebKit Port Diagram" width="638" height="118" class="aligncenter size-full wp-image-2772" />
</p>
<p>Note that while there are ports that are operating system specific, like the Mac and Windows ports, there are also ports for platforms like Qt, which is a library that can be used on many different operating systems. The short of it is that in order to build WebKit, you need to choose the proper port to build for your purposes.</p>
<p>The best place to start to learn how to build WebKit is to take a look at the <a href="http://www.webkit.org/building/tools.html">documentation on installing the developer tools to build webkit</a>. It lists out the most common ports with either instructions in the page or links to the Wiki documentation on how to set up a development environment for that port. I would suggest using the Mac port if you&#8217;re on a Mac, and the Windows port if you&#8217;re on Windows. If you&#8217;re on Linux, you can choose between the <a href="http://trac.webkit.org/wiki/BuildingGtk">Gtk</a>, <a href="http://trac.webkit.org/wiki/QtWebKit">Qt</a>, and <a href="http://trac.webkit.org/wiki/EFLWebKit">EFL</a> ports. If you don&#8217;t care or don&#8217;t know which one to choose, you could use the <a href="http://trac.webkit.org/wiki/BuildingGtk">Gtk port</a> if you&#8217;re using Gnome, and the <a href="http://trac.webkit.org/wiki/QtWebKit">Qt port</a> if you&#8217;re using KDE.</p>
<p>If you&#8217;re building a port other than the Mac or Windows port, all of the build instructions are on the wiki page about that port, which I linked to in the paragraph above. Otherwise, you will want to read the <a href="http://www.webkit.org/building/build.html">build instructions for the Mac and Windows ports</a>.</p>
<p>There are more ports than the ones I mentioned here; however, when doing WebKit development, it is probably easiest to start with one of the ports I mentioned above. If you would like to know about others, there is a <a href="http://trac.webkit.org/wiki#WebKitPorts">list of ports on the WebKit wiki</a>.</p>
<h4>Help! I followed all the instructions and it still doesn&#8217;t work!</h4>
<p>If you can&#8217;t get your chosen port to build, or if you&#8217;re unsure of which port to choose, there is a <a href="http://www.webkit.org/contact.html">page of contact information for the WebKit project</a>. I would suggest starting by sending a message to the <a href="http://lists.webkit.org/mailman/listinfo/webkit-help">webkit-help mailing list</a>, as that will get you in contact with people that should be able to help with any build problems or questions that you may encounter. You can also contact the developers on IRC: the <a href="irc://irc.freenode.net/#webkit">#webkit channel on irc.freenode.net</a> is WebKit central.</p>
<h2>Visualizing layout</h2>
<p>The layout process determines what features of a web page get drawn into which locations. However, when starting out, it can be hard to link the C++ code to the visual result that you see in your browser. Probably the easiest way to make this connection in a visual way is to modify the code that draws everything to the screen. This drawing step happens after layout, and WebKit calls it painting.</p>
<h3>Basics of painting</h3>
<p>After layout has finished, the process of painting begins. It happens in a very similar way to layout: each rendering class has a <code>paint</code> method that is analogous to the <code>layout</code> method we discussed in the last post. This <code>paint</code> method is responsible for drawing the current renderer and it&#8217;s children onto the display.</p>
<p>The <a href="http://www.w3.org/TR/CSS21/zindex.html">CSS specification defines the painting order for elements</a>, and the WebKit implementation has painting phases for all of these steps. As with many of these things, it is too complex to explain here in its entirety, but the rules of the painting order ensures that all of CSS&#8217;s positioning rules are rendered properly. This must be taken into account when thinking of where in the individual <code>paint</code> methods changes should be made.</p>
<p>The <code>paint</code> method can be instrumented to draw the outline of the area painted by the class. This can make it much easier to understand which parts of the code create which parts of the rendered page.</p>
<h3>What does it look like?</h3>
<p style="text-align: center;"><img class="aligncenter" title="Web page with instrumented RenderBlock" alt="" src="http://blogs.adobe.com/webplatform/files/2013/01/1359391204.jpg" width="600" height="380" align="centered" /></p>
<p>To generate the above screenshot, <code>RenderBlock::paint</code> method (Look in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlock.cpp?rev=141611">Source/WebCore/rendering/RenderBlock.cpp</a> for the definition) was instrumented to draw a green border around the block itself.</p>
<h3>Drawing the outlines</h3>
<p>The C++ code that generated those lovely green outlines is the following:</p>
<pre class="brush: cpp; title: ; notranslate">
Color color;
color.setRGB(0, 255, 0);
paintInfo.context-&gt;setStrokeColor(color, style()-&gt;colorSpace());
paintInfo.context-&gt;strokeRect(overflowBox, 2);
</pre>
<p>Let&#8217;s break this down line by line:</p>
<pre class="brush: cpp; title: ; notranslate">
Color color;
</pre>
<p>This creates a <code>Color</code> object. It is hopefully not surprising that this object represents a color, and will be used to set the color that we are going to draw our border with.</p>
<pre class="brush: cpp; title: ; notranslate">
color.setRGB(0, 255, 0);
</pre>
<p>This call sets the color for our <code>Color</code> object. It takes 3 numbers between 0 and 255, each one representing the amount of red, green, or blue that makes up the color. For simplicity, I just went with entirely green, but you could do any sort of fancy thing you like here. Setting the color to different values could come in handy if you want to instrument multiple classes at once: each could have a different color, making it easy to tell them apart.</p>
<pre class="brush: cpp; title: ; notranslate">
paintInfo.context-&gt;setStrokeColor(color, style()-&gt;colorSpace());
</pre>
<p>Now&#8217;s when things get more complex. <code>paintInfo</code> is an instance of <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/PaintInfo.h?rev=141611">PaintInfo</a> that is passed as an argument to the <code>paint</code> method. <code>PaintInfo</code> is a simple structure that contains the state of the painting operation as well as the object used to actually call the native drawing routines. That object is the <code>context</code> member of <code>PaintInfo</code>. This object is actually a facade to provide a platform independent API for drawing. It is declared in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/platform/graphics/GraphicsContext.h?rev=141611">platform/graphics/GraphicsContext.h</a>, and there are corresponding platform specific implementations that it uses depending in which WebKit port is in use.</p>
<p>If you have done graphics programming before (Even using HTML&#8217;s canvas element), you will probably find the use of the <code>GraphicsContext</code> familiar. The methods may have different names, but the underlying concepts of the API are exactly the same. For example, this <code>setStrokeColor</code> call sets the color that is used by subsequent drawing operations that use this context.</p>
<p>The last piece of this line that I should explain is the <code>style()</code> call. This gets the CSS style information for the <code>RenderBlock</code>, and queries it for the color space. This is one of the things that will need to change when modifying this code to work in <code>paint</code> methods in other objects, since there are some cases when a renderer delegates painting some part of it&#8217;s content to another class that itself is not a renderer. In those cases, that class has a reference to the renderer it is attached to, and the <code>style()</code> method can be called via that member. In most cases, this member is called <code>m_renderer</code>, so this call changes to <code>m_renderer-&gt;style()-&gt;colorSpace()</code>. I give an example of this case later in this post.</p>
<pre class="brush: cpp; title: ; notranslate">
paintInfo.context-&gt;strokeRect(overflowBox, 2);
</pre>
<p>This is the call that actually draws the border rectangle. The <code>overflowBox</code> is the dimensions of the block plus any visible overflow: that&#8217;s the entire area of the page that is rendered by this block and its children. The second argument to <code>strokeRect</code> is the width of the line used to draw the rectangleA.</p>
<h3>Where is this code added?</h3>
<p>Of course, this code cannot just be added at random, you need to put it in a specific place in the <code>paint</code> method. As of this writing, the <code>paint</code> method in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderBlock.cpp?rev=141611">RenderBlock.cpp</a> looks like the following:</p>
<pre class="brush: cpp; title: ; notranslate">
void RenderBlock::paint(PaintInfo&amp; paintInfo, const LayoutPoint&amp; paintOffset)
{
    LayoutPoint adjustedPaintOffset = paintOffset + location();

    PaintPhase phase = paintInfo.phase;

    // Check if we need to do anything at all.
    // FIXME: Could eliminate the isRoot() check if we fix background painting
    // so that the RenderView paints the root's background.
    if (!isRoot()) {
        LayoutRect overflowBox = overflowRectForPaintRejection();
        flipForWritingMode(overflowBox);
        overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
        overflowBox.moveBy(adjustedPaintOffset);
        if (!overflowBox.intersects(paintInfo.rect))
            return;
    }

    bool pushedClip = pushContentsClip(paintInfo, adjustedPaintOffset);
    paintObject(paintInfo, adjustedPaintOffset);
    if (pushedClip)
        popContentsClip(paintInfo, phase, adjustedPaintOffset);

    // Our scrollbar widgets paint exactly when we tell them to,
    // so that they work properly with z-index.  We paint after we painted
    // the background/border, so that the scrollbars will sit above
    // the background/border.
    if (hasOverflowClip() &amp;&amp; style()-&gt;visibility() == VISIBLE &amp;&amp;
            (phase == PaintPhaseBlockBackground ||
                phase == PaintPhaseChildBlockBackground) &amp;&amp;
            paintInfo.shouldPaintWithinRoot(this))
        layer()-&gt;paintOverflowControls(paintInfo.context,
            roundedIntPoint(adjustedPaintOffset), paintInfo.rect);
}
</pre>
<p>I&#8217;m not going to go over this one line at a time, as by the time you read this, this method may or may not look the same. However, I would like to share where I placed the code and the rationale behind it so that hopefully you will still be able to instrument the code yourself even if it has changed, and will be able to think about how to instrument the <code>paint</code> methods in other render classes as well.</p>
<p>When looking for a place to put the code in this method, the first thing I needed to find was where I could find a <code>LayoutRect</code> that represents the area that this renderer will paint into. This is the dimensions of the block plus any visible overflow. This value is usually used early on in the <code>paint</code> method to determine if the current block is actually in area to be painted (<code>paintInfo.rect</code>). In <code>RenderBlock::paint</code>, you can see this in the <code>if</code> statement following the helpful comment &#8220;Check if we need to do anything at all.&#8221;:</p>
<pre class="brush: cpp; title: ; notranslate">
if (!isRoot()) {
    LayoutRect overflowBox = overflowRectForPaintRejection();
    flipForWritingMode(overflowBox);
    overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
    overflowBox.moveBy(adjustedPaintOffset);
    if (!overflowBox.intersects(paintInfo.rect))
        return;
}
</pre>
<p>So <code>overflowBox</code> is our variable, which you might remember from the instrumentation code example above. Now, we need to determine where to put our instrumentation code. In this case, unless we want to move the definition of <code>overflowBox</code>, we don&#8217;t have much choice: it must go in the body of the <code>if</code> statement above. Since we don&#8217;t want to draw the outline if the block is not in the area to be painted, we should put it after the <code>return</code> statement at the end, like so:</p>
<pre class="brush: cpp; title: ; notranslate">
if (!isRoot()) {
    LayoutRect overflowBox = overflowRectForPaintRejection();
    flipForWritingMode(overflowBox);
    overflowBox.inflate(maximalOutlineSize(paintInfo.phase));
    overflowBox.moveBy(adjustedPaintOffset);
    if (!overflowBox.intersects(paintInfo.rect))
        return;

    Color color;
    color.setRGB(0, 255, 0);
    paintInfo.context-&gt;setStrokeColor(color, style()-&gt;colorSpace());
    paintInfo.context-&gt;strokeRect(overflowBox, 2);
}
</pre>
<p>And now if we build and run the code, we should see an effect like in the screenshot above. It is also very interesting to launch the web inspector with this active.</p>
<h3>More complex paint methods</h3>
<p>The <code>paint</code> method of <code>RenderBlock</code> makes for a nice example because it is pretty small and it is pretty straightforward to see how to instrument it. (Most of the complexity is nicely factored out into helper methods.) However, this is not the case for the <code>paint</code> method in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/InlineFlowBox.cpp?rev=141611#L1059">InlineFlowBox</a>. InlineFlowBox is used to manage flows of inline content, like text.</p>
<p>I am not going to reproduce the entirety of <code>InlineFlowBox::paint</code> here, but you should be able to follow along by either opening the file in your favorite editor if you opted to download the code, or by looking at <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/InlineFlowBox.cpp?rev=141611#L1059">InlineFlowBox.cpp on Trac</a>.</p>
<p>While this is a more complex paint method, the check if painting should happen is right at the top of the method:</p>
<pre class="brush: cpp; title: ; notranslate">
LayoutRect overflowRect(visualOverflowRect(lineTop, lineBottom));
overflowRect.inflate(renderer()-&gt;maximalOutlineSize(paintInfo.phase));
flipForWritingMode(overflowRect);
overflowRect.moveBy(paintOffset);

if (!paintInfo.rect.intersects(pixelSnappedIntRect(overflowRect)))
    return;
</pre>
<p>From this, we can glean two pieces of information, just like we did in the <code>RenderBox</code> example: that <code>overflowRect</code> defines our painted area, and that we should instrument after the <code>if</code> statement that determines if we should paint or not.</p>
<p>Looking at the rest of the method and the plethora of <code>if</code> and <code>return</code> statements, it is less obvious how far into the method our instrumentation code should go. All of those conditions might look very opaque, but you may be happy to know that you don&#8217;t need to understand them all to decide where to put the instrumentation code.</p>
<p>Most of the conditions in <code>InlineFlowBox::paint</code> have to do with the different phases of painting. I mentioned earlier that CSS defines the order in which painting should be done: WebKit uses paint phases to implement this. So all these <code>if</code> statements are doing is ensuring that only the proper things are drawn in a given phase. If we were writing production code, we would need to determine in which phase our outline should be drawn in, and make sure that it is only drawn in that phase. However, since this is exploratory code, we can just draw the outline in every phase, which will ensure that it gets shows up on top of any other content rendered by this object. The simplest way to do this is to place the instrumentation code as the first thing after it is determined that painting should happen.</p>
<p>Great! Now we know where the code should go, and we know which variable contains our bounding box, so we can take the code from earlier, changing <code>overflowBox</code> to <code>overflowRect</code> and changing the color to red just in case we want to have this active at the same time as the changes to <code>RenderBlock</code>:</p>
<pre class="brush: cpp; title: ; notranslate">
Color color;
color.setRGB(255, 0, 0);
paintInfo.context-&gt;setStrokeColor(color, style()-&gt;colorSpace());
paintInfo.context-&gt;strokeRect(overflowRect, 2);
</pre>
<p>That&#8217;s the right direction, but if you do this, you will find out that it doesn&#8217;t compile: the compiler can&#8217;t find a <code>style()</code> method! That&#8217;s because we&#8217;ve discovered that <code>InlineFlowBox</code> is not a render object, it is a helper, used by render objects like <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderInline.h?rev=141611">RenderInline</a>.</p>
<p>Luckily, these helper objects have a reference to their render object, accessible via the <code>m_renderer</code> instance variable. This allows us to make one more change to our code which will allow it to compile:</p>
<pre class="brush: cpp; title: ; notranslate">
Color color;
color.setRGB(255, 0, 0);
paintInfo.context-&gt;setStrokeColor(color, m_renderer-&gt;style()-&gt;colorSpace());
paintInfo.context-&gt;strokeRect(overflowRect, 2);
</pre>
<p>And then you can see the InlineFlowBoxes in all their glory:</p>
<p style="text-align: center;"><img class="aligncenter" title="Inline Flow Box Instrumented" alt="" src="http://blogs.adobe.com/webplatform/files/2013/01/1359530061.jpg" width="600" height="382" align="centered" /></p>
<h2>What&#8217;s next?</h2>
<p>If you didn&#8217;t get a working build before reading the whole thing, I would suggest going back, setting up a build, and then trying out the code. It really is a great way to learn how layout (and even a bit of painting) works.</p>
<p>If you have a working build and were following along at home, you should try instrumenting the paint methods of some of the other classes in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/?rev=141611">Source/WebCore/rendering</a> (<a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/InlineBox.cpp?rev=141611#L219">InlineBox</a> and <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/InlineTextBox.cpp?rev=141611#L484">InlineTextBox</a> are good places to start), and see how these classes map to the visual elements of a web page. You might be surprised by what you discover.</p>
<p>And if that isn&#8217;t enough for you, there are plenty of issues on <a href="http://bugs.webkit.org/">bugs.webkit.org</a> that you could dig into. (And if you can&#8217;t find something you find interesting there, I&#8217;m sure that someone on the <a href="irc://irc.freenode.net/#webkit">#webkit channel on irc.freenode.net</a> could give suggestions.) After all, there&#8217;s no better way to learn than to really work with the code.</p>
<p>Of course, I will be also writing more posts here as well. Stay tuned for my next post on WebKit&#8217;s layout tests and the infrastructure that runs them.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/02/05/a-visual-method-for-understanding-webkit-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Introduction to the Performance-Tests in WebKit</title>
		<link>http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/#comments</comments>
		<pubDate>Thu, 24 Jan 2013 17:01:08 +0000</pubDate>
		<dc:creator>Zoltan Horvath</dc:creator>
				<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2597</guid>
		<description><![CDATA[In this post I would like to give a short overview of WebKit’s performance and memory testing framework. Along with a bunch of WebKit geeks, I have been involved in the development process for a while, mostly from the side of contributions to memory-measurement. If I were to summarize the evolution of performance tests in...]]></description>
				<content:encoded><![CDATA[<p>In this post I would like to give a short overview of WebKit’s performance and memory testing framework. Along with a bunch of WebKit geeks, I have been involved in the development process for a while, mostly from the side of contributions to memory-measurement.</p>
<p>If I were to summarize the evolution of performance tests in WebKit, I&#8217;d starting with the early ages when we had JavaScript performance tests only for JavaScriptCore (<a href="http://trac.webkit.org/browser/trunk/PerformanceTests/SunSpider" target="_blank" shape="rect">SunSpider test suite</a>) and we had another set of tests for V8 (<a href="http://trac.webkit.org/browser/trunk/PerformanceTests/SunSpider/tests/v8-v6" target="_blank" shape="rect">V8 test suite</a>). We also had a ton of layout tests, which could give performance feedback, but had purposes other than performance testing. You can say at this point: &#8220;Hey, stop! There are benchmark sites and suites all around online!&#8221; I totally agree with this, but we needed something more Web-Engine specific, something for testing WebKit itself (including the JavaScript engine and the Web engine) instead of the browser that is built above WebKit.</p>
<p>Let&#8217;s distinguish between online benchmarks for <em>browser-level</em> performance (e.g. <a href="http://www.chromium.org/developers/testing/chromium-build-infrastructure/performance-test-plots" target="_blank" shape="rect">Chromium performance testing</a>) and the <em>engine-level</em> performance tests. <em>Engine-level</em> performance tests do not test the browser or the underlying platform&#8217;s graphical performance, they intend to test a part of a specific component of the <em>web-engine</em> (e.g. parse time of the HTML parser or runtime of the layout-system for floating containers). <em>Browser-level</em> performance tests usually do complex things that most likely try to use more components of the web-engine. Usually the goal is with these tests to reproduce some kind of real browsing behavior to measure the browser&#8217;s response time. This post is only about the <em>engine-level</em> testing.</p>
<p><a href="http://trac.webkit.org/browser/trunk/PerformanceTests" target="_blank" shape="rect">Engine Level Performance Tests </a>have been in WebKit trunk for more than a year now. We improved the system a lot in the last year (e.g. we added support for memory measurements in <a href="https://bugs.webkit.org/show_bug.cgi?id=78984" target="_blank" shape="rect">WebKit Bug #78984</a>), so I think it is time to blog about it to a wider audience. Although work on the system is still in progress, it’s already capable both of demonstrating improvements or catching both performance and memory regressions.</p>
<p>In the first part of this entry, I want to give you a short introduction to the system and a short description how you can use the testing infrastructure. In the second part I intend to talk about the continuous performance measuring system and its online visualizer - <a href="http://webkit-perf.appspot.com/" target="_blank" shape="rect">the performance-test website</a>. If you follow carefully I&#8217;m sure you get some information about our super-exciting future plans!</p>
<h2>What is a performance test in WebKit?</h2>
<p>&nbsp;</p>
<p>Our performance tests measure the run-time performance and the memory usage of WebKit. In all the test cases we start the measurement before the concrete test (the function, the animation, the page loading) starts and stop it when it finishes. Although measuring performance and memory sound pretty straightforward, it can be deceptively difficult. For example, what do we mean by run-time performance? The right answer depends on the test itself. The animation performance-tests produce frame per second values (fps). The tests that measure the runtime of different JS functions (DOM manipulation, page loading, etc.) can produce either milliseconds (ms) or runs per second (run/s). If we really want to understand the meaning of a specific set of performance measurements, we need to look deeper at the actual test cases, but that&#8217;s not goal of this post. C&#8217;mon, this is just an introduction!</p>
<p>The memory consumption tests produce two values. The first one is the general heap usage of WebKit (memory allocated through the FastMalloc interface) and the second is the heap usage of JavaScript (memory allocated by the actual JavaScript engine). We count all of our raw memory results in bytes, but as you will see it later on the result pages, we display them in kilobytes.</p>
<p>Both the performance and the memory results are produced via the JavaScript engine. All of our performance-tests are JavaScript-based except the Webpage Replay Tests (you can read about them on the <a href="http://trac.webkit.org/wiki/Performance%20Tests" target="_blank" shape="rect">related page in WebKit trac</a>). We experimented with other approaches like C++ and Python, but the JavaScript one was the most general over the different WebKit ports, so we stayed with it.</p>
<h2>How to run performance tests in WebKit?</h2>
<p>&nbsp;</p>
<p>It&#8217;s time do some actual experiments! We have a script to run performance tests, it is located under the <a href="http://trac.webkit.org/browser/trunk/Tools/Scripts" target="_blank" shape="rect">trunk/Tools/Scripts</a> directory called <a href="http://trac.webkit.org/browser/trunk/Tools/Scripts/run-perf-tests" target="_blank" shape="rect">run-perf-tests</a>. I assume you have a WebKit build (if you don&#8217;t have a WebKit build, there is a <a href="http://trac.webkit.org/wiki#WebKitPorts" target="_blank" shape="rect">documentation how to set one up</a>), so to run all performance tests (located under <a href="http://trac.webkit.org/browser/trunk/PerformanceTests" target="_blank" shape="rect">trunk/PerformanceTests</a>) you only need to run that script (different ports require additional parameters, for the details check out the <em>&#8211;platform</em> parameter). Because running all the tests can take long time, you can restrict the number of the tests run by specifying some directories or a list of tests as a parameter for run-perf-tests.</p>
<p>The script produces pretty straightforward output:</p>
<p>&nbsp;</p>
<pre style="font-size: 11pt; background-color: black; padding: 15px; color: gainsboro;">Running Bindings/set-attribute.html (18 of 115)
DESCRIPTION: This benchmark covers 'setAttribute' in Dromaeo/dom-attr.html and
             other DOM methods that return an undefined.
RESULT Bindings: set-attribute= 670.696533834 runs/s
median= 670.967741935 runs/s, stdev= 4.72565174943 runs/s, 
        min= 663.265306122 runs/s, max= 677.966101695 runs/s
RESULT Bindings: set-attribute: JSHeap= 57804.8 bytes
median= 57832.0 bytes, stdev= 1283.97383151 bytes, 
        min= 54112.0 bytes, max= 59296.0 bytes
RESULT Bindings: set-attribute: Malloc= 1574148.0 bytes
median= 1572772.0 bytes, stdev= 3346.56713349 bytes, 
        min= 1568992.0 bytes, max= 1584504.0 bytes
Finished: 16.537399 s</pre>
<p>&nbsp;</p>
<p>The output contains all the things that we are interested in, like test names, descriptions (if they exist) and the performance and memory results. By default after the warm-up run, we run each test 20 times (<a href="http://trac.webkit.org/browser/trunk/Tools/DumpRenderTree" target="_blank" shape="rect">DumpRenderTree</a> / <a href="http://trac.webkit.org/browser/trunk/Tools/WebKitTestRunner" target="_blank" shape="rect">WebKitTestRunner</a>) to provide a stable result.</p>
<p>After the script has finished the testing, in addition to the console output we get a nice HTML based table with all of our results. The results in the table show the average values and their deviation for each test. If the result is not stable enough we also get a nice sign.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/results_table/" rel="attachment wp-att-2598"><img class="size-full wp-image-2598 aligncenter" alt="results_table" src="http://blogs.adobe.com/webplatform/files/2013/01/results_table.png" width="711" height="333" /></a></p>
<p>&nbsp;</p>
<p>It&#8217;s possible to switch between the Time and the Memory view and reorder the results. If we are interested in a specific test, we can select it to see more details, as the screenshot below.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/results_table_detailed-2/" rel="attachment wp-att-2612"><img class="aligncenter" alt="results_table_detailed" src="http://blogs.adobe.com/webplatform/files/2013/01/results_table_detailed1.png" width="712" height="461" /></a></p>
<h2>How to compare performance results?</h2>
<p><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/results_table_detailed-2/" rel="attachment wp-att-2612"><br />
</a>Let&#8217;s see a simple workflow: we have a clean WebKit repository with a build. We run all the performance-tests and we want to compare the results with our modified WebKit. Since we store all the performance results by default in the <em>WebKitBuild/Release/PerformanceTestsResults.json</em> file, it&#8217;s very simple to compare the results&#8230; You just need to apply your patch to the repository, rebuild WebKit and run performance-tests again. After the rerun, the results HTML page contains a new column and shows all the new and old results in the same table. You can repeat the measurement as many times as you wish, each run will add a new column to your results. Additionally, you can use compare different repositories or specify another file for storing the results. You can find additional details if you run the <em>run-perf-tests &#8211;help</em> command.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/results_table_compare/" rel="attachment wp-att-2600"><img class="size-full wp-image-2600 aligncenter" alt="results_table_compare" src="http://blogs.adobe.com/webplatform/files/2013/01/results_table_compare.png" width="712" height="334" /></a></p>
<p>&nbsp;</p>
<p>This way you can easily test the effect of your changes. Furthermore the results table will inform you about your improvements and regressions in a simple and clear way.</p>
<h2>Continuous performance and memory results online</h2>
<p>&nbsp;</p>
<p>Each platform has its own performance bot (<a href="http://build.webkit.org/waterfall?show=Apple%20Lion%20Release%20%28Perf%29&amp;show=Apple%20MountainLion%20Release%20%28Perf%29&amp;show=Chromium%20Linux%20Release%20%28Perf%29&amp;show=Chromium%20Mac%20Release%20%28Perf%29&amp;show=Chromium%20Win%20Release%20%28Perf%29&amp;show=Qt%20Linux%2064-bit%20Release%20%28Perf%29&amp;show=Qt%20Linux%2064-bit%20Release%20%28WebKit2%20Perf%29" target="_blank" shape="rect">build.webkit.org</a>) that provides continuous performance measurements and test results are submitted to <a href="http://webkit-perf.appspot.com/" target="_blank" shape="rect">​http://webkit-perf.appspot.com/</a>.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/perfomatic_front/" rel="attachment wp-att-2601"><img class="size-full wp-image-2601 aligncenter" alt="perfomatic_front" src="http://blogs.adobe.com/webplatform/files/2013/01/perfomatic_front.png" width="712" height="404" /></a></p>
<p>&nbsp;</p>
<p>I think the most useful feature of the Perf-O-Matic system is the Custom Charts section. With the help of Custom Charts, we are able to make custom queries to check out, compare, and investigate individual test results that run on the performance bots in the past. This way we can verify improvements or catch regressions on the individual test level. See below for an example test evaluating CSS property setters and getters by setting all the possible CSS properties to a pre-defined value and access properties through JavaScript.</p>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/perfomatic_custom_test/" rel="attachment wp-att-2602"><img class="size-full wp-image-2602 aligncenter" alt="perfomatic_custom_test" src="http://blogs.adobe.com/webplatform/files/2013/01/perfomatic_custom_test.png" width="712" height="531" /></a></p>
<p>&nbsp;</p>
<p>You can find several useful pieces of information in the chart above. We always want to know the name of the test, the port that we have tested, the difference to the previous measurement, the SVN revision and the date of the measurement. All of this information is located on a nice zoomable chart. Take some time to play with the charts, I&#8217;m pretty sure that you will also find it useful. We are planning to update this system to a newer version soon, so more useful features are coming!</p>
<h2>Looking into the future of performance measurements</h2>
<p>&nbsp;</p>
<p>After we further stabilize the continuous performance testing system (<a href="https://bugs.webkit.org/show_bug.cgi?id=77037" target="_blank" shape="rect">WebKit Bug #77037</a>) and we can identify a well-defined set of tests with low deviation and meaningful results (<a href="https://bugs.webkit.org/show_bug.cgi?id=105003" target="_blank" shape="rect">WebKit Bug #105003</a>), we are planning to add a performance-testing Early Warning System support to Bugzilla. The system will report the possible performance and memory regressions for the uploaded patches automatically in a Bugzilla comment, so it will work just like the build/layout Early Warning System. It will help to improve the quality of our developments in WebKit a lot. It sounds cool, doesn&#8217;t it?</p>
<p>I hope you enjoyed this little introduction to the WebKit Performance Test system and its online visualizer, and that you will try some of these tools.</p>
<h2>Links</h2>
<p>&nbsp;</p>
<div>
<ul>
<li><a href="http://trac.webkit.org/wiki/Performance%20Tests" target="_blank" shape="rect">WebKit Performance Tests &#8211; technical page in the wiki</a></li>
<li><a href="http://webkit-perf.appspot.com/" target="_blank" shape="rect">Continuous Performance Testing Results page</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/01/24/introduction-to-the-performance-tests-in-webkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started With the WebKit Layout Code</title>
		<link>http://blogs.adobe.com/webplatform/2013/01/21/getting-started-with-the-webkit-layout-code/</link>
		<comments>http://blogs.adobe.com/webplatform/2013/01/21/getting-started-with-the-webkit-layout-code/#comments</comments>
		<pubDate>Mon, 21 Jan 2013 17:09:36 +0000</pubDate>
		<dc:creator>Bem Jones-Bey</dc:creator>
				<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2448</guid>
		<description><![CDATA[I am a newcomer to the world of WebKit. Before starting here at Adobe I had never even looked at the source code, so I had quite a bit of learning to do once I started. I&#8217;ve done a few things in WebKit since then, but I&#8217;m definitely still in the early stages – it...]]></description>
				<content:encoded><![CDATA[<p>I am a newcomer to the world of WebKit. Before starting here at Adobe I had never even looked at the source code, so I had quite a bit of learning to do once I started. I&#8217;ve done <a href="https://bugs.webkit.org/buglist.cgi?query_format=advanced&amp;short_desc_type=allwordssubstr&amp;short_desc=&amp;long_desc_type=substring&amp;long_desc=&amp;bug_file_loc_type=allwordssubstr&amp;bug_file_loc=&amp;keywords_type=allwords&amp;keywords=&amp;bug_status=RESOLVED&amp;resolution=FIXED&amp;emailassigned_to1=1&amp;emailtype1=substring&amp;email1=bjonesbe%40adobe.com&amp;emailassigned_to2=1&amp;emailreporter2=1&amp;emailcc2=1&amp;emailtype2=substring&amp;email2=&amp;bugidtype=include&amp;bug_id=&amp;chfieldfrom=&amp;chfieldto=Now&amp;chfieldvalue=&amp;cmdtype=doit&amp;order=Reuse+same+sort+as+last+time&amp;field0-0-0=noop&amp;type0-0-0=noop&amp;value0-0-0=">a few things in WebKit</a> since then, but I&#8217;m definitely still in the early stages – it is a large, complex project! <a href="http://arunpatole.com/blog/2011/webkit-documentation/">WebKit has a lot of documentation</a>, but due to the rapid pace of change in the code base, much of it is very high level or outdated. As a beginner, I found this to be rather challenging when trying to learn the ins and outs of the layout system.</p>
<p>Out of this challenge grew the desire to do make it less challenging for others, and help my learning process at the same time. I&#8217;ve found that the best way to learn something is to explain it to someone else, so I am beginning a series of posts about learning WebKit and WebKit layout. This first post will focus on the basics and pointers to documentation that has helped me along the way. Note that I assume that you have a working knowledge of HTML, CSS, and JavaScript. I also assume that you have a knowledge of C languages, as WebKit itself is written in C++. You shouldn&#8217;t need any great knowledge of C++ to follow along, but you will definitely need to learn C++ if you want to contribute to the code.</p>
<h2>What is WebKit?</h2>
<p>The first thing that may stump a beginner is quite simply the definition of WebKit itself. WebKit is not a browser, it is a rendering engine. Web browsers use a rendering engine to translate from the code that is written by developers into the visual representation familiar to end users. WebKit is used in many different browsers, from Chrome and Safari to the Playstation 3.</p>
<p>In order to support all of these platforms, the WebKit code base is separated into platform dependent code and platform independent code. Things like reading HTML and CSS, executing JavaScript, and figuring out where different elements should be drawn on the screen (layout) are shared between all of the platforms. However, things like networking and drawing on the screen are implemented differently for each platform (or &#8220;port&#8221; in WebKit speak), because each platform has its own way of doing these things.</p>
<p>WebKit is further separated into components for different functions:</p>
<p><img class="aligncenter size-full wp-image-2469" style="display: block; margin-right: auto; margin-left: auto;" alt="Webkit Block Diagram" src="http://blogs.adobe.com/webplatform/files/2013/01/Webkit-Block-Diagram1.png" width="344" height="326" /></p>
<p>WebKit is not only the name of the entire project, it is also the name of the API that&#8217;s used by browsers and other applications. There is a second version of this API, called WebKit2, which was developed to bring multi-process capabilities to WebKit. JavaScriptCore is the JavaScript engine that comes with WebKit, but many browsers replace it with their own implementations. The part of the system responsible for layout is WebCore, which also covers everything to do with CSS, HTML, the DOM, rendering, and more. All of these are built on top of WTF (Web Template Framework), which is a utility library containing things like common data structures and threading primitives.</p>
<h2>What is Layout?</h2>
<p>When WebKit consumes a web page, it generates a DOM tree from the HTML source. The details of how this is done are outside the scope of this post, but there is an <a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/">excellent article that describes the general workings and data structures behind both WebKit and Gecko</a> and is highly recommended reading. The task of layout is to examine the DOM tree and determine the size and position of all of the elements so that the rendering step can then draw them.</p>
<h3>Understanding the rules of layout</h3>
<p>Unfortunately, the mechanics of layout are much too complex to summarize here. The current standard rules for laying out content are defined in the <a href="http://www.w3.org/TR/CSS2/">CSS 2.1 Specification</a>, but that can be very hard to understand for the uninitiated. Both <a href="http://docs.webplatform.org/wiki/guides/the_css_layout_model">Web Platform Docs</a> and <a href="https://developer.mozilla.org/en-US/docs/CSS/Visual_formatting_model">Mozilla Developer Network</a> have more accessible descriptions of the rules for layout. Most of what is in these documents should be familiar to seasoned web developers, as it is impossible to get a web site to behave the way you want without understanding how things will get placed on the page. While these are not a substitute for reading the spec if you are a browser implementer, being familiar with the concepts makes the spec much easier to read.</p>
<p>The W3C (the organization that defines many of the standards for the web) acknowledges that the CSS standard can be hard to read, and provides <a href="http://www.w3.org/Style/CSS/read">a helpful guide</a> to reading the CSS specifications. The most important sections of the spec for a developer working in WebKit&#8217;s layout engine are <a href="http://www.w3.org/TR/CSS2/box.html">Box model</a>, <a href="http://www.w3.org/TR/CSS2/visuren.html">Visual formatting model</a>, and <a href="http://www.w3.org/TR/CSS2/visudet.html">Visual formatting model details</a>. Many of the variable and function names in WebKit&#8217;s layout code are taken straight out of the specification, so knowing the terminology can greatly help with understanding the system.</p>
<p>As you get more into the layout code, you will find things that are not specified in CSS 2.1, as WebKit has already started implementing features from CSS 3. Unlike CSS 2.1, CSS 3 isn&#8217;t a single specification, as it has been broken into modules for each feature area. The modules are all versioned independently, so there isn&#8217;t really a canonical list of what makes up CSS 3. The <a href="http://www.w3.org/Style/CSS/current-work.en.html">CSS current work</a> page at the W3C is a very good place to see what the latest status of the specifications are.</p>
<h2>How is layout done in WebKit?</h2>
<p>While understanding the other parts of the spec are very useful, once you have an understanding of the <a href="http://www.w3.org/TR/CSS2/box.html">CSS Box Model</a>, you should be able to dive in and understand much of the layout code.</p>
<p>I said earlier that layout is done on the DOM tree, which isn&#8217;t entirely true. Before starting layout, a tree of render objects is created. Most DOM elements get corresponding render objects, but some special ones like head and elements with display: none don&#8217;t have renderers, since they have no visual representation. Also, some elements get more than one renderer. For example, when text must be wrapped to fit into the width of its container, a new render object is created for each line, even though there is only one DOM element for the run of text. The following diagram shows a simplified version of the render tree and it&#8217;s relation to the DOM tree:</p>
<p><img class="aligncenter size-full wp-image-2450" style="display: block; margin-right: auto; margin-left: auto;" alt="DOM and Render Trees" src="http://blogs.adobe.com/webplatform/files/2013/01/DOM-and-Render-Trees.png" width="531" height="390" /></p>
<p>The layout process is managed by the FrameView C++ class, which can start layout from the root of the render object tree (a full layout), or from a subtree (a partial layout). Full layout is the most common, as partial layout can only be done when it is certain that laying out the subtree cannot affect any elements that are not part of that subtree. For example, partial layout is used for when text fields are updated by the user typing in new text.</p>
<p>Regardless of if a full or partial layout is initiated, once the layout method is called on the renderer at the root of the tree (or subtree), it follows this recursive algorithm:</p>
<ol style="margin-left: 3em;">
<li style="margin-bottom: 0;">The current renderer computes its width.</li>
<li style="margin-bottom: 0;">For each child, the current renderer:
<ol style="margin-bottom: 0;">
<li style="margin-bottom: 0;">Determines the position of the child.</li>
<li style="margin-bottom: 0;">Asks the child to compute its dimensions.</li>
</ol>
</li>
<li style="margin-bottom: 0;">The current renderer computes its height.</li>
</ol>
<p>Of course there are exceptions and special cases to this, which are as complex as the rules for layout themselves. For much more detail, you should read the <a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#Render_tree_construction">render tree construction</a> and the <a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#Layout">layout</a> sections of <a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/">How Browsers Work</a>.</p>
<p>Once the layout process has finished, the tree can then be drawn. Each render object has a paint method to accomplish this, but that&#8217;s no longer layout and thus outside of the scope of this post.</p>
<h3>That&#8217;s great, but how does this match up with the code?</h3>
<p>It can be a bit dangerous to give links to specific parts of the WebKit code base, as it changes so rapidly that the links are soon out of date. Thus, I will stick to generalizations here. The C++ classes that make up the DOM tree live under <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/dom">Source/WebCore/dom</a>, while the render classes live in <a href="http://trac.webkit.org/browser/trunk/Source/WebCore/rendering">Source/WebCore/rendering</a>. Instead of duplicating what has already been written, I will defer to Dave Hyatt&#8217;s blog post on <a href="https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/">Layout and Rendering Basics</a> for a list of the major C++ classes that are used in the layout process. The links in his post are broken, but the names of the classes and the files that contain them are the same. (You can look in the directories I mentioned above for the classes, or just insert &#8220;Source/&#8221; in the URLs between &#8220;trunk/&#8221; and &#8220;WebCore/&#8221;.)</p>
<p>The <a href="https://www.webkit.org/blog/114/webcore-rendering-i-the-basics/">basics article</a> is the first in a <a href="http://www.webkit.org/projects/layout/index.html">series of blog posts</a> that Dave Hyatt wrote about WebKit layout. They are a bit old and incomplete, but are one of the most useful sources of information about WebKit layout.</p>
<p>I would be remiss if I didn&#8217;t mention Eric Seidel&#8217;s <a href="http://www.youtube.com/watch?v=RVnARGhhs9w">talk on rendering in WebKit</a>. It is of more recent vintage than Hyatt&#8217;s blog posts, and packs a lot of knowledge into a 30 minute presentation.</p>
<h2>What now?</h2>
<p>If that didn&#8217;t give you enough reading, I&#8217;ll be following up with a post on <a href="http://blogs.adobe.com/webplatform/2013/02/05/a-visual-method-for-understanding-webkit-layout/">a way to visualize which render classes are responsible for which parts of the page</a>. After that, I intend to cover layout tests and DumpRenderTree. And you&#8217;ll just have to stay tuned to find out what happens after that! I&#8217;ll be sure to update this post with links to the future posts in this series.</p>
<h2>Links</h2>
<p>There are a lot of links in this article, so here&#8217;s a section listing the important ones for your convenience.</p>
<ul>
<li><a href="http://arunpatole.com/blog/2011/webkit-documentation/">Arun Patole&#8217;s blog post on WebKit documentation</a>. This is an amazingly comprehensive list of WebKit documentation, and not just for layout.</li>
<li><a href="http://www.html5rocks.com/en/tutorials/internals/howbrowserswork/">How Browsers Work</a>: comprehensive explanation of the workings of both WebKit and Gecko.</li>
<li><a href="http://www.webkit.org/projects/layout/index.html">Dave Hyatt&#8217;s Layout Blogs</a>: Layout and rendering explained by the master.</li>
<li><a href="http://www.youtube.com/watch?v=RVnARGhhs9w">Eric Seidel&#8217;s talk on WebKit rendering</a>: More on layout and rendering by an expert in a 30 minute talk.</li>
<li><a href="http://www.w3.org/TR/CSS2/">CSS 2.1 Specification</a>: The definition on how layout should work.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2013/01/21/getting-started-with-the-webkit-layout-code/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Exclusion Shape Coordinates Get Logical</title>
		<link>http://blogs.adobe.com/webplatform/2012/12/19/exclusion-shape-coordinates/</link>
		<comments>http://blogs.adobe.com/webplatform/2012/12/19/exclusion-shape-coordinates/#comments</comments>
		<pubDate>Thu, 20 Dec 2012 00:36:07 +0000</pubDate>
		<dc:creator>bear</dc:creator>
				<category><![CDATA[Exclusions]]></category>
		<category><![CDATA[WebKit]]></category>
		<category><![CDATA[exclusions]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=2330</guid>
		<description><![CDATA[Until recently, the code for calculating intersections between lines and exclusion shapes was using its own coordinate system. This was in addition to the two main coordinate systems used in WebKit, physical and logical (sometimes called abstract) from the CSS Writing Modes Specification. After some mulling, Hans decided to do some additional up-front processing and...]]></description>
				<content:encoded><![CDATA[<p>Until recently, the code for calculating intersections between lines and exclusion shapes was using its own coordinate system. This was in addition to the two main coordinate systems used in WebKit, physical and logical (sometimes called abstract) from the <a href='http://dev.w3.org/csswg/css3-writing-modes/#abstract-box'>CSS Writing Modes Specification</a>. After some mulling, Hans decided to do some additional up-front processing and use logical coordinates rather than our own home-brewed variety. As it turns out, two coordinate systems are plenty. Read more over at <a href='http://hansmuller-webkit.blogspot.com/2012/12/exclusionshape-coordinates-get-logical.html'>his blog</a>.</p>
<div style='text-align:center'><a class="lightbox"  title ="circular-writing-modes" href="http://blogs.adobe.com/webplatform/files/2012/12/circular-writing-modes.png"><img src="http://blogs.adobe.com/webplatform/files/2012/12/circular-writing-modes.png" alt="" title="circular-writing-modes" width="300" height="301" class="aligncenter size-full wp-image-2331" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2012/12/19/exclusion-shape-coordinates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with Built-in CSS Filters</title>
		<link>http://blogs.adobe.com/webplatform/2012/11/21/fun-with-built-in-css-filters/</link>
		<comments>http://blogs.adobe.com/webplatform/2012/11/21/fun-with-built-in-css-filters/#comments</comments>
		<pubDate>Wed, 21 Nov 2012 17:15:10 +0000</pubDate>
		<dc:creator>CJ Gammon</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[CSS Filter Effects]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=1442</guid>
		<description><![CDATA[With all the buzz around CSS Custom Filters, you&#8217;re hopefully aware of all the cool effects you can play around with in Chrome Canary using our CSS FilterLab.  While we have to wait for CSS Custom Filters to hit mainstream browsers, you can use CSS Filter Lab to play with built-in CSS filters already available...]]></description>
				<content:encoded><![CDATA[<p>With all the buzz around CSS Custom Filters, you&#8217;re hopefully aware of all the cool effects you can play around with in Chrome Canary using our <a href="http://html.adobe.com/webstandards/csscustomfilters/cssfilterlab/">CSS FilterLab</a>.  While we have to wait for CSS Custom Filters to hit mainstream browsers, you can use CSS Filter Lab to play with built-in CSS filters already available in most WebKit browsers today, including Chrome, Safari, and even Mobile Safari on iOS6.  These come to us from the world of SVG, where built-in filter shortcuts could be applied to SVG elements, but we will focus on the CSS specification here.  Built-in filters are easy to use by simply applying the filter property and using a filter function, which accepts a value as a parameter.  This is very similar to how <a href="http://dev.w3.org/csswg/css3-transforms/#transform-functions">CSS Transforms work</a>. You can even apply multiple filters in the same filter property, the same way you can apply multiple transforms.  In these examples, I will be using the un-prefixed filter property, but current release versions of Chrome and Safari use the <code>-webkit-</code> experimental prefix.</p>
<h2>Photo Filter Demo</h2>
<p>It is possible to combine these filter functions in interesting ways to simulate complex photo filter effects.  You can extend the visuals even further by layering the same element at varying opacity with different filters applied.  We used a combination of filter functions to create a Photo Filter demo that we showcased at <a href="http://blogs.adobe.com/webplatform/2012/09/24/create-the-web-in-action/">The Create The Web event in SF</a>. This demo is <a href="https://github.com/adobe/iphone-filter-demo">now available on GitHub</a>.</p>
<p>Here is what we used to create an Old-Style photo effect:</p>
<p><code>filter: sepia(0.8) saturate(3) brightness(0.25) contrast(2);</code></p>
<table>
<tbody>
<tr>
<td>
<p><div id="attachment_1472" class="wp-caption aligncenter" style="width: 296px"><img class="size-full wp-image-1472 " title="before" src="http://blogs.adobe.com/webplatform/files/2012/10/before.png" alt="" width="286" height="564" /><p class="wp-caption-text"><strong>Before</strong></p></div></td>
<td>
<p><div id="attachment_1473" class="wp-caption aligncenter" style="width: 296px"><img class="size-full wp-image-1473" title="after" src="http://blogs.adobe.com/webplatform/files/2012/10/after.png" alt="After" width="286" height="564" /><p class="wp-caption-text"><strong>After</strong></p></div></td>
</tr>
</tbody>
</table>
<p>You can use many other built-in filter effects in tandem. The available built-in filters are:</p>
<ul>
<li>grayscale</li>
<li>sepia</li>
<li>saturate</li>
<li>brightness</li>
<li>contrast</li>
<li>opacity</li>
<li>invert</li>
<li>hue-rotate</li>
<li>blur</li>
<li>drop-shadow</li>
</ul>
<p><a href="https://github.com/adobe/iphone-filter-demo">Take a look at our code</a> to find many ways these functions can be used to create complex photo filters. You can also read more about the built-in filters and their values in the <a href="https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#FilterFunction">specification</a>.</p>
<p>As built-in CSS Filters are already available in Chrome, Safari, &#038; Mobile Safari on iOS, you can start playing with them today and see how they can be used to enhance your web application. The <a href="http://html.adobe.com/webstandards/csscustomfilters/cssfilterlab/">CSS FilterLab</a> is a great resource to play with filters and instantly see the results. </p>
<p>Have you been playing with Filter effects? Please do share your code samples with us in the comments! </p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2012/11/21/fun-with-built-in-css-filters/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Capitalization change for regionlayoutupdate</title>
		<link>http://blogs.adobe.com/webplatform/2012/11/12/capitalization-change-for-regionlayoutupdate/</link>
		<comments>http://blogs.adobe.com/webplatform/2012/11/12/capitalization-change-for-regionlayoutupdate/#comments</comments>
		<pubDate>Mon, 12 Nov 2012 19:11:05 +0000</pubDate>
		<dc:creator>Alan Stearns</dc:creator>
				<category><![CDATA[Regions]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=1956</guid>
		<description><![CDATA[If you have been experimenting with CSS Regions in Chrome Canary or some other browser built from WebKit trunk, there has been a minor change you may need to account for. If you have code that used the regionLayoutUpdate event, note that the capitalization of this event has changed to regionlayoutupdate to match other DOM...]]></description>
				<content:encoded><![CDATA[<p>If you have been experimenting with <a href="http://dev.w3.org/csswg/css3-regions/">CSS Regions</a> in <a href="https://tools.google.com/dlpage/chromesxs">Chrome Canary</a> or some other browser built from WebKit trunk, there has been a minor change you may need to account for.</p>
<p>If you have code that used the <strong>regionLayoutUpdate</strong> event, note that the capitalization of this event has changed to <strong>regionlayoutupdate</strong> to match other <a href="http://www.w3.org/TR/DOM-Level-3-Events/">DOM Level 3</a> events like mouseover and compositionupdate. The event in the latest WebKit builds is now <strong>webkitregionlayoutupdate</strong>, a change tracked in WebKit bug <a href="https://bugs.webkit.org/show_bug.cgi?id=100335">100355</a>. If your code using the event suddenly stops working with a new WebKit build, this is likely the culprit.</p>
<p>And remember the CSS Regions functionality remains behind a <a href="http://blogs.adobe.com/webplatform/2012/09/18/new-flag-for-css-regions-in-chrome-canary/">run-time flag</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2012/11/12/capitalization-change-for-regionlayoutupdate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>European WebKit hackathon wrap-up</title>
		<link>http://blogs.adobe.com/webplatform/2012/10/01/european-webkit-hackathon-wrap-up/</link>
		<comments>http://blogs.adobe.com/webplatform/2012/10/01/european-webkit-hackathon-wrap-up/#comments</comments>
		<pubDate>Mon, 01 Oct 2012 16:04:20 +0000</pubDate>
		<dc:creator>miChou</dc:creator>
				<category><![CDATA[Community Events]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[hackathon]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://blogs.adobe.com/webplatform/?p=1396</guid>
		<description><![CDATA[Between September 22nd and September 24th the Adobe WebKit team in Bucharest organized and hosted an European WebKit hackathon. Why a WebKit hackathon? And an European one for that, you might ask. Well, there are a couple of reasons, having to do with both building code and building communities. Open source projects, more than “closed”...]]></description>
				<content:encoded><![CDATA[<p><a class="lightbox" title="the hackathon gang" href="http://blogs.adobe.com/webplatform/files/2012/10/DSC_4711-mic.jpg"><img class="aligncenter size-large wp-image-1400" title="the hackathon gang" src="http://blogs.adobe.com/webplatform/files/2012/10/DSC_4711-mic-1024x586.jpg" alt="" width="1024" height="586" /></a></p>
<p>Between September 22nd and September 24th the Adobe WebKit team in Bucharest organized and hosted an European WebKit hackathon.</p>
<h2>Why a WebKit hackathon?</h2>
<p>And an European one for that, you might ask. Well, there are a couple of reasons, having to do with both building code and building communities.</p>
<p><span id="more-1396"></span>Open source projects, more than “closed” projects, need to have at their core a community of people that know, understand and respect each other &#8211; technically and, to some extent, personally, too. While it’s possible to meet and be part of the community via the Internet, sometimes direct, face to face interaction can go a long way in helping to understand each other’s position, interests and opinions as well as their skills and areas of expertise.</p>
<p>As such, a WebKit hackathon proved to be the perfect environment for contributing to WebKit &#8211; both in terms of code but also in terms of better understanding the contributions and interests of different contributing entities, be it companies or individuals. Hacking sessions were interspersed with presentations and talks about different on-going efforts &#8211; ranging from “administrative” tasks to ongoing specification efforts and less common use-cases for WebKit.</p>
<h2>European webkittens</h2>
<p>With more than 25 people expressing interest in the hackathon, in the end 20 people attended the event &#8211; a mix of developers from Intel, Samsung USA, Igalia (Spain) and the University of Szeged (Hungary) and Adobe employees from US and Romania.<br />
The first day debuted with presentations by each team about their work in WebKit and their areas of interest for the rest of the hackathon. In alphabetical order, here’s a brief description of each of these teams.</p>
<p><a href="http://html.adobe.com/"><strong>Adobe</strong></a>&#8216;s current contributions are mainly around new CSS features and their implementation in WebKit &#8211; things like <a href="http://html.adobe.com/webstandards/cssregions/">CSS Regions </a>and <a href="http://html.adobe.com/webstandards/cssexclusions/">Exclusions</a>, <a href="http://html.adobe.com/webstandards/csscompositing/">CSS compositing</a>, <a href="http://html.adobe.com/webstandards/csscustomfilters/">CSS filters</a> and <a href="http://html.adobe.com/webstandards/csstransforms/">CSS transforms</a>. There&#8217;s also some work around the <a href="http://code.google.com/p/chromiumembedded/">Chromium Embedding Framework</a>.</p>
<p><a href="http://www.igalia.com/webkit/"><strong>Igalia</strong></a> is a company based in Spain and the main contributors/maintainers of the GTK port, their main commercial work being consulting and helping other companies embed WebKitGTK in their products. They shared some interesting insights regarding WebKit development in China and India &#8211; apparently many companies are using WebKit and hacking on it and fixing bugs, but close to none contribute back to the trunk.</p>
<p><a href="https://www.01.org/"><strong>Intel</strong></a> is investing a lot in WebKit in the context of the EFL WebKit port that is built on Linux. Besides the EFL work, Intel also significantly contributes to other areas of WebKit and Chrome such as WebAudio, enabling Chromium on Android for the x86 architecture and improving the V8 JavaScript engine.</p>
<p><strong>Samsung US</strong> is the other important contributor to the EFL port. They also have some interesting contributions around <a href="http://code.google.com/p/webcl/">WebCL</a>, working on both the spec and the implementation in WebKit. Igor showed us some nifty bits and pieces but apparently the best is yet to be announced.</p>
<p>The <a href="http://webkit.sed.hu/"><strong>University of Szeged</strong></a> is an important contributor to the Qt WebKit port and the <em>de facto</em> gardeners for it (<em>gardening</em> means making sure the bots for a certain port are green and investigating/fixing issues/logging bugs and rolling out patches when they become red). They also have students working on WebKit for other companies, through different academic collaboration programs like sponsorships and internships. Given the academic environment they’re also involved in more “researchy” projects, mainly around JavaScript optimizations (in JavaScriptCore), parallel image decoding, memory usage instrumentation and optimization.</p>
<h2>So what did we hack?</h2>
<p>Once we got to know each other a little bit better through the aforementioned presentations, there came the tricky part of deciding what to hack on for the next two days. A number of topics were proposed and in the end three groups were created, focused around SVG &amp; graphics, enabling CSS Regions on other ports and Web Inspector. The better part of the next two days was a mix of hacking, discussing approaches and ideas for the bugs we started on, a more in-depth look at Qt gardening and of course, fun and beer (in the evening!).</p>
<p>Saturday afternoon, before heading for a walk in the city, we had a demo session where everyone had the opportunity to present their work after the hackathon. Here are the highlights of this session:</p>
<h3>SVG &amp; graphics</h3>
<p><strong>Raul Hudea</strong> worked on WebKit bug <a href="https://bugs.webkit.org/show_bug.cgi?id=96381" target="_blank">#96381</a>, enabling <code>-webkit-clip-path</code> to reference fragments inside an SVG document. <strong>Andrei Bucur</strong> did some similar work, enabling use of gradients defined in an SVG document as CSS masks (think <code>-webkit-mask</code>). <strong>Dirk Schultze</strong> decided to try something different (non-SVG <img src='http://blogs.adobe.com/webplatform/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) and worked on a prototype implementation for the path object in the upcoming canvas specification.</p>
<h3>Web Inspector</h3>
<p><strong>Mirela Budaes</strong> fixed bug <a href="https://bugs.webkit.org/show_bug.cgi?id=97120" target="_blank">#97120</a> that prevented a pop-out from closing when moving the mouse outside it in certain conditions. <strong>Andrei Poenaru</strong>, one of our summer interns, continued his great work on enabling <a href="https://bugs.webkit.org/show_bug.cgi?id=90786" target="_blank">CSS Regions support in Web Inspector</a> by bringing the ability to highlight multiple elements at a time in the Elements panel one step closer to completion . As for myself, I worked on bug <a href="https://bugs.webkit.org/show_bug.cgi?id=91382" target="_blank">#91382</a>, adding the ability to comment lines in the JavaScript source editor using the <code>Cmd (Ctrl) + /</code> keyboard shortcut.</p>
<h3>CSS Regions on other ports</h3>
<p>The team spent some time on figuring out exactly how to enable and disable features both at compile time and at runtime on the different ports. The good news is that on Qt, GTK and EFL with Regions enabled, most of the regions tests already pass. There are still issues around WebKit vs. WebKit 2 as different ports ship different flavors of WebKit by default. They also set up and configured a VM that can compile and run the Qt, GTK and EFL ports with Regions enabled &#8211; very useful for testing patches before hitting the bots.</p>
<h3>Other hacks</h3>
<p>Working somehow outside of the established teams, <strong>Horia Olaru</strong> prototyped an extension to the <code>document</code> DOM API, similar to <code>document.elementFromPoint()</code> but that actually returns all the elements at the given position, not just the top-most in z-order. <strong>Alex Chiculita</strong> added the last finishing touches to the CSS FilterLab while also landing a WebKit patch and helping other hackers with his WebKit experience and reviews.</p>
<h2>What’s next?</h2>
<p>This is the first European WebKit hackathon that Adobe has sponsored. Besides the actual hacking, it was good to see the amount of interaction, learning new things about others, and drafting common lines of actions. Going forward, we’re looking forward to repeating this event, hopefully with even more contributors from more companies interested in WebKit.<br />
In the meanwhile, if you want to make the web better, and would fancy spending a couple of days with web gurus of all stripes in Beijing or Paris, be sure to check out the <a href="http://testthewebforward.org/#events">Test the Web Forward events</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.adobe.com/webplatform/2012/10/01/european-webkit-hackathon-wrap-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
