Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ constexpr int32_t kRootNodeId = 0;
- (BOOL)nodeWillCauseScroll:(const flutter::SemanticsNode*)node;
- (BOOL)nodeShouldTriggerAnnouncement:(const flutter::SemanticsNode*)node;
- (void)collectRoutes:(NSMutableArray<SemanticsObject*>*)edges;
- (NSString*)routeName;
- (SemanticsObject*)routeFocusObject;
- (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action;

@end
Expand Down
15 changes: 8 additions & 7 deletions shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -282,20 +282,21 @@ - (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action {
return YES;
}

- (NSString*)routeName {
// Returns the first non-null and non-empty semantic label of a child
// with an NamesRoute flag. Otherwise returns nil.
- (SemanticsObject*)routeFocusObject {
// Returns the first SemanticObject in this branch that has
// the NamesRoute flag with a non-nil semantic label. Otherwise
// returns nil.
if ([self node].HasFlag(flutter::SemanticsFlags::kNamesRoute)) {
NSString* newName = [self accessibilityLabel];
if (newName != nil && [newName length] > 0) {
return newName;
return self;
}
}
if ([self hasChildren]) {
for (SemanticsObject* child in self.children) {
NSString* newName = [child routeName];
if (newName != nil && [newName length] > 0) {
return newName;
SemanticsObject* focusObject = [child routeFocusObject];
if (focusObject != nil) {
return focusObject;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,8 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification,
layoutChanged = layoutChanged || [doomed_uids count] > 0;
if (routeChanged) {
if (!ios_delegate_->IsFlutterViewControllerPresentingModalViewController(view_)) {
NSString* routeName = [lastAdded routeName];
ios_delegate_->PostAccessibilityNotification(UIAccessibilityScreenChangedNotification,
routeName);
[lastAdded routeFocusObject]);
}
} else if (layoutChanged) {
// TODO(goderbauer): figure out which node to focus next.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ - (void)testAnnouncesRouteChanges {
bridge->UpdateSemantics(/*nodes=*/nodes, /*actions=*/actions);

XCTAssertEqual([accessibility_notifications count], 1ul);
XCTAssertEqualObjects(accessibility_notifications[0][@"argument"], @"route");
SemanticsObject* focusObject = accessibility_notifications[0][@"argument"];
XCTAssertEqual([focusObject uid], 1);
XCTAssertEqualObjects([focusObject accessibilityLabel], @"route");
XCTAssertEqual([accessibility_notifications[0][@"notification"] unsignedIntValue],
UIAccessibilityScreenChangedNotification);
}
Expand Down