Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit c1d3fd0

Browse files
author
Chris Yang
committed
fix
1 parent 1473eb1 commit c1d3fd0

File tree

2 files changed

+7
-49
lines changed

2 files changed

+7
-49
lines changed

shell/platform/darwin/ios/framework/Source/SemanticsObject.mm

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,6 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {
9393

9494
} // namespace
9595

96-
@interface NSObject (FlutterSemantics)
97-
98-
- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event;
99-
100-
@end
101-
10296
@interface FlutterSwitchSemanticsObject ()
10397
@property(nonatomic, readonly) UISwitch* nativeSwitch;
10498
@end
@@ -578,13 +572,7 @@ - (id)search:(CGPoint)point {
578572
// IOS 16. Overrides this method to focus the first eligiable semantics
579573
// object in hit test order.
580574
- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
581-
id hittest = [self search:point];
582-
if (![hittest isKindOfClass:[SemanticsObject class]]) {
583-
// If hittest result is not a SemanticsObject (e.g. PlatformView),
584-
// call the default hittest method to find the hittest result inside the "hittest".
585-
return [(NSObject*)hittest _accessibilityHitTest:point withEvent:event];
586-
}
587-
return hittest;
575+
return [self search:point];
588576
}
589577

590578
// iOS calls this method when this item is swipe-to-focusd in VoiceOver.
@@ -890,17 +878,9 @@ - (void)dealloc {
890878
[super dealloc];
891879
}
892880

893-
- (id)nativeAccessibility {
894-
return _platformView;
895-
}
896-
897-
- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
898-
return [_platformView _accessibilityHitTest:point withEvent:event];
899-
}
900-
901-
- (BOOL)isFocusable {
902-
return YES;
903-
}
881+
// - (id)nativeAccessibility {
882+
// return _platformView;
883+
// }
904884

905885
- (BOOL)isAccessibilityElement {
906886
return NO;

shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ void AccessibilityObjectDidLoseFocus(int32_t id) override {}
8989
} // namespace
9090
} // namespace flutter
9191

92-
@interface FakePlatformView : UIView
93-
94-
@property(nonatomic, strong, readonly) UIView* subview;
95-
96-
@end
97-
98-
@implementation FakePlatformView
99-
100-
- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
101-
if (_subview) {
102-
_subview = [[UIView alloc] init];
103-
}
104-
return _subview;
105-
}
106-
107-
@end
108-
10992
@interface SemanticsObjectTest : XCTestCase
11093
@end
11194

@@ -220,15 +203,14 @@ - (void)testAccessibilityHitTestNoFocusableItem {
220203
XCTAssertNil(hitTestResult);
221204
}
222205

223-
- (void)testAccessibilityHitTestSearchPlatformViewSubtree {
206+
- (void)testAccessibilityHitTestSearchCanReturnPlatformView {
224207
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
225208
new flutter::MockAccessibilityBridge());
226209
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
227210
SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0];
228211
SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1];
229212
SemanticsObject* object3 = [[SemanticsObject alloc] initWithBridge:bridge uid:3];
230-
FakePlatformView* platformView =
231-
[[FakePlatformView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
213+
UIView* platformView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
232214
FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer =
233215
[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge
234216
uid:1
@@ -264,13 +246,9 @@ - (void)testAccessibilityHitTestSearchPlatformViewSubtree {
264246
[object3 setSemanticsNode:&node3];
265247

266248
CGPoint point = CGPointMake(10, 10);
267-
// id partialMockPlatformView = OCMPartialMock(platformView);
268-
// OCMStub([partialMockPlatformView _accessibilityHitTest:point
269-
// withEvent:nil]).andReturn(subView);
270249
id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil];
271250

272-
// Focus to object2 because it's the first object in hit test order
273-
XCTAssertEqual(hitTestResult, platformView.subview);
251+
XCTAssertEqual(hitTestResult, platformView);
274252
}
275253

276254
- (void)testAccessibilityScrollToVisible {

0 commit comments

Comments
 (0)