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

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jun 9, 2021

Fixes scrolling issues once and for all
Use a UIScrollView to represent scroll view in iOS accessibility.

fixes flutter/flutter#80711
fixes flutter/flutter#37974

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard

This comment has been minimized.

@chunhtai chunhtai requested a review from gaaclarke June 10, 2021 18:55
@chunhtai
Copy link
Contributor Author

chunhtai commented Jun 10, 2021

This makes scrollable work natively in iOS, this however makes the scrollable focusable in voiceover. I think this is ok because that matches the UIScrollView in native App if you want it to be scrollable.

- (void)accessibilityBridgeDidFinishUpdate;

/** Should only be called in conjunction with setting child/parent relationship. */
- (void)setParent:(SemanticsObject*)parent;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of providing this method, switch the property away from readonly and make sure the memory semantics are clear i.e. is this retaining a weak or strong reference?

/// iOS.
@interface FlutterScrollableSemanticsObject : UIScrollView

- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject;
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_UNAVAILABLE init and NS_DESIGNATED_INITIALIZER for this initializer to force people to use this initializer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initWithSemanticsObject still uses init, I can't NS_UNAVAILABLE the init?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm i got it

return globalTransform;
}

void ApplyTransform(SkPoint& point, const SkM44& transform) {
Copy link
Member

Choose a reason for hiding this comment

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

Instead of mutating the parameter, just return a new SkPoint. That leads to more clear usage.

@end // FlutterSwitchSemanticsObject

@implementation FlutterScrollableSemanticsObject {
SemanticsObject* _semanticsObject;
Copy link
Member

Choose a reason for hiding this comment

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

Please move this to a property so the memory semantics are explicit.

}

- (id)accessibilityContainer {
if (_container == nil)
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines 96 to 97
/** Should only be called in conjunction with setting child/parent relationship. */
- (void)privateSetParent:(SemanticsObject*)parent;
Copy link
Member

Choose a reason for hiding this comment

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

Why get rid of this flimsy protection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the parent become a public property, do we still want to keep this?

Copy link
Member

Choose a reason for hiding this comment

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

I would. I admit it is flimsy but it at least brings attention to it.


void AccessibilityBridge::VisitObjectsRecursivelyAndRemove(SemanticsObject* object,
NSMutableArray<NSNumber*>* doomed_uids) {
[object accessibilityBridgeDidFinishUpdate];
Copy link
Member

Choose a reason for hiding this comment

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

The name of this method doesn't seem to match to me with where it is being called. If i had to name it I'd call it accessibilityBridgeWillVisitObjectsRecursivelyAndRemove, know what I mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The accessibilityBridgeWillVisitObjectsRecursivelyAndRemove name is vague and is hard to interpret. I put it in VisitObjectsRecursivelyAndRemove because I don't want to do another tree walk just to call this method.

Copy link
Member

Choose a reason for hiding this comment

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

The problem with what it is called now is that is leaking context information about where VisitObjectsRecursivelyAndRemove is called into calls higher in the call stack. Would it make more sense to move that to where VisitObjectsRecursivelyAndRemove is being called? Maybe you could make a method like this:

void finishUpdating(bridge, object) {
  doomed_uids = calculateDoomedUids();
  [object accessibilityBridgeDidFinishUpdate];
  bridge->VisitObjectsRecursivelyAndRemove(object, doomed_uids);
}

That would make the name make more sense.

@chunhtai
Copy link
Contributor Author

@gaaclarke PTAL :)

@chunhtai chunhtai requested a review from gaaclarke June 11, 2021 18:25
- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject {
self = [super initWithFrame:CGRectZero];
if (self) {
self.semanticsObject = semanticsObject;
Copy link
Member

Choose a reason for hiding this comment

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

You should use _semanticsObject = [semanticsObject retain]; You aren't suppose to reference properties through self in init methods.

Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

LGTM modulo those 2 comments.

@chunhtai chunhtai added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jun 14, 2021
@fluttergithubbot fluttergithubbot merged commit e56dd3a into flutter:master Jun 14, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 14, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 15, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 15, 2021
chunhtai added a commit to chunhtai/engine that referenced this pull request Jun 17, 2021
chunhtai added a commit that referenced this pull request Jun 17, 2021
wqyfavor pushed a commit to wqyfavor/engine that referenced this pull request Jun 21, 2021
naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request Sep 2, 2021
naudzghebre pushed a commit to naudzghebre/engine that referenced this pull request Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-ios waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scroll Down/Up not working with iOS Voice Control Scrolling a scrollable widget with Switch Control on iOS is not very comfortable

3 participants