Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Apr 3, 2020

Follow up refactor for pr: #17499

This should be a noop change, just splitting up a cyclical dependency and giving greater control over visibility of SemanticObject to AccessibilityBridge. More could be done to split out files in SemanticsObject in the future.

There is technically a slight performance cost with the introduction of virtual methods. This will make testing SemanticsObjects easier though.

@gaaclarke gaaclarke force-pushed the split-out-semantics-object branch from 027f0f1 to f6698f8 Compare April 3, 2020 22:57
@gaaclarke gaaclarke changed the title split up accessibility bridge and semantics object REFACTOR: split up accessibility bridge and semantics object Apr 3, 2020
@gaaclarke gaaclarke marked this pull request as ready for review April 3, 2020 23:04
@auto-assign auto-assign bot requested a review from flar April 3, 2020 23:04
@gaaclarke gaaclarke requested a review from dnfield April 3, 2020 23:04
@dnfield dnfield requested a review from jmagman April 3, 2020 23:12
@dnfield
Copy link
Contributor

dnfield commented Apr 3, 2020

@jmagman to help with ObjC review if possible.

@gaaclarke
Copy link
Member Author

@jmagman to help with ObjC review if possible.

FYI all objc changes were just moving code around and switching references from AccessibilityBridge to AccessibilityBridgeIos. The net result is that AccessibilityBridge no longer has the ability to set a SemanticObject's parent.

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM.

@gaaclarke
Copy link
Member Author

landing, remaining ci tasks are for unaffected platforms and are taking forever.

@gaaclarke gaaclarke merged commit bac37de into flutter:master Apr 3, 2020
/**
* A node in the iOS semantics tree.
*/
@interface SemanticsObject : UIAccessibilityElement
Copy link
Member

Choose a reason for hiding this comment

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

Classes should be prefixed.

Can any of these classes be put into their own files? The implementation file is giant. I know some of them are using private categories to set private properties.

@@ -0,0 +1,156 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

I know you're refactoring and moving code that you didn't necessarily write or want to edit, so I'm just going to do a full review and you can take the suggestions that make sense for you.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, this already merged, want to make a PR with the choice cuts so we don't lose it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, tread lightly, the accessibility stuff doesn't have good automated testing.

constexpr int32_t kRootNodeId = 0;

@class FlutterPlatformViewSemanticsContainer;

Copy link
Member

Choose a reason for hiding this comment

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

Add NS_ASSUME_NONNULL_BEGIN and _END to all edited headers and fix add nullability decorators.

* NO for isAccessibilityElement).
*/
@interface SemanticsObjectContainer : UIAccessibilityElement
- (instancetype)init __attribute__((unavailable("Use initWithSemanticsObject instead")));
Copy link
Member

Choose a reason for hiding this comment

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

NS_UNAVAILABLE
Also mark +new as NS_UNAVAILABLE


#pragma mark - Designated initializers

- (instancetype)init __attribute__((unavailable("Use initWithBridge instead")));
Copy link
Member

Choose a reason for hiding this comment

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

NS_UNAVAILABLE
Also mark +new unavailable.

Is -[UIAccessibilityElement initWithAccessibilityContainer:] supposed to be available?

if (controller) {
_platformView = [controller->GetPlatformViewByID(object.node.platformViewId) view];
}
self.accessibilityElements = @[ _semanticsObject, _platformView ];
Copy link
Member

Choose a reason for hiding this comment

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

Don't use self in init to access properties. _ accessibilityElements = ...

#pragma mark - UIAccessibilityContainer overrides

- (NSInteger)accessibilityElementCount {
NSInteger count = [[_semanticsObject children] count] + 1;
Copy link
Member

Choose a reason for hiding this comment

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

Don't need the local.

Comment on lines +663 to +664
if (element == _semanticsObject)
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

Parentheses?

Comment on lines +657 to +658
if ([child hasChildren])
return [child accessibilityContainer];
Copy link
Member

Choose a reason for hiding this comment

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

Parentheses?

Comment on lines +672 to +677
for (size_t i = 0; i < [children count]; i++) {
SemanticsObject* child = children[i];
if ((![child hasChildren] && child == element) ||
([child hasChildren] && [child accessibilityContainer] == element))
return i + 1;
}
Copy link
Member

Choose a reason for hiding this comment

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

-enumerateObjectsUsingBlock to get fast enumeration and index.

@Hixie
Copy link
Contributor

Hixie commented Apr 14, 2020

@gaaclarke Do you have a follow-up PR to handle @jmagman's comments, perchance?

goderbauer pushed a commit to goderbauer/engine that referenced this pull request Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants