Fix for a11y crash on iOS (flutter/engine#12990)
This commit is contained in:
@@ -32,7 +32,7 @@ class AccessibilityBridge;
|
||||
/**
|
||||
* A node in the iOS semantics tree.
|
||||
*/
|
||||
@interface SemanticsObject : NSObject
|
||||
@interface SemanticsObject : UIAccessibilityElement
|
||||
|
||||
/**
|
||||
* The globally unique identifier for this node.
|
||||
@@ -126,7 +126,7 @@ class AccessibilityBridge;
|
||||
* * `SemanticsObject` for the other type of semantics objects.
|
||||
* * `FlutterSemanticsObject` for default implementation of `SemanticsObject`.
|
||||
*/
|
||||
@interface FlutterPlatformViewSemanticsContainer : NSObject
|
||||
@interface FlutterPlatformViewSemanticsContainer : UIAccessibilityElement
|
||||
|
||||
/**
|
||||
* The position inside an accessibility container.
|
||||
|
||||
@@ -81,7 +81,7 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
* there for structure and they don't provide any semantic information to VoiceOver (they return
|
||||
* NO for isAccessibilityElement).
|
||||
*/
|
||||
@interface SemanticsObjectContainer : NSObject
|
||||
@interface SemanticsObjectContainer : UIAccessibilityElement
|
||||
- (instancetype)init __attribute__((unavailable("Use initWithSemanticsObject instead")));
|
||||
- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject
|
||||
bridge:(fml::WeakPtr<flutter::AccessibilityBridge>)bridge
|
||||
@@ -109,7 +109,11 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
- (instancetype)initWithBridge:(fml::WeakPtr<flutter::AccessibilityBridge>)bridge uid:(int32_t)uid {
|
||||
FML_DCHECK(bridge) << "bridge must be set";
|
||||
FML_DCHECK(uid >= kRootNodeId);
|
||||
self = [super init];
|
||||
// Initialize with the UIView as the container.
|
||||
// The UIView will not necessarily be accessibility parent for this object.
|
||||
// The bridge informs the OS of the actual structure via
|
||||
// `accessibilityContainer` and `accessibilityElementAtIndex`.
|
||||
self = [super initWithAccessibilityContainer:bridge->view()];
|
||||
|
||||
if (self) {
|
||||
_bridge = bridge;
|
||||
@@ -429,7 +433,11 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
|
||||
- (instancetype)initWithSemanticsObject:(SemanticsObject*)object {
|
||||
FML_CHECK(object);
|
||||
if (self = [super init]) {
|
||||
// Initialize with the UIView as the container.
|
||||
// The UIView will not necessarily be accessibility parent for this object.
|
||||
// The bridge informs the OS of the actual structure via
|
||||
// `accessibilityContainer` and `accessibilityElementAtIndex`.
|
||||
if (self = [super initWithAccessibilityContainer:object.bridge->view()]) {
|
||||
_semanticsObject = object;
|
||||
flutter::FlutterPlatformViewsController* controller =
|
||||
object.bridge->GetPlatformViewsController();
|
||||
@@ -476,7 +484,11 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
|
||||
- (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject
|
||||
bridge:(fml::WeakPtr<flutter::AccessibilityBridge>)bridge {
|
||||
FML_DCHECK(semanticsObject) << "semanticsObject must be set";
|
||||
self = [super init];
|
||||
// Initialize with the UIView as the container.
|
||||
// The UIView will not necessarily be accessibility parent for this object.
|
||||
// The bridge informs the OS of the actual structure via
|
||||
// `accessibilityContainer` and `accessibilityElementAtIndex`.
|
||||
self = [super initWithAccessibilityContainer:bridge->view()];
|
||||
|
||||
if (self) {
|
||||
_semanticsObject = semanticsObject;
|
||||
|
||||
Reference in New Issue
Block a user