From 814ca8ab3fdfa69e706622aede221184cc29f7fb Mon Sep 17 00:00:00 2001 From: Navid EMAD Date: Tue, 19 May 2026 20:43:54 +0200 Subject: [PATCH] accessibility: unify query+tree writers, route objectId via dom.getNode Fold QueryWriter into Writer behind an Opts.filter. Tree mode is unchanged (filter=null); query mode walks the full subtree (including AX-ignored nodes per the queryAXTree spec) and emits the flat-match shape. Shared resolveRole helper handles label-promotion for both paths so the two can't drift. Drop the "objectId not yet supported" carve-out: queryAXTree now reuses dom.getNode, which already resolves nodeId/backendNodeId/objectId. --- src/cdp/AXNode.zig | 176 ++++++++++++++---------------- src/cdp/CDP.zig | 22 +--- src/cdp/domains/accessibility.zig | 46 ++------ src/cdp/domains/dom.zig | 2 +- 4 files changed, 92 insertions(+), 154 deletions(-) diff --git a/src/cdp/AXNode.zig b/src/cdp/AXNode.zig index dd781b99..1621085d 100644 --- a/src/cdp/AXNode.zig +++ b/src/cdp/AXNode.zig @@ -45,11 +45,31 @@ pub const Writer = struct { visibility_cache: *DOMNode.Element.VisibilityCache, label_index: *Label.LabelByForIndex, temp_arena: std.mem.Allocator, + // When null, emit the full AX tree (getFullAXTree). When set, walk the + // subtree visiting all nodes (including AX-ignored ones, per the + // queryAXTree spec) and emit only nodes whose role + accessible name + // match the filter, in a flat shape. + filter: ?Filter = null, - pub const Opts = struct {}; + pub const Filter = struct { + role: ?[]const u8 = null, + accessible_name: ?[]const u8 = null, + }; + + pub const Opts = struct { + filter: ?Filter = null, + }; + + const ResolvedRole = struct { + role: []const u8, + // Non-null when the current node is a