@native-sdk/cli 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +55 -0
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/core.ts +3 -1
  7. package/skill-data/native-ui/SKILL.md +7 -7
  8. package/skill-data/ts-core/SKILL.md +1 -1
  9. package/src/app_runner/root.zig +93 -6
  10. package/src/app_runner/ts_core_main.zig +4 -4
  11. package/src/app_runner/window_placement.zig +63 -0
  12. package/src/embed/app_exports.zig +2 -1
  13. package/src/embed/conversions.zig +1 -0
  14. package/src/embed/host.zig +10 -3
  15. package/src/embed/root.zig +1 -0
  16. package/src/embed/tests.zig +13 -1
  17. package/src/embed/types.zig +2 -0
  18. package/src/embed/ui_host.zig +26 -2
  19. package/src/platform/android/NativeSdkActivity.java +49 -4
  20. package/src/platform/android/android_host.c +3 -3
  21. package/src/platform/android/native_sdk_app.h +1 -1
  22. package/src/platform/ios/apple_image_fit.h +38 -0
  23. package/src/platform/ios/files.zig +1 -0
  24. package/src/platform/ios/native_sdk_app.h +1 -1
  25. package/src/platform/ios/uikit_host.m +28 -5
  26. package/src/platform/linux/cef_host.cpp +10 -2
  27. package/src/platform/linux/gtk_host.c +43 -10
  28. package/src/platform/linux/gtk_host.h +3 -3
  29. package/src/platform/linux/root.zig +22 -7
  30. package/src/platform/macos/appkit_host.h +7 -4
  31. package/src/platform/macos/appkit_host.m +192 -40
  32. package/src/platform/macos/cef_host.mm +132 -34
  33. package/src/platform/macos/image_fit_test.m +44 -0
  34. package/src/platform/macos/root.zig +154 -9
  35. package/src/platform/null_platform.zig +17 -3
  36. package/src/platform/null_platform_tests.zig +58 -4
  37. package/src/platform/root.zig +2 -0
  38. package/src/platform/types.zig +69 -19
  39. package/src/platform/windows/root.zig +22 -7
  40. package/src/platform/windows/webview2_host.cpp +31 -6
  41. package/src/primitives/app_manifest/root.zig +3 -0
  42. package/src/primitives/app_manifest/tests.zig +24 -0
  43. package/src/primitives/app_manifest/types.zig +13 -0
  44. package/src/primitives/app_manifest/validation.zig +24 -0
  45. package/src/primitives/canvas/a11y_audit.zig +9 -7
  46. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  47. package/src/primitives/canvas/events.zig +50 -0
  48. package/src/primitives/canvas/layout_audit.zig +6 -6
  49. package/src/primitives/canvas/markdown.zig +4 -0
  50. package/src/primitives/canvas/markdown_tests.zig +1 -0
  51. package/src/primitives/canvas/png.zig +138 -0
  52. package/src/primitives/canvas/root.zig +13 -2
  53. package/src/primitives/canvas/text_span_tests.zig +5 -3
  54. package/src/primitives/canvas/text_spans.zig +2 -0
  55. package/src/primitives/canvas/text_tests.zig +20 -0
  56. package/src/primitives/canvas/ui.zig +55 -2
  57. package/src/primitives/canvas/ui_markup.zig +40 -13
  58. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  59. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  60. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  62. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  63. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  64. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  65. package/src/primitives/canvas/ui_schema.zig +17 -13
  66. package/src/primitives/canvas/ui_tests.zig +47 -0
  67. package/src/primitives/canvas/widget_access.zig +3 -3
  68. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  69. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  70. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  71. package/src/primitives/canvas/widget_layout.zig +333 -126
  72. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  73. package/src/primitives/canvas/widget_metrics.zig +7 -8
  74. package/src/primitives/canvas/widget_render.zig +76 -44
  75. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  76. package/src/primitives/canvas/widget_render_style.zig +58 -18
  77. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  78. package/src/primitives/canvas/widget_routing.zig +40 -34
  79. package/src/primitives/canvas/widget_runtime.zig +11 -2
  80. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  81. package/src/primitives/canvas/widget_semantics.zig +8 -3
  82. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  83. package/src/primitives/canvas/widget_tree.zig +99 -5
  84. package/src/primitives/canvas/widgets.zig +20 -7
  85. package/src/root.zig +3 -0
  86. package/src/runtime/api.zig +6 -0
  87. package/src/runtime/automation_widget_dispatch.zig +48 -6
  88. package/src/runtime/builtin_bridge.zig +5 -2
  89. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  90. package/src/runtime/canvas_image_tests.zig +146 -2
  91. package/src/runtime/canvas_images.zig +35 -16
  92. package/src/runtime/canvas_limits.zig +13 -3
  93. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  94. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  95. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  96. package/src/runtime/canvas_widget_events.zig +151 -26
  97. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  98. package/src/runtime/canvas_widget_runtime.zig +322 -102
  99. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  100. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  101. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  102. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  103. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  104. package/src/runtime/canvas_widget_state.zig +33 -7
  105. package/src/runtime/core.zig +16 -0
  106. package/src/runtime/effects.zig +14 -14
  107. package/src/runtime/effects_image_tests.zig +91 -0
  108. package/src/runtime/gpu_surface_events.zig +25 -2
  109. package/src/runtime/root.zig +2 -0
  110. package/src/runtime/session_replay.zig +13 -8
  111. package/src/runtime/session_tests.zig +111 -4
  112. package/src/runtime/shell_layout_tests.zig +12 -0
  113. package/src/runtime/ts_core_host_tests.zig +47 -0
  114. package/src/runtime/ui_app.zig +9 -3
  115. package/src/runtime/ui_app_tests.zig +119 -19
  116. package/src/runtime/ui_app_window_tests.zig +13 -1
  117. package/src/runtime/view.zig +3 -0
  118. package/src/runtime/view_widget_control.zig +18 -0
  119. package/src/runtime/view_widget_scroll.zig +112 -18
  120. package/src/runtime/view_widget_tree.zig +110 -13
  121. package/src/runtime/widget_bridge.zig +2 -0
  122. package/src/runtime/window_command_bridge_tests.zig +86 -0
  123. package/src/runtime/window_storage.zig +16 -1
  124. package/src/runtime/window_views.zig +1 -0
  125. package/src/tooling/ios.zig +3 -0
  126. package/src/tooling/manifest.zig +90 -2
  127. package/src/tooling/package.zig +67 -2
  128. package/src/tooling/raw_manifest.zig +10 -0
  129. package/src/tooling/templates.zig +128 -18
  130. package/src/tooling/web_engine.zig +1 -1
