From 13d5ea21e7dbcbd69c6ff4dd53db9f4a57513d75 Mon Sep 17 00:00:00 2001 From: cameron Date: Wed, 18 Mar 2026 07:09:57 +0000 Subject: [PATCH] set bounds and focuable properties --- crates/gpui/src/element.rs | 20 ++++++++++++++++---- crates/gpui/src/elements/div.rs | 6 ++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/element.rs b/crates/gpui/src/element.rs index a6191cd6aab9fc725b00038f5b6cf3b5fe255600..9cf2069c7e4db1d27e105ab4f31a39e4224a49e8 100644 --- a/crates/gpui/src/element.rs +++ b/crates/gpui/src/element.rs @@ -432,7 +432,12 @@ impl Drawable { } } - fn push_a11y_node(&self, global_id: &GlobalElementId, window: &mut Window) -> bool { + fn push_a11y_node( + &self, + global_id: &GlobalElementId, + bounds: Bounds, + window: &mut Window, + ) -> bool { if !window.is_a11y_active() { return false; } @@ -441,6 +446,13 @@ impl Drawable { let mut node = accesskit::Node::new(role); + node.set_bounds(accesskit::Rect::new( + f64::from(bounds.origin.x), + f64::from(bounds.origin.y), + f64::from(bounds.origin.x + bounds.size.width), + f64::from(bounds.origin.y + bounds.size.height), + )); + if let Some((_parent_id, parent_node)) = window.a11y_nodes.peek_mut() { parent_node.push_child(global_id); } @@ -474,13 +486,13 @@ impl Drawable { debug_assert_eq!(&*global_id.as_ref().unwrap().0, &*window.element_id_stack); } + let bounds = window.layout_bounds(layout_id); + let a11y_node_pushed = if let Some(global_id) = &global_id { - self.push_a11y_node(global_id, window) + self.push_a11y_node(global_id, bounds, window) } else { false }; - - let bounds = window.layout_bounds(layout_id); let node_id = window.next_frame.dispatch_tree.push_node(); let prepaint = self.element.prepaint( global_id.as_ref(), diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs index 8af2c5e9ca9c6b83bfd7e508a618888c7c1fb2d7..aa602cacc9e28a42050b84fcb3ba4aa3175e28df 100644 --- a/crates/gpui/src/elements/div.rs +++ b/crates/gpui/src/elements/div.rs @@ -1801,6 +1801,12 @@ impl Element for Div { if let Some(label) = &self.interactivity.aria_label { node.set_label(label.as_str()); } + if !self.interactivity.click_listeners.is_empty() { + node.add_action(accesskit::Action::Click); + } + if self.interactivity.tracked_focus_handle.is_some() { + node.add_action(accesskit::Action::Focus); + } if let Some(selected) = self.interactivity.aria_selected { node.set_selected(selected); }