Allow UIView subviews to be a part of Accessibility Tree#2111
Allow UIView subviews to be a part of Accessibility Tree#2111patryk-sredzinski wants to merge 9 commits intoTextureGroup:masterfrom
Conversation
| } | ||
| } | ||
|
|
||
| if (modalSubnode) { |
There was a problem hiding this comment.
This is a long complicated method. It is quite possible that in the future someone will add to it, likely at the end of the method. This early return could cause newly added logic to be skipped. To protect against that, I'd prefer you put your logic inside of an if and not early return:
if (!modalSubnode) {
// your logic
....
}
| } | ||
|
|
||
| // If a view is hidden or has an alpha of 0.0 we should not include it | ||
| if (viewIsHiddenFromAcessibility(subview)) { |
There was a problem hiding this comment.
This is cheaper than iterating over elements and should be done first.
| NSArray *subviews = view.subviews; | ||
| for (UIView *subview in subviews) { | ||
| // If a view is is already added then skip it | ||
| if ([elements containsObject:subview]) { |
There was a problem hiding this comment.
We are looping over subviews and elements for each subview. It would be more efficient to put the elements in a set so lookup is O(1), or use a smart diff algorithm to get only the subviews not in elements and iterate over those.
[elements containsObject:subview] is likely the most expensive operation in this loop, so it should at the very least be moved to the last possible check. e.g.,
if ((subview.isAccessibilityElement || subview.accessibilityElementCount > 0)) && ! [elements containsObject:subview]) {
[elements addObject:subview];
}
If you add views to node.view, then those views aren't visible by AccessibilityInspector. This PR allows that