Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASDisplayViewAccessibility] A few accessibility improvements #1812

Merged
merged 9 commits into from
May 6, 2020

Conversation

rcancro
Copy link
Contributor

@rcancro rcancro commented May 5, 2020

This diff includes a few improvements for accessibility in Texture.

  • When determining a node’s accessibility elements, ignore any elements that are hidden, transparent, or out of the window. This matches UIKit’s behavior.
  • When sorting the accessible elements and their origins are equal, give precedence to elements with shorter accessibility frames, followed by elements with narrower widths.
  • Allow the ability to customize the comparator block that sorts the accessibility elements
  • Create an experiment to stop caching accessibilityElements in _ASDisplayView. If we cache elements, we will require users to clear the cache (by calling setAccessibilityElements to get the side effect of clearing the cache) when nodes change their hidden state or opacity. This seems like a lot to request of the user. We will put this in an experiment so we can see the perf implication is both when using voice over and when not using voice over.

A few other notes:

  • I got rid of the ASAccessibilityElementPositioning protocol in favor of passing NSObjects to the sort comparator. NSObject implements the informal UIAccessibility protocol and therefore has an accessibilityFrame property.
  • I removed static from the SortAccessibilityElements() method definition. This allows me to declare it as extern in test it via unit tests.

This diff includes a few improvements for accessibility in Texture.

* When determining a node’s accessibility elements, ignore any elements that are hidden, transparent, or out of the window. This matches UIKit’s behavior.
* When sorting the accessible elements and their origins are equal, give precedence to elements with shorter accessibility frames, followed by elements with narrower widths.
* Allow the ability to customize the comparator block that sorts the accessibility elements
* Create an experiment to stop caching accessibilityElements in `_ASDisplayView`. If we cache elements, we will require users to clear the cache (by calling `setAccessibilityElements` to get the side effect of clearing the cache) when nodes change their hidden state or opacity. This seems like a lot to request of the user. We will put this in an experiment so we can see the perf implication is both when using voice over and when not using voice over.

A few other notes:
* I got rid of the `ASAccessibilityElementPositioning` protocol in favor of passing `NSObjects` to the sort comparator. `NSObject` implements the informal `UIAccessibilityProtocol` and therefore has an `accessibilityFrame` property.
* I removed `static` from the `SortAccessibilityElements()` method definition. This allows me to declare it as `extern` in test it via unit tests.
In `CollectAccessibilityElements` if the view has no window, don’t do the bounds check.

Would it be better to exit completely if our view wasn’t in a window?
Source/Details/_ASDisplayViewAccessiblity.mm Outdated Show resolved Hide resolved
Changed name of `defaultComparator` to `defaultAccessibilityComparator`
For some reason a accessibility test keeps failing on github, but runs fine locally. Changed the tests to make sure the array contains the proper items but not enforce order.
This was the last error:
`fatal: unable to access 'https://github.com/pinterest/PINCache.git/': Could not resolve host: github.com`
Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update ASConfigurationTests.mm and configuration.json with your experiment

Copy link
Member

@nguyenhuy nguyenhuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits aside, LGTM. Feel free to land after addressing them, and thank you for continue improving a11y support!

Source/Details/_ASDisplayViewAccessiblity.h Outdated Show resolved Hide resolved
Source/Details/_ASDisplayViewAccessiblity.mm Outdated Show resolved Hide resolved
* early exit if our view has no window when creating accessibility elements (This change also requiring making sure nodes in accessibility tests were in a window)
* fixed test around experiments.
@rcancro rcancro merged commit d085cd6 into TextureGroup:master May 6, 2020
piotrdebosz pushed a commit to getstoryteller/Texture that referenced this pull request Mar 1, 2021
…eGroup#1812)

* [ASDisplayViewAccessibility] A few accessibility improvements

This diff includes a few improvements for accessibility in Texture.

* When determining a node’s accessibility elements, ignore any elements that are hidden, transparent, or out of the window. This matches UIKit’s behavior.
* When sorting the accessible elements and their origins are equal, give precedence to elements with shorter accessibility frames, followed by elements with narrower widths.
* Allow the ability to customize the comparator block that sorts the accessibility elements
* Create an experiment to stop caching accessibilityElements in `_ASDisplayView`. If we cache elements, we will require users to clear the cache (by calling `setAccessibilityElements` to get the side effect of clearing the cache) when nodes change their hidden state or opacity. This seems like a lot to request of the user. We will put this in an experiment so we can see the perf implication is both when using voice over and when not using voice over.

A few other notes:
* I got rid of the `ASAccessibilityElementPositioning` protocol in favor of passing `NSObjects` to the sort comparator. `NSObject` implements the informal `UIAccessibilityProtocol` and therefore has an `accessibilityFrame` property.
* I removed `static` from the `SortAccessibilityElements()` method definition. This allows me to declare it as `extern` in test it via unit tests.
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.

None yet

3 participants