Repository navigation
fix(layout): keep block axis unconstrained for abs-pos auto height - #46
Conversation
There was a problem hiding this comment.
Unconditionally clearing the block-axis max_content also removes the explicit max-height constraint needed to calculate the intrinsic width of a wrapping column flex container.
Inside a 200px × 200px positioned containing block, use:
.container {
position: absolute;
top: 0;
left: 0;
display: flex;
flex-direction: column;
flex-wrap: wrap;
max-height: 100px;
}
.item {
width: 50px;
height: 60px;
flex: none;
}
With three items, the parent commit and Chrome produce a container width of 150px. This commit produces 50px, while the items still occupy three columns and overflow the container.
The initial AllSize pass measures a single column without the height constraint. The subsequent Position pass wraps the items, but the incorrect width is already fixed. Flexbox §9.9.2 requires the max-content cross size of a multiline column container to account for the resulting column widths.
Suggested fix
Remove the containing block’s remaining-space fallback from the block axis, while preserving definite sizes and resolved explicit maxima:
let max_content = min_max_limit.normalized_size(match style.writing_mode() {
WritingMode::HorizontalTb => OptionSize::new(
inline_max_content.width,
size.height.or(min_max_limit.max_height),
),
WritingMode::VerticalLr | WritingMode::VerticalRl => OptionSize::new(
size.width.or(min_max_limit.max_width),
inline_max_content.height,
),
});8f1c9be to
d409cc2
Compare
An absolutely-positioned box with
height: autowas capped by the space left in its containing block, so content taller than that space got squeezed. A column flex container inside such a box would fall back to its min-content main size and shrink items that declared an explicit height.Root cause:
compute_special_positionfilled both axes of themax_contentconstraint withcontaining block size - insets. Shrink-to-fit is inline-axis only (CSS2.1 §10.3.7); the block axis of an auto-height abs-pos box is content-determined (§10.6.4). Withbottom: 200pxinside a 0-height bar the value went negative, got floored to 0, andflex_boxthen took theavailable < max-contentbranch (min-content floor) for the column container.Fix: keep the inline-axis constraint (behaviour unchanged, still clamped by the element's own min/max), pass
Nonefor the block axis, chosen bywriting_mode.Noneis already a supported "indefinite" state for every consumer — flow containers measure content when the cross size is indefinite, and flex takesmax_content_sizewhen available space isNone.