@native-sdk/cli 0.5.4 → 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 +50 -1
- package/build.zig +534 -3
- package/build.zig.zon +7 -0
- package/native-sdk.d.ts +3 -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 +280 -8
- package/packages/core/sdk/core.ts +481 -2
- 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 +599 -3
- package/packages/core/src/typed_ast.ts +51 -4
- package/packages/core/src/types.ts +34 -1
- package/skill-data/native-ui/SKILL.md +39 -2
- package/skill-data/ts-core/SKILL.md +4 -2
- package/src/app_runner/root.zig +32 -10
- 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/ui_host.zig +13 -0
- package/src/platform/linux/gtk_host.c +527 -13
- package/src/platform/linux/gtk_host.h +25 -0
- package/src/platform/linux/root.zig +280 -7
- package/src/platform/macos/appkit_host.h +104 -6
- package/src/platform/macos/appkit_host.m +1283 -66
- package/src/platform/macos/cef_host.mm +110 -1
- package/src/platform/macos/root.zig +287 -7
- package/src/platform/null_platform.zig +398 -4
- package/src/platform/null_platform_tests.zig +35 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +386 -14
- package/src/platform/windows/root.zig +298 -9
- package/src/platform/windows/webview2_host.cpp +330 -5
- 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 +1 -0
- package/src/primitives/canvas/text_tests.zig +39 -4
- package/src/primitives/canvas/tokens.zig +115 -12
- package/src/primitives/canvas/ui.zig +524 -5
- package/src/primitives/canvas/ui_markup.zig +195 -2
- package/src/primitives/canvas/ui_markup_compiled.zig +172 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +133 -8
- package/src/primitives/canvas/ui_markup_contract.zig +88 -5
- package/src/primitives/canvas/ui_markup_contract_tests.zig +39 -1
- 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 +149 -0
- package/src/primitives/canvas/ui_markup_view.zig +191 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +403 -19
- package/src/primitives/canvas/ui_schema.zig +97 -17
- package/src/primitives/canvas/ui_schema_tests.zig +18 -11
- 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 +16 -0
- package/src/runtime/api.zig +70 -1
- 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 +1 -0
- 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_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 +73 -2
- package/src/runtime/effects.zig +6389 -54
- package/src/runtime/effects_channel_tests.zig +3519 -0
- package/src/runtime/effects_pty_tests.zig +1362 -0
- package/src/runtime/effects_tests.zig +14 -9
- package/src/runtime/effects_video_tests.zig +3609 -0
- package/src/runtime/flow.zig +25 -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 +25 -0
- package/src/runtime/runtime_event_tests.zig +20 -1
- package/src/runtime/session_journal.zig +367 -61
- package/src/runtime/session_record.zig +16 -0
- package/src/runtime/session_replay.zig +395 -11
- package/src/runtime/session_tests.zig +109 -15
- 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/tests.zig +6 -0
- package/src/runtime/ts_core_host.zig +980 -140
- package/src/runtime/ts_core_host_tests.zig +1059 -1
- package/src/runtime/ts_ui_app.zig +16 -5
- package/src/runtime/ui_app.zig +2333 -63
- 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 +268 -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_storage.zig +45 -2
- package/src/runtime/window_view_runtime.zig +34 -2
- package/src/runtime/window_views.zig +1 -0
- package/src/terminal_session_tests_root.zig +15 -0
- package/src/tooling/templates.zig +25 -7
|
@@ -16,6 +16,7 @@ const WidgetLayoutNode = event_model.WidgetLayoutNode;
|
|
|
16
16
|
const WidgetSemanticsNode = event_model.WidgetSemanticsNode;
|
|
17
17
|
const WidgetListMetrics = event_model.WidgetListMetrics;
|
|
18
18
|
const WidgetScrollMetrics = event_model.WidgetScrollMetrics;
|
|
19
|
+
const ScrollAxis = token_model.ScrollAxis;
|
|
19
20
|
const VirtualListRange = token_model.VirtualListRange;
|
|
20
21
|
const virtualListRange = token_model.virtualListRange;
|
|
21
22
|
const semanticActions = event_model.semanticActions;
|
|
@@ -149,6 +150,10 @@ pub fn semanticRole(widget: Widget) WidgetRole {
|
|
|
149
150
|
// The grouped input announces as ONE named group; the entry and
|
|
150
151
|
// the accessory controls inside stay individually reachable.
|
|
151
152
|
.input_group => .group,
|
|
153
|
+
// The terminal announces as an editable text region whose label
|
|
154
|
+
// carries the live viewport text (a terminal's semantic content
|
|
155
|
+
// IS its text) — the same register the platform terminals use.
|
|
156
|
+
.terminal => .textbox,
|
|
152
157
|
};
|
|
153
158
|
}
|
|
154
159
|
|
|
@@ -200,7 +205,12 @@ fn defaultExpandedState(widget: Widget) ?bool {
|
|
|
200
205
|
|
|
201
206
|
fn semanticTextValue(widget: Widget) []const u8 {
|
|
202
207
|
return switch (widget.kind) {
|
|
203
|
-
|
|
208
|
+
// A terminal's screen text is its content value, distinct from
|
|
209
|
+
// its stable control name (the author label): the builder puts
|
|
210
|
+
// the live viewport text in `widget.text`, so it must surface as
|
|
211
|
+
// the text VALUE — assistive tech reads output changes and the
|
|
212
|
+
// a11y-tree fingerprint covers the screen.
|
|
213
|
+
.input, .text_field, .search_field, .combobox, .textarea, .terminal => widget.text,
|
|
204
214
|
else => "",
|
|
205
215
|
};
|
|
206
216
|
}
|
|
@@ -418,6 +428,50 @@ pub const WidgetScrollSemantics = struct {
|
|
|
418
428
|
scrollable: bool = false,
|
|
419
429
|
};
|
|
420
430
|
|
|
431
|
+
/// One axis of a scroll region as the one-axis metrics record, or
|
|
432
|
+
/// `present = false` when the region does not grant that axis (a
|
|
433
|
+
/// horizontal-only shelf has no vertical metrics, a vertical list no
|
|
434
|
+
/// horizontal ones). The engine scrollbar renders each axis from this;
|
|
435
|
+
/// `widgetScrollSemantics` picks the primary axis for the assistive
|
|
436
|
+
/// node.
|
|
437
|
+
pub fn widgetScrollAxisMetrics(layout: anytype, node_index: usize, virtual_content_extent_fn: anytype, comptime axis: ScrollAxis, viewport: geometry.RectF) WidgetScrollMetrics {
|
|
438
|
+
const node = layout.nodes[node_index];
|
|
439
|
+
switch (axis) {
|
|
440
|
+
.vertical => {
|
|
441
|
+
if (node.widget.kind == .scroll_view and !node.widget.layout.virtualized and !node.widget.scroll_axes.scrollsVertically()) return .{};
|
|
442
|
+
const content_extent = widgetScrollContentExtent(layout, node_index, viewport, virtual_content_extent_fn);
|
|
443
|
+
const max_offset = @max(0, content_extent - viewport.height);
|
|
444
|
+
return .{
|
|
445
|
+
.present = true,
|
|
446
|
+
.offset = std.math.clamp(nonNegative(node.widget.value), 0, max_offset),
|
|
447
|
+
.viewport_extent = viewport.height,
|
|
448
|
+
.content_extent = content_extent,
|
|
449
|
+
};
|
|
450
|
+
},
|
|
451
|
+
.horizontal => {
|
|
452
|
+
if (node.widget.kind != .scroll_view or node.widget.layout.virtualized or !node.widget.scroll_axes.scrollsHorizontally()) return .{};
|
|
453
|
+
const content_extent = widgetScrollContentExtentX(layout, node_index, viewport);
|
|
454
|
+
const max_offset = @max(0, content_extent - viewport.width);
|
|
455
|
+
return .{
|
|
456
|
+
.present = true,
|
|
457
|
+
.offset = std.math.clamp(nonNegative(node.widget.value_x), 0, max_offset),
|
|
458
|
+
.viewport_extent = viewport.width,
|
|
459
|
+
.content_extent = content_extent,
|
|
460
|
+
};
|
|
461
|
+
},
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/// Scroll semantics report the region's PRIMARY axis: the vertical one
|
|
466
|
+
/// wherever it is granted AND has scrollable range (the pre-axis
|
|
467
|
+
/// behavior for every vertical-only region, byte-identical), otherwise
|
|
468
|
+
/// the horizontal one — so an assistive query on a sideways shelf, or
|
|
469
|
+
/// on a `both` region whose content only overflows sideways, reads a
|
|
470
|
+
/// live position instead of a permanently unscrollable axis. The
|
|
471
|
+
/// one-axis metrics shape is deliberate: it rides the embed ABI and
|
|
472
|
+
/// automation snapshots, and the assistive scroll ACTIONS resolve
|
|
473
|
+
/// their axis through the same primary-axis rule
|
|
474
|
+
/// (`widgetSemanticScrollDelta`).
|
|
421
475
|
pub fn widgetScrollSemantics(layout: anytype, node_index: usize, virtual_content_extent_fn: anytype) WidgetScrollSemantics {
|
|
422
476
|
if (node_index >= layout.nodes.len) return .{};
|
|
423
477
|
const node = layout.nodes[node_index];
|
|
@@ -426,17 +480,21 @@ pub fn widgetScrollSemantics(layout: anytype, node_index: usize, virtual_content
|
|
|
426
480
|
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
427
481
|
if (viewport.isEmpty()) return .{};
|
|
428
482
|
|
|
429
|
-
const
|
|
430
|
-
const
|
|
431
|
-
const
|
|
483
|
+
const vertical = widgetScrollAxisMetrics(layout, node_index, virtual_content_extent_fn, .vertical, viewport);
|
|
484
|
+
const horizontal = widgetScrollAxisMetrics(layout, node_index, virtual_content_extent_fn, .horizontal, viewport);
|
|
485
|
+
const vertical_range = vertical.present and vertical.content_extent > vertical.viewport_extent;
|
|
486
|
+
const horizontal_range = horizontal.present and horizontal.content_extent > horizontal.viewport_extent;
|
|
487
|
+
const metrics = if (vertical_range or (vertical.present and !horizontal_range))
|
|
488
|
+
vertical
|
|
489
|
+
else if (horizontal.present)
|
|
490
|
+
horizontal
|
|
491
|
+
else
|
|
492
|
+
vertical;
|
|
493
|
+
if (!metrics.present) return .{};
|
|
494
|
+
const max_offset = @max(0, metrics.content_extent - metrics.viewport_extent);
|
|
432
495
|
return .{
|
|
433
|
-
.metrics =
|
|
434
|
-
|
|
435
|
-
.offset = offset,
|
|
436
|
-
.viewport_extent = viewport.height,
|
|
437
|
-
.content_extent = content_extent,
|
|
438
|
-
},
|
|
439
|
-
.value = if (max_offset > 0) offset / max_offset else 0,
|
|
496
|
+
.metrics = metrics,
|
|
497
|
+
.value = if (max_offset > 0) metrics.offset / max_offset else 0,
|
|
440
498
|
.scrollable = max_offset > 0,
|
|
441
499
|
};
|
|
442
500
|
}
|
|
@@ -461,6 +519,16 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
|
|
|
461
519
|
var index = scroll_index + 1;
|
|
462
520
|
while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
|
|
463
521
|
const node = layout.nodes[index];
|
|
522
|
+
// A subtree anchored DIRECTLY to the scroll region stays
|
|
523
|
+
// stationary under scrolling (its anchor base never moves), so
|
|
524
|
+
// `frame + offset` is not a content-space position for it —
|
|
525
|
+
// counting it would inflate the range on every scroll. Deeper
|
|
526
|
+
// anchored subtrees ride their in-content anchors and keep
|
|
527
|
+
// their historical contribution.
|
|
528
|
+
if (node.widget.layout.anchor != null and node.parent_index == scroll_index) {
|
|
529
|
+
index = skipSubtree(layout, index);
|
|
530
|
+
continue;
|
|
531
|
+
}
|
|
464
532
|
bottom = @max(bottom, node.frame.maxY() + offset);
|
|
465
533
|
// A disclosure widget's own frame is authoritative for how far
|
|
466
534
|
// its content currently reaches: concealed content lays out at
|
|
@@ -480,6 +548,46 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
|
|
|
480
548
|
return @max(0, bottom - viewport.y);
|
|
481
549
|
}
|
|
482
550
|
|
|
551
|
+
/// The horizontal content reach for a horizontal scroll view's
|
|
552
|
+
/// semantics — the sideways mirror of `widgetScrollContentExtent`, with
|
|
553
|
+
/// the honest-range exclusions the engine's clamp/driver walker applies
|
|
554
|
+
/// (`canvasWidgetLayoutScrollContentExtentX`): anchored floating
|
|
555
|
+
/// subtrees are out of flow, a nested clip scope bounds its own
|
|
556
|
+
/// children, and disclosure content counts only while settled open.
|
|
557
|
+
fn widgetScrollContentExtentX(layout: anytype, scroll_index: usize, viewport: geometry.RectF) f32 {
|
|
558
|
+
const scroll_node = layout.nodes[scroll_index];
|
|
559
|
+
const scroll_depth = scroll_node.depth;
|
|
560
|
+
const offset = scroll_node.widget.value_x;
|
|
561
|
+
var right = viewport.maxX();
|
|
562
|
+
var index = scroll_index + 1;
|
|
563
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
|
|
564
|
+
const node = layout.nodes[index];
|
|
565
|
+
if (node.widget.layout.anchor != null) {
|
|
566
|
+
index = skipSubtree(layout, index);
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
right = @max(right, node.frame.maxX() + offset);
|
|
570
|
+
if (widget_tree.widgetClipsContent(node.widget) or node.widget.layout.virtualized) {
|
|
571
|
+
index = skipSubtree(layout, index);
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
if (widget_tree.widgetKindDisclosureAnimated(node.widget.kind) and !widget_tree.disclosureSettledOpen(layout, index)) {
|
|
575
|
+
index = skipSubtree(layout, index);
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
index += 1;
|
|
579
|
+
}
|
|
580
|
+
return @max(0, right - viewport.x);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/// The index just past `index`'s whole subtree.
|
|
584
|
+
fn skipSubtree(layout: anytype, index: usize) usize {
|
|
585
|
+
const subtree_depth = layout.nodes[index].depth;
|
|
586
|
+
var next = index + 1;
|
|
587
|
+
while (next < layout.nodes.len and layout.nodes[next].depth > subtree_depth) : (next += 1) {}
|
|
588
|
+
return next;
|
|
589
|
+
}
|
|
590
|
+
|
|
483
591
|
fn nonNegative(value: f32) f32 {
|
|
484
592
|
return if (value < 0) 0 else value;
|
|
485
593
|
}
|
|
@@ -1040,6 +1040,415 @@ test "a composited cover media texture is byte-contained in the reference render
|
|
|
1040
1040
|
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 18, 12);
|
|
1041
1041
|
}
|
|
1042
1042
|
|
|
1043
|
+
/// Render one contain-fit media surface headlessly and hand back the
|
|
1044
|
+
/// composited pixels: the widget's emitted display list (placeholder
|
|
1045
|
+
/// fill + black remainder bars + fitted quad) reference-rendered with
|
|
1046
|
+
/// the texture fed in as an ORDINARY resource under the media-derived
|
|
1047
|
+
/// id, defeating the presentation-only skip so the letterbox geometry
|
|
1048
|
+
/// itself is pixel-assertable. The texture is solid white at the
|
|
1049
|
+
/// STREAM's own aspect (a decoder pushes frames at stream geometry, so
|
|
1050
|
+
/// the draw's contain re-fit against the real texture is a no-op —
|
|
1051
|
+
/// exactly production); the pass clears to opaque blue so bars
|
|
1052
|
+
/// (black), picture (white), and page (blue) are three unmistakable
|
|
1053
|
+
/// bands.
|
|
1054
|
+
fn renderContainVideoSurface(
|
|
1055
|
+
frame: geometry.RectF,
|
|
1056
|
+
stream: ?geometry.SizeF,
|
|
1057
|
+
texture_width: usize,
|
|
1058
|
+
texture_height: usize,
|
|
1059
|
+
pixels: *[32 * 24 * 4]u8,
|
|
1060
|
+
) !ReferenceRenderSurface {
|
|
1061
|
+
const surface_id: u64 = 5;
|
|
1062
|
+
const widget = Widget{
|
|
1063
|
+
.id = 9,
|
|
1064
|
+
.kind = .media_surface,
|
|
1065
|
+
.frame = frame,
|
|
1066
|
+
.image_id = surface_id,
|
|
1067
|
+
.image_fit = .contain,
|
|
1068
|
+
.stream_size = stream,
|
|
1069
|
+
};
|
|
1070
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1071
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1072
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1073
|
+
var builder = Builder.init(&commands);
|
|
1074
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1075
|
+
|
|
1076
|
+
var texture_pixels: [4 * 2 * 4]u8 = undefined;
|
|
1077
|
+
@memset(&texture_pixels, 255);
|
|
1078
|
+
const images = [_]ReferenceImage{.{
|
|
1079
|
+
.id = canvas.mediaSurfaceTextureImageId(surface_id),
|
|
1080
|
+
.width = texture_width,
|
|
1081
|
+
.height = texture_height,
|
|
1082
|
+
.pixels = texture_pixels[0 .. texture_width * texture_height * 4],
|
|
1083
|
+
}};
|
|
1084
|
+
var render_commands: [8]RenderCommand = undefined;
|
|
1085
|
+
const plan = try builder.displayList().renderPlan(&render_commands);
|
|
1086
|
+
@memset(pixels, 0);
|
|
1087
|
+
const surface = (try ReferenceRenderSurface.init(32, 24, pixels)).withImages(&images);
|
|
1088
|
+
try surface.renderPass(.{
|
|
1089
|
+
.commands = plan.commands,
|
|
1090
|
+
.surface_size = geometry.SizeF.init(32, 24),
|
|
1091
|
+
.full_repaint = true,
|
|
1092
|
+
}, Color.rgb8(0, 0, 255));
|
|
1093
|
+
return surface;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
test "a contain video surface pillarboxes a narrow stream on black" {
|
|
1097
|
+
// A square (1:1) stream into a 2:1 box: the fitted quad is the
|
|
1098
|
+
// 16x16 center, with 8px black bars left and right.
|
|
1099
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1100
|
+
const widget = Widget{
|
|
1101
|
+
.id = 9,
|
|
1102
|
+
.kind = .media_surface,
|
|
1103
|
+
.frame = frame,
|
|
1104
|
+
.image_id = 5,
|
|
1105
|
+
.image_fit = .contain,
|
|
1106
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1107
|
+
};
|
|
1108
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1109
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1110
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1111
|
+
var builder = Builder.init(&commands);
|
|
1112
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1113
|
+
const display_list = builder.displayList();
|
|
1114
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1115
|
+
|
|
1116
|
+
// The letterbox field: black across the WHOLE frame at the frame's
|
|
1117
|
+
// radius — the silhouette is exact by construction.
|
|
1118
|
+
switch (display_list.commands[0]) {
|
|
1119
|
+
.fill_rounded_rect => |fill| {
|
|
1120
|
+
try expectRect(frame, fill.rect);
|
|
1121
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1122
|
+
},
|
|
1123
|
+
else => return error.TestUnexpectedResult,
|
|
1124
|
+
}
|
|
1125
|
+
// The deterministic placeholder, confined to the quad: goldens and
|
|
1126
|
+
// replay screenshots (which skip the texture) show it exactly where
|
|
1127
|
+
// the picture goes, inside the black field.
|
|
1128
|
+
switch (display_list.commands[1]) {
|
|
1129
|
+
.fill_rounded_rect => |fill| {
|
|
1130
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), fill.rect);
|
|
1131
|
+
try std.testing.expectEqual(Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) }, fill.fill);
|
|
1132
|
+
},
|
|
1133
|
+
else => return error.TestUnexpectedResult,
|
|
1134
|
+
}
|
|
1135
|
+
// The frame quad: aspect-fitted from the REPORTED dimensions and
|
|
1136
|
+
// centered — the engine computed it, no host fit math required.
|
|
1137
|
+
// `image_src` keeps its ordinary source-crop meaning (untouched
|
|
1138
|
+
// here, so null).
|
|
1139
|
+
switch (display_list.commands[2]) {
|
|
1140
|
+
.draw_image => |draw| {
|
|
1141
|
+
try std.testing.expectEqual(canvas.mediaSurfaceTextureImageId(5), draw.image_id);
|
|
1142
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), draw.dst);
|
|
1143
|
+
// The quad IS the fit: the draw stretches into it, so a
|
|
1144
|
+
// decoder whose true dimensions round off the report can
|
|
1145
|
+
// never open a host-side contain seam inside the quad.
|
|
1146
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1147
|
+
try std.testing.expectEqual(@as(?geometry.RectF, null), draw.src);
|
|
1148
|
+
},
|
|
1149
|
+
else => return error.TestUnexpectedResult,
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// Pixel truth: black side regions, picture centered, page untouched.
|
|
1153
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1154
|
+
const surface = try renderContainVideoSurface(frame, .{ .width = 240, .height = 240 }, 2, 2, &pixels);
|
|
1155
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 3, 12); // left bar
|
|
1156
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 28, 12); // right bar
|
|
1157
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12); // picture
|
|
1158
|
+
try support.expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 16, 1); // page above the frame
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
test "a contain video surface letterboxes a wide stream on black" {
|
|
1162
|
+
// A 2:1 stream into a 2:3 box: the fitted quad is the 16x8 center
|
|
1163
|
+
// band, with 8px black bars above and below.
|
|
1164
|
+
const frame = geometry.RectF.init(8, 0, 16, 24);
|
|
1165
|
+
const stream = geometry.SizeF{ .width = 480, .height = 240 };
|
|
1166
|
+
const widget = Widget{
|
|
1167
|
+
.id = 9,
|
|
1168
|
+
.kind = .media_surface,
|
|
1169
|
+
.frame = frame,
|
|
1170
|
+
.image_id = 5,
|
|
1171
|
+
.image_fit = .contain,
|
|
1172
|
+
.stream_size = stream,
|
|
1173
|
+
};
|
|
1174
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1175
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1176
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1177
|
+
var builder = Builder.init(&commands);
|
|
1178
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1179
|
+
const display_list = builder.displayList();
|
|
1180
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1181
|
+
// Black field over the frame, placeholder confined to the quad.
|
|
1182
|
+
switch (display_list.commands[0]) {
|
|
1183
|
+
.fill_rounded_rect => |fill| {
|
|
1184
|
+
try expectRect(frame, fill.rect);
|
|
1185
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1186
|
+
},
|
|
1187
|
+
else => return error.TestUnexpectedResult,
|
|
1188
|
+
}
|
|
1189
|
+
switch (display_list.commands[1]) {
|
|
1190
|
+
.fill_rounded_rect => |fill| {
|
|
1191
|
+
try expectRect(geometry.RectF.init(8, 8, 16, 8), fill.rect);
|
|
1192
|
+
try std.testing.expectEqual(Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) }, fill.fill);
|
|
1193
|
+
},
|
|
1194
|
+
else => return error.TestUnexpectedResult,
|
|
1195
|
+
}
|
|
1196
|
+
switch (display_list.commands[2]) {
|
|
1197
|
+
.draw_image => |draw| try expectRect(geometry.RectF.init(8, 8, 16, 8), draw.dst),
|
|
1198
|
+
else => return error.TestUnexpectedResult,
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1202
|
+
const surface = try renderContainVideoSurface(frame, stream, 4, 2, &pixels);
|
|
1203
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 16, 4); // top bar
|
|
1204
|
+
try support.expectPixelRgba8(.{ 0, 0, 0, 255 }, surface, 16, 20); // bottom bar
|
|
1205
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12); // picture
|
|
1206
|
+
try support.expectPixelRgba8(.{ 0, 0, 255, 255 }, surface, 4, 12); // page beside the frame
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
test "a contain video surface with matching aspect fills the frame barless" {
|
|
1210
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1211
|
+
const stream = geometry.SizeF{ .width = 640, .height = 320 };
|
|
1212
|
+
var pixels: [32 * 24 * 4]u8 = undefined;
|
|
1213
|
+
const surface = try renderContainVideoSurface(frame, stream, 4, 2, &pixels);
|
|
1214
|
+
// Every frame corner is picture — no bars on either axis.
|
|
1215
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 1, 5);
|
|
1216
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 30, 18);
|
|
1217
|
+
try support.expectPixelRgba8(.{ 255, 255, 255, 255 }, surface, 16, 12);
|
|
1218
|
+
|
|
1219
|
+
// No bar fills, and the full-frame quad keeps the frame's own
|
|
1220
|
+
// corner radius (an inset quad drops it — its corners sit in the
|
|
1221
|
+
// bars, not at the surface's silhouette).
|
|
1222
|
+
const widget = Widget{
|
|
1223
|
+
.id = 9,
|
|
1224
|
+
.kind = .media_surface,
|
|
1225
|
+
.frame = frame,
|
|
1226
|
+
.image_id = 5,
|
|
1227
|
+
.image_fit = .contain,
|
|
1228
|
+
.stream_size = stream,
|
|
1229
|
+
.style = .{ .radius = 6 },
|
|
1230
|
+
};
|
|
1231
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1232
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1233
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1234
|
+
var builder = Builder.init(&commands);
|
|
1235
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1236
|
+
const display_list = builder.displayList();
|
|
1237
|
+
try std.testing.expectEqual(@as(usize, 2), display_list.commandCount());
|
|
1238
|
+
switch (display_list.commands[1]) {
|
|
1239
|
+
.draw_image => |draw| {
|
|
1240
|
+
try expectRect(frame, draw.dst);
|
|
1241
|
+
try std.testing.expectEqual(@as(f32, 6), draw.radius.top_left);
|
|
1242
|
+
// Known geometry always stretches into the engine's quad —
|
|
1243
|
+
// the barless exact-aspect case seams just like the boxed
|
|
1244
|
+
// ones if a host re-fits the real texture.
|
|
1245
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1246
|
+
},
|
|
1247
|
+
else => return error.TestUnexpectedResult,
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
test "bars thinner than the corner radius shrink the quad's mask to the tangent radius" {
|
|
1252
|
+
// A 2.25:1 stream into a 2:1 box leaves ~0.89px letterbox bars —
|
|
1253
|
+
// thinner than the 6px corner radius. The quad's mask is the TIGHT
|
|
1254
|
+
// inset radius, max(0, 6 - bar) ~ 5.11: internally tangent to the
|
|
1255
|
+
// frame's corner circle, so the picture never paints outside the
|
|
1256
|
+
// rounded silhouette (a hairline bar cannot cover a 6px corner)
|
|
1257
|
+
// and never loses more corner than the silhouette demands.
|
|
1258
|
+
const frame = geometry.RectF.init(0, 0, 32, 16);
|
|
1259
|
+
const widget = Widget{
|
|
1260
|
+
.id = 9,
|
|
1261
|
+
.kind = .media_surface,
|
|
1262
|
+
.frame = frame,
|
|
1263
|
+
.image_id = 5,
|
|
1264
|
+
.image_fit = .contain,
|
|
1265
|
+
.stream_size = .{ .width = 36, .height = 16 },
|
|
1266
|
+
.style = .{ .radius = 6 },
|
|
1267
|
+
};
|
|
1268
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1269
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1270
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1271
|
+
var builder = Builder.init(&commands);
|
|
1272
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1273
|
+
const display_list = builder.displayList();
|
|
1274
|
+
// Black field + placeholder quad + the picture quad.
|
|
1275
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1276
|
+
const bar: f32 = (16.0 - 32.0 * 16.0 / 36.0) * 0.5;
|
|
1277
|
+
switch (display_list.commands[2]) {
|
|
1278
|
+
.draw_image => |draw| {
|
|
1279
|
+
try std.testing.expect(draw.dst.height < frame.height);
|
|
1280
|
+
try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, draw.radius.top_left, 0.0001);
|
|
1281
|
+
try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, draw.radius.bottom_right, 0.0001);
|
|
1282
|
+
},
|
|
1283
|
+
else => return error.TestUnexpectedResult,
|
|
1284
|
+
}
|
|
1285
|
+
// The placeholder stand-in carries the same tight mask.
|
|
1286
|
+
switch (display_list.commands[1]) {
|
|
1287
|
+
.fill_rounded_rect => |fill| try std.testing.expectApproxEqAbs(@as(f32, 6) - bar, fill.radius.top_left, 0.0001),
|
|
1288
|
+
else => return error.TestUnexpectedResult,
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
test "an unbounded style radius clamps to the frame before the tangent mask" {
|
|
1293
|
+
// Radius 100 on a 32x16 surface: renderers clamp every corner to
|
|
1294
|
+
// half the short side (8). The tangent math must start from that
|
|
1295
|
+
// effective value — from the raw 100, an 8px-bar quad would carry
|
|
1296
|
+
// mask radius 92, which renderers clamp to 8 on the 16x16 quad and
|
|
1297
|
+
// round the picture into a circle. Effective 8 minus the 8px bar
|
|
1298
|
+
// is 0: a square quad, exactly the silhouette's demand.
|
|
1299
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1300
|
+
const widget = Widget{
|
|
1301
|
+
.id = 9,
|
|
1302
|
+
.kind = .media_surface,
|
|
1303
|
+
.frame = frame,
|
|
1304
|
+
.image_id = 5,
|
|
1305
|
+
.image_fit = .contain,
|
|
1306
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1307
|
+
.style = .{ .radius = 100 },
|
|
1308
|
+
};
|
|
1309
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1310
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1311
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1312
|
+
var builder = Builder.init(&commands);
|
|
1313
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1314
|
+
const display_list = builder.displayList();
|
|
1315
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1316
|
+
switch (display_list.commands[0]) {
|
|
1317
|
+
.fill_rounded_rect => |fill| try std.testing.expectEqual(@as(f32, 8), fill.radius.top_left),
|
|
1318
|
+
else => return error.TestUnexpectedResult,
|
|
1319
|
+
}
|
|
1320
|
+
switch (display_list.commands[2]) {
|
|
1321
|
+
.draw_image => |draw| {
|
|
1322
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), draw.dst);
|
|
1323
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.top_left);
|
|
1324
|
+
},
|
|
1325
|
+
else => return error.TestUnexpectedResult,
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
test "the fitted video draw composites the whole frame; image_src crops do not apply" {
|
|
1330
|
+
// `DrawImage.src` is adopted-TEXTURE pixel coordinates, and the
|
|
1331
|
+
// video texture's size is unknowable at emit time (macOS
|
|
1332
|
+
// budget-fits large decodes to a smaller texture), so a crop
|
|
1333
|
+
// declared against the stream cannot be translated — forwarding it
|
|
1334
|
+
// raw would sample the wrong region or nothing, and fitting the
|
|
1335
|
+
// quad to it would stretch whatever the host's clip leaves. The
|
|
1336
|
+
// fitted draw therefore always samples the whole texture at the
|
|
1337
|
+
// stream's aspect; crops remain a generic-producer facility in
|
|
1338
|
+
// texture coordinates (the non-fitted paths pass them through
|
|
1339
|
+
// unchanged, as ever).
|
|
1340
|
+
const frame = geometry.RectF.init(0, 0, 32, 16);
|
|
1341
|
+
const widget = Widget{
|
|
1342
|
+
.id = 9,
|
|
1343
|
+
.kind = .media_surface,
|
|
1344
|
+
.frame = frame,
|
|
1345
|
+
.image_id = 5,
|
|
1346
|
+
.image_fit = .contain,
|
|
1347
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1348
|
+
.image_src = geometry.RectF.init(100, 40, 240, 240),
|
|
1349
|
+
};
|
|
1350
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1351
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1352
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1353
|
+
var builder = Builder.init(&commands);
|
|
1354
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1355
|
+
const display_list = builder.displayList();
|
|
1356
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1357
|
+
switch (display_list.commands[2]) {
|
|
1358
|
+
.draw_image => |draw| {
|
|
1359
|
+
// Square stream into the 2:1 box: the quad is the stream's
|
|
1360
|
+
// 16x16 center, the sample is the whole texture.
|
|
1361
|
+
try expectRect(geometry.RectF.init(8, 0, 16, 16), draw.dst);
|
|
1362
|
+
try std.testing.expectEqual(@as(?geometry.RectF, null), draw.src);
|
|
1363
|
+
try std.testing.expectEqual(ImageFit.stretch, draw.fit);
|
|
1364
|
+
},
|
|
1365
|
+
else => return error.TestUnexpectedResult,
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
test "a rounded pillarboxed surface keeps its silhouette on the black field and unmasks the deep-set quad" {
|
|
1370
|
+
// Bars (8px) wider than the corner radius (6): the black field
|
|
1371
|
+
// carries the frame's rounding — the silhouette lives there, never
|
|
1372
|
+
// approximated per bar — and the quad's tight mask relaxes to
|
|
1373
|
+
// square (max(0, 6 - 8) = 0): its corners sit fully inside the
|
|
1374
|
+
// frame's straight edges, so no picture is notched.
|
|
1375
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1376
|
+
const widget = Widget{
|
|
1377
|
+
.id = 9,
|
|
1378
|
+
.kind = .media_surface,
|
|
1379
|
+
.frame = frame,
|
|
1380
|
+
.image_id = 5,
|
|
1381
|
+
.image_fit = .contain,
|
|
1382
|
+
.stream_size = .{ .width = 240, .height = 240 },
|
|
1383
|
+
.style = .{ .radius = 6 },
|
|
1384
|
+
};
|
|
1385
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1386
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1387
|
+
var commands: [6]CanvasCommand = undefined;
|
|
1388
|
+
var builder = Builder.init(&commands);
|
|
1389
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1390
|
+
const display_list = builder.displayList();
|
|
1391
|
+
try std.testing.expectEqual(@as(usize, 3), display_list.commandCount());
|
|
1392
|
+
switch (display_list.commands[0]) {
|
|
1393
|
+
.fill_rounded_rect => |fill| {
|
|
1394
|
+
try expectRect(frame, fill.rect);
|
|
1395
|
+
try std.testing.expectEqual(Fill{ .color = Color.rgba8(0, 0, 0, 255) }, fill.fill);
|
|
1396
|
+
try std.testing.expectEqual(@as(f32, 6), fill.radius.top_left);
|
|
1397
|
+
},
|
|
1398
|
+
else => return error.TestUnexpectedResult,
|
|
1399
|
+
}
|
|
1400
|
+
switch (display_list.commands[1]) {
|
|
1401
|
+
.fill_rounded_rect => |fill| {
|
|
1402
|
+
try expectRect(geometry.RectF.init(8, 4, 16, 16), fill.rect);
|
|
1403
|
+
try std.testing.expectEqual(@as(f32, 0), fill.radius.top_left);
|
|
1404
|
+
},
|
|
1405
|
+
else => return error.TestUnexpectedResult,
|
|
1406
|
+
}
|
|
1407
|
+
switch (display_list.commands[2]) {
|
|
1408
|
+
.draw_image => |draw| {
|
|
1409
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.top_left);
|
|
1410
|
+
try std.testing.expectEqual(@as(f32, 0), draw.radius.bottom_right);
|
|
1411
|
+
},
|
|
1412
|
+
else => return error.TestUnexpectedResult,
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
test "a contain video surface with unknown stream geometry keeps the placeholder draw" {
|
|
1417
|
+
// Pre-LOADED: no reported dimensions, so no fit math runs (nothing
|
|
1418
|
+
// to divide by) — the id-derived placeholder fills the frame and
|
|
1419
|
+
// the texture draw keeps the full frame as its dst.
|
|
1420
|
+
const frame = geometry.RectF.init(0, 4, 32, 16);
|
|
1421
|
+
const widget = Widget{
|
|
1422
|
+
.id = 9,
|
|
1423
|
+
.kind = .media_surface,
|
|
1424
|
+
.frame = frame,
|
|
1425
|
+
.image_id = 5,
|
|
1426
|
+
.image_fit = .contain,
|
|
1427
|
+
};
|
|
1428
|
+
var nodes: [1]WidgetLayoutNode = undefined;
|
|
1429
|
+
const layout = try layoutWidgetTree(widget, frame, &nodes);
|
|
1430
|
+
var commands: [4]CanvasCommand = undefined;
|
|
1431
|
+
var builder = Builder.init(&commands);
|
|
1432
|
+
try layout.emitDisplayList(&builder, .{});
|
|
1433
|
+
const display_list = builder.displayList();
|
|
1434
|
+
switch (display_list.commands[0]) {
|
|
1435
|
+
.fill_rounded_rect => |fill| {
|
|
1436
|
+
try std.testing.expectEqual(
|
|
1437
|
+
Fill{ .color = canvas.mediaSurfacePlaceholderColor(5) },
|
|
1438
|
+
fill.fill,
|
|
1439
|
+
);
|
|
1440
|
+
},
|
|
1441
|
+
else => return error.TestUnexpectedResult,
|
|
1442
|
+
}
|
|
1443
|
+
switch (display_list.commands[1]) {
|
|
1444
|
+
.draw_image => |draw| {
|
|
1445
|
+
try expectRect(frame, draw.dst);
|
|
1446
|
+
try std.testing.expectEqual(ImageFit.contain, draw.fit);
|
|
1447
|
+
},
|
|
1448
|
+
else => return error.TestUnexpectedResult,
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1043
1452
|
test "widget text fields expose textbox semantics and render focused chrome" {
|
|
1044
1453
|
const text_field = Widget{
|
|
1045
1454
|
.id = 8,
|
|
@@ -114,6 +114,23 @@ pub fn widgetVirtualRuntimeScrolled(widget: Widget) bool {
|
|
|
114
114
|
return widget.kind == .scroll_view and widget.layout.virtualized and widget.layout.virtual_item_count > 0;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
/// Whether one widget scrolls on the named axis. This is THE axis
|
|
118
|
+
/// capability predicate: wheel/trackpad routing resolves each axis
|
|
119
|
+
/// against it independently, keyboard and semantic scroll intents pick
|
|
120
|
+
/// their axis through it, and the scrollbar/driver emit only the axes
|
|
121
|
+
/// it grants. Vertical: every scrollable kind (scroll views unless
|
|
122
|
+
/// declared `horizontal`, textareas, the virtualized containers).
|
|
123
|
+
/// Horizontal: only a non-virtualized `.scroll_view` declared
|
|
124
|
+
/// `horizontal` or `both` — virtualization is vertical machinery
|
|
125
|
+
/// (windowed ranges price rows, not columns), so a virtualized region
|
|
126
|
+
/// never grants the horizontal axis.
|
|
127
|
+
pub fn widgetScrollsAxis(widget: Widget, axis: token_model.ScrollAxis) bool {
|
|
128
|
+
return switch (axis) {
|
|
129
|
+
.vertical => widget.kind != .scroll_view or widget.scroll_axes.scrollsVertically() or widget.layout.virtualized,
|
|
130
|
+
.horizontal => widget.kind == .scroll_view and widget.scroll_axes.scrollsHorizontally() and !widget.layout.virtualized,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
117
134
|
/// The effective scroll physics for one scroll region: the shared
|
|
118
135
|
/// `ScrollPhysics` token with the region's `Widget.overscroll` override
|
|
119
136
|
/// resolved onto `physics.overscroll` (`.default` keeps the token's
|