0

[AX Mac] prepare NSAccessibilityStyleRangeForIndexParameterizedAttribute

for migration.

Redirect NSAccessibilityStyleRangeForIndexParameterizedAttribute
implementation to accessibilityStyleRangeForIndex method.

Test: `out/.../accessibility_unittests \
   --gtest_filter="*AccessibilityStyleRangeForIndex*"`

Include-Ci-Only-Tests: true
Cq-Include-Trybots: luci.chromium.try:mac-fieldtrial-tester

Bug: 363275809
Change-Id: I83c9297e3afb68e253361e9b6618cad57ec2259e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6115309
Reviewed-by: David Tseng <dtseng@chromium.org>
Reviewed-by: Jayson Adams <shrike@chromium.org>
Commit-Queue: Alexander Surkov <asurkov@igalia.com>
Cr-Commit-Position: refs/heads/main@{#1406484}
This commit is contained in:
Alexander Surkov
2025-01-14 18:35:01 -08:00
committed by Chromium LUCI CQ
parent 460bf168f8
commit bc4d17f1f8
2 changed files with 22 additions and 6 deletions

@ -2460,12 +2460,13 @@ const ui::CocoaActionList& GetCocoaActionListForTesting() {
}
- (id)AXStyleRangeForIndex:(id)parameter {
if (![parameter isKindOfClass:[NSNumber class]])
NSNumber* indexNumber = base::apple::ObjCCast<NSNumber>(parameter);
if (!indexNumber) {
return nil;
// TODO(crbug.com/41456329): Implement this for real.
}
return [NSValue
valueWithRange:NSMakeRange(0, [self accessibilityNumberOfCharacters])];
valueWithRange:[self accessibilityStyleRangeForIndex:[indexNumber
intValue]]];
}
- (id)AXAttributedStringForRange:(id)parameter {
@ -3362,10 +3363,12 @@ const ui::CocoaActionList& GetCocoaActionListForTesting() {
}
- (NSRange)accessibilityStyleRangeForIndex:(NSInteger)index {
if (!_node)
if (![self instanceActive]) {
return NSMakeRange(0, 0);
}
return [[self AXStyleRangeForIndex:@(index)] rangeValue];
// TODO(crbug.com/41456329): Implement this for real.
return NSMakeRange(0, [self accessibilityNumberOfCharacters]);
}
- (NSRange)accessibilityRangeForLine:(NSInteger)line {

@ -820,6 +820,19 @@ TEST_P(AXPlatformNodeCocoaTest, AccessibilityStringForRange) {
EXPECT_TRUE([string isEqualToString:@"hey"]);
}
// accessibilityStyleRangeForIndex
TEST_P(AXPlatformNodeCocoaTest, AccessibilityStyleRangeForIndex) {
Init(std::string(R"HTML(
++1 kRootWebArea
++++2 kStaticText name="heybullfrog"
)HTML"));
AXPlatformNodeCocoa* text_field = GetCocoaNode(2);
NSRange range = [text_field accessibilityStyleRangeForIndex:0];
EXPECT_EQ(range.location, 0U);
EXPECT_EQ(range.length, 11U);
}
// Non-header cells should not support accessibilitySortDirection, even if
// there's a sort direction in the AXNodeData. Their sort order is "unknown".
TEST_P(AXPlatformNodeCocoaTest, AccessibilitySortDirectionOnCell) {