-
Notifications
You must be signed in to change notification settings - Fork 330
cdp: add AXTree #1308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
cdp: add AXTree #1308
Conversation
bbaa33c to
e20ad0c
Compare
| if (value.value) |v| { | ||
| try w.objectField("value"); | ||
| switch (v) { | ||
| .uint => try w.write(v.uint), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would work:
switch (v) {
inline else => |v| v try w.write(v),
}| fn toJSON(self: *const Writer, node: *const Node, w: anytype) !void { | ||
| try w.beginArray(); | ||
| const root = try AXNode.fromNode(node.dom); | ||
| if (try self.writeNode(node.id, root, w)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably reverse this, so that writeNode returns true if the children should be written, so that you can just do:
if (try self.writeNode(node.id, root, w)) {
try self.writeNodeChildren(root, w);
}
return w.endArray();| dom: *DOMNode, | ||
| role_attr: ?[]const u8, | ||
|
|
||
| pub fn fromNode(dom: *DOMNode) !AXNode { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't return an error. If you remove the error union here, then you can remove it from isIgnore
| switch (dom_node._type) { | ||
| .document => |document| { | ||
| const uri = document.getURL(page); | ||
| try self.writeAXProperty(.{ .name = .url, .value = .{ .type = .string, .value = .{ .string = uri } } }, w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the type field and union a redundant? Could you make it work with:
.{ .name = .url, .value = .{.string = uri } }And use the std.meta.activeTag(value) in writeAXValue ? (renaming the uint tag to integer)
| } | ||
|
|
||
| fn isHidden(elt: *DOMNode.Element) bool { | ||
| if (elt.getAttributeSafe("aria-hidden")) |value| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outside this PR, we could potentially optimize checking/fetching multiple attributes. (I think there's a number of small optimizations we might be able to do for attributes, and this multi-attribute check use-case is worth thinking about)
Backport of #1244 for
zigdomfixes #1220
relates with #1217