M2: layout — LayoutEngine on Milky2018/chicle, 1,038-fixture conformance suite #3

Merged
nandi merged 1 commits from feat/layout into feat/style 2026-11-24 22:14:04 +00:00
Owner

Stacked on #2 (base feat/style); the diff shows only M2. Retarget to main after #1 and #2 are merged.

What's here

  • layout is a port of gpui's TaffyLayoutEngine (taffy.rs):
    • request_layout, request_measured_layout, compute_layout, layout_bounds, stretch_auto_size_to_fill, clear.
    • style_to_engine, a port of LayoutStyle::to_taffy. It resolves rems and lays out in device pixels with gpui's snapping rules: round_half_toward_zero, border widths snapped like strokes, measured sizes rounded up to device pixels, and bounds divided back into logical pixels.
    • AvailableSpace, LayoutId, and MeasureFn, which measure functions receive and return in logical pixels.
  • Dependency change: we use Milky2018/chicle@0.6.3 instead of vendoring moon_taffy. Chicle is the maintained successor of moon_taffy, published from the same upstream repository, and it builds on the current toolchain. This revises decision 3 in PORTING.md §7.
  • conformance/chicle is a standalone module, not part of the main build. It holds moon_taffy's 1,038 taffy fixture tests, which chicle no longer ships, run against chicle. All 1,038 pass on wasm, wasm-gc, js and native (about 40 seconds). Run it before any chicle upgrade.
  • The card example now lays out the card, its title and its body text through the engine. Text uses a stand-in fixed-width measure until M9. Its output is snapshot-tested.
  • Docs: PORTING.md has the M2 status, the revised decision 3 and the M2 deviations. The README and NOTICE are updated, with attribution for the fixtures (Apache-2.0, from taffy, MIT).

Testing

  • moon check --target all and moon test --target all pass: 76 tests on each of the four backends.
  • New layout tests:
    • gpui's test_round_half_toward_zero and border_widths_to_taffy_use_stroke_snapping, ported.
    • Flex distribution, rems, padding, gap and percentages, borders, device-pixel snapping at 1.5x, nested absolute bounds and recomputing them, measured text-like leaves (in logical pixels, rounded up), stretch to fill, grid columns with spans, absolute positioning and display: none, alignment, and clear.

Deviations

These are recorded in PORTING.md §6:

  • There is no cross-frame node or measure cache yet. It depends on element ids, so it comes in M6.
  • compute_layout takes the scale factor instead of &mut Window.
  • Measure closures don't receive gpui's final_layout flag, because chicle doesn't report the run mode.
  • An unknown or stale LayoutId, or a child given two parents, aborts.

🤖 Generated with Claude Code

Stacked on #2 (base `feat/style`); the diff shows only M2. Retarget to `main` after #1 and #2 are merged. ## What's here - **`layout`** is a port of gpui's `TaffyLayoutEngine` (`taffy.rs`): - `request_layout`, `request_measured_layout`, `compute_layout`, `layout_bounds`, `stretch_auto_size_to_fill`, `clear`. - `style_to_engine`, a port of `LayoutStyle::to_taffy`. It resolves rems and lays out in device pixels with gpui's snapping rules: `round_half_toward_zero`, border widths snapped like strokes, measured sizes rounded up to device pixels, and bounds divided back into logical pixels. - `AvailableSpace`, `LayoutId`, and `MeasureFn`, which measure functions receive and return in logical pixels. - **Dependency change:** we use `Milky2018/chicle@0.6.3` instead of vendoring `moon_taffy`. Chicle is the maintained successor of `moon_taffy`, published from the same upstream repository, and it builds on the current toolchain. This revises decision 3 in PORTING.md §7. - **`conformance/chicle`** is a standalone module, not part of the main build. It holds `moon_taffy`'s 1,038 taffy fixture tests, which chicle no longer ships, run against chicle. **All 1,038 pass on wasm, wasm-gc, js and native** (about 40 seconds). Run it before any chicle upgrade. - **The card example** now lays out the card, its title and its body text through the engine. Text uses a stand-in fixed-width measure until M9. Its output is snapshot-tested. - **Docs:** PORTING.md has the M2 status, the revised decision 3 and the M2 deviations. The README and NOTICE are updated, with attribution for the fixtures (Apache-2.0, from taffy, MIT). ## Testing - `moon check --target all` and `moon test --target all` pass: 76 tests on each of the four backends. - New layout tests: - gpui's `test_round_half_toward_zero` and `border_widths_to_taffy_use_stroke_snapping`, ported. - Flex distribution, rems, padding, gap and percentages, borders, device-pixel snapping at 1.5x, nested absolute bounds and recomputing them, measured text-like leaves (in logical pixels, rounded up), stretch to fill, grid columns with spans, absolute positioning and `display: none`, alignment, and `clear`. ## Deviations These are recorded in PORTING.md §6: - There is no cross-frame node or measure cache yet. It depends on element ids, so it comes in M6. - `compute_layout` takes the scale factor instead of `&mut Window`. - Measure closures don't receive gpui's `final_layout` flag, because chicle doesn't report the run mode. - An unknown or stale `LayoutId`, or a child given two parents, aborts. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nandi added 1 commit 2026-11-24 22:10:14 +00:00
- layout: port of GPUI's TaffyLayoutEngine (request_layout,
  request_measured_layout, compute_layout, layout_bounds,
  stretch_auto_size_to_fill) and LayoutStyle::to_taffy, with rem resolution
  and device-pixel snapping (round_half_toward_zero, stroke snapping, ceiled
  measured sizes). No cross-frame node cache yet (needs element ids, M6).
- Depend on Milky2018/chicle 0.6.3, the maintained successor of
  moon_taffy (which no longer compiles), instead of vendoring.
- conformance/chicle: standalone module running moon_taffy's 1,038 taffy
  fixtures against chicle; all pass on wasm, wasm-gc, js and native.
- card example now lays out its content with the engine.
- Docs: PORTING.md M2 status, revised decision 3, M2 deviations; README;
  NOTICE attribution for the conformance fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nandi merged commit b5daf13d47 into feat/style 2026-11-24 22:14:04 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: experiments/moon-gpui#3