Bug 272852

Summary: AX: Whitespace-only aria-labels should not be respected in accname calculation
Product: WebKit Reporter: Tyler Wilcock <tyler_w>
Component: AccessibilityAssignee: Tyler Wilcock <tyler_w>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cdumez, cfleizach, cmarcelo, dmazzoni, esprehn+autocc, ews-watchlist, jcraig, kangil.han, samuel_white, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Tyler Wilcock 2024-04-17 14:11:07 PDT
https://w3c.github.io/accname/#comp_label

> AriaLabel: Otherwise, if the current node has an aria-label attribute whose value is not undefined, not the empty string, nor, when trimmed of whitespace, is not the empty string:
>  1. If traversal of the current node is due to recursion and the current node is an embedded control, ignore aria-label and skip to rule Embedded Control.
>  2. Otherwise, return the value of aria-label.
Comment 1 Radar WebKit Bug Importer 2024-04-17 14:11:18 PDT
<rdar://problem/126643869>
Comment 2 Tyler Wilcock 2024-04-17 14:26:28 PDT
Created attachment 470970 [details]
Patch
Comment 3 chris fleizach 2024-04-17 23:47:13 PDT
Comment on attachment 470970 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityObject.h:544
> +    bool hasValidAriaLabel() const { return !getAttributeTrimmed(HTMLNames::aria_labelAttr).isEmpty(); }

Feel like we usually say "hasValidARIALabel". 
are we doing Aria in other places? I'm not a fan of that because ARIA is an acronym, not a name

> Source/WebCore/accessibility/AccessibilitySlider.cpp:-110
> -    if (auto* input = inputElement())

we handle this inputElement() thing in the single get attribute method?
Comment 4 Tyler Wilcock 2024-04-18 08:05:46 PDT
Created attachment 470986 [details]
Patch
Comment 5 Tyler Wilcock 2024-04-18 08:18:35 PDT
(In reply to chris fleizach from comment #3)
> Comment on attachment 470970 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=470970&action=review
> 
> > Source/WebCore/accessibility/AccessibilityObject.h:544
> > +    bool hasValidAriaLabel() const { return !getAttributeTrimmed(HTMLNames::aria_labelAttr).isEmpty(); }
> 
> Feel like we usually say "hasValidARIALabel". 
> are we doing Aria in other places? I'm not a fan of that because ARIA is an
> acronym, not a name
We do use "Aria" in other places, e.g. determineAriaRoleAttribute, isPresentationalChildOfAriaRole, handleAriaExpandedChange, isNodeAriaVisible, remapAriaRoleDueToParent, and more.

But I think your point makes sense. I've switched it to hasValidARIALabel (but happy to change it back, I don't feel strongly either way).

> > Source/WebCore/accessibility/AccessibilitySlider.cpp:-110
> > -    if (auto* input = inputElement())
> 
> we handle this inputElement() thing in the single get attribute method?
Yeah, AccessibilitySlider was the only one who overrode getAttribute, and it did so needlessly. The default AccessibilityObject implementation has the same behavior — cast the underlying m_node to an element and get the attribute off of it. This function is called a lot, so de-virtualizing it is nice.
Comment 6 Tyler Wilcock 2024-04-18 15:58:17 PDT
Created attachment 470994 [details]
Patch
Comment 7 Tyler Wilcock 2024-04-19 19:05:00 PDT
Created attachment 471019 [details]
Patch
Comment 8 EWS 2024-04-20 08:10:02 PDT
Committed 277781@main (04d118a7c6f4): <https://commits.webkit.org/277781@main>

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