未验证 提交 2f352d66 编写于 作者: D Dan Field 提交者: GitHub

Fix for a11y crash on iOS (#12990)

上级 a29385d9
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册