Sign in Join
Wiki copytemporary

Fresnel CSS Algorithm

Contents

Overview

This page describes the how Fresnel parses and applies CSS, layouts and renders.

Delayed computation

Whenever an element or CSS is added, removed, altered TFresnelElement.DomChanged is called. This does not compute anything immediately in contrary to LCL or VCL. Instead a change:

Each form has its own queued call.

If you need to compute a change immediately call Form.ApplyCSS.

ApplyCSS

The article gives an overview of the order and how the CSS is parsed and computed in Fresnel. The central method is TFresnelViewport.ApplyCSS.

Collecting type stylesheets

The Viewport gathers all used type stylesheets via GetCSSTypeStyle and adds them to resolver. These have origin user-agent.

Parsing stylesheets

Each form has one Resolver: TCSSResolver. The resolver parses all stylesheets:

Collect CSS attributes for each element

The Viewport traverses all nodes (TFresnelElement) to compute basic attributes:

Box-Modell

Layout

The Viewport calls Layouter.Apply , which is TViewportLayouter.Apply.

Layout Top-Down

First all elements are traversed top-down.

Layout Final

After the top-down traversal, all fixed or relative to fixed lengths are computed.

The elements are again traversed top-down, but now the layouters can use child lengths and compute intrinsic sizes recursively. Intrinsic sizes are the width and/or height of the content ignoring the element's min/max-width/height. The intrinsic sizes are cached, so the recursion runs in linear time.

After the layout was computed, each TFresnelElement.ComputeCSSLayoutFinished is called.

Flow Layouter

Flex Layouter

Grid Layouter


From the Free Pascal wiki, page "Fresnel CSS Algorithm", as the Internet Archive kept it on 2026-01-08, last changed on 2025-11-15. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.