Skip to main content

Module processor

Module processor 

Source
Expand description

A processor that runs the layout builder on a background thread.

build_layout_and_info_* is expensive (CSS cascade, text measurement, layout-tree construction), so it is offloaded to a background thread to keep the UI thread responsive. The builder walks a Send DomSnapshot, so the snapshot is the only input that needs to be handed to the thread.

Per-frame lightweight layout (LayoutEngine::layout) still runs on the UI thread as before. This processor only handles the heavier tree build.

Tasks are coalesced: each task carries a monotonic sequence number, and the thread skips a task as soon as a newer one has been queued. The newest task always captures the latest DOM/styles/images, so the skipped build’s work would be wasted anyway.

Structs§

LayoutProcessor
A processor that accepts a DomSnapshot and returns the layout result produced by the thread.
LayoutResult
The layout the builder finished on the background thread.
LayoutTask
The complete set of inputs the builder needs to run on the background thread.