-
Notifications
You must be signed in to change notification settings - Fork 6k
[ios] Link PlatformView back to semantics tree #46471
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,10 @@ | |
| static FlutterPlatformViewsTestMockPlatformView* gMockPlatformView = nil; | ||
| const float kFloatCompareEpsilon = 0.001; | ||
|
|
||
| @interface FlutterTouchInterceptingView (Test) | ||
| - (id)accessibilityContainer; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This entire redeclaration block should be removed in favor of including the test header. |
||
| @end | ||
|
|
||
| @interface FlutterPlatformViewsTestMockPlatformView : UIView | ||
| @end | ||
| @implementation FlutterPlatformViewsTestMockPlatformView | ||
|
|
@@ -3099,4 +3103,12 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { | |
| XCTAssertEqual(mockFlutterView.subviews.firstObject, someView); | ||
| } | ||
|
|
||
| - (void)testFlutterTouchInterceptingViewLinksToAccessibilityContainer { | ||
| FlutterTouchInterceptingView* touchInteceptorView = | ||
| [[[FlutterTouchInterceptingView alloc] init] autorelease]; | ||
| NSObject* container = [[[NSObject alloc] init] autorelease]; | ||
| [touchInteceptorView setFlutterAccessibilityContainer:container]; | ||
| XCTAssertEqualObjects([touchInteceptorView accessibilityContainer], container); | ||
| } | ||
|
|
||
| @end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" | ||
| #import "flutter/shell/platform/darwin/ios/ios_context.h" | ||
|
|
||
| @class FlutterTouchInterceptingView; | ||
|
|
@@ -234,6 +235,8 @@ class FlutterPlatformViewsController { | |
| // returns nil. | ||
| UIView* GetPlatformViewByID(int64_t view_id); | ||
|
|
||
| FlutterTouchInterceptingView* GetFlutterTouchInterceptingViewByID(int64_t); | ||
|
stuartmorgan-g marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I missed that this parameter doesn't have a name; it should be |
||
|
|
||
| PostPrerollResult PostPrerollAction( | ||
| const fml::RefPtr<fml::RasterThreadMerger>& raster_thread_merger); | ||
|
|
||
|
|
@@ -409,7 +412,7 @@ class FlutterPlatformViewsController { | |
| // This view has 2 roles: | ||
| // 1. Delay or prevent touch events from arriving the embedded view. | ||
| // 2. Dispatching all events that are hittested to the embedded view to the FlutterView. | ||
| @interface FlutterTouchInterceptingView : UIView | ||
| @interface FlutterTouchInterceptingView : UIView <FlutterSemanticsProtocol> | ||
| - (instancetype)initWithEmbeddedView:(UIView*)embeddedView | ||
| platformViewsController: | ||
| (fml::WeakPtr<flutter::FlutterPlatformViewsController>)platformViewsController | ||
|
|
@@ -424,6 +427,7 @@ class FlutterPlatformViewsController { | |
|
|
||
| // Get embedded view | ||
| - (UIView*)embeddedView; | ||
|
|
||
| @end | ||
|
|
||
| @interface UIView (FirstResponder) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,14 @@ constexpr float kScrollExtentMaxForInf = 1000; | |
| @class FlutterCustomAccessibilityAction; | ||
| @class FlutterPlatformViewSemanticsContainer; | ||
|
|
||
| @protocol FlutterSemanticsProtocol <NSObject> | ||
| // Adding functionalities for any object to assign accessibilityContainer. | ||
| // For example, this allows the PlatformView be able to link back to the accessibility tree. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm confused by what this property is actually for. I see where it's set, but I don't see anything reading it except in tests. Am I missing some non-test behavior that's influenced by this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is read in I initially added the method to the Then I discovered that SemanticsObjectTests is ARC, so we couldn't not include This does make the code more confusing. Maybe I should revert back to my initial implementation (no protocol, FlutterTouchInterceptingView has a setFlutterAccessiblityContainer method), then move the related tests to mrc. |
||
| // See: https://github.com/flutter/flutter/issues/135504 | ||
| - (void)setFlutterAccessibilityContainer:(NSObject*)flutterAccessibilityContainer; | ||
|
|
||
| @end | ||
|
|
||
| /** | ||
| * A node in the iOS semantics tree. This object is a wrapper over a native accessibiliy | ||
| * object, which is stored in the property `nativeAccessibility`. In the most case, the | ||
|
|
@@ -171,7 +179,8 @@ constexpr float kScrollExtentMaxForInf = 1000; | |
|
|
||
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | ||
| uid:(int32_t)uid | ||
| platformView:(UIView*)platformView NS_DESIGNATED_INITIALIZER; | ||
| platformView:(UIView<FlutterSemanticsProtocol>*)platformView | ||
| NS_DESIGNATED_INITIALIZER; | ||
|
|
||
| @end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
| #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" | ||
|
|
||
| #include "flutter/fml/platform/darwin/scoped_nsobject.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" | ||
| #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterSemanticsScrollView.h" | ||
|
|
||
| namespace { | ||
|
|
@@ -157,9 +156,7 @@ @interface FlutterScrollableSemanticsObject () | |
| @property(nonatomic, retain) FlutterSemanticsScrollView* scrollView; | ||
| @end | ||
|
|
||
| @implementation FlutterScrollableSemanticsObject { | ||
| fml::scoped_nsobject<SemanticsObjectContainer> _container; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated to the PR, but the variable is unused so I removed it |
||
| } | ||
| @implementation FlutterScrollableSemanticsObject | ||
|
|
||
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | ||
| uid:(int32_t)uid { | ||
|
|
@@ -865,9 +862,10 @@ @implementation FlutterPlatformViewSemanticsContainer | |
|
|
||
| - (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridgeIos>)bridge | ||
| uid:(int32_t)uid | ||
| platformView:(nonnull UIView*)platformView { | ||
| platformView:(UIView<FlutterSemanticsProtocol>*)platformView { | ||
| if (self = [super initWithBridge:bridge uid:uid]) { | ||
| _platformView = [platformView retain]; | ||
| [platformView setFlutterAccessibilityContainer:self]; | ||
| } | ||
| return self; | ||
| } | ||
|
|
@@ -882,12 +880,6 @@ - (id)nativeAccessibility { | |
| return _platformView; | ||
| } | ||
|
|
||
| #pragma mark - UIAccessibilityContainer overrides | ||
|
|
||
| - (NSArray*)accessibilityElements { | ||
| return @[ _platformView ]; | ||
| } | ||
|
Comment on lines
-887
to
-889
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We implemented nativeAccessibility, this is not necessary. |
||
|
|
||
| @end | ||
|
|
||
| @implementation SemanticsObjectContainer { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.