Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
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
27 changes: 12 additions & 15 deletions shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,13 @@ - (instancetype)init __attribute__((unavailable("Use initWithSemanticsObject ins
- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject
bridge:(fml::WeakPtr<shell::AccessibilityBridge>)bridge
NS_DESIGNATED_INITIALIZER;

@property(nonatomic, weak) SemanticsObject* semanticsObject;

@end

@implementation SemanticsObject {
SemanticsObjectContainer* _container;
fml::scoped_nsobject<SemanticsObjectContainer> _container;
}

#pragma mark - Override base class designated initializers
Expand Down Expand Up @@ -123,8 +126,7 @@ - (void)dealloc {
[_children removeAllObjects];
[_children release];
_parent = nil;
[_container release];
_container = nil;
_container.get().semanticsObject = nil;
Copy link

@pedia pedia Feb 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this really worked? maybe better:

_container.release(); 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember the details now, but this was part of breaking the circular references.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember the details now, but this was part of breaking the circular references.

[super dealloc];
}

Expand Down Expand Up @@ -268,9 +270,9 @@ - (CGRect)globalRect {
- (id)accessibilityContainer {
if ([self hasChildren] || [self uid] == kRootNodeId) {
if (_container == nil)
_container = [[SemanticsObjectContainer alloc] initWithSemanticsObject:self
bridge:[self bridge]];
return _container;
_container.reset([[SemanticsObjectContainer alloc] initWithSemanticsObject:self
bridge:[self bridge]]);
return _container.get();
}
if ([self parent] == nil) {
// This can happen when we have released the accessibility tree but iOS is
Expand Down Expand Up @@ -410,24 +412,17 @@ - (instancetype)init {

- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject
bridge:(fml::WeakPtr<shell::AccessibilityBridge>)bridge {
FML_DCHECK(semanticsObject != nil) << "semanticsObject must be set";
FML_DCHECK(semanticsObject) << "semanticsObject must be set";
self = [super init];

if (self) {
_semanticsObject = semanticsObject;
// The pointer is managed manually.
[_semanticsObject retain];
_bridge = bridge;
}

return self;
}

- (void)dealloc {
[_semanticsObject release];
[super dealloc];
}

#pragma mark - UIAccessibilityContainer overrides

- (NSInteger)accessibilityElementCount {
Expand All @@ -437,8 +432,9 @@ - (NSInteger)accessibilityElementCount {
- (nullable id)accessibilityElementAtIndex:(NSInteger)index {
if (index < 0 || index >= [self accessibilityElementCount])
return nil;
if (index == 0)
if (index == 0) {
return _semanticsObject;
}
SemanticsObject* child = [_semanticsObject children][index - 1];
if ([child hasChildren])
return [child accessibilityContainer];
Expand Down Expand Up @@ -506,6 +502,7 @@ - (BOOL)accessibilityScroll:(UIAccessibilityScrollDirection)direction {
}

AccessibilityBridge::~AccessibilityBridge() {
clearState();
view_.accessibilityElements = nil;
[accessibility_channel_.get() setMessageHandler:nil];
}
Expand Down