@native-sdk/cli 0.5.3 → 0.6.0
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.
- package/build/app.zig +91 -2
- package/build.zig +756 -5
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +19 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +416 -9
- package/packages/core/sdk/core.ts +706 -5
- package/packages/core/sdk/events.ts +17 -8
- package/packages/core/src/checker.ts +305 -2
- package/packages/core/src/diagnostics.ts +12 -0
- package/packages/core/src/emitter.ts +3187 -264
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +42 -4
- package/skill-data/ts-core/SKILL.md +13 -3
- package/src/app_runner/root.zig +112 -10
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/automation/layout_fingerprint.zig +160 -0
- package/src/automation/protocol.zig +82 -33
- package/src/automation/root.zig +1 -0
- package/src/automation/server.zig +1 -1
- package/src/automation/snapshot.zig +68 -9
- package/src/automation/watcher.zig +1 -1
- package/src/embed/host.zig +5 -0
- package/src/embed/tests.zig +119 -1
- package/src/embed/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +639 -16
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +351 -7
- package/src/platform/macos/appkit_host.h +152 -8
- package/src/platform/macos/appkit_host.m +1816 -100
- package/src/platform/macos/cef_host.mm +372 -11
- package/src/platform/macos/root.zig +379 -11
- package/src/platform/null_platform.zig +696 -9
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +42 -0
- package/src/platform/types.zig +524 -18
- package/src/platform/windows/root.zig +432 -9
- package/src/platform/windows/webview2_host.cpp +482 -45
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/app_manifest/validation.zig +18 -0
- package/src/primitives/canvas/a11y_audit.zig +33 -11
- package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
- package/src/primitives/canvas/drawing.zig +25 -0
- package/src/primitives/canvas/equality.zig +8 -0
- package/src/primitives/canvas/events.zig +103 -16
- package/src/primitives/canvas/frame.zig +125 -1
- package/src/primitives/canvas/layout_audit.zig +22 -5
- package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
- package/src/primitives/canvas/render_tests.zig +13 -10
- package/src/primitives/canvas/root.zig +48 -0
- package/src/primitives/canvas/terminal_box.zig +471 -0
- package/src/primitives/canvas/terminal_grid.zig +978 -0
- package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/tests.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +535 -12
- package/src/primitives/canvas/ui_markup.zig +253 -36
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
- package/src/primitives/canvas/ui_markup_contract.zig +89 -6
- package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
- package/src/primitives/canvas/ui_markup_tests.zig +178 -9
- package/src/primitives/canvas/ui_markup_view.zig +220 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
- package/src/primitives/canvas/ui_schema.zig +110 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -10
- package/src/primitives/canvas/ui_tests.zig +141 -9
- package/src/primitives/canvas/widget_access.zig +28 -2
- package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
- package/src/primitives/canvas/widget_invalidation.zig +81 -1
- package/src/primitives/canvas/widget_layout.zig +59 -11
- package/src/primitives/canvas/widget_layout_tests.zig +125 -4
- package/src/primitives/canvas/widget_render.zig +272 -18
- package/src/primitives/canvas/widget_render_scroll.zig +108 -27
- package/src/primitives/canvas/widget_routing.zig +59 -7
- package/src/primitives/canvas/widget_runtime.zig +23 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
- package/src/primitives/canvas/widget_semantics.zig +119 -11
- package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
- package/src/primitives/canvas/widget_tree.zig +17 -0
- package/src/primitives/canvas/widgets.zig +132 -0
- package/src/root.zig +23 -0
- package/src/runtime/api.zig +76 -5
- package/src/runtime/automation_commands.zig +20 -1
- package/src/runtime/automation_snapshot.zig +25 -1
- package/src/runtime/automation_widget_dispatch.zig +73 -8
- package/src/runtime/bridge_payload.zig +8 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_frame.zig +62 -7
- package/src/runtime/canvas_frame_animation_tests.zig +5 -4
- package/src/runtime/canvas_frame_helpers.zig +190 -1
- package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
- package/src/runtime/canvas_frame_patch_tests.zig +161 -10
- package/src/runtime/canvas_frame_retained_tests.zig +5 -2
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
- package/src/runtime/canvas_widget_context_menu.zig +269 -32
- package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
- package/src/runtime/canvas_widget_display.zig +1 -1
- package/src/runtime/canvas_widget_event_tests.zig +1823 -0
- package/src/runtime/canvas_widget_events.zig +240 -24
- package/src/runtime/canvas_widget_runtime.zig +213 -29
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
- package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
- package/src/runtime/canvas_widget_state.zig +6 -0
- package/src/runtime/canvas_widget_text_tests.zig +1 -1
- package/src/runtime/core.zig +131 -13
- package/src/runtime/effects.zig +8136 -180
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +167 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +42 -4
- package/src/runtime/gpu_surface_events.zig +473 -13
- package/src/runtime/media_surface.zig +116 -11
- package/src/runtime/media_surface_tests.zig +61 -0
- package/src/runtime/pty.zig +1252 -0
- package/src/runtime/pty_windows.zig +1780 -0
- package/src/runtime/root.zig +36 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +432 -62
- package/src/runtime/session_record.zig +43 -2
- package/src/runtime/session_replay.zig +556 -20
- package/src/runtime/session_tests.zig +2087 -1
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/terminal_session.zig +1569 -0
- package/src/runtime/terminal_session_tests.zig +450 -0
- package/src/runtime/terminal_vt_ghostty.zig +15 -0
- package/src/runtime/terminal_vt_stub.zig +13 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +8 -0
- package/src/runtime/ts_core_host.zig +1320 -45
- package/src/runtime/ts_core_host_tests.zig +1100 -1
- package/src/runtime/ts_ui_app.zig +23 -5
- package/src/runtime/ui_app.zig +2444 -69
- package/src/runtime/ui_app_tests.zig +3171 -744
- package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
- package/src/runtime/ui_app_window_tests.zig +736 -0
- package/src/runtime/view.zig +190 -2
- package/src/runtime/view_widget_scroll.zig +218 -68
- package/src/runtime/view_widget_text.zig +11 -2
- package/src/runtime/view_widget_tree.zig +111 -3
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +77 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +62 -1
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +244 -8
|
@@ -83,6 +83,9 @@ fn shellWindowFrom(comptime window: anytype) types.ShellWindow {
|
|
|
83
83
|
}
|
|
84
84
|
if (@hasField(@TypeOf(window), "min_width")) out.min_width = window.min_width;
|
|
85
85
|
if (@hasField(@TypeOf(window), "min_height")) out.min_height = window.min_height;
|
|
86
|
+
if (@hasField(@TypeOf(window), "close_policy")) {
|
|
87
|
+
out.close_policy = enumField(types.WindowClosePolicy, window.close_policy, "close_policy");
|
|
88
|
+
}
|
|
86
89
|
if (@hasField(@TypeOf(window), "views")) {
|
|
87
90
|
var views: []const types.ShellView = &.{};
|
|
88
91
|
for (window.views) |view| {
|
|
@@ -210,6 +213,7 @@ test "shellConfigFrom converts a zon-shaped scene" {
|
|
|
210
213
|
.height = 320,
|
|
211
214
|
.restore_state = false,
|
|
212
215
|
.restore_policy = "center_on_primary",
|
|
216
|
+
.close_policy = "hide",
|
|
213
217
|
.views = .{
|
|
214
218
|
.{ .label = "main-canvas", .kind = "gpu_surface", .fill = true, .gpu_backend = "metal", .gpu_vsync = true },
|
|
215
219
|
},
|
|
@@ -223,6 +227,7 @@ test "shellConfigFrom converts a zon-shaped scene" {
|
|
|
223
227
|
try std.testing.expectEqualStrings("Demo", scene.windows[0].title.?);
|
|
224
228
|
try std.testing.expectEqual(@as(f32, 480), scene.windows[0].width);
|
|
225
229
|
try std.testing.expectEqual(types.WindowRestorePolicy.center_on_primary, scene.windows[0].restore_policy);
|
|
230
|
+
try std.testing.expectEqual(types.WindowClosePolicy.hide, scene.windows[0].close_policy);
|
|
226
231
|
try std.testing.expectEqual(@as(usize, 1), scene.windows[0].views.len);
|
|
227
232
|
try std.testing.expectEqual(types.ViewKind.gpu_surface, scene.windows[0].views[0].kind);
|
|
228
233
|
try std.testing.expectEqual(types.GpuSurfaceBackend.metal, scene.windows[0].views[0].gpu_backend.?);
|
|
@@ -52,6 +52,7 @@ pub const FrontendDevConfig = types.FrontendDevConfig;
|
|
|
52
52
|
pub const FrontendConfig = types.FrontendConfig;
|
|
53
53
|
pub const WindowRestorePolicy = types.WindowRestorePolicy;
|
|
54
54
|
pub const WindowTitlebarStyle = types.WindowTitlebarStyle;
|
|
55
|
+
pub const WindowClosePolicy = types.WindowClosePolicy;
|
|
55
56
|
pub const Window = types.Window;
|
|
56
57
|
pub const ViewKind = types.ViewKind;
|
|
57
58
|
pub const GpuSurfaceBackend = types.GpuSurfaceBackend;
|
|
@@ -310,6 +310,31 @@ pub const WindowTitlebarStyle = enum {
|
|
|
310
310
|
chromeless,
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
+
/// What the window's CLOSE affordance (the red traffic light, cmd+W,
|
|
314
|
+
/// the caption X) does. `.quit` is the classic document-app default:
|
|
315
|
+
/// the window really closes, and closing the last one follows the
|
|
316
|
+
/// host's exit semantics — behavior unchanged for every app that never
|
|
317
|
+
/// declares the field.
|
|
318
|
+
///
|
|
319
|
+
/// `.hide` is the menu-bar/tray-app shape: the close affordance hides
|
|
320
|
+
/// the window (it stays alive with its views, `WindowState.hidden`
|
|
321
|
+
/// flips true) and the app keeps running behind its status item — a
|
|
322
|
+
/// tray action's `Effects.showWindow`, or the macOS Dock reopen,
|
|
323
|
+
/// brings it back. Supported where the host can re-show a hidden
|
|
324
|
+
/// window (macOS, Windows); platforms without that affordance refuse
|
|
325
|
+
/// the declaration loudly at create time rather than stranding a
|
|
326
|
+
/// hidden window.
|
|
327
|
+
///
|
|
328
|
+
/// Room is deliberately left for a future `.event` tier — the model
|
|
329
|
+
/// receives the close request as a Msg and owns the consequence
|
|
330
|
+
/// (unsaved-changes prompts) — which is NOT implemented yet;
|
|
331
|
+
/// model-declared secondary windows already have that shape today via
|
|
332
|
+
/// `WindowDescriptor.on_close`.
|
|
333
|
+
pub const WindowClosePolicy = enum {
|
|
334
|
+
quit,
|
|
335
|
+
hide,
|
|
336
|
+
};
|
|
337
|
+
|
|
313
338
|
pub const Window = struct {
|
|
314
339
|
label: []const u8 = "main",
|
|
315
340
|
title: ?[]const u8 = null,
|
|
@@ -329,6 +354,8 @@ pub const Window = struct {
|
|
|
329
354
|
/// layout clamping/clipping panes below it. 0 = no floor.
|
|
330
355
|
min_width: f32 = 0,
|
|
331
356
|
min_height: f32 = 0,
|
|
357
|
+
/// What the user's close affordance does — see `WindowClosePolicy`.
|
|
358
|
+
close_policy: WindowClosePolicy = .quit,
|
|
332
359
|
};
|
|
333
360
|
|
|
334
361
|
pub const ViewKind = enum {
|
|
@@ -459,6 +486,11 @@ pub const ShellWindow = struct {
|
|
|
459
486
|
/// runtime-created windows apply their own declaration at create.
|
|
460
487
|
min_width: f32 = 0,
|
|
461
488
|
min_height: f32 = 0,
|
|
489
|
+
/// What the user's close affordance does — see `WindowClosePolicy`.
|
|
490
|
+
/// Like `titlebar`, close handling is host window state: the
|
|
491
|
+
/// STARTUP window threads it through the host create, and
|
|
492
|
+
/// runtime-created windows apply their own declaration at create.
|
|
493
|
+
close_policy: WindowClosePolicy = .quit,
|
|
462
494
|
views: []const ShellView = &.{},
|
|
463
495
|
};
|
|
464
496
|
|
|
@@ -690,6 +690,24 @@ fn validateShortcutKey(key: []const u8) ValidationError!void {
|
|
|
690
690
|
"arrowright",
|
|
691
691
|
"arrowup",
|
|
692
692
|
"arrowdown",
|
|
693
|
+
"delete",
|
|
694
|
+
"home",
|
|
695
|
+
"end",
|
|
696
|
+
"pageup",
|
|
697
|
+
"pagedown",
|
|
698
|
+
"insert",
|
|
699
|
+
"f1",
|
|
700
|
+
"f2",
|
|
701
|
+
"f3",
|
|
702
|
+
"f4",
|
|
703
|
+
"f5",
|
|
704
|
+
"f6",
|
|
705
|
+
"f7",
|
|
706
|
+
"f8",
|
|
707
|
+
"f9",
|
|
708
|
+
"f10",
|
|
709
|
+
"f11",
|
|
710
|
+
"f12",
|
|
693
711
|
};
|
|
694
712
|
for (&specials) |special| {
|
|
695
713
|
if (std.ascii.eqlIgnoreCase(key, special)) return;
|
|
@@ -207,10 +207,17 @@ fn widgetClipsForAudit(widget: Widget) bool {
|
|
|
207
207
|
return widget_tree.widgetClipsContent(widget) or widget.layout.virtualized;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
///
|
|
211
|
-
/// reachable after a scroll, so
|
|
210
|
+
/// Whether a scroll scope carries content into view along each axis:
|
|
211
|
+
/// content past a granted axis's fold is reachable after a scroll, so a
|
|
212
|
+
/// full-clip on that axis never counts. A horizontal-only shelf grants
|
|
213
|
+
/// x and NOT y — an offscreen-right tile is reachable, a below-viewport
|
|
214
|
+
/// one is genuinely stranded.
|
|
212
215
|
fn scopeScrollsVertically(widget: Widget) bool {
|
|
213
|
-
return widget.kind == .scroll_view or widget.layout.virtualized;
|
|
216
|
+
return (widget.kind == .scroll_view and widget.scroll_axes.scrollsVertically()) or widget.layout.virtualized;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn scopeScrollsHorizontally(widget: Widget) bool {
|
|
220
|
+
return widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized;
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
fn auditFocusReachable(layout: WidgetLayoutTree, node_index: usize, sink: *FindingSink) void {
|
|
@@ -221,14 +228,17 @@ fn auditFocusReachable(layout: WidgetLayoutTree, node_index: usize, sink: *Findi
|
|
|
221
228
|
|
|
222
229
|
const frame = node.frame.normalized();
|
|
223
230
|
var current = node_index;
|
|
224
|
-
// Once the walk crosses a
|
|
225
|
-
//
|
|
226
|
-
// carries it into every OUTER scope's band, so
|
|
227
|
-
//
|
|
228
|
-
// scroll region — windowed virtual lists included —
|
|
229
|
-
//
|
|
230
|
-
// re-flag
|
|
231
|
+
// Once the walk crosses a scrolling scope, the widget's layout-space
|
|
232
|
+
// position ALONG THAT AXIS is scroll content, not screen geometry:
|
|
233
|
+
// scrolling carries it into every OUTER scope's band, so full-clips
|
|
234
|
+
// on that axis stop counting from there up (below-the-fold rows in
|
|
235
|
+
// a long scroll region — windowed virtual lists included — and
|
|
236
|
+
// offscreen-right tiles on a horizontal shelf are reachable by
|
|
237
|
+
// design; a pane clipping the scroll's frame must not re-flag
|
|
238
|
+
// them). Each axis tracks independently: a horizontal shelf forgives
|
|
239
|
+
// x overhang while a below-viewport button inside it stays flagged.
|
|
231
240
|
var scrolls_vertically = false;
|
|
241
|
+
var scrolls_horizontally = false;
|
|
232
242
|
while (true) {
|
|
233
243
|
// Anchored floating widgets escape every ancestor clip (the
|
|
234
244
|
// routing layer keeps focus targets inside open overlays live).
|
|
@@ -239,14 +249,26 @@ fn auditFocusReachable(layout: WidgetLayoutTree, node_index: usize, sink: *Findi
|
|
|
239
249
|
const scope = parent.frame.normalized();
|
|
240
250
|
const outside_x = frame.maxX() <= scope.x or frame.x >= scope.maxX();
|
|
241
251
|
const outside_y = frame.maxY() <= scope.y or frame.y >= scope.maxY();
|
|
252
|
+
const parent_scrolls_horizontally = scopeScrollsHorizontally(parent.widget);
|
|
242
253
|
const vertical_scroll_scope = scrolls_vertically or scopeScrollsVertically(parent.widget);
|
|
243
|
-
const
|
|
254
|
+
const horizontal_scroll_scope = scrolls_horizontally or parent_scrolls_horizontally;
|
|
255
|
+
// A horizontal scroll forgives only what scrolling can
|
|
256
|
+
// REVEAL. Offsets clamp at zero, so content wholly BEFORE
|
|
257
|
+
// the origin in content space (layout x plus the region's
|
|
258
|
+
// own offset, checkable exactly at the immediate scope) is
|
|
259
|
+
// stranded on the leading side forever.
|
|
260
|
+
const stranded_leading_x = parent_scrolls_horizontally and !scrolls_horizontally and
|
|
261
|
+
frame.maxX() + parent.widget.value_x <= scope.x;
|
|
262
|
+
const unreachable_here = (outside_x and !horizontal_scroll_scope) or
|
|
263
|
+
(outside_y and !vertical_scroll_scope) or
|
|
264
|
+
stranded_leading_x;
|
|
244
265
|
if (unreachable_here) {
|
|
245
266
|
sink.append(.{ .rule = .focus_unreachable, .node_index = node_index, .other_index = parent_index });
|
|
246
267
|
return;
|
|
247
268
|
}
|
|
248
269
|
}
|
|
249
270
|
if (scopeScrollsVertically(parent.widget)) scrolls_vertically = true;
|
|
271
|
+
if (scopeScrollsHorizontally(parent.widget)) scrolls_horizontally = true;
|
|
250
272
|
current = parent_index;
|
|
251
273
|
}
|
|
252
274
|
}
|
|
@@ -190,6 +190,26 @@ test "below-the-fold scroll content stays reachable through OUTER clip scopes" {
|
|
|
190
190
|
try std.testing.expectEqual(a11y_audit.A11yAuditRuleKind.focus_unreachable, issues.findings[0].rule);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
test "a horizontal shelf forgives offscreen-right tiles and still flags below-viewport content" {
|
|
194
|
+
var nodes: [32]canvas.WidgetLayoutNode = undefined;
|
|
195
|
+
var storage: [8]a11y_audit.A11yAuditFinding = undefined;
|
|
196
|
+
|
|
197
|
+
// A horizontal-only scroll region: a tile past its RIGHT edge is
|
|
198
|
+
// scroll content (reachable by design), while a button fully below
|
|
199
|
+
// the viewport is genuinely stranded — nothing scrolls vertically
|
|
200
|
+
// to reveal it.
|
|
201
|
+
const root = Widget{ .kind = .column, .children = &.{
|
|
202
|
+
.{ .kind = .scroll_view, .id = 2, .scroll_axes = .horizontal, .frame = geometry.RectF.init(0, 0, 400, 80), .children = &.{
|
|
203
|
+
.{ .kind = .button, .id = 3, .text = "Visible", .frame = geometry.RectF.init(0, 0, 140, 60) },
|
|
204
|
+
.{ .kind = .button, .id = 4, .text = "Offscreen right", .frame = geometry.RectF.init(500, 0, 140, 60) },
|
|
205
|
+
.{ .kind = .button, .id = 5, .text = "Below the shelf", .frame = geometry.RectF.init(0, 120, 140, 30) },
|
|
206
|
+
} },
|
|
207
|
+
} };
|
|
208
|
+
const issues = try auditTree(root, window, &nodes, &storage);
|
|
209
|
+
try std.testing.expectEqual(@as(usize, 1), issues.total);
|
|
210
|
+
try std.testing.expectEqual(a11y_audit.A11yAuditRuleKind.focus_unreachable, issues.findings[0].rule);
|
|
211
|
+
}
|
|
212
|
+
|
|
193
213
|
test "the formatter names the path, the role, and the fix" {
|
|
194
214
|
var nodes: [16]canvas.WidgetLayoutNode = undefined;
|
|
195
215
|
var storage: [8]a11y_audit.A11yAuditFinding = undefined;
|
|
@@ -207,6 +207,31 @@ pub const ImageFit = enum {
|
|
|
207
207
|
cover,
|
|
208
208
|
};
|
|
209
209
|
|
|
210
|
+
/// The `contain` destination rect: the largest `source_width` x
|
|
211
|
+
/// `source_height`-proportioned rect that fits inside `dst`, centered —
|
|
212
|
+
/// the remainder is the caller's letterbox/pillarbox. Non-positive
|
|
213
|
+
/// source dimensions (an unloaded stream) answer the whole `dst`
|
|
214
|
+
/// unchanged, so callers never divide by zero on unknown geometry.
|
|
215
|
+
pub fn containDestinationRect(dst: geometry.RectF, source_width: f32, source_height: f32) geometry.RectF {
|
|
216
|
+
const normalized = dst.normalized();
|
|
217
|
+
if (normalized.isEmpty() or source_width <= 0 or source_height <= 0) return normalized;
|
|
218
|
+
const source_aspect = source_width / source_height;
|
|
219
|
+
const dst_aspect = normalized.width / normalized.height;
|
|
220
|
+
var width = normalized.width;
|
|
221
|
+
var height = normalized.height;
|
|
222
|
+
if (dst_aspect > source_aspect) {
|
|
223
|
+
width = height * source_aspect;
|
|
224
|
+
} else {
|
|
225
|
+
height = width / source_aspect;
|
|
226
|
+
}
|
|
227
|
+
return geometry.RectF.init(
|
|
228
|
+
normalized.x + (normalized.width - width) * 0.5,
|
|
229
|
+
normalized.y + (normalized.height - height) * 0.5,
|
|
230
|
+
width,
|
|
231
|
+
height,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
210
235
|
pub const ImageSampling = enum {
|
|
211
236
|
nearest,
|
|
212
237
|
linear,
|
|
@@ -244,6 +244,14 @@ pub fn sizesEqual(a: geometry.SizeF, b: geometry.SizeF) bool {
|
|
|
244
244
|
return a.width == b.width and a.height == b.height;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
pub fn optionalSizesEqual(a: ?geometry.SizeF, b: ?geometry.SizeF) bool {
|
|
248
|
+
if (a) |left| {
|
|
249
|
+
if (b) |right| return sizesEqual(left, right);
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
return b == null;
|
|
253
|
+
}
|
|
254
|
+
|
|
247
255
|
pub fn insetsEqual(a: geometry.InsetsF, b: geometry.InsetsF) bool {
|
|
248
256
|
return a.top == b.top and
|
|
249
257
|
a.right == b.right and
|
|
@@ -56,6 +56,17 @@ pub const WidgetPointerEvent = struct {
|
|
|
56
56
|
/// press that started the gesture, which is how a double-click
|
|
57
57
|
/// drag knows to extend by words.
|
|
58
58
|
click_count: u8 = 1,
|
|
59
|
+
/// The host's pointer identity (`GpuSurfaceInputEvent.pointer_id`),
|
|
60
|
+
/// forwarded so per-pointer state can tell devices apart on hosts
|
|
61
|
+
/// that distinguish them: the hover-Msg containment gate scopes its
|
|
62
|
+
/// hover-capable-pointer proof to this id, so a touch contact can
|
|
63
|
+
/// never ride a mouse's proof. Desktop hosts with one pointer leave
|
|
64
|
+
/// it 0.
|
|
65
|
+
pointer_id: u64 = 0,
|
|
66
|
+
/// Platform button number for down/up events (0 = primary). Motion
|
|
67
|
+
/// may leave this at 0; gesture owners use the initiating down to
|
|
68
|
+
/// decide whether to capture.
|
|
69
|
+
button: i32 = 0,
|
|
59
70
|
};
|
|
60
71
|
|
|
61
72
|
pub const WidgetKeyboardPhase = enum {
|
|
@@ -254,7 +265,12 @@ pub const WidgetControlIntent = struct {
|
|
|
254
265
|
kind: WidgetControlIntentKind,
|
|
255
266
|
actions: WidgetActions = .{},
|
|
256
267
|
value: ?f32 = null,
|
|
257
|
-
|
|
268
|
+
/// Scroll step for `scroll_by` intents, in canvas points on each
|
|
269
|
+
/// axis. Keyboard and semantic scroll steps set exactly one axis;
|
|
270
|
+
/// which one follows the widget's scroll-axes grant (vertical
|
|
271
|
+
/// keymap on vertical-capable regions, horizontal on
|
|
272
|
+
/// horizontal-only ones).
|
|
273
|
+
delta: geometry.OffsetF = .{},
|
|
258
274
|
};
|
|
259
275
|
|
|
260
276
|
pub const WidgetSemanticAction = enum {
|
|
@@ -657,29 +673,68 @@ pub fn widgetScrollKeyboardIntent(widget: Widget, keyboard: WidgetKeyboardEvent)
|
|
|
657
673
|
if (std.ascii.eqlIgnoreCase(keyboard.key, "home")) return .{ .kind = .scroll_to_start, .actions = .{ .decrement = true } };
|
|
658
674
|
if (std.ascii.eqlIgnoreCase(keyboard.key, "end")) return .{ .kind = .scroll_to_end, .actions = .{ .increment = true } };
|
|
659
675
|
const delta = widgetScrollKeyboardDelta(widget, keyboard) orelse return null;
|
|
676
|
+
const step = if (delta.dy != 0) delta.dy else delta.dx;
|
|
660
677
|
return .{
|
|
661
678
|
.kind = .scroll_by,
|
|
662
679
|
.actions = .{
|
|
663
|
-
.increment =
|
|
664
|
-
.decrement =
|
|
680
|
+
.increment = step > 0,
|
|
681
|
+
.decrement = step < 0,
|
|
665
682
|
},
|
|
666
683
|
.delta = delta,
|
|
667
684
|
};
|
|
668
685
|
}
|
|
669
686
|
|
|
670
|
-
|
|
687
|
+
/// True when a scroll-intent widget takes the HORIZONTAL keymap: a
|
|
688
|
+
/// horizontal-only `.scroll_view`. Vertical-capable regions (including
|
|
689
|
+
/// `both`, whose left/right arrows step sideways below) and every other
|
|
690
|
+
/// scrollable kind keep the vertical keymap they always had.
|
|
691
|
+
fn widgetScrollKeymapHorizontalOnly(widget: Widget) bool {
|
|
692
|
+
return widget.kind == .scroll_view and !widget.layout.virtualized and widget.scroll_axes == .horizontal;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/// The keyboard scroll step, axis-aware:
|
|
696
|
+
/// - vertical regions keep the exact legacy map (both arrow pairs step
|
|
697
|
+
/// the vertical axis — Left/Up a line up, Right/Down a line down —
|
|
698
|
+
/// and PageUp/PageDown page it);
|
|
699
|
+
/// - a horizontal-only region mirrors that whole map onto its one axis,
|
|
700
|
+
/// with line/page steps measured from the viewport WIDTH;
|
|
701
|
+
/// - a `both` region keeps the vertical map and gives Left/Right to the
|
|
702
|
+
/// horizontal axis — the two-axis convention native scroll views use.
|
|
703
|
+
pub fn widgetScrollKeyboardDelta(widget: Widget, keyboard: WidgetKeyboardEvent) ?geometry.OffsetF {
|
|
671
704
|
if (keyboard.phase != .key_down or keyboard.modifiers.hasNavigationModifier()) return null;
|
|
672
705
|
const viewport = widget.frame.inset(widget.layout.padding).normalized();
|
|
706
|
+
if (widgetScrollKeymapHorizontalOnly(widget)) {
|
|
707
|
+
const line_step = @max(24, viewport.width * 0.35);
|
|
708
|
+
const page_step = @max(line_step, viewport.width * 0.85);
|
|
709
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowleft") or std.ascii.eqlIgnoreCase(keyboard.key, "arrowup")) {
|
|
710
|
+
return geometry.OffsetF.init(-line_step, 0);
|
|
711
|
+
}
|
|
712
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowright") or std.ascii.eqlIgnoreCase(keyboard.key, "arrowdown")) {
|
|
713
|
+
return geometry.OffsetF.init(line_step, 0);
|
|
714
|
+
}
|
|
715
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "pageup")) return geometry.OffsetF.init(-page_step, 0);
|
|
716
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "pagedown")) return geometry.OffsetF.init(page_step, 0);
|
|
717
|
+
return null;
|
|
718
|
+
}
|
|
719
|
+
const dual = widget.kind == .scroll_view and !widget.layout.virtualized and widget.scroll_axes == .both;
|
|
673
720
|
const line_step = @max(24, viewport.height * 0.35);
|
|
674
721
|
const page_step = @max(line_step, viewport.height * 0.85);
|
|
675
|
-
if (
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return line_step;
|
|
722
|
+
if (dual) {
|
|
723
|
+
const line_step_x = @max(24, viewport.width * 0.35);
|
|
724
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowleft")) return geometry.OffsetF.init(-line_step_x, 0);
|
|
725
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowright")) return geometry.OffsetF.init(line_step_x, 0);
|
|
726
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowup")) return geometry.OffsetF.init(0, -line_step);
|
|
727
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowdown")) return geometry.OffsetF.init(0, line_step);
|
|
728
|
+
} else {
|
|
729
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowleft") or std.ascii.eqlIgnoreCase(keyboard.key, "arrowup")) {
|
|
730
|
+
return geometry.OffsetF.init(0, -line_step);
|
|
731
|
+
}
|
|
732
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowright") or std.ascii.eqlIgnoreCase(keyboard.key, "arrowdown")) {
|
|
733
|
+
return geometry.OffsetF.init(0, line_step);
|
|
734
|
+
}
|
|
680
735
|
}
|
|
681
|
-
if (std.ascii.eqlIgnoreCase(keyboard.key, "pageup")) return -page_step;
|
|
682
|
-
if (std.ascii.eqlIgnoreCase(keyboard.key, "pagedown")) return page_step;
|
|
736
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "pageup")) return geometry.OffsetF.init(0, -page_step);
|
|
737
|
+
if (std.ascii.eqlIgnoreCase(keyboard.key, "pagedown")) return geometry.OffsetF.init(0, page_step);
|
|
683
738
|
return null;
|
|
684
739
|
}
|
|
685
740
|
|
|
@@ -712,11 +767,43 @@ fn widgetSemanticStepControlIntent(widget: Widget, direction: WidgetSemanticStep
|
|
|
712
767
|
};
|
|
713
768
|
}
|
|
714
769
|
|
|
715
|
-
|
|
770
|
+
/// Assistive scroll steps page ONE axis — the region's primary, by the
|
|
771
|
+
/// same range-aware rule its scroll semantics report through: vertical
|
|
772
|
+
/// wherever the vertical axis is granted and can move, the horizontal
|
|
773
|
+
/// axis on horizontal-only regions and on `both` regions whose content
|
|
774
|
+
/// only overflows sideways. A diagonal step would move the viewport on
|
|
775
|
+
/// an axis the assistive node never exposed. Range for the `both` case
|
|
776
|
+
/// reads the widget's own children (widget-walk trees carry them);
|
|
777
|
+
/// retained layout nodes drop children, and their caller — the
|
|
778
|
+
/// runtime's accessibility-action path — resolves the axis with live
|
|
779
|
+
/// extents instead (`canvasWidgetStepKey`).
|
|
780
|
+
fn widgetSemanticScrollDelta(widget: Widget, direction: WidgetSemanticStepDirection) geometry.OffsetF {
|
|
716
781
|
const viewport = widget.frame.inset(widget.layout.padding).normalized();
|
|
717
|
-
const
|
|
718
|
-
const
|
|
719
|
-
|
|
782
|
+
const sign: f32 = if (direction == .increment) 1 else -1;
|
|
783
|
+
const horizontal_primary = widgetScrollKeymapHorizontalOnly(widget) or
|
|
784
|
+
(widget.kind == .scroll_view and !widget.layout.virtualized and widget.scroll_axes == .both and
|
|
785
|
+
widgetChildrenScrollHorizontalOnly(widget, viewport));
|
|
786
|
+
if (horizontal_primary) {
|
|
787
|
+
const page_step_x = @max(@max(24, viewport.width * 0.35), viewport.width * 0.85);
|
|
788
|
+
return geometry.OffsetF.init(sign * page_step_x, 0);
|
|
789
|
+
}
|
|
790
|
+
const page_step_y = @max(@max(24, viewport.height * 0.35), viewport.height * 0.85);
|
|
791
|
+
return geometry.OffsetF.init(0, sign * page_step_y);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/// Whether a `both` region's mounted children overflow ONLY sideways:
|
|
795
|
+
/// no vertical range (nothing reaches past the fold) while something
|
|
796
|
+
/// reaches past the right edge. False on childless nodes — retained
|
|
797
|
+
/// trees drop children, and their callers resolve range elsewhere.
|
|
798
|
+
fn widgetChildrenScrollHorizontalOnly(widget: Widget, viewport: geometry.RectF) bool {
|
|
799
|
+
if (widget.children.len == 0) return false;
|
|
800
|
+
var right = viewport.maxX();
|
|
801
|
+
var bottom = viewport.maxY();
|
|
802
|
+
for (widget.children) |child| {
|
|
803
|
+
right = @max(right, child.frame.maxX() + widget.value_x);
|
|
804
|
+
bottom = @max(bottom, child.frame.maxY() + widget.value);
|
|
805
|
+
}
|
|
806
|
+
return bottom <= viewport.maxY() and right > viewport.maxX();
|
|
720
807
|
}
|
|
721
808
|
|
|
722
809
|
pub fn semanticActions(widget: Widget) WidgetActions {
|
|
@@ -792,7 +879,7 @@ pub fn defaultFocusable(widget: Widget) bool {
|
|
|
792
879
|
// part of the tree's roving keyboard focus set.
|
|
793
880
|
if (widget.semantics.role == .treeitem) return !widget.state.disabled;
|
|
794
881
|
return switch (widget.kind) {
|
|
795
|
-
.scroll_view, .accordion, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .split_divider => !widget.state.disabled,
|
|
882
|
+
.scroll_view, .accordion, .button, .toggle_button, .icon_button, .select, .input, .text_field, .search_field, .combobox, .textarea, .menu_item, .list_item, .data_cell, .segmented_control, .checkbox, .radio, .switch_control, .toggle, .slider, .split_divider, .terminal => !widget.state.disabled,
|
|
796
883
|
else => false,
|
|
797
884
|
};
|
|
798
885
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const std = @import("std");
|
|
1
2
|
const geometry = @import("geometry");
|
|
2
3
|
const canvas = @import("root.zig");
|
|
3
4
|
const render_model = @import("render.zig");
|
|
@@ -606,7 +607,14 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
606
607
|
dirty_bounds = fullRepaintBounds(options.surface_size, render_plan.bounds);
|
|
607
608
|
} else {
|
|
608
609
|
changes = try DisplayList.diff(previous.?, next, storage.changes);
|
|
609
|
-
|
|
610
|
+
// Incremental damage carries a one-device-pixel AA bleed
|
|
611
|
+
// allowance and lands snapped outward on the device-pixel grid
|
|
612
|
+
// (see the runtime planner's dirty finalization): the bleed
|
|
613
|
+
// covers the up-to-a-device-pixel ink past a command's bounds,
|
|
614
|
+
// and the snap keeps the cull region identical to the cleared
|
|
615
|
+
// pixels so a fractional dirty edge cannot erase an unchanged
|
|
616
|
+
// neighbor's boundary-pixel coverage without redrawing it.
|
|
617
|
+
dirty_bounds = bleedAlignedDirtyBounds(unionOptionalBounds(dirtyBoundsFromChanges(changes), render_override_dirty_bounds), options.scale, 1, options.surface_size);
|
|
610
618
|
}
|
|
611
619
|
|
|
612
620
|
return .{
|
|
@@ -649,6 +657,122 @@ fn dirtyBoundsFromChanges(changes: []const DiffChange) ?geometry.RectF {
|
|
|
649
657
|
return result;
|
|
650
658
|
}
|
|
651
659
|
|
|
660
|
+
/// Bleed-and-snap for incremental damage, the twin of the runtime's
|
|
661
|
+
/// `bleedAlignedCanvasDirtyBounds` (see that doc comment): whole device
|
|
662
|
+
/// pixels of AA bleed folded in on integer device boundaries, edges
|
|
663
|
+
/// chosen so the STORED rect's f32 round trip lands exactly on them.
|
|
664
|
+
fn bleedAlignedDirtyBounds(bounds: ?geometry.RectF, scale: f32, bleed_pixels: f32, surface_size: geometry.SizeF) ?geometry.RectF {
|
|
665
|
+
const dirty = bounds orelse return null;
|
|
666
|
+
const normalized = dirty.normalized();
|
|
667
|
+
const device = if (std.math.isFinite(scale) and scale > 0) scale else 1;
|
|
668
|
+
// Surface clipping happens on the integer device boundaries, never
|
|
669
|
+
// on the finished rect (see the runtime twin's doc comment).
|
|
670
|
+
const x_boundaries = surfaceClampedDirtyBoundaries(
|
|
671
|
+
@floor(normalized.minX() * device) - bleed_pixels,
|
|
672
|
+
@ceil(normalized.maxX() * device) + bleed_pixels,
|
|
673
|
+
surface_size.width,
|
|
674
|
+
device,
|
|
675
|
+
) orelse return null;
|
|
676
|
+
const y_boundaries = surfaceClampedDirtyBoundaries(
|
|
677
|
+
@floor(normalized.minY() * device) - bleed_pixels,
|
|
678
|
+
@ceil(normalized.maxY() * device) + bleed_pixels,
|
|
679
|
+
surface_size.height,
|
|
680
|
+
device,
|
|
681
|
+
) orelse return null;
|
|
682
|
+
const x_edges = dirtyAxisEdges(x_boundaries.min, x_boundaries.max, device);
|
|
683
|
+
const y_edges = dirtyAxisEdges(y_boundaries.min, y_boundaries.max, device);
|
|
684
|
+
if (x_edges.span <= 0 or y_edges.span <= 0) return null;
|
|
685
|
+
return geometry.RectF.init(x_edges.min, y_edges.min, x_edges.span, y_edges.span);
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
const DirtyBoundaries = struct { min: f32, max: f32 };
|
|
689
|
+
|
|
690
|
+
/// Clamp one axis' device boundaries to the surface's device
|
|
691
|
+
/// boundaries (see the runtime twin's doc comment).
|
|
692
|
+
fn surfaceClampedDirtyBoundaries(min_boundary: f32, max_boundary: f32, surface_extent: f32, device: f32) ?DirtyBoundaries {
|
|
693
|
+
var min_b = min_boundary;
|
|
694
|
+
var max_b = max_boundary;
|
|
695
|
+
if (std.math.isFinite(surface_extent) and surface_extent > 0) {
|
|
696
|
+
const surface_boundary = @ceil(surface_extent * device);
|
|
697
|
+
if (std.math.isFinite(surface_boundary)) {
|
|
698
|
+
min_b = std.math.clamp(min_b, 0, surface_boundary);
|
|
699
|
+
max_b = std.math.clamp(max_b, 0, surface_boundary);
|
|
700
|
+
if (!(max_b > min_b)) return null;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return .{ .min = min_b, .max = max_b };
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
const DirtyAxisEdges = struct { min: f32, span: f32 };
|
|
707
|
+
|
|
708
|
+
/// One axis of the bleed-aligned damage (see the runtime twin's doc
|
|
709
|
+
/// comment): exact edge walks inside f32's exact-integer range, a
|
|
710
|
+
/// finite non-collapsed superset beyond it.
|
|
711
|
+
fn dirtyAxisEdges(min_boundary: f32, max_boundary: f32, device: f32) DirtyAxisEdges {
|
|
712
|
+
const walk_limit: f32 = 16_777_216;
|
|
713
|
+
const walkable = min_boundary >= -walk_limit and min_boundary <= walk_limit and
|
|
714
|
+
max_boundary >= -walk_limit and max_boundary <= walk_limit;
|
|
715
|
+
if (!walkable) {
|
|
716
|
+
const min_edge = nudgedFiniteDirtyEdge(min_boundary / device, -2);
|
|
717
|
+
const max_edge = nudgedFiniteDirtyEdge(max_boundary / device, 2);
|
|
718
|
+
var span = @max(0, nudgedFiniteDirtyEdge(max_edge - min_edge, 2));
|
|
719
|
+
// The reconstructed max edge must stay finite at the f32 range
|
|
720
|
+
// edge; shave the span until the sum stops overflowing.
|
|
721
|
+
while (span > 0 and !std.math.isFinite(min_edge + span)) span = std.math.nextAfter(f32, span, -std.math.inf(f32));
|
|
722
|
+
return .{ .min = min_edge, .span = span };
|
|
723
|
+
}
|
|
724
|
+
const min_edge = dirtyEdgeForFloorBoundary(min_boundary, device);
|
|
725
|
+
return .{ .min = min_edge, .span = dirtySpanForCeilBoundary(min_edge, max_boundary, device) };
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/// Finite superset value (see the runtime twin's doc comment): only
|
|
729
|
+
/// NaN and the infinities are replaced, so far-but-representable
|
|
730
|
+
/// content keeps its damage in place.
|
|
731
|
+
fn nudgedFiniteDirtyEdge(value: f32, ulps: i8) f32 {
|
|
732
|
+
if (std.math.isNan(value)) return 0;
|
|
733
|
+
const limit = std.math.floatMax(f32);
|
|
734
|
+
var result = std.math.clamp(value, -limit, limit);
|
|
735
|
+
var remaining: i8 = if (ulps < 0) -ulps else ulps;
|
|
736
|
+
const toward: f32 = if (ulps < 0) -std.math.inf(f32) else std.math.inf(f32);
|
|
737
|
+
while (remaining > 0) : (remaining -= 1) result = std.math.nextAfter(f32, result, toward);
|
|
738
|
+
return std.math.clamp(result, -limit, limit);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/// Smallest representable coordinate whose product with `device`
|
|
742
|
+
/// reaches `boundary`, judged in f64 — exact for f32 operands and what
|
|
743
|
+
/// retained hosts compute (see the runtime twin's doc comment).
|
|
744
|
+
fn dirtyEdgeForFloorBoundary(boundary: f32, device: f32) f32 {
|
|
745
|
+
const b: f64 = boundary;
|
|
746
|
+
const d: f64 = device;
|
|
747
|
+
var edge = boundary / device;
|
|
748
|
+
while (@as(f64, edge) * d >= b) edge = std.math.nextAfter(f32, edge, -std.math.inf(f32));
|
|
749
|
+
while (@as(f64, edge) * d < b) edge = std.math.nextAfter(f32, edge, std.math.inf(f32));
|
|
750
|
+
// The walk can settle on negative zero (a boundary of zero steps
|
|
751
|
+
// below and back); canonicalize so serialized rects never carry a
|
|
752
|
+
// signed zero.
|
|
753
|
+
return if (edge == 0) 0 else edge;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
/// Largest span whose reconstructed max edge (`min_edge + span`) keeps
|
|
757
|
+
/// its product with `device` at or under `boundary`, judged in f64 (see
|
|
758
|
+
/// the runtime twin's doc comment); the walk steps the edge value,
|
|
759
|
+
/// never the span.
|
|
760
|
+
fn dirtySpanForCeilBoundary(min_edge: f32, boundary: f32, device: f32) f32 {
|
|
761
|
+
const b: f64 = boundary;
|
|
762
|
+
const d: f64 = device;
|
|
763
|
+
var target = boundary / device;
|
|
764
|
+
while (@as(f64, target) * d <= b) target = std.math.nextAfter(f32, target, std.math.inf(f32));
|
|
765
|
+
while (@as(f64, target) * d > b) target = std.math.nextAfter(f32, target, -std.math.inf(f32));
|
|
766
|
+
if (target <= min_edge) return 0;
|
|
767
|
+
var span = target - min_edge;
|
|
768
|
+
while (span > 0 and @as(f64, min_edge) + @as(f64, span) > @as(f64, target)) {
|
|
769
|
+
const next = std.math.nextAfter(f32, span, -std.math.inf(f32));
|
|
770
|
+
if (next == span) return 0;
|
|
771
|
+
span = next;
|
|
772
|
+
}
|
|
773
|
+
return if (span <= 0) 0 else span;
|
|
774
|
+
}
|
|
775
|
+
|
|
652
776
|
fn fullRepaintBounds(surface_size: geometry.SizeF, render_bounds: ?geometry.RectF) ?geometry.RectF {
|
|
653
777
|
if (surfaceRect(surface_size)) |surface| return surface;
|
|
654
778
|
return render_bounds;
|
|
@@ -395,9 +395,17 @@ fn widgetClipsForAudit(widget: Widget) bool {
|
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
/// Whether the clip scope scrolls vertically by design, making vertical
|
|
398
|
-
/// overhang the normal operating mode rather than damage.
|
|
398
|
+
/// overhang the normal operating mode rather than damage. A
|
|
399
|
+
/// horizontal-only scroll view does NOT scroll vertically: content
|
|
400
|
+
/// escaping it downward is damage nothing can reveal.
|
|
399
401
|
fn scopeScrollsVertically(widget: Widget) bool {
|
|
400
|
-
return widget.kind == .scroll_view or widget.layout.virtualized;
|
|
402
|
+
return (widget.kind == .scroll_view and widget.scroll_axes.scrollsVertically()) or widget.layout.virtualized;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/// The horizontal twin: a scroll viewport granting the horizontal axis
|
|
406
|
+
/// makes horizontal overhang the operating mode, not damage.
|
|
407
|
+
fn scopeScrollsHorizontally(widget: Widget) bool {
|
|
408
|
+
return widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized;
|
|
401
409
|
}
|
|
402
410
|
|
|
403
411
|
/// Nearest ancestor whose clip bounds this node: the first clipping
|
|
@@ -428,6 +436,7 @@ fn auditNodeContainerEscape(
|
|
|
428
436
|
const scope_index = clipScopeIndex(layout, node_index);
|
|
429
437
|
const scope = if (scope_index) |index| layout.nodes[index].frame.normalized() else window.normalized();
|
|
430
438
|
const vertical_checked = if (scope_index) |index| !scopeScrollsVertically(layout.nodes[index].widget) else true;
|
|
439
|
+
const horizontal_checked = if (scope_index) |index| !scopeScrollsHorizontally(layout.nodes[index].widget) else true;
|
|
431
440
|
|
|
432
441
|
// Attribute the escape to the outermost offender: if any ancestor
|
|
433
442
|
// inside the same scope is already reported, this node's overhang is
|
|
@@ -441,8 +450,16 @@ fn auditNodeContainerEscape(
|
|
|
441
450
|
|
|
442
451
|
const frame = node.frame.normalized();
|
|
443
452
|
var overrun_x: f32 = 0;
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
if (horizontal_checked) {
|
|
454
|
+
overrun_x = @max(overrun_x, overrunPast(frame.maxX(), scope.maxX()));
|
|
455
|
+
overrun_x = @max(overrun_x, overrunPast(scope.x, frame.x));
|
|
456
|
+
} else if (scope_index) |index| {
|
|
457
|
+
// A horizontal scroll scope forgives trailing overhang (the
|
|
458
|
+
// scroll reveals it) but not content stranded BEFORE the
|
|
459
|
+
// origin: offsets clamp at zero, so anything the region's own
|
|
460
|
+
// offset cannot explain on the leading side is damage.
|
|
461
|
+
overrun_x = @max(overrun_x, overrunPast(scope.x, frame.x + layout.nodes[index].widget.value_x));
|
|
462
|
+
}
|
|
446
463
|
var overrun_y: f32 = 0;
|
|
447
464
|
if (vertical_checked) {
|
|
448
465
|
overrun_y = @max(overrun_y, overrunPast(frame.maxY(), scope.maxY()));
|
|
@@ -469,7 +486,7 @@ fn auditNodeContainerEscape(
|
|
|
469
486
|
/// inline link hotspots follow text metrics by convention; both exempt.
|
|
470
487
|
fn widgetKindIsPointerTarget(kind: WidgetKind) bool {
|
|
471
488
|
return switch (kind) {
|
|
472
|
-
.button, .toggle_button, .icon_button, .select, .combobox, .input, .text_field, .search_field, .textarea, .checkbox, .radio, .switch_control, .toggle, .slider, .menu_item, .segmented_control, .list_item => true,
|
|
489
|
+
.button, .toggle_button, .icon_button, .select, .combobox, .input, .text_field, .search_field, .textarea, .checkbox, .radio, .switch_control, .toggle, .slider, .menu_item, .segmented_control, .list_item, .terminal => true,
|
|
473
490
|
else => false,
|
|
474
491
|
};
|
|
475
492
|
}
|