Skip to main content

Module context

Module context 

Source
Expand description

Layout context — shared state for a layout pass.

Chrome equivalent: the combination of LayoutView (document-level state) and NGLayoutAlgorithmParams (per-algorithm context).

LayoutContext is created once per layout pass and threaded through every algorithm call. It carries dependencies that algorithms need but should NOT hardcode (text measurement, font system, etc.).

§Why a struct, not individual parameters?

  1. Adding a new dependency (e.g., image loader) doesn’t change every function signature in the call chain.
  2. Algorithms can’t accidentally create their own measurer — they MUST use the one provided.
  3. Mirrors Chrome: algorithms receive context, not individual services.

Structs§

LayoutContext
Shared context for a layout pass.