From 54da569e8faecea48301a20be33b97025a261b29 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 7 Oct 2019 17:28:39 -0700 Subject: [PATCH 1/4] Fix for a11y crash on iOS --- .../darwin/ios/framework/Source/accessibility_bridge.h | 4 ++-- .../darwin/ios/framework/Source/accessibility_bridge.mm | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h index f563b73ce266a..aaba31842c9e5 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h @@ -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. diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index ddd5478f8c573..75d2f45857d0b 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -81,7 +81,7 @@ @implementation FlutterCustomAccessibilityAction { * 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)bridge @@ -109,7 +109,7 @@ - (instancetype)init { - (instancetype)initWithBridge:(fml::WeakPtr)bridge uid:(int32_t)uid { FML_DCHECK(bridge) << "bridge must be set"; FML_DCHECK(uid >= kRootNodeId); - self = [super init]; + self = [super initWithAccessibilityContainer:bridge->view()]; if (self) { _bridge = bridge; @@ -426,7 +426,7 @@ - (instancetype)init { - (instancetype)initWithSemanticsObject:(SemanticsObject*)object { FML_CHECK(object); - if (self = [super init]) { + if (self = [super initWithAccessibilityContainer:object.bridge->view()]) { _semanticsObject = object; flutter::FlutterPlatformViewsController* controller = object.bridge->GetPlatformViewsController(); @@ -473,7 +473,7 @@ - (instancetype)init { - (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject bridge:(fml::WeakPtr)bridge { FML_DCHECK(semanticsObject) << "semanticsObject must be set"; - self = [super init]; + self = [super initWithAccessibilityContainer:bridge->view()]; if (self) { _semanticsObject = semanticsObject; @@ -507,6 +507,7 @@ - (nullable id)accessibilityElementAtIndex:(NSInteger)index { if ([child hasChildren]) return [child accessibilityContainer]; + return child; } From 43331472f51ea3eb8c2eb80affb2b9ec9cb2d143 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 7 Oct 2019 17:31:45 -0700 Subject: [PATCH 2/4] unintended ws change --- build/zip_bundle.gni | 7 +++++++ .../darwin/ios/framework/Source/accessibility_bridge.mm | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 build/zip_bundle.gni diff --git a/build/zip_bundle.gni b/build/zip_bundle.gni new file mode 100644 index 0000000000000..8b48ec1282668 --- /dev/null +++ b/build/zip_bundle.gni @@ -0,0 +1,7 @@ +# Copyright 2013 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +template("zip_bundle") { + +} diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 75d2f45857d0b..31c0b19c151f3 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -507,7 +507,6 @@ - (nullable id)accessibilityElementAtIndex:(NSInteger)index { if ([child hasChildren]) return [child accessibilityContainer]; - return child; } From 49f359c07f9453f9700d18cba5aaebc7fde7e1b1 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Oct 2019 09:31:47 -0700 Subject: [PATCH 3/4] remove unintended file --- build/zip_bundle.gni | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 build/zip_bundle.gni diff --git a/build/zip_bundle.gni b/build/zip_bundle.gni deleted file mode 100644 index 8b48ec1282668..0000000000000 --- a/build/zip_bundle.gni +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright 2013 The Flutter Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -template("zip_bundle") { - -} From 7a8159998a626b42afac79a1af2ef065ad75cd25 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 8 Oct 2019 16:04:53 -0700 Subject: [PATCH 4/4] comments --- .../ios/framework/Source/accessibility_bridge.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index dfb43a6c8448a..36f320d93856e 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -109,6 +109,10 @@ - (instancetype)init { - (instancetype)initWithBridge:(fml::WeakPtr)bridge uid:(int32_t)uid { FML_DCHECK(bridge) << "bridge must be set"; FML_DCHECK(uid >= kRootNodeId); + // 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) { @@ -429,6 +433,10 @@ - (instancetype)init { - (instancetype)initWithSemanticsObject:(SemanticsObject*)object { FML_CHECK(object); + // 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 = @@ -476,6 +484,10 @@ - (instancetype)init { - (instancetype)initWithSemanticsObject:(SemanticsObject*)semanticsObject bridge:(fml::WeakPtr)bridge { FML_DCHECK(semanticsObject) << "semanticsObject must be set"; + // 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) {