Layouter

Computes the styles of a tree of elements and lays it out.

Layout happens in two kinds of steps. Measuring determines the size an element wants for a given containing size, it does not change any state, its results are cached for the duration of a layout pass. Arranging sets the sizes and positions of the children of an element, using the measured sizes. Every element in the flow is sized and positioned by its parent, fixed and absolute elements size and position themselves.

Sizes are border-box sizes: they include the padding and the border, but not the margins of an element. Percentages are taken of the content size of the containing element; margins and padding are always taken of its width.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard

true when style sheets have media queries

Link copied to clipboard

the elements whose styles changed properties that lay out, since updateStyles was last called

Link copied to clipboard
Link copied to clipboard

What the media queries of style sheets in @media rules are evaluated against, null when they do not apply; set it before the styles are computed

Link copied to clipboard

Functions

Link copied to clipboard
fun computeStyles(element: Element)

computes the styles of element and its descendants, all of them

Link copied to clipboard
fun height(element: Element, width: Double? = null, includeMargins: Boolean = true): Double

The height element wants inside its parent when it is width wide, including its margins when includeMargins is set.

Link copied to clipboard
fun layout(element: Element)

Lays out element and its descendants. The element is sized relative to its parent, keeping its position unless it is fixed or absolute. An element in a flex or grid container keeps the size that the container gave it, which its own style alone does not give, like a flex item that grows into the space of its parent.

Link copied to clipboard
fun marginBottom(element: Element): Double
Link copied to clipboard
fun marginLeft(element: Element): Double
Link copied to clipboard
fun marginRight(element: Element): Double
Link copied to clipboard
fun marginTop(element: Element): Double
Link copied to clipboard

the style sheets that select element, in the order of the cascade: the last wins, important declarations aside

Link copied to clipboard
fun updateStyles(element: Element, forced: Boolean = false): Int

Computes the styles of element and of the descendants whose styles can have changed: of elements whose classes, states, id or inline style changed, of their descendants, and of the children of elements whose styles changed. Elements whose computed styles changed are drawn again.

Link copied to clipboard
fun width(element: Element, includeMargins: Boolean = true): Double

The width element wants inside its parent, including its margins when includeMargins is set.