Bug 235414

Summary: AX: Move Mac subrole logic to new subrolePlatformString AXCoreObject interface method
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch none

Description Tyler Wilcock 2022-01-20 12:07:50 PST
This causes string comparisons to fail unexpectedly not match here:

    if (backingObject->isStyleFormatGroup()) {
        using namespace HTMLNames;
        auto tagName = backingObject->tagName();
        if (tagName == kbdTag)
            return @"AXKeyboardInputStyleGroup";
        if (tagName == codeTag)
            return @"AXCodeStyleGroup";
        if (tagName == preTag)
            return @"AXPreformattedStyleGroup";
        if (tagName == sampTag)
            return @"AXSampleStyleGroup";
        if (tagName == varTag)
            return @"AXVariableStyleGroup";
        if (tagName == citeTag)
            return @"AXCiteStyleGroup";
        ASSERT_NOT_REACHED();
    }
Comment 1 Radar WebKit Bug Importer 2022-01-20 12:08:10 PST
<rdar://problem/87842864>
Comment 2 Tyler Wilcock 2022-01-20 12:21:47 PST
Created attachment 449601 [details]
Patch
Comment 3 Tyler Wilcock 2022-01-20 13:14:25 PST
Created attachment 449605 [details]
Patch
Comment 4 chris fleizach 2022-01-20 13:33:37 PST
Comment on attachment 449605 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=449605&action=review

> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:2020
> +        return Accessibility::retrieveValueFromMainThread<String>([protectedSelf = retainPtr(self)] () -> String {

should we cache this rather than hitting main thread?
Comment 5 Tyler Wilcock 2022-01-20 21:07:44 PST
Created attachment 449638 [details]
Patch
Comment 6 Tyler Wilcock 2022-01-20 21:51:02 PST
Created attachment 449639 [details]
Patch
Comment 7 chris fleizach 2022-01-20 22:18:07 PST
Comment on attachment 449639 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=449639&action=review

> Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:1807
> +        && (!backingObject->isModel() || backingObject->modelElementChildren().isEmpty())

I think even if the model is empty we want to return the special subrole so that VO can land on it directly and know that it's a model
Comment 8 Tyler Wilcock 2022-01-21 08:09:48 PST
Created attachment 449658 [details]
Patch
Comment 9 Tyler Wilcock 2022-01-21 08:11:20 PST
(In reply to chris fleizach from comment #7)
> Comment on attachment 449639 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=449639&action=review
> 
> > Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:1807
> > +        && (!backingObject->isModel() || backingObject->modelElementChildren().isEmpty())
> 
> I think even if the model is empty we want to return the special subrole so
> that VO can land on it directly and know that it's a model
Fixed.
Comment 10 Andres Gonzalez 2022-01-21 11:22:49 PST
(In reply to Tyler Wilcock from comment #8)
> Created attachment 449658 [details]
> Patch

--- a/Source/WebCore/accessibility/AccessibilityObject.cpp
+++ a/Source/WebCore/accessibility/AccessibilityObject.cpp

+String AccessibilityObject::subrolePlatformString() const
+{
+    return String();
+}
+
I think we do these hallowed implementations as inlines in the header.

--- a/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm
+++ a/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm

+    setProperty(AXPropertyName::SubrolePlatformString, object.subrolePlatformString().isolatedCopy());

We can do this in the cross-platform initializeData since it is the same for all platforms.

--- a/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm
+++ a/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm

+String AccessibilityObject::subrolePlatformString() const
+{

This can not be implemented twice in AccessibilityObject.cpp and Mac.mm.

--- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
+++ a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

+    if (subrole != String())
+        return subrole;

Change to if (!subrole.isEmpty())
Comment 11 Tyler Wilcock 2022-01-21 12:25:20 PST
Created attachment 449684 [details]
Patch
Comment 12 Tyler Wilcock 2022-01-21 12:30:18 PST
> +String AccessibilityObject::subrolePlatformString() const
> +{
> +    return String();
> +}
> +
> I think we do these hallowed implementations as inlines in the header.
> --- a/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm
> +++ a/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm
> 
> +String AccessibilityObject::subrolePlatformString() const
> +{
> 
> This can not be implemented twice in AccessibilityObject.cpp and Mac.mm.
The patch diff doesn't show enough context for you to have seen this, but it's not implemented twice. I added the hollow implementation of subrolePlatformString to the .cpp source file to match how we do it for roles, as that is already wrapped in an #if !PLATFORM(MAC) guard:

#if !PLATFORM(MAC)
String AccessibilityObject::rolePlatformString() const
{
    return Accessibility::roleToPlatformString(roleValue());
}

String AccessibilityObject::rolePlatformDescription() const
{
    // FIXME: implement in other platforms.
    return String();
}

String AccessibilityObject::subrolePlatformString() const
{
    return String();
}
#endif

Then we provide the real implementation in AccessibilityObjectMac.mm.

I can still change it if you'd like, though.

Fixed your other two comments, thanks!
Comment 13 Tyler Wilcock 2022-01-21 12:31:35 PST
Created attachment 449686 [details]
Patch
Comment 14 EWS 2022-01-21 17:25:01 PST
Committed r288390 (246287@main): <https://commits.webkit.org/246287@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 449686 [details].