Compute_blockSourceCSS Block layout algorithm implementation.
Implements the CSS block layout algorithm for containers with block-level children. This module computes layout for nodes using display:block, handling margin collapsing, auto-sizing, and positioning of both in-flow and absolutely positioned children.
Block layout proceeds in phases:
The algorithm handles margin collapsing via Collapsible_margin_set tracking. In-flow layout maintains two margin sets: first_child_top_margin_set for collapsing with container's top margin, and active_collapsible_margin_set for tracking bottom margins. Nodes can be "collapsed through" when they have no content, padding, border, or height constraints.
Absolutely positioned children use static position as fallback when inset properties are auto. Static position is computed during in-flow layout pass even though the child is not placed in normal flow.
Scrollbar gutters are reserved in the opposite axis (vertical scroll reserves horizontal space). Tables receive special treatment and do not participate in stretch-sizing.
val compute_block_layout :
(module Tree.LAYOUT_PARTIAL_TREE with type t = 't) ->
't ->
Tree.Node_id.t ->
Tree.Layout_input.t ->
Tree.Layout_output.tcompute_block_layout tree_module tree node_id inputs computes block layout for node_id.
Implements CSS block layout with margin collapsing, auto-sizing, and absolute positioning. Returns Layout_output containing final size, content size, and margin collapse state.
Algorithm:
The implementation tracks margin collapsing state through Collapsible_margin_set. Vertical margins of adjacent in-flow blocks collapse when separated only by collapsible space. Auto horizontal margins expand to fill available space. Absolute children use static position when inset is auto.