diff --git a/Cargo.toml b/Cargo.toml index 535825d..81f1c6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "3" members = ["crates/tauri-runtime-blitz"] [workspace.package] -version = "0.3.6" +version = "0.3.7" edition = "2024" license = "MIT OR Apache-2.0" publish = true diff --git a/crates/tauri-runtime-blitz/src/agent.rs b/crates/tauri-runtime-blitz/src/agent.rs index 3f134be..785784d 100644 --- a/crates/tauri-runtime-blitz/src/agent.rs +++ b/crates/tauri-runtime-blitz/src/agent.rs @@ -300,6 +300,10 @@ pub fn snapshot_document( let inner = document.inner(); let layout_node_limit = inner.tree().iter().count(); let active_element = inner.get_focussed_node_id().map(|id| id.as_u64()); + // Once for the whole snapshot: the question a control asks is "which label + // points at me", and answering it from the control costs a document scan + // each time. + let labels = LabelIndex::build(&inner); let nodes: Vec = inner .tree() .iter() @@ -335,7 +339,7 @@ pub fn snapshot_document( dom_id: element_attr(element, "id").map(str::to_owned), id: id.as_u64(), parent: semantic_parent(&inner, id, None).map(|id| id.as_u64()), - name: semantic_name(element, node, &role), + name: semantic_name(element, node, &role, &inner, id, &labels), role, value, enabled: element_attr(element, "disabled").is_none() @@ -518,19 +522,239 @@ pub(crate) fn semantic_role(element: &blitz_dom::ElementData) -> String { .into() } +/// Where the labels are, so a control can be asked what names it. +/// +/// # Why this exists +/// +/// A name was computed from `aria-label`, `alt` and `title` and from nothing +/// else, so the ordinary way to label a form control -- a `