[webkit-dev] RenderObject hasLayer method
simon.fraser at apple.com
Fri Jun 12 08:11:22 PDT 2009
On Jun 12, 2009, at 7:08 AM, Scott Thompson wrote:
> On Jun 12, 2009, at 12:17 AM, Meryl Silverburgh wrote:
>> Can someone please tell me what does the 'layer' in a RenderObject
>> in other words, what does hasLayer method returns or purpose of
>> that method?
> I'm going to speculate here, but on the MacOS, there is a technology
> called "Core Animation". Core Animation allows a program to create
> rectangular graphical areas and easily animate them on the screen.
> These rectangular areas are called "Layers".
> Safari supports CSS transitions and effects which (again I
> speculate) make use of those layers to simplify their animations. I
> suspect, then, that a RenderObject, while animating, is associated
> with at least one CALayer and the "hasLayer" method would tell you
> whether or not that was, in fact, occurring.
Indeed, that is all speculation :-)
The layer() method on RenderObject (actually, it has now moved to
RenderBoxModelObject if you look at TOT) returns a RenderLayer object.
RenderLayers are responsible for painting and hit testing some subset
of the render tree that shares a common coordinate space, to put it
simply. RenderLayers "hang off" of the tree of RenderObjects, and are
themselves parented in parallel with their associated RenderObjects.
However, we build a painting order tree of RenderObjects via their z-
order lists, which controls the back-to-front painting order between
When painting happens, we start painting with the root RenderLayer,
which paints tells any RLs behind it to paint, then paints its
enclosing RenderObjects, and then tells any RLs in front of it to
paint, and this continues down the RL tree. Hit testing all uses the z-
order tree to do front-to-back hit testing.
RenderLayers get created for elements with overflow, absolute or
relative position, transforms, masks, opacity < 1 and various other
reasons. RenderLayers are used on all platforms, and have no platform-
Now we do have some support in the code for accelerated compositing,
and that does involve RenderLayers indirectly, but there is a much
more complex relationship between a RenderLayer and associated
hardware-based layers than Scott alludes to above (see the
RenderLayerCompositor/RenderLayerBacking/GraphicsLayer code for that
More information about the webkit-dev