Skip to content

Commit

Permalink
[macOS] A11y Zoom Crash (flutter#35453)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wallen authored Aug 18, 2022
1 parent e85e13d commit 73b5da2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,9 @@ - (NSRange)accessibilityRangeForLine:(NSInteger)line {
}

- (NSRange)accessibilityRangeForPosition:(NSPoint)point {
BASE_UNREACHABLE();
// TODO(a-wallen): Framework needs to send Text Metrics
// to the AXTree in order for a NSPoint (x, y) to be
// translated to the appropriate range of UTF-16 chars.
return NSMakeRange(0, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,25 @@
EXPECT_TRUE(native_root != nullptr);
}

// Test that [AXPlatformNodeCocoa accessbilityRangeForPosition:] doesn't crash.
// https://github.com/flutter/flutter/issues/102416
TEST_F(AXPlatformNodeMacTest, AccessibilityRangeForPositionDoesntCrash) {
AXNodeData root;
root.id = 1;
root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);

Init(root);
AXNode* root_node = GetRootAsAXNode();
ASSERT_TRUE(root_node != nullptr);

AXPlatformNode* platform_node = AXPlatformNodeFromNode(root_node);
ASSERT_TRUE(platform_node != nullptr);

NSPoint point = NSMakePoint(0, 0);
AXPlatformNodeCocoa* native_root = platform_node->GetNativeViewAccessible();
ASSERT_TRUE(native_root != nullptr);

[native_root accessibilityRangeForPosition:(NSPoint)point];
}

} // namespace ui

0 comments on commit 73b5da2

Please sign in to comment.