From c1d3fd0885fec72ca0eb34cdaa793960558ee531 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Tue, 1 Aug 2023 13:36:41 -0700 Subject: [PATCH] fix --- .../ios/framework/Source/SemanticsObject.mm | 28 +++---------------- .../framework/Source/SemanticsObjectTest.mm | 28 ++----------------- 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm index 7d0fe4c75d234..7221a35c7b86a 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm @@ -93,12 +93,6 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) { } // namespace -@interface NSObject (FlutterSemantics) - -- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event; - -@end - @interface FlutterSwitchSemanticsObject () @property(nonatomic, readonly) UISwitch* nativeSwitch; @end @@ -578,13 +572,7 @@ - (id)search:(CGPoint)point { // IOS 16. Overrides this method to focus the first eligiable semantics // object in hit test order. - (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event { - id hittest = [self search:point]; - if (![hittest isKindOfClass:[SemanticsObject class]]) { - // If hittest result is not a SemanticsObject (e.g. PlatformView), - // call the default hittest method to find the hittest result inside the "hittest". - return [(NSObject*)hittest _accessibilityHitTest:point withEvent:event]; - } - return hittest; + return [self search:point]; } // iOS calls this method when this item is swipe-to-focusd in VoiceOver. @@ -890,17 +878,9 @@ - (void)dealloc { [super dealloc]; } -- (id)nativeAccessibility { - return _platformView; -} - -- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event { - return [_platformView _accessibilityHitTest:point withEvent:event]; -} - -- (BOOL)isFocusable { - return YES; -} +// - (id)nativeAccessibility { +// return _platformView; +// } - (BOOL)isAccessibilityElement { return NO; diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index 2b9e955e7d740..c2200af6a6881 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -89,23 +89,6 @@ void AccessibilityObjectDidLoseFocus(int32_t id) override {} } // namespace } // namespace flutter -@interface FakePlatformView : UIView - -@property(nonatomic, strong, readonly) UIView* subview; - -@end - -@implementation FakePlatformView - -- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event { - if (_subview) { - _subview = [[UIView alloc] init]; - } - return _subview; -} - -@end - @interface SemanticsObjectTest : XCTestCase @end @@ -220,15 +203,14 @@ - (void)testAccessibilityHitTestNoFocusableItem { XCTAssertNil(hitTestResult); } -- (void)testAccessibilityHitTestSearchPlatformViewSubtree { +- (void)testAccessibilityHitTestSearchCanReturnPlatformView { fml::WeakPtrFactory factory( new flutter::MockAccessibilityBridge()); fml::WeakPtr bridge = factory.GetWeakPtr(); SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; SemanticsObject* object3 = [[SemanticsObject alloc] initWithBridge:bridge uid:3]; - FakePlatformView* platformView = - [[FakePlatformView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; + UIView* platformView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer = [[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge uid:1 @@ -264,13 +246,9 @@ - (void)testAccessibilityHitTestSearchPlatformViewSubtree { [object3 setSemanticsNode:&node3]; CGPoint point = CGPointMake(10, 10); - // id partialMockPlatformView = OCMPartialMock(platformView); - // OCMStub([partialMockPlatformView _accessibilityHitTest:point - // withEvent:nil]).andReturn(subView); id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil]; - // Focus to object2 because it's the first object in hit test order - XCTAssertEqual(hitTestResult, platformView.subview); + XCTAssertEqual(hitTestResult, platformView); } - (void)testAccessibilityScrollToVisible {