On Sat, 11 Apr 2026 23:17:36 GMT, Phil Race <[email protected]> wrote:

>>> I think it sounds like an inconsistent mess.
>> 
>> Well that's something of a relief. (That is: at least you're not telling me 
>> that the design is fine and I'm just misunderstanding it.)
>> 
>>> And internally we probably should never be calling APIs that like 
>>> getAccessibleActionDescription() to use in the implementation, if that is, 
>>> they can be returning localized messages for an end user.
>> We should be doing something else.
>> 
>> I agree. Here is my first choice (assuming changing existing method 
>> signatures is a nonstarter) for a "something else" we could try:
>> 
>> https://github.com/openjdk/jdk/compare/master...mickleness:8377938B?expand=1
>> 
>> This preserves `AccessibleAction.getAccessibleActionDescription(int)`, but 
>> it adds `AccessibleAction.getAccessibleActionType(int)`. This new method 
>> returns a constant field from AccessibleAction. (It's modeled after 
>> BufferedImage#getType().)
>> 
>> In your opinion is that approach worth pursuing, or would you like to see 
>> something else?
>> 
>> (One last important piece of context: JavaAccessibilityActions.m hardwires 
>> its own table of actions:
>> 
>> void initializeActions() {
>>     int actionsCount = 5;
>> 
>>     sActions = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
>> 
>>     [sActions setObject:NSAccessibilityPressAction forKey:@"click"];
>>     [sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
>>     [sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
>>     [sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle 
>> popup"];
>>     [sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];
>>     ...
>> 
>> 
>> So this is what we'd be cross referencing when we consult the new `type` 
>> method.)
>
>> > I think it sounds like an inconsistent mess.
>> 
>> Well that's something of a relief. (That is: at least you're not telling me 
>> that the design is fine and I'm just misunderstanding it.)
>> 
>> > And internally we probably should never be calling APIs that like 
>> > getAccessibleActionDescription() to use in the implementation, if that is, 
>> > they can be returning localized messages for an end user.
>> > We should be doing something else.
>> 
>> I agree. Here is my first choice (assuming changing existing method 
>> signatures is a nonstarter) for a "something else" we could try:
>> 
>> https://github.com/openjdk/jdk/compare/master...mickleness:8377938B?expand=1
>> 
>> This preserves `AccessibleAction.getAccessibleActionDescription(int)`, but 
>> it adds `AccessibleAction.getAccessibleActionType(int)`. This new method 
>> returns a constant field from AccessibleAction. (It's modeled after 
>> BufferedImage#getType().)
>> 
>> In your opinion is that approach worth pursuing, or would you like to see 
>> something else?
>> 
>> (One last important piece of context: JavaAccessibilityActions.m hardwires 
>> its own table of actions:
>> 
>> ```
>> void initializeActions() {
>>     int actionsCount = 5;
>> 
>>     sActions = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
>> 
>>     [sActions setObject:NSAccessibilityPressAction forKey:@"click"];
>>     [sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
>>     [sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
>>     [sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle 
>> popup"];
>>     [sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];
>>     ...
>> ```
>> 
>> So this is what we'd be cross referencing when we consult the new `type` 
>> method.)
> 
> I am not sufficiently familiar with the design and philosophy of the public 
> APIs to know if this is the right direction.
> It is a non-trivial and wide-ranging change, and adding a method to an 
> interface that external code might implement without an obvious default 
> method implementation is something we'd need to think about.
> I was hoping for something much simpler and more specific.

@prrace would you like me to add comments in the code for future readers?

For ex in CommonComponentAccessibility.m:


        fActionSelectors = [[NSMutableArray alloc] initWithCapacity:count];
        for (int i =0; i < count; i++) {
            JavaAxAction *action = [[JavaAxAction alloc] initWithEnv:env 
withAccessibleAction:axAction withIndex:i withComponent:fComponent];
            // sActions uses English keys, and the action descriptions may be 
translated.
            if ([fParent isKindOfClass:[CommonComponentAccessibility class]] &&


... and then in JavaAccessibilityAction.m:

void initializeActions() {
    int actionsCount = 5;

    sActions = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];

// These keys correspond to AccessibleAction constants.
    [sActions setObject:NSAccessibilityPressAction forKey:@"click"];
    [sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
    [sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
    [sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle popup"];
    [sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];

-------------

PR Comment: https://git.openjdk.org/jdk/pull/30181#issuecomment-4361901185

Reply via email to