M2: layout — LayoutEngine on Milky2018/chicle, 1,038-fixture conformance suite (#3)
This commit was merged in pull request #3.
This commit is contained in:
1 parent
10ee6d1f21
commit
b5daf13d47
60 files changed
+46155
-27
No files matched your search
+30
-10
@@ -132,7 +132,7 @@ stays isolated.
|
||||
| `scene` | `scene.rs`, `bounds_tree.rs`, `AtlasTile` (platform.rs) | pure | **done** (see deviations) |
|
||||
| `font` | `Font`, `FontWeight`, `FontStyle`, `FontFeatures`, `FontFallbacks` (text_system.rs) | pure | **done** (descriptors only) |
|
||||
| `style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | pure | **done** (generated by `tools/gen_style.py`) |
|
||||
| `layout` | `taffy.rs` (+ a taffy port) | pure | next |
|
||||
| `layout` | `taffy.rs` (engine on `Milky2018/chicle`, a taffy port) | pure | **done** (no cross-frame node cache yet) |
|
||||
| `keymap` | `keymap.rs`, `keymap/*`, `platform/keystroke.rs` | pure | planned |
|
||||
| `action` | `action.rs` | pure | planned |
|
||||
| `app` | `app.rs`, `app/*`, `subscription.rs`, `global.rs`, `gpui.rs` traits | pure | planned |
|
||||
@@ -209,6 +209,7 @@ records what I verified with toolchain `moon 0.1.20261119`.
|
||||
| Need | Package | Backends | Notes |
|
||||
| --- | --- | --- | --- |
|
||||
| Flexbox/grid layout | `Milky2018/moon_taffy@0.5.3` | all (pure) | Port of taffy 0.5.2 (GPUI uses 0.15). **Does not compile on the current toolchain**: 32 errors in `style/style_json.mbt` from the new explicit trait-method `extend` rule. Needs an upstream fix or a vendored patch. |
|
||||
| Flexbox/grid layout (used) | `Milky2018/chicle@0.6.3` | all (pure) | Successor of `moon_taffy` from the same upstream repository; builds on the current toolchain. **All 1,038 of `moon_taffy`'s taffy fixtures pass against it on all four backends** (`conformance/chicle`). |
|
||||
| Flexbox (alt.) | `NoahLiu/yoga-mbt@0.1.1` | pure | Yoga-style flexbox only, with no grid. |
|
||||
| Text shaping/layout | `Milky2018/moon_cosmic@0.3.9` | all (pure) | Port of cosmic-text on `moon_swash`, `moon_skrifa`, and `moon_zeno`. **Checks on js and native.** It is what `gpui_web`/`gpui_wgpu` use upstream (cosmic-text), so it fits well. |
|
||||
| Font parsing | `Milky2018/moon_skrifa`, `mizchi/font`, `bikallem/freetype` | pure | |
|
||||
@@ -221,7 +222,7 @@ records what I verified with toolchain `moon 0.1.20261119`.
|
||||
| Taffy-free layout ref | `Frank-III/onebit-tui` | native | Uses Yoga through FFI. Not useful here. |
|
||||
|
||||
Recommendation: depend on `moon_cosmic` for text when that milestone
|
||||
arrives. For layout, **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for
|
||||
arrives. For layout, the original plan was to **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for
|
||||
the toolchain, or send the fix upstream. Writing flexbox from scratch would
|
||||
be the costlier path.
|
||||
|
||||
@@ -342,13 +343,15 @@ gantt
|
||||
`rounded_md`, `shadow_lg`, ...).
|
||||
- Tests: refinement cascade semantics, and helper values matching GPUI's
|
||||
(for example `p_2 == rems(0.5)`).
|
||||
- **M2: layout.**
|
||||
- Vendor and fix `moon_taffy`, or port the taffy flexbox, block, and grid
|
||||
algorithms needed.
|
||||
- **M2: layout (done).**
|
||||
- Depends on `Milky2018/chicle` (see decision 3).
|
||||
- `LayoutEngine` with `request_layout`, `request_measured_layout`,
|
||||
`compute_layout`, and `layout_bounds`, plus `Style` → taffy conversion
|
||||
with rem and scale resolution.
|
||||
- Tests: a corpus of flexbox cases (taffy's generated tests).
|
||||
`compute_layout`, `layout_bounds`, and `stretch_auto_size_to_fill`.
|
||||
- `Style` → engine conversion with rem resolution and device-pixel
|
||||
snapping.
|
||||
- Tests: GPUI's rounding and stroke-snapping tests, plus layout
|
||||
scenarios. The engine is checked separately by the 1,038-fixture
|
||||
conformance suite in `conformance/chicle`.
|
||||
- **M3: app model.**
|
||||
- `App`, `Entity[T]`/`WeakEntity[T]`, and `Context[T]`.
|
||||
- `notify`, `observe`, `subscribe`/`emit` with typed event keys, globals,
|
||||
@@ -444,6 +447,19 @@ gantt
|
||||
- The refinement `Cascade` and `Style::paint` (which needs `Window`) wait for
|
||||
M6. The conversion to taffy styles waits for M2.
|
||||
|
||||
### Deviations taken in M2 (layout)
|
||||
- There is no cross-frame node cache yet. GPUI reuses taffy nodes keyed by
|
||||
element path, and reuses measure closures by key. That cache depends on
|
||||
element ids from the Window, so it comes in M6. Until then the engine is
|
||||
rebuilt on `clear()`, as older GPUI versions did.
|
||||
- `compute_layout` takes the scale factor instead of `&mut Window`.
|
||||
- Measure functions are `(known, available) -> Size[Pixels]` closures. They
|
||||
do not receive GPUI's `final_layout` flag, because chicle's measure
|
||||
callback does not report the run mode.
|
||||
- The engine keeps its own parent/child maps, because chicle has no
|
||||
`parent`/`children` queries. Misuse fails loudly: an unknown or stale
|
||||
`LayoutId`, or a child given two parents, aborts.
|
||||
|
||||
## 7. Design decisions
|
||||
|
||||
Decided on 2026-11-24, following the recommendations below.
|
||||
@@ -454,8 +470,12 @@ Decided on 2026-11-24, following the recommendations below.
|
||||
2. **Text shaping on the web.** Shape with `moon_cosmic`, which is pure, the
|
||||
same on every backend, and matches upstream `gpui_web`, using bundled
|
||||
fonts. Canvas text is used only as an emoji/CJK fallback, as upstream does.
|
||||
3. **Layout engine.** Vendor `moon_taffy`, fix it for the current toolchain,
|
||||
and send the fixes upstream.
|
||||
3. **Layout engine.** The decision was to vendor `moon_taffy`, fix it, and
|
||||
upstream the fixes. Revised in M2: upstream had already moved on and
|
||||
published the fixed successor `Milky2018/chicle` 0.6.3. We depend on it
|
||||
instead of forking. `moon_taffy`'s 1,038 taffy fixtures, which chicle no
|
||||
longer ships, all pass against it. They are kept in `conformance/chicle`
|
||||
and must be rerun before any chicle upgrade.
|
||||
4. **First renderer.** Canvas2D on js first, then WebGPU reusing GPUI's WGSL
|
||||
shaders.
|
||||
5. **API surface naming.** Keep GPUI names verbatim (`div()`, `px()`,
|
||||
|
||||
Reference in new issue
Block a user