
These positions are relative to the ancestor that is responsible for deciding where this box should be placed. I will cover this in more detail in a separate section on scrolling.īoxes also have x and y positions. The size of the scrollable area and the current scroll position can both be obtained from the RenderObject. Scrollbars are not part of the content box. A scrollbar’s size is included in the client width and client height. When a box has a horizontal or vertical scrollbar, it is placed in between the border and the padding. This is the most common walk that occurs in the render tree code.įor (RenderObject* child = firstChild() child child = child->nextSibling()) Here is an example of a loop that walks a renderer’s immediate children. The following methods are most commonly used to walk the render tree. The RenderObject for a DOM node can be obtained using the renderer() method on Node.

The base class of all render tree nodes is RenderObject. The render tree can also contain additional objects that have no corresponding DOM node. The render tree is very similar to the DOM in that it is a tree of objects, where each object can correspond to the document, elements or text nodes. Text nodes store this raw text, and the render tree can query the node for its character data.Īt the heart of rendering is the render tree. Text – Raw text that occurs in between elements gets turned into text nodes.

From a rendering perspective, an element is a node with a tag name that can be used to cast to a specific subclass that can be queried for data that the renderer needs.
#Webkit margin before code
The node types that are relevant to the rendering code are: Nodes break down into several categories. The base class for all nodes in the tree is Node.

The DOM TreeĪ Web page is parsed into a tree of nodes called the Document Object Model (DOM for short). I’ll be posting these articles as I finish them on this blog, and they will also be available in the documentation section of the Web site.
#Webkit margin before series
This is the first of a series of posts designed to help people interested in hacking on WebCore’s rendering system.
