Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .github/workflows/ra-native-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Recovery Phase A native accessibility validation

on:
pull_request:
paths:
- .github/workflows/ra-native-validation.yml

permissions:
contents: read

env:
TARGET_SHA: 3189c1fc8ff7e1bd041bf115f0189c1c207b2539
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "1"

jobs:
windows:
runs-on: windows-2022
env:
CARGO_HOME: C:\c
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
ref: ${{ env.TARGET_SHA }}
- name: Verify checkout and toolchain
shell: pwsh
run: |
if ((git rev-parse HEAD) -ne $env:TARGET_SHA) { throw "checkout SHA mismatch" }
git config --global core.longpaths true
rustup toolchain install 1.95.0 --profile minimal --component clippy
rustup default 1.95.0
Write-Output "ImageOS=$env:ImageOS ImageVersion=$env:ImageVersion RUNNER_OS=$env:RUNNER_OS RUNNER_ARCH=$env:RUNNER_ARCH"
rustup show active-toolchain
rustc -Vv
cargo -V
- name: Validate gpui_windows
shell: pwsh
run: |
./script/clippy.ps1 -p gpui_windows
if ($LASTEXITCODE) { throw "clippy exit $LASTEXITCODE" }
$env:RUSTFLAGS='-Dwarnings'
cargo test -p gpui_windows --all-features --no-run
if ($LASTEXITCODE) { throw "test build exit $LASTEXITCODE" }

macos:
runs-on: macos-14
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
ref: ${{ env.TARGET_SHA }}
- name: Verify checkout and toolchain
run: |
test "$(git rev-parse HEAD)" = "$TARGET_SHA"
rustup toolchain install 1.95.0 --profile minimal --component clippy
rustup default 1.95.0
echo "ImageOS=$ImageOS ImageVersion=$ImageVersion RUNNER_OS=$RUNNER_OS RUNNER_ARCH=$RUNNER_ARCH"
rustup show active-toolchain
rustc -Vv
cargo -V
- name: Validate gpui_macos
run: |
./script/clippy -p gpui_macos
RUSTFLAGS='-Dwarnings' cargo test -p gpui_macos --all-features --no-run

linux:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
with:
ref: ${{ env.TARGET_SHA }}
- name: Verify checkout and toolchain
run: |
test "$(git rev-parse HEAD)" = "$TARGET_SHA"
rustup toolchain install 1.95.0 --profile minimal --component clippy
rustup default 1.95.0
echo "ImageOS=$ImageOS ImageVersion=$ImageVersion RUNNER_OS=$RUNNER_OS RUNNER_ARCH=$RUNNER_ARCH"
rustup show active-toolchain
rustc -Vv
cargo -V
- name: Set up Linux dependencies
run: ./script/linux
- name: Validate gpui_linux
run: |
./script/clippy -p gpui_linux
RUSTFLAGS='-Dwarnings' cargo test -p gpui_linux --all-features --no-run
2 changes: 1 addition & 1 deletion crates/gpui/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ impl<E: Element> Drawable<E> {
y1: ((bounds.origin.y.0 + bounds.size.height.0) * scale) as f64,
});
self.element.write_a11y_info(&mut node);
window.a11y.node_bounds.insert(node_id, bounds);
window.a11y.set_node_bounds(node_id, bounds);
pushed_a11y_node = window.a11y.nodes.push(node_id, node);
#[cfg(debug_assertions)]
if pushed_a11y_node {
Expand Down
12 changes: 10 additions & 2 deletions crates/gpui/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,14 @@ pub struct A11yCallbacks {
pub deactivation: Box<dyn Fn() + Send + 'static>,
}

/// An accessibility tree update and its matching sequential focus order.
pub struct PlatformAccessibilityUpdate {
/// The complete AccessKit tree update.
pub tree_update: accesskit::TreeUpdate,
/// Root-tree node IDs in GPUI tab order.
pub sequential_focus_order: Vec<accesskit::NodeId>,
}

#[derive(Debug, Copy, Clone, Eq, PartialEq, Default)]
#[expect(missing_docs)]
pub struct RequestFrameOptions {
Expand Down Expand Up @@ -853,8 +861,8 @@ pub trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
/// Initialize the accessibility adapter with callbacks.
fn a11y_init(&self, _callbacks: A11yCallbacks) {}

/// Provide a TreeUpdate to the accessibility adapter.
fn a11y_tree_update(&self, _tree_update: accesskit::TreeUpdate) {}
/// Provide an accessibility update to the platform adapter.
fn a11y_tree_update(&self, _update: PlatformAccessibilityUpdate) {}

/// Inform the adapter of updated window bounds.
fn a11y_update_window_bounds(&self) {}
Expand Down
29 changes: 29 additions & 0 deletions crates/gpui/src/tab_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ impl Default for TabStopMap {

impl TabStopMap {
pub fn insert(&mut self, focus_handle: &FocusHandle) {
if let Some(previous) = self.by_id.remove(&focus_handle.id) {
self.order.remove(&previous, ());
}
self.insertion_history
.push(TabStopOperation::Insert(focus_handle.clone()));
let mut path = self.current_path.clone();
Expand Down Expand Up @@ -200,6 +203,19 @@ impl TabStopMap {
self.by_id.values().filter(|node| node.tab_stop).count()
}

pub(crate) fn ordered_tab_stop_focus_ids(&self) -> Vec<FocusId> {
self.order
.iter()
.filter(|node| node.tab_stop)
.filter_map(|node| {
self.insertion_history
.get(node.node_insertion_index)
.and_then(TabStopOperation::focus_handle)
.map(|handle| handle.id)
})
.collect()
}

fn focus_handle_for_order(&self, order: &TabStopNode) -> Option<FocusHandle> {
let handle = self.insertion_history[order.node_insertion_index].focus_handle();
debug_assert!(
Expand Down Expand Up @@ -408,6 +424,19 @@ mod tests {
);
}

#[test]
fn replacing_a_focus_handle_updates_its_tab_order_entry() {
let focus_map = Arc::new(FocusMap::default());
let mut tab_stop_map = TabStopMap::default();
let handle = FocusHandle::new(&focus_map).tab_stop(true).tab_index(2);
tab_stop_map.insert(&handle);
let replacement = handle.clone().tab_index(0);
tab_stop_map.insert(&replacement);

assert_eq!(tab_stop_map.ordered_tab_stop_focus_ids(), vec![handle.id]);
assert_eq!(tab_stop_map.tab_stop_count(), 1);
}

#[test]
fn test_tab_non_stop_filtering() {
let focus_map = Arc::new(FocusMap::default());
Expand Down
Loading