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
29 changes: 27 additions & 2 deletions shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,35 @@ - (void)dealloc {
[super dealloc];
}

- (NSArray*)accessibilityElements {
return @[ _semanticsObject, _platformView ];
#pragma mark - UIAccessibilityContainer overrides

- (NSInteger)accessibilityElementCount {
// This container should only contain 2 elements:
// 1. The semantic object that represents this container.
// 2. The platform view object.
return 2;
}

- (nullable id)accessibilityElementAtIndex:(NSInteger)index {
FML_DCHECK(index < 2);
if (index == 0) {
return _semanticsObject;
} else {
return _platformView;
}
}

- (NSInteger)indexOfAccessibilityElement:(id)element {
FML_DCHECK(element == _semanticsObject || element == _platformView);
if (element == _semanticsObject) {
return 0;
} else {
return 1;
}
}

#pragma mark - UIAccessibilityElement overrides

- (CGRect)accessibilityFrame {
return _semanticsObject.accessibilityFrame;
}
Expand Down
12 changes: 12 additions & 0 deletions shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,16 @@ - (void)testShouldDispatchShowOnScreenActionForHidden {
XCTAssertTrue(bridge->observations[0].action == flutter::SemanticsAction::kShowOnScreen);
}

- (void)testSemanticsObjectAndPlatformViewSemanticsContainerDontHaveRetainCycle {
fml::WeakPtrFactory<flutter::MockAccessibilityBridge> factory(
new flutter::MockAccessibilityBridge());
fml::WeakPtr<flutter::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
SemanticsObject* object = [[SemanticsObject alloc] initWithBridge:bridge uid:1];
object.platformViewSemanticsContainer =
[[FlutterPlatformViewSemanticsContainer alloc] initWithSemanticsObject:object];
__weak SemanticsObject* weakObject = object;
object = nil;
XCTAssertNil(weakObject);
}

@end