Repository navigation
fix(a11y): expose macOS native child NSViews to VoiceOver - #2633
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1680
Summary
NSViews invendor/accesskit_macos/src/subclass.rs(andvendor/accesskit_macos.patch):accessibilityChildren: keeps AccessKit's children and appends non-empty[super accessibilityChildren]after releasing the adapter'sRefCellborrow (so re-entrant queries cannot conflict, and lazily populated trees such asWKWebVieware 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, oraccessibilityParent, which AppKit returns viaNSAccessibilityUnignoredAncestor(self)when no subview handles the point); otherwise falls through to AccessKit.accessibilityFocusedUIElement: whenwindow.firstResponderis a strict descendantNSViewof the content view (e.g.WKWebView/WKContentViewor an embedded text field), forwards to[responder accessibilityFocusedUIElement](guarded against re-entrancy) and falls through to AccessKit otherwise.RuneMaterialHostfrom AppKit accessibility (crates/rune/src/system_material/macos.rs):isAccessibilityElement(NO),accessibilityIsIgnored(YES),accessibilityChildren/accessibilityChildrenInNavigationOrder(emptyNSArray), andaccessibilityHitTest:(nil) so Rune's internal backdrop effect views never appear in VoiceOver or capture hit tests.vendor/accesskit_macos.patchapplies cleanly to clean upstreamaccesskit_macos 0.27.2and matchesvendor/accesskit_macos/src/subclass.rsbyte-for-byte.crates/rune/src/a11y/macos_tests.rsand a#[cfg(target_os = "macos")]runtime test forRuneMaterialHostincrates/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) andcargo test -p rune --lib system_material::tests(29 passed) on Windows.git apply --checkofvendor/accesskit_macos.patchagainst cleanaccesskit_macos 0.27.2: passed.WKWebView/ AppKit GUI session (this machine is Windows; macOS runtime behavior should be verified on macOS hardware / scheduled macOS CI).