@@ -223,9 +223,21 @@ pub fn restoreCanvasWidgetLayoutScrollOffsets(
223
223
  nodes: []canvas.WidgetLayoutNode,
224
224
  previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
225
225
  previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
226
+ ) void {
227
+ restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(nodes, previous_runtime_offsets, previous_source_offsets, null);
228
+ }
229
+
230
+ fn restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
231
+ nodes: []canvas.WidgetLayoutNode,
232
+ previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
233
+ previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
234
+ anchored_depth: ?usize,
226
235
  ) void {
227
236
  for (nodes, 0..) |node, index| {
228
237
  if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
238
+ if (anchored_depth) |depth| {
239
+ if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
240
+ }
229
241
  const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id) orelse continue;
230
242
  const previous_source = canvasWidgetSourceScrollEntryById(previous_source_offsets, node.widget.id) orelse continue;
231
243
  // Each axis reconciles on its own: a programmatic vertical
@@ -268,10 +280,14 @@ fn clampCanvasWidgetLayoutProgrammaticScrollOffsets(
268
280
  source: canvas.WidgetLayoutTree,
269
281
  previous_runtime_offsets: []const CanvasWidgetSourceScrollEntry,
270
282
  previous_source_offsets: []const CanvasWidgetSourceScrollEntry,
283
+ anchored_depth: ?usize,
271
284
  ) void {
272
285
  for (nodes, 0..) |node, index| {
273
286
  if (node.widget.kind != .scroll_view or node.widget.id == 0) continue;
274
287
  if (node.widget.layout.virtualized and !canvas.widgetVirtualRuntimeScrolled(node.widget)) continue;
288
+ if (anchored_depth) |depth| {
289
+ if (canvas.anchoredNestingDepth(nodes, index) != depth) continue;
290
+ }
275
291
 
276
292
  const source_node = source.findById(node.widget.id) orelse continue;
277
293
  const previous_runtime = canvasWidgetSourceScrollEntryById(previous_runtime_offsets, node.widget.id);
@@ -326,11 +342,14 @@ fn previousLayoutHasSelectedTab(previous: canvas.WidgetLayoutTree, id: canvas.Ob
326
342
  /// viewport. This runs after retained scroll restoration, against final layout
327
343
  /// frames, so an already-visible tab preserves the exact offset and a newly
328
344
  /// mounted native scroll driver never paints a speculative leading-edge jump.
329
- fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode) void {
345
+ fn revealNewlySelectedTabs(previous: canvas.WidgetLayoutTree, nodes: []canvas.WidgetLayoutNode, anchored_depth: ?usize) void {
330
346
  for (nodes, 0..) |tab_node, tab_index| {
331
347
  const tab = tab_node.widget;
332
348
  if (tab.semantics.role != .tab or !tab.state.selected) continue;
333
349
  if (tab.id != 0 and previousLayoutHasSelectedTab(previous, tab.id)) continue;
350
+ if (anchored_depth) |depth| {
351
+ if (canvas.anchoredNestingDepth(nodes, tab_index) != depth) continue;
352
+ }
334
353
 
335
354
  var ancestor = tab_node.parent_index;
336
355
  while (ancestor) |index| {
@@ -490,9 +509,9 @@ pub fn canvasWidgetLayoutNodeFrameVisible(layout: canvas.WidgetLayoutTree, node_
490
509
  if (frame.isEmpty()) return false;
491
510
  var current: usize = node_index;
492
511
  while (true) {
493
- // Anchored floating widgets escape ancestor clip regions (they
494
- // render in the hoisted window-level pass).
495
- if (canvas.widgetIsAnchored(layout.nodes[current].widget)) return true;
512
+ // Window-level surfaces render in the hoisted pass and escape
513
+ // ancestor clip regions.
514
+ if (canvas.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
496
515
  const index = layout.nodes[current].parent_index orelse return true;
497
516
  if (index >= layout.nodes.len) return true;
498
517
  const ancestor = layout.nodes[index];
@@ -510,9 +529,9 @@ pub fn canvasWidgetLayoutNodeClippedBounds(layout: canvas.WidgetLayoutTree, node
510
529
 
511
530
  var current: usize = node_index;
512
531
  while (true) {
513
- // Anchored floating widgets escape ancestor clip regions, so
514
- // dirty bounds under them clip to the window only.
515
- if (canvas.widgetIsAnchored(layout.nodes[current].widget)) break;
532
+ // Window-level surfaces escape ancestor clip regions, so dirty
533
+ // bounds under them clip to the window only.
534
+ if (canvas.widgetEscapesAncestorClips(layout.nodes[current].widget)) break;
516
535
  const index = layout.nodes[current].parent_index orelse break;
517
536
  if (index >= layout.nodes.len) return null;
518
537
  const ancestor = layout.nodes[index];
@@ -531,7 +550,7 @@ pub fn canvasWidgetClipsContent(widget: canvas.Widget) bool {
531
550
 
532
551
  pub fn canvasWidgetRuntimeHitTarget(widget: canvas.Widget) bool {
533
552
  // Widget-level hit-target-ness lives in one place (canvas
534
- // widget_access.zig: kind predicate plus bound press/toggle handlers)
553
+ // widget_access.zig: kind predicate plus bound press/toggle/drag handlers)
535
554
  // so the runtime, the engines' hit test, and the markup validation of
536
555
  // pointer handlers can never drift.
537
556
  return canvas.widgetIsHitTarget(widget);
@@ -1031,11 +1050,19 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
1031
1050
  &text_len,
1032
1051
  );
1033
1052
 
1034
- // Split fractions reconcile FIRST, as a staged copy of the laid-out
1035
- // tree, so the per-node passes below see final geometry. Outer
1036
- // splits restore before nested ones (ascending node order), so a
1037
- // nested split re-laid (or slid) by its ancestor still restores its
1038
- // own fraction afterwards. Two restore shapes:
1053
+ // Geometry reconciles in anchored-surface strata. The authored source
1054
+ // layout is first finalized outside every surface, then direct anchored
1055
+ // children are replayed against that final geometry. Runtime-owned
1056
+ // scroll/split/tab state inside those surfaces is restored before their
1057
+ // own nested surfaces replay, and so on. A surface replay can therefore
1058
+ // recover authored intrinsic sizing without erasing already-finalized
1059
+ // descendant state.
1060
+ //
1061
+ // Within each stratum split fractions reconcile FIRST, as a staged copy
1062
+ // of the laid-out tree, so the per-node passes below see final geometry.
1063
+ // Outer splits restore before nested ones (ascending node order), so a
1064
+ // nested split re-laid (or slid) by its ancestor still restores its own
1065
+ // fraction afterwards. Two restore shapes:
1039
1066
  // - SETTLED runtime-owned fraction (a past drag, no tween in
1040
1067
  // flight): re-run the split's child layout in place — content
1041
1068
  // honestly wraps at the restored width;
@@ -1048,63 +1075,78 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
1048
1075
  // frame at a time (the disclosure doctrine, horizontal).
1049
1076
  const staged_nodes = node_buffer[0..next.nodes.len];
1050
1077
  @memcpy(staged_nodes, next.nodes);
1051
- for (staged_nodes, 0..) |node, index| {
1052
- if (node.widget.kind != .split or node.widget.id == 0) continue;
1053
- const tween_armed = objectIdInList(armed_split_tween_ids, node.widget.id);
1054
- const previous_runtime = canvasWidgetSourceScrollById(previous_runtime_offsets, node.widget.id) orelse {
1055
- // A FRESH split (no retained fraction): a declared enter
1056
- // origin slides the first layout's boundary to the origin
1057
- // pose — children keep the declared value's (target) wrap —
1058
- // so the tween armed right after this reconcile eases it in
1059
- // instead of the mount popping to its value.
1060
- if (node.widget.resize_duration_ms != 0 and node.widget.resize_origin >= 0 and node.widget.children.len != 0) {
1061
- canvas.slideSplitChildren(node.frame, node.widget.resize_origin, index, staged_nodes);
1078
+ const staged_root_bounds = next.root_bounds orelse if (staged_nodes.len > 0) staged_nodes[0].frame else geometry.RectF.init(0, 0, 0, 0);
1079
+ const max_anchored_depth = canvas.maxAnchoredNestingDepth(staged_nodes);
1080
+ var anchored_depth: usize = 0;
1081
+ while (anchored_depth <= max_anchored_depth) : (anchored_depth += 1) {
1082
+ for (staged_nodes, 0..) |node, index| {
1083
+ if (node.widget.kind != .split or node.widget.id == 0) continue;
1084
+ if (canvas.anchoredNestingDepth(staged_nodes, index) != anchored_depth) continue;
1085
+ const tween_armed = objectIdInList(armed_split_tween_ids, node.widget.id);
1086
+ const previous_runtime = canvasWidgetSourceScrollById(previous_runtime_offsets, node.widget.id) orelse {
1087
+ // A FRESH split (no retained fraction): a declared enter
1088
+ // origin slides the first layout's boundary to the origin
1089
+ // pose — children keep the declared value's (target) wrap —
1090
+ // so the tween armed right after this reconcile eases it in
1091
+ // instead of the mount popping to its value.
1092
+ if (node.widget.resize_duration_ms != 0 and node.widget.resize_origin >= 0 and node.widget.children.len != 0) {
1093
+ canvas.slideSplitChildren(node.frame, node.widget.resize_origin, index, staged_nodes);
1094
+ }
1095
+ continue;
1096
+ };
1097
+ const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id) orelse continue;
1098
+ // Source-wins: the runtime-owned fraction survives rebuilds only
1099
+ // while the SOURCE fraction is unchanged; a source-side change
1100
+ // (the model echoing or driving the fraction) wins — UNLESS the
1101
+ // split declares a layout tween (`resize_duration_ms` nonzero)
1102
+ // or one is already in flight: then the moved source value is a
1103
+ // TARGET, the rendered fraction stays where it is, and the
1104
+ // runtime's tween lowering (armed right after this reconcile
1105
+ // lands, in setCanvasWidgetLayout) eases it there one presented
1106
+ // frame at a time. Reduced motion still snaps: the tween
1107
+ // lowering's snap path applies the target through this same
1108
+ // mutation family in the same rebuild.
1109
+ const source_moved = node.widget.value != previous_source;
1110
+ if (source_moved and node.widget.resize_duration_ms == 0 and !tween_armed) continue;
1111
+ if (node.widget.value == previous_runtime) continue;
1112
+ staged_nodes[index].widget.value = previous_runtime;
1113
+ // Retained trees clear children; a split without them keeps the
1114
+ // value restore only (frames follow on the next full layout).
1115
+ if (node.widget.children.len == 0) continue;
1116
+ // A pressed divider is a live drag: its echo rebuilds must keep
1117
+ // re-wrapping at the dragged width (the pinned drag behavior),
1118
+ // so the slide shape only applies to tween-owned motion.
1119
+ const dragging = pressed_split_id != 0 and node.widget.id == pressed_split_id;
1120
+ if (!dragging and (tween_armed or (source_moved and node.widget.resize_duration_ms != 0))) {
1121
+ canvas.slideSplitChildren(node.frame, previous_runtime, index, staged_nodes);
1122
+ } else {
1123
+ try canvas.relayoutSplitChildren(staged_nodes[index].widget, node.frame, index, node.depth, node_buffer, staged_root_bounds, tokens);
1062
1124
  }
1063
- continue;
1064
- };
1065
- const previous_source = canvasWidgetSourceScrollById(previous_source_scroll_entries, node.widget.id) orelse continue;
1066
- // Source-wins: the runtime-owned fraction survives rebuilds only
1067
- // while the SOURCE fraction is unchanged; a source-side change
1068
- // (the model echoing or driving the fraction) wins — UNLESS the
1069
- // split declares a layout tween (`resize_duration_ms` nonzero)
1070
- // or one is already in flight: then the moved source value is a
1071
- // TARGET, the rendered fraction stays where it is, and the
1072
- // runtime's tween lowering (armed right after this reconcile
1073
- // lands, in setCanvasWidgetLayout) eases it there one presented
1074
- // frame at a time. Reduced motion still snaps: the tween
1075
- // lowering's snap path applies the target through this same
1076
- // mutation family in the same rebuild.
1077
- const source_moved = node.widget.value != previous_source;
1078
- if (source_moved and node.widget.resize_duration_ms == 0 and !tween_armed) continue;
1079
- if (node.widget.value == previous_runtime) continue;
1080
- staged_nodes[index].widget.value = previous_runtime;
1081
- // Retained trees clear children; a split without them keeps the
1082
- // value restore only (frames follow on the next full layout).
1083
- if (node.widget.children.len == 0) continue;
1084
- // A pressed divider is a live drag: its echo rebuilds must keep
1085
- // re-wrapping at the dragged width (the pinned drag behavior),
1086
- // so the slide shape only applies to tween-owned motion.
1087
- const dragging = pressed_split_id != 0 and node.widget.id == pressed_split_id;
1088
- if (!dragging and (tween_armed or (source_moved and node.widget.resize_duration_ms != 0))) {
1089
- canvas.slideSplitChildren(node.frame, previous_runtime, index, staged_nodes);
1090
- } else {
1091
- try canvas.relayoutSplitChildren(staged_nodes[index].widget, node.frame, index, node.depth, node_buffer, tokens);
1092
1125
  }
1093
- }
1094
1126
 
1095
- // Scroll restore is staged too (after splits, so translated frames
1096
- // are final geometry): the retained offset comes back WITH its
1097
- // descendants translated to match. Engine-side clamping happens at
1098
- // the caller AFTER native scroll drivers are stamped — a rebuild
1099
- // mid-rubber-band must not clamp an offset the OS scroller owns.
1100
- restoreCanvasWidgetLayoutScrollOffsets(staged_nodes, previous_runtime_offsets, previous_source_scroll_entries);
1101
- clampCanvasWidgetLayoutProgrammaticScrollOffsets(
1102
- staged_nodes,
1103
- next,
1104
- previous_runtime_offsets,
1105
- previous_source_scroll_entries,
1106
- );
1107
- revealNewlySelectedTabs(previous, staged_nodes);
1127
+ // Scroll restore is staged too (after splits, so translated frames
1128
+ // are final geometry): the retained offset comes back WITH its
1129
+ // descendants translated to match. Engine-side clamping happens at
1130
+ // the caller AFTER native scroll drivers are stamped — a rebuild
1131
+ // mid-rubber-band must not clamp an offset the OS scroller owns.
1132
+ restoreCanvasWidgetLayoutScrollOffsetsAtAnchoredDepth(
1133
+ staged_nodes,
1134
+ previous_runtime_offsets,
1135
+ previous_source_scroll_entries,
1136
+ anchored_depth,
1137
+ );
1138
+ clampCanvasWidgetLayoutProgrammaticScrollOffsets(
1139
+ staged_nodes,
1140
+ next,
1141
+ previous_runtime_offsets,
1142
+ previous_source_scroll_entries,
1143
+ anchored_depth,
1144
+ );
1145
+ revealNewlySelectedTabs(previous, staged_nodes, anchored_depth);
1146
+ if (anchored_depth < max_anchored_depth) {
1147
+ try canvas.relayoutAnchoredChildrenAtDepth(staged_nodes, staged_root_bounds, tokens, anchored_depth);
1148
+ }
1149
+ }
1108
1150
 
1109
1151
  const index_scratch = canvas_widget_reconcile_index_scratch.get();
1110
1152
  index_scratch.controls.build(previous_control_states);
@@ -1112,7 +1154,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
1112
1154
  index_scratch.texts.build(previous_text_states);
1113
1155
  index_scratch.semantics.build(source_semantics);
1114
1156
 
1115
- const staged = canvas.WidgetLayoutTree{ .nodes = staged_nodes };
1157
+ const staged = canvas.WidgetLayoutTree{ .nodes = staged_nodes, .root_bounds = next.root_bounds };
1116
1158
  for (staged_nodes, 0..) |node, index| {
1117
1159
  const text_copy = canvasWidgetLayoutNodeWithTextReconcileState(node, staged, index, &index_scratch.texts);
1118
1160
  const control_copy = canvasWidgetLayoutNodeWithControlReconcileState(text_copy, staged, index, &index_scratch.controls, &index_scratch.source_controls);
@@ -1120,7 +1162,7 @@ pub fn canvasWidgetLayoutTreeWithRuntimeReconcileState(
1120
1162
  }
1121
1163
  const reconciled = node_buffer[0..next.nodes.len];
1122
1164
  clampCanvasWidgetLayoutTextOffsets(reconciled, tokens);
1123
- return .{ .nodes = reconciled };
1165
+ return .{ .nodes = reconciled, .root_bounds = next.root_bounds };
1124
1166
  }
1125
1167
 
1126
1168
  pub fn canvasWidgetLayoutNodeWithSourceSemantics(
@@ -1151,7 +1193,24 @@ pub fn applyCanvasWidgetSourceScrollSemantics(
1151
1193
  }
1152
1194
  }
1153
1195
 
1154
- pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState) void {
1196
+ pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState, root_bounds: ?geometry.RectF, tokens: canvas.DesignTokens) anyerror!void {
1197
+ try clampCanvasWidgetLayoutScrollOffsetsImpl(nodes, states, root_bounds, tokens, true);
1198
+ }
1199
+
1200
+ /// The staged rebuild reconcile already replayed anchored surfaces in
1201
+ /// top-down strata. Its final engine clamp must not replay them a second
1202
+ /// time: at this point their descendants carry restored runtime state.
1203
+ pub fn clampCanvasWidgetLayoutScrollOffsetsAfterReconcile(nodes: []canvas.WidgetLayoutNode, states: ?[]canvas.ScrollState, root_bounds: ?geometry.RectF, tokens: canvas.DesignTokens) anyerror!void {
1204
+ try clampCanvasWidgetLayoutScrollOffsetsImpl(nodes, states, root_bounds, tokens, false);
1205
+ }
1206
+
1207
+ fn clampCanvasWidgetLayoutScrollOffsetsImpl(
1208
+ nodes: []canvas.WidgetLayoutNode,
1209
+ states: ?[]canvas.ScrollState,
1210
+ root_bounds: ?geometry.RectF,
1211
+ tokens: canvas.DesignTokens,
1212
+ relayout_anchored: bool,
1213
+ ) anyerror!void {
1155
1214
  for (nodes, 0..) |node, index| {
1156
1215
  if (node.widget.kind != .scroll_view) continue;
1157
1216
  // Legacy virtualized containers are model-driven: the source
@@ -1234,6 +1293,9 @@ pub fn clampCanvasWidgetLayoutScrollOffsets(nodes: []canvas.WidgetLayoutNode, st
1234
1293
  }
1235
1294
  }
1236
1295
  }
1296
+ if (relayout_anchored and nodes.len > 0) {
1297
+ try canvas.relayoutAnchoredChildrenWithRootBounds(nodes, root_bounds orelse nodes[0].frame, tokens);
1298
+ }
1237
1299
  }
1238
1300
 
1239
1301
  pub fn clampCanvasWidgetLayoutTextOffsets(nodes: []canvas.WidgetLayoutNode, tokens: canvas.DesignTokens) void {
@@ -1273,6 +1335,10 @@ pub fn canvasWidgetLayoutScrollContentExtent(nodes: []const canvas.WidgetLayoutN
1273
1335
  var bottom = viewport.maxY();
1274
1336
  var index = scroll_index + 1;
1275
1337
  while (index < nodes.len and nodes[index].depth > scroll_depth) {
1338
+ if (canvas.widgetIsRootRelativeModal(nodes[index].widget)) {
1339
+ index = skipCanvasWidgetSubtree(nodes, index);
1340
+ continue;
1341
+ }
1276
1342
  // A subtree anchored DIRECTLY to the scroll region stays
1277
1343
  // stationary while content scrolls (its anchor base never
1278
1344
  // moves), so `frame + offset` is not a content-space position
@@ -1296,7 +1362,7 @@ pub fn canvasWidgetLayoutScrollContentExtent(nodes: []const canvas.WidgetLayoutN
1296
1362
  /// content pins to the viewport width. Three subtree exclusions keep the
1297
1363
  /// range honest — each names blank space the user could otherwise scroll
1298
1364
  /// to (or live content they otherwise could not reach):
1299
- /// - ANCHORED floating subtrees are out of flow and window-clipped;
1365
+ /// - WINDOW-LEVEL floating subtrees are out of flow and window-clipped;
1300
1366
  /// an open dropdown to the right of the viewport is not content;
1301
1367
  /// - a NESTED CLIP SCOPE (scroll view, `clip_content` surface,
1302
1368
  /// virtualized container) bounds its own children — its frame is
@@ -1315,7 +1381,7 @@ pub fn canvasWidgetLayoutScrollContentExtentX(nodes: []const canvas.WidgetLayout
1315
1381
  var index = scroll_index + 1;
1316
1382
  while (index < nodes.len and nodes[index].depth > scroll_depth) {
1317
1383
  const node = nodes[index];
1318
- if (node.widget.layout.anchor != null) {
1384
+ if (canvas.widgetEscapesAncestorClips(node.widget)) {
1319
1385
  index = skipCanvasWidgetSubtree(nodes, index);
1320
1386
  continue;
1321
1387
  }
@@ -1341,18 +1407,21 @@ fn skipCanvasWidgetSubtree(nodes: []const canvas.WidgetLayoutNode, index: usize)
1341
1407
  return next;
1342
1408
  }
1343
1409
 
1344
- /// Scrolled content carries its descendants — including floating
1345
- /// surfaces anchored to widgets INSIDE it — but a surface anchored to
1346
- /// the SCROLL REGION ITSELF stays put: its anchor base is the region's
1347
- /// own frame, which never moves when the content under it does (the
1348
- /// live-scroll translate applies the same rule).
1410
+ /// Scrolled content carries its descendants — including floating surfaces
1411
+ /// anchored to widgets INSIDE it — but root-relative modal surfaces never
1412
+ /// ride content, and a surface anchored to the SCROLL REGION ITSELF stays
1413
+ /// put: its anchor base is the region's own frame, which never moves when
1414
+ /// the content under it does (the live-scroll translate applies the same
1415
+ /// rule).
1349
1416
  pub fn translateCanvasWidgetLayoutScrollDescendants(nodes: []canvas.WidgetLayoutNode, scroll_index: usize, offset: geometry.OffsetF) void {
1350
1417
  if (scroll_index >= nodes.len) return;
1351
1418
  const scroll_depth = nodes[scroll_index].depth;
1352
1419
  var index = scroll_index + 1;
1353
1420
  while (index < nodes.len and nodes[index].depth > scroll_depth) {
1354
1421
  const node = nodes[index];
1355
- if (node.widget.layout.anchor != null and node.parent_index == scroll_index) {
1422
+ if (canvas.widgetIsRootRelativeModal(node.widget) or
1423
+ node.widget.layout.anchor != null and node.parent_index == scroll_index)
1424
+ {
1356
1425
  index = skipCanvasWidgetSubtree(nodes, index);
1357
1426
  continue;
1358
1427
  }
@@ -1472,7 +1541,14 @@ pub fn canvasWidgetSpatialFocusAllowed(layout: canvas.WidgetLayoutTree, focused:
1472
1541
  .data_cell => true,
1473
1542
  .list_item, .menu_item => same_parent and (direction == .up or direction == .down),
1474
1543
  .segmented_control => same_parent and (direction == .left or direction == .right),
1475
- .radio => same_parent,
1544
+ .radio => blk: {
1545
+ const focused_scope = canvasWidgetRadioGroupScopeIndex(layout, focused.index);
1546
+ const target_scope = canvasWidgetRadioGroupScopeIndex(layout, target.index);
1547
+ if (focused_scope != null or target_scope != null) {
1548
+ break :blk focused_scope != null and focused_scope == target_scope;
1549
+ }
1550
+ break :blk same_parent;
1551
+ },
1476
1552
  .button, .icon_button => same_parent and canvasWidgetParentAllowsHorizontalButtonFocus(canvasWidgetFocusParentKind(layout, focused)) and (direction == .left or direction == .right),
1477
1553
  .toggle_button => same_parent and canvasWidgetParentAllowsHorizontalToggleFocus(canvasWidgetFocusParentKind(layout, focused)) and (direction == .left or direction == .right),
1478
1554
  else => false,
@@ -1521,6 +1597,7 @@ pub const CanvasWidgetGroupDirection = enum {
1521
1597
  };
1522
1598
 
1523
1599
  pub fn canvasWidgetGroupDirectionalFocusTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, direction: canvas.WidgetFocusDirection) ?canvas.WidgetFocusTarget {
1600
+ if (canvasWidgetRadioGroupDirectionalFocusTarget(layout, focused, direction)) |target| return target;
1524
1601
  if (focused.index >= layout.nodes.len) return null;
1525
1602
  const parent_index = layout.nodes[focused.index].parent_index orelse return null;
1526
1603
  if (parent_index >= layout.nodes.len) return null;
@@ -1543,10 +1620,6 @@ pub fn canvasWidgetGroupDirectionForFocus(parent_kind: canvas.WidgetKind, child_
1543
1620
  canvasWidgetHorizontalGroupDirection(direction)
1544
1621
  else
1545
1622
  null,
1546
- .radio_group => if (child_kind == .radio)
1547
- canvasWidgetAnyAxisGroupDirection(direction)
1548
- else
1549
- null,
1550
1623
  .list => if (child_kind == .list_item)
1551
1624
  canvasWidgetVerticalGroupDirection(direction)
1552
1625
  else
@@ -1559,6 +1632,163 @@ pub fn canvasWidgetGroupDirectionForFocus(parent_kind: canvas.WidgetKind, child_
1559
1632
  };
1560
1633
  }
1561
1634
 
1635
+ // --------------------------------------------------- radio-group focus
1636
+ //
1637
+ // Radios at ANY depth under their nearest `radio_group` ancestor form
1638
+ // one logical, roving-focus set. Node order is the authored/DFS order;
1639
+ // logical targets intentionally omit only scroll clipping so keyboard
1640
+ // focus can reveal an offscreen radio before committing to it.
1641
+
1642
+ /// Index of the nearest `.radio_group` ancestor, or null for a bare
1643
+ /// radio (and for any other node outside a radio group).
1644
+ pub fn canvasWidgetRadioGroupScopeIndex(layout: canvas.WidgetLayoutTree, node_index: usize) ?usize {
1645
+ if (node_index >= layout.nodes.len) return null;
1646
+ var current = layout.nodes[node_index].parent_index;
1647
+ while (current) |index| {
1648
+ if (index >= layout.nodes.len) return null;
1649
+ if (layout.nodes[index].widget.kind == .radio_group) return index;
1650
+ current = layout.nodes[index].parent_index;
1651
+ }
1652
+ return null;
1653
+ }
1654
+
1655
+ /// The radio-scoped form of a future-general roving Tab scope. Keeping
1656
+ /// the scope identity separate from traversal lets tabs/toolbars adopt
1657
+ /// the same entry/exit contract later without changing radio behavior.
1658
+ pub const CanvasWidgetRovingTabScope = struct {
1659
+ kind: enum { radio_group },
1660
+ index: usize,
1661
+ };
1662
+
1663
+ pub fn canvasWidgetRovingTabScope(layout: canvas.WidgetLayoutTree, node_index: usize) ?CanvasWidgetRovingTabScope {
1664
+ if (node_index >= layout.nodes.len or layout.nodes[node_index].widget.kind != .radio) return null;
1665
+ return .{ .kind = .radio_group, .index = canvasWidgetRadioGroupScopeIndex(layout, node_index) orelse return null };
1666
+ }
1667
+
1668
+ fn canvasWidgetRadioGroupFocusTarget(
1669
+ layout: canvas.WidgetLayoutTree,
1670
+ radio_group_index: usize,
1671
+ node_index: usize,
1672
+ ) ?canvas.WidgetFocusTarget {
1673
+ if (node_index >= layout.nodes.len or layout.nodes[node_index].widget.kind != .radio) return null;
1674
+ if (canvasWidgetRadioGroupScopeIndex(layout, node_index) != radio_group_index) return null;
1675
+ return canvasWidgetLogicalFocusTarget(layout, node_index);
1676
+ }
1677
+
1678
+ /// The group's one Tab entry: selected focusable radio, else first
1679
+ /// focusable radio. Selection may be represented by state or value.
1680
+ pub fn canvasWidgetRovingTabEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
1681
+ if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
1682
+ const scope_depth = layout.nodes[scope.index].depth;
1683
+ var first: ?canvas.WidgetFocusTarget = null;
1684
+ var index = scope.index + 1;
1685
+ while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
1686
+ const target = canvasWidgetRadioGroupFocusTarget(layout, scope.index, index) orelse continue;
1687
+ if (first == null) first = target;
1688
+ if (canvasWidgetSelectableSelected(layout.nodes[index].widget)) return target;
1689
+ }
1690
+ return first;
1691
+ }
1692
+
1693
+ /// The flat Tab order position occupied by a radio-group scope. It is
1694
+ /// deliberately the first CURRENTLY VISIBLE radio in authored order,
1695
+ /// rather than the selected entry: selection may live after another
1696
+ /// nested radio group (or an ordinary control) and must not move this
1697
+ /// composite's position around those intervening Tab stops.
1698
+ pub fn canvasWidgetRovingTabStopTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
1699
+ if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
1700
+ const scope_depth = layout.nodes[scope.index].depth;
1701
+ var index = scope.index + 1;
1702
+ while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
1703
+ if (layout.nodes[index].widget.kind != .radio) continue;
1704
+ if (canvasWidgetRadioGroupScopeIndex(layout, index) != scope.index) continue;
1705
+ if (layout.focusTargetById(layout.nodes[index].widget.id)) |target| return target;
1706
+ }
1707
+ return null;
1708
+ }
1709
+
1710
+ /// The group's best CURRENTLY VISIBLE Tab entry. The ordinary entry
1711
+ /// resolver above intentionally admits scroll-clipped logical targets so
1712
+ /// focus can reveal them. Callers use this narrower fallback only after a
1713
+ /// logical target could not be revealed (for example under a fixed
1714
+ /// `clip_content` card), keeping the group reachable without committing
1715
+ /// an invisible focus id.
1716
+ pub fn canvasWidgetRovingTabVisibleEntryTarget(layout: canvas.WidgetLayoutTree, scope: CanvasWidgetRovingTabScope) ?canvas.WidgetFocusTarget {
1717
+ if (scope.index >= layout.nodes.len or layout.nodes[scope.index].widget.kind != .radio_group) return null;
1718
+ const scope_depth = layout.nodes[scope.index].depth;
1719
+ var first: ?canvas.WidgetFocusTarget = null;
1720
+ var index = scope.index + 1;
1721
+ while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
1722
+ if (layout.nodes[index].widget.kind != .radio) continue;
1723
+ if (canvasWidgetRadioGroupScopeIndex(layout, index) != scope.index) continue;
1724
+ const target = layout.focusTargetById(layout.nodes[index].widget.id) orelse continue;
1725
+ if (first == null) first = target;
1726
+ if (canvasWidgetSelectableSelected(layout.nodes[index].widget)) return target;
1727
+ }
1728
+ return first;
1729
+ }
1730
+
1731
+ pub fn canvasWidgetRadioGroupDirectionalFocusTarget(
1732
+ layout: canvas.WidgetLayoutTree,
1733
+ focused: canvas.WidgetFocusTarget,
1734
+ direction: canvas.WidgetFocusDirection,
1735
+ ) ?canvas.WidgetFocusTarget {
1736
+ if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
1737
+ const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
1738
+ const group_direction = canvasWidgetAnyAxisGroupDirection(direction) orelse return null;
1739
+ return canvasWidgetRadioGroupAdjacentRadio(layout, scope_index, focused.index, group_direction) orelse focused;
1740
+ }
1741
+
1742
+ pub fn canvasWidgetRadioGroupFocusEdgeTarget(
1743
+ layout: canvas.WidgetLayoutTree,
1744
+ focused: canvas.WidgetFocusTarget,
1745
+ edge: CanvasWidgetGroupFocusEdge,
1746
+ ) ?canvas.WidgetFocusTarget {
1747
+ if (focused.kind != .radio or focused.index >= layout.nodes.len) return null;
1748
+ const scope_index = canvasWidgetRadioGroupScopeIndex(layout, focused.index) orelse return null;
1749
+ if (scope_index >= layout.nodes.len) return null;
1750
+ const scope_depth = layout.nodes[scope_index].depth;
1751
+ var last: ?canvas.WidgetFocusTarget = null;
1752
+ var index = scope_index + 1;
1753
+ while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
1754
+ const target = canvasWidgetRadioGroupFocusTarget(layout, scope_index, index) orelse continue;
1755
+ if (edge == .first) return target;
1756
+ last = target;
1757
+ }
1758
+ return last;
1759
+ }
1760
+
1761
+ fn canvasWidgetRadioGroupAdjacentRadio(
1762
+ layout: canvas.WidgetLayoutTree,
1763
+ scope_index: usize,
1764
+ focused_index: usize,
1765
+ direction: CanvasWidgetGroupDirection,
1766
+ ) ?canvas.WidgetFocusTarget {
1767
+ if (scope_index >= layout.nodes.len) return null;
1768
+ const scope_depth = layout.nodes[scope_index].depth;
1769
+ var first: ?canvas.WidgetFocusTarget = null;
1770
+ var last: ?canvas.WidgetFocusTarget = null;
1771
+ var previous: ?canvas.WidgetFocusTarget = null;
1772
+ var saw_focused = false;
1773
+ var index = scope_index + 1;
1774
+ while (index < layout.nodes.len and layout.nodes[index].depth > scope_depth) : (index += 1) {
1775
+ if (index == focused_index) {
1776
+ if (direction == .previous and previous != null) return previous;
1777
+ saw_focused = true;
1778
+ continue;
1779
+ }
1780
+ const target = canvasWidgetRadioGroupFocusTarget(layout, scope_index, index) orelse continue;
1781
+ if (first == null) first = target;
1782
+ last = target;
1783
+ if (direction == .next and saw_focused) return target;
1784
+ if (!saw_focused) previous = target;
1785
+ }
1786
+ return switch (direction) {
1787
+ .previous => last,
1788
+ .next => first,
1789
+ };
1790
+ }
1791
+
1562
1792
  pub fn canvasWidgetHorizontalGroupDirection(direction: canvas.WidgetFocusDirection) ?CanvasWidgetGroupDirection {
1563
1793
  return switch (direction) {
1564
1794
  .left => .previous,
@@ -1642,25 +1872,14 @@ fn canvasWidgetTreeRowFocusTarget(layout: canvas.WidgetLayoutTree, node_index: u
1642
1872
  return canvasWidgetLogicalFocusTarget(layout, node_index);
1643
1873
  }
1644
1874
 
1645
- /// A roving group must be able to name its next LOGICAL row even when a
1646
- /// scroll ancestor clips that row out of the current viewport. Keep every
1647
- /// other focus gate (identity, disabled/hidden state, hidden ancestors,
1648
- /// concealed disclosure content), but deliberately omit only the geometry
1649
- /// clip check performed by `WidgetLayoutTree.focusTargetById`. The runtime
1650
- /// scrolls this target into view before it commits focus.
1651
- fn canvasWidgetLogicalFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
1652
- if (node_index >= layout.nodes.len) return null;
1653
- if (canvas.isWidgetHiddenInAncestors(layout, node_index)) return null;
1654
- if (canvas.isWidgetConcealedByDisclosure(layout, node_index)) return null;
1655
- const node = layout.nodes[node_index];
1656
- if (!canvas.widgetIsFocusable(node.widget)) return null;
1657
- return .{
1658
- .id = node.widget.id,
1659
- .kind = node.widget.kind,
1660
- .bounds = node.frame,
1661
- .index = node_index,
1662
- .state = node.widget.state,
1663
- };
1875
+ /// Keyboard roving and programmatic focus must be able to name a LOGICAL
1876
+ /// target even when a scroll ancestor clips it out of the current viewport.
1877
+ /// Keep every other focus gate (identity, disabled/hidden state, hidden
1878
+ /// ancestors, concealed disclosure content), but deliberately omit only the
1879
+ /// geometry clip check performed by `WidgetLayoutTree.focusTargetById`. The
1880
+ /// shared reveal seam scrolls this target into view before focus commits.
1881
+ pub fn canvasWidgetLogicalFocusTarget(layout: canvas.WidgetLayoutTree, node_index: usize) ?canvas.WidgetFocusTarget {
1882
+ return layout.logicalFocusTargetAtIndex(node_index);
1664
1883
  }
1665
1884
 
1666
1885
  /// The tree keymap's focus moves. Up/Down walk the scope's rows in node
@@ -1796,6 +2015,7 @@ fn canvasWidgetTreeFirstChildRow(layout: canvas.WidgetLayoutTree, tree_index: us
1796
2015
  }
1797
2016
 
1798
2017
  pub fn canvasWidgetGroupFocusEdgeTarget(layout: canvas.WidgetLayoutTree, focused: canvas.WidgetFocusTarget, edge: CanvasWidgetGroupFocusEdge) ?canvas.WidgetFocusTarget {
2018
+ if (canvasWidgetRadioGroupFocusEdgeTarget(layout, focused, edge)) |target| return target;
1799
2019
  if (!canvasWidgetGroupHomeEndFocusKind(layout, focused)) return null;
1800
2020
  if (focused.index >= layout.nodes.len) return null;
1801
2021
  const parent_index = layout.nodes[focused.index].parent_index;
@@ -845,3 +845,37 @@ test "floating surfaces push occluders that block underlying drivers but not the
845
845
  try std.testing.expectEqual(@as(u64, 0), drivers[0].parent_id);
846
846
  try std.testing.expectEqual(@as(u64, 1), drivers[1].parent_id);
847
847
  }
848
+
849
+ test "lower-layer later surfaces do not occlude a modal scroll driver" {
850
+ const harness = try TestHarness().create(std.testing.allocator, .{});
851
+ defer harness.destroy(std.testing.allocator);
852
+ harness.null_platform.gpu_surfaces = true;
853
+ harness.null_platform.gpu_surface_scroll_drivers = true;
854
+ var app_state: PassiveApp = .{};
855
+ try harness.start(app_state.app());
856
+
857
+ _ = try harness.runtime.createView(.{
858
+ .window_id = 1,
859
+ .label = "canvas",
860
+ .kind = .gpu_surface,
861
+ .frame = geometry.RectF.init(0, 0, 240, 160),
862
+ });
863
+
864
+ // The modal mounts before a default anchored popover, but its effective
865
+ // layer is higher. Its nested scroll driver must therefore ignore both
866
+ // its own modal catcher and the later surface painted beneath it.
867
+ const nodes = [_]canvas.WidgetLayoutNode{
868
+ .{ .widget = .{ .id = 1, .kind = .stack }, .frame = geometry.RectF.init(0, 0, 240, 160), .depth = 0 },
869
+ .{ .widget = .{ .id = 10, .kind = .dialog, .scrim = true }, .frame = geometry.RectF.init(20, 20, 200, 120), .depth = 1, .parent_index = 0 },
870
+ .{ .widget = .{ .id = 11, .kind = .scroll_view }, .frame = geometry.RectF.init(30, 30, 180, 80), .depth = 2, .parent_index = 1 },
871
+ .{ .widget = .{ .id = 12, .kind = .panel }, .frame = geometry.RectF.init(30, 30, 180, 200), .depth = 3, .parent_index = 2 },
872
+ .{ .widget = .{ .id = 20, .kind = .popover, .layout = .{ .anchor = .{} } }, .frame = geometry.RectF.init(40, 40, 100, 60), .depth = 1, .parent_index = 0 },
873
+ };
874
+ _ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", .{ .nodes = &nodes });
875
+
876
+ try std.testing.expectEqual(@as(usize, 2), harness.null_platform.scroll_occluder_count);
877
+ const drivers = harness.null_platform.scrollDrivers();
878
+ try std.testing.expectEqual(@as(usize, 1), drivers.len);
879
+ try std.testing.expectEqual(@as(u64, 11), drivers[0].id);
880
+ try std.testing.expectEqual(@as(u32, 0), drivers[0].occluder_mask);
881
+ }