From d999bddd9e969813cdd3ce60c858027a7f399149 Mon Sep 17 00:00:00 2001 From: Darren Austin Date: Fri, 13 Dec 2019 18:27:37 -0800 Subject: [PATCH 1/2] Change the screen change notification on iOS to use the route's name node as the focused node. --- .../framework/Source/accessibility_bridge.mm | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 86cec67044dd0..f0bdbcccbb471 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -224,20 +224,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. +- (id)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; + NSString *label = [self accessibilityLabel]; + if (label != nil && [label length] > 0) { + return self; } } if ([self hasChildren]) { for (SemanticsObject* child in self.children) { - NSString* newName = [child routeName]; - if (newName != nil && [newName length] > 0) { - return newName; + SemanticsObject* labelObject = [child routeFocusObject]; + if (labelObject != nil) { + return labelObject; } } } @@ -733,8 +734,7 @@ - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction { layoutChanged = layoutChanged || [doomed_uids count] > 0; if (routeChanged) { - NSString* routeName = [lastAdded routeName]; - UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, routeName); + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, [lastAdded routeFocusObject]); } else if (layoutChanged) { // TODO(goderbauer): figure out which node to focus next. UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); From 187b575c7fa4f6b83dc909a2a40b0a198b95a896 Mon Sep 17 00:00:00 2001 From: Darren Austin Date: Mon, 16 Dec 2019 11:29:28 -0800 Subject: [PATCH 2/2] Update to fix formatting --- .../darwin/ios/framework/Source/accessibility_bridge.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index f0bdbcccbb471..276926b359103 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -229,7 +229,7 @@ - (id)routeFocusObject { // the NamesRoute flag with a non-nil semantic label. Otherwise // returns nil. if ([self node].HasFlag(flutter::SemanticsFlags::kNamesRoute)) { - NSString *label = [self accessibilityLabel]; + NSString* label = [self accessibilityLabel]; if (label != nil && [label length] > 0) { return self; } @@ -734,7 +734,8 @@ - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction { layoutChanged = layoutChanged || [doomed_uids count] > 0; if (routeChanged) { - UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, [lastAdded routeFocusObject]); + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, + [lastAdded routeFocusObject]); } else if (layoutChanged) { // TODO(goderbauer): figure out which node to focus next. UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);