Skip to content

fix(a11y): expose macOS native child NSViews to VoiceOver - #2633

Merged
Hona merged 1 commit into
devfrom
fix/macos-native-child-view-a11y
Nov 27, 2026
Merged

Hona merged 1 commit into
devfrom
fix/macos-native-child-view-a11y

Conversation

@Hona

@Hona Hona commented Nov 27, 2026

Copy link
Copy Markdown
Member

Fixes #1680

Summary

  • Expose native child NSViews in vendor/accesskit_macos/src/subclass.rs (and vendor/accesskit_macos.patch):
    • accessibilityChildren: keeps AccessKit's children and appends non-empty [super accessibilityChildren] after releasing the adapter's RefCell borrow (so re-entrant queries cannot conflict, and lazily populated trees such as WKWebView are queried fresh on each walk).
    • accessibilityHitTest:: asks [super accessibilityHitTest:] first and returns the result when it lands on a native subview rather than the content view itself or an ancestor (NSWindow, superviews, or accessibilityParent, which AppKit returns via NSAccessibilityUnignoredAncestor(self) when no subview handles the point); otherwise falls through to AccessKit.
    • accessibilityFocusedUIElement: when window.firstResponder is a strict descendant NSView of the content view (e.g. WKWebView / WKContentView or an embedded text field), forwards to [responder accessibilityFocusedUIElement] (guarded against re-entrancy) and falls through to AccessKit otherwise.
  • Hide RuneMaterialHost from AppKit accessibility (crates/rune/src/system_material/macos.rs):
    • Overrides isAccessibilityElement (NO), accessibilityIsIgnored (YES), accessibilityChildren / accessibilityChildrenInNavigationOrder (empty NSArray), and accessibilityHitTest: (nil) so Rune's internal backdrop effect views never appear in VoiceOver or capture hit tests.
  • Tests and patch hygiene:
    • Verified vendor/accesskit_macos.patch applies cleanly to clean upstream accesskit_macos 0.27.2 and matches vendor/accesskit_macos/src/subclass.rs byte-for-byte.
    • Added regression tests in crates/rune/src/a11y/macos_tests.rs and a #[cfg(target_os = "macos")] runtime test for RuneMaterialHost in crates/rune/src/system_material/tests.rs.

Verification

  • cargo check -p accesskit_macos --target aarch64-apple-darwin: passed.
  • cargo clippy -p accesskit_macos --target aarch64-apple-darwin -- -D warnings: passed.
  • cargo test -p rune --lib a11y::macos_tests (5 passed) and cargo test -p rune --lib system_material::tests (29 passed) on Windows.
  • git apply --check of vendor/accesskit_macos.patch against clean accesskit_macos 0.27.2: passed.
  • Not run locally: live macOS VoiceOver / WKWebView / AppKit GUI session (this machine is Windows; macOS runtime behavior should be verified on macOS hardware / scheduled macOS CI).

AccessKit's SubclassingAdapter on macOS overrode accessibilityChildren,
accessibilityHitTest:, and accessibilityFocusedUIElement on winit's content
view to answer exclusively from AccessKit, dropping any native child NSViews
(such as an embedded WKWebView added through WindowHandle::with_raw_handle).

- In vendor/accesskit_macos/src/subclass.rs (and vendor/accesskit_macos.patch):
  - accessibilityChildren now appends [super accessibilityChildren] after
    AccessKit's nodes, releasing the adapter's RefCell borrow before messaging
    super.
  - accessibilityHitTest: queries [super accessibilityHitTest:] first and
    returns the hit when it lands on a native subview rather than the content
    view or its ancestors (such as NSWindow, which AppKit returns when an
    ignored view has no subview at the point), falling through to AccessKit
    otherwise.
  - accessibilityFocusedUIElement delegates to window.firstResponder when it is
    a strict descendant NSView (guarded against re-entrancy), falling through
    to AccessKit otherwise.
- In crates/rune/src/system_material/macos.rs:
  - Hide RuneMaterialHost from AppKit accessibility (isAccessibilityElement = NO,
    accessibilityIsIgnored = YES, empty accessibilityChildren /
    accessibilityChildrenInNavigationOrder, nil accessibilityHitTest:) so
    internal backdrop effect views never leak into VoiceOver or capture hit
    tests.
@Hona
Hona merged commit 80f2354 into dev Nov 27, 2026
2 checks passed
@Hona
Hona deleted the fix/macos-native-child-view-a11y branch November 27, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS: native child views are invisible to VoiceOver

1 participant