mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Revert "fix On iOS, dialog titles are announced twice (#19826)" (flutter/engine#21714)
This commit is contained in:
parent
6288ffac43
commit
389b4fd25b
@ -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;
|
||||
- (SemanticsObject*)routeFocusObject;
|
||||
- (NSString*)routeName;
|
||||
- (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action;
|
||||
|
||||
@end
|
||||
|
||||
@ -282,21 +282,20 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (SemanticsObject*)routeFocusObject {
|
||||
// Returns the first SemanticObject in this branch that has
|
||||
// the NamesRoute flag with a non-nil semantic label. Otherwise
|
||||
// returns nil.
|
||||
- (NSString*)routeName {
|
||||
// Returns the first non-null and non-empty semantic label of a child
|
||||
// with an NamesRoute flag. Otherwise returns nil.
|
||||
if ([self node].HasFlag(flutter::SemanticsFlags::kNamesRoute)) {
|
||||
NSString* newName = [self accessibilityLabel];
|
||||
if (newName != nil && [newName length] > 0) {
|
||||
return self;
|
||||
return newName;
|
||||
}
|
||||
}
|
||||
if ([self hasChildren]) {
|
||||
for (SemanticsObject* child in self.children) {
|
||||
SemanticsObject* focusObject = [child routeFocusObject];
|
||||
if (focusObject != nil) {
|
||||
return focusObject;
|
||||
NSString* newName = [child routeName];
|
||||
if (newName != nil && [newName length] > 0) {
|
||||
return newName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,12 +198,9 @@ void AccessibilityBridge::UpdateSemantics(flutter::SemanticsNodeUpdates nodes,
|
||||
// We should send out only one notification per semantics update.
|
||||
if (routeChanged) {
|
||||
if (!ios_delegate_->IsFlutterViewControllerPresentingModalViewController(view_controller_)) {
|
||||
SemanticsObject* nextToFocus = [lastAdded routeFocusObject];
|
||||
if (!nextToFocus && root) {
|
||||
nextToFocus = FindFirstFocusable(root);
|
||||
}
|
||||
NSString* routeName = [lastAdded routeName];
|
||||
ios_delegate_->PostAccessibilityNotification(UIAccessibilityScreenChangedNotification,
|
||||
nextToFocus);
|
||||
routeName);
|
||||
}
|
||||
} else if (layoutChanged) {
|
||||
SemanticsObject* nextToFocus = nil;
|
||||
|
||||
@ -328,9 +328,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(std::string name) {
|
||||
bridge->UpdateSemantics(/*nodes=*/nodes, /*actions=*/actions);
|
||||
|
||||
XCTAssertEqual([accessibility_notifications count], 1ul);
|
||||
SemanticsObject* focusObject = accessibility_notifications[0][@"argument"];
|
||||
XCTAssertEqual([focusObject uid], 3);
|
||||
XCTAssertEqualObjects([focusObject accessibilityLabel], @"node3");
|
||||
XCTAssertEqualObjects(accessibility_notifications[0][@"argument"], @"node3");
|
||||
XCTAssertEqual([accessibility_notifications[0][@"notification"] unsignedIntValue],
|
||||
UIAccessibilityScreenChangedNotification);
|
||||
}
|
||||
@ -373,7 +371,8 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(std::string name) {
|
||||
flutter::SemanticsNode node1;
|
||||
node1.id = 1;
|
||||
node1.label = "node1";
|
||||
node1.flags = static_cast<int32_t>(flutter::SemanticsFlags::kScopesRoute);
|
||||
node1.flags = static_cast<int32_t>(flutter::SemanticsFlags::kScopesRoute) |
|
||||
static_cast<int32_t>(flutter::SemanticsFlags::kNamesRoute);
|
||||
node1.childrenInTraversalOrder = {2, 3};
|
||||
node1.childrenInHitTestOrder = {2, 3};
|
||||
nodes[node1.id] = node1;
|
||||
@ -394,9 +393,9 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(std::string name) {
|
||||
|
||||
// Notification should focus first focusable node, which is node1.
|
||||
XCTAssertEqual([accessibility_notifications count], 1ul);
|
||||
SemanticsObject* focusObject = accessibility_notifications[0][@"argument"];
|
||||
XCTAssertEqual([focusObject uid], 2);
|
||||
XCTAssertEqualObjects([focusObject accessibilityLabel], @"node2");
|
||||
id focusObject = accessibility_notifications[0][@"argument"];
|
||||
XCTAssertTrue([focusObject isKindOfClass:[NSString class]]);
|
||||
XCTAssertEqualObjects(focusObject, @"node1");
|
||||
XCTAssertEqual([accessibility_notifications[0][@"notification"] unsignedIntValue],
|
||||
UIAccessibilityScreenChangedNotification);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user