Description#
Implement proper inline layout in the layout crate, replacing the current simplified text wrapping with spec-compliant inline formatting context.
Acceptance Criteria#
- Implement inline formatting context (IFC):
- Inline boxes: generated by inline-level elements (
<span>,<a>,<em>,<strong>, etc.) - Line boxes: horizontal lines that contain inline boxes and text runs
- Anonymous inline boxes: for bare text not wrapped in an inline element
- Inline boxes: generated by inline-level elements (
- Text runs within inline boxes:
- Break text into words at whitespace boundaries
- Wrap lines when content exceeds containing block width
- Handle
<br>as a forced line break
- Vertical alignment within line boxes:
vertical-align: baseline(default)- Line box height determined by tallest content
- Baseline alignment of text across different font sizes
- Inline box model:
- Inline elements can have margin, padding, border (left/right applied, top/bottom don't affect line height)
- Background and borders render across line breaks (split across lines)
- Text alignment (
text-align):left(default),center,right,justify
- Line height (
line-height):- Normal (default ~1.2x font size)
- Number (multiplier)
- Length (px, em)
- Replace hardcoded layout defaults with computed styles from the style crate
- Write tests for multi-line wrapping, inline elements with padding, text alignment, mixed font sizes
Dependencies#
- Cascade and computed style resolution (to get inline styles)
- CSS value parsing (for lengths)
Implementation Notes#
- The current layout crate has basic text wrapping — this replaces it with proper inline layout
- Key change: layout reads from ComputedStyle instead of hardcoded tag-based defaults
- This is the most complex layout task in Phase 4