0

[iOS] Accessibility bug fix: selecting identity disc and logo

With the previous implementation, on an iOS 18 device users cannot go
to the top of the NTP to select identity disc / logo if they scrolled
too far down into the feed. It seems that iOS 18 has different parsing
mechanisms for switch control and voice-over, so adding listener for
switch control to avoid that. (VO and switch control could NOT be turned
on simultaneously.)

Fixed: 399123658
Change-Id: I716d6acbb776a1e26352677931bc02d4f88cf404
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6316931
Reviewed-by: Scott Yoder <scottyoder@google.com>
Commit-Queue: Scott Yoder <scottyoder@google.com>
Reviewed-by: Louis Romero <lpromero@google.com>
Commit-Queue: Ginny Huang <ginnyhuang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1427171}
This commit is contained in:
ginnnnnnny
2025-03-03 08:49:31 -08:00
committed by Chromium LUCI CQ
parent bef79a7807
commit 5b06106b6e

@@ -531,7 +531,7 @@ const CGFloat kFeedContainerExtraHeight = 500;
[self setMinimumHeight]; [self setMinimumHeight];
} }
[self updateAccessibilityElements]; [self updateAccessibilityElementsForSwitchControl];
} }
- (void)willUpdateSnapshot { - (void)willUpdateSnapshot {
@@ -1346,6 +1346,10 @@ const CGFloat kFeedContainerExtraHeight = 500;
selector:@selector(deviceOrientationDidChange) selector:@selector(deviceOrientationDidChange)
name:UIDeviceOrientationDidChangeNotification name:UIDeviceOrientationDidChangeNotification
object:nil]; object:nil];
[center addObserver:self
selector:@selector(updateAccessibilityElementsForSwitchControl)
name:UIAccessibilitySwitchControlStatusDidChangeNotification
object:nil];
} }
// Handles device rotation. // Handles device rotation.
@@ -1558,16 +1562,23 @@ const CGFloat kFeedContainerExtraHeight = 500;
} }
} }
// Updates the accessibilityElements used by VoiceOver / Switch Control to // The default behavior of Switch Control does not iterate through elements
// iterate through on-screen elements. The feed collectionView does not seem to // added to the collection view by default; manually setting
// include non-feed items in its `accessibilityElements` so they are added here. // `accessibilityElements` for these elements to be recognized by Switch
- (void)updateAccessibilityElements { // Control.
- (void)updateAccessibilityElementsForSwitchControl {
if (!UIAccessibilityIsSwitchControlRunning()) {
// Reset to `nil` after switch control has been turned off. Other a11y
// features can handle the iteration correctly.
self.containerView.accessibilityElements = nil;
return;
}
NSMutableArray* elements = [[NSMutableArray alloc] init]; NSMutableArray* elements = [[NSMutableArray alloc] init];
for (UIViewController* viewController in self.viewControllersAboveFeed) { for (UIViewController* viewController in self.viewControllersAboveFeed) {
[elements addObject:viewController.view]; [elements addObject:viewController.view];
} }
[elements addObject:self.collectionView]; [elements addObject:self.collectionView];
self.view.accessibilityElements = elements; self.containerView.accessibilityElements = elements;
} }
// Calculate the scroll position that should be saved in the NTP state and // Calculate the scroll position that should be saved in the NTP state and