mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-23 05:04:42 +00:00
SemanticTree: use AXRole enum for interactive role check
This commit is contained in:
@@ -31,20 +31,6 @@ const CDPNode = @import("cdp/Node.zig");
|
|||||||
|
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
|
|
||||||
const interactive_roles = std.StaticStringMap(void).initComptime(.{
|
|
||||||
.{ "button", {} },
|
|
||||||
.{ "link", {} },
|
|
||||||
.{ "checkbox", {} },
|
|
||||||
.{ "radio", {} },
|
|
||||||
.{ "textbox", {} },
|
|
||||||
.{ "combobox", {} },
|
|
||||||
.{ "searchbox", {} },
|
|
||||||
.{ "slider", {} },
|
|
||||||
.{ "spinbutton", {} },
|
|
||||||
.{ "switch", {} },
|
|
||||||
.{ "menuitem", {} },
|
|
||||||
});
|
|
||||||
|
|
||||||
dom_node: *Node,
|
dom_node: *Node,
|
||||||
registry: *CDPNode.Registry,
|
registry: *CDPNode.Registry,
|
||||||
page: *Page,
|
page: *Page,
|
||||||
@@ -131,7 +117,8 @@ fn dump(self: Self, node: *Node, jw: *std.json.Stringify, parent_xpath: []const
|
|||||||
if (node.is(Element)) |el| {
|
if (node.is(Element)) |el| {
|
||||||
node_name = el.getTagNameLower();
|
node_name = el.getTagNameLower();
|
||||||
|
|
||||||
if (interactive_roles.has(role)) {
|
const ax_role = std.meta.stringToEnum(AXNode.AXRole, role) orelse .none;
|
||||||
|
if (ax_role.isInteractive()) {
|
||||||
is_interactive = true;
|
is_interactive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -560,13 +560,31 @@ pub const AXRole = enum(u8) {
|
|||||||
none, article, banner, blockquote, button, caption, cell, checkbox, code,
|
none, article, banner, blockquote, button, caption, cell, checkbox, code,
|
||||||
columnheader, combobox, complementary, contentinfo, definition, deletion,
|
columnheader, combobox, complementary, contentinfo, definition, deletion,
|
||||||
dialog, document, emphasis, figure, form, group, heading, image, insertion,
|
dialog, document, emphasis, figure, form, group, heading, image, insertion,
|
||||||
link, list, listbox, listitem, main, marquee, meter, navigation, option,
|
link, list, listbox, listitem, main, marquee, menuitem, meter, navigation, option,
|
||||||
paragraph, presentation, progressbar, radio, region, row, rowgroup,
|
paragraph, presentation, progressbar, radio, region, row, rowgroup,
|
||||||
rowheader, searchbox, separator, slider, spinbutton, status, strong,
|
rowheader, searchbox, separator, slider, spinbutton, status, strong,
|
||||||
subscript, superscript, table, term, textbox, time, RootWebArea, LineBreak,
|
subscript, superscript, @"switch", table, term, textbox, time, RootWebArea, LineBreak,
|
||||||
StaticText,
|
StaticText,
|
||||||
// zig fmt: on
|
// zig fmt: on
|
||||||
|
|
||||||
|
pub fn isInteractive(self: AXRole) bool {
|
||||||
|
return switch (self) {
|
||||||
|
.button,
|
||||||
|
.link,
|
||||||
|
.checkbox,
|
||||||
|
.radio,
|
||||||
|
.textbox,
|
||||||
|
.combobox,
|
||||||
|
.searchbox,
|
||||||
|
.slider,
|
||||||
|
.spinbutton,
|
||||||
|
.@"switch",
|
||||||
|
.menuitem,
|
||||||
|
=> true,
|
||||||
|
else => false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
fn fromNode(node: *DOMNode) !AXRole {
|
fn fromNode(node: *DOMNode) !AXRole {
|
||||||
return switch (node._type) {
|
return switch (node._type) {
|
||||||
.document => return .RootWebArea, // Chrome specific.
|
.document => return .RootWebArea, // Chrome specific.
|
||||||
|
|||||||
Reference in New Issue
Block a user