Bug 239848

Summary: Code cleanup in preparation for refactoring of computing relationships between AXObjects.
Product: WebKit Reporter: Andres Gonzalez <andresg_22>
Component: AccessibilityAssignee: Andres Gonzalez <andresg_22>
Status: RESOLVED FIXED    
Severity: Normal CC: aboxhall, andresg_22, apinheiro, cfleizach, dmazzoni, ews-watchlist, jcraig, jdiggs, samuel_white, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch none

Description Andres Gonzalez 2022-04-28 05:58:27 PDT
Code cleanup in preparation for refactoring of computing relationships between AXObjects.
Comment 1 Radar WebKit Bug Importer 2022-04-28 05:58:35 PDT
<rdar://problem/92455544>
Comment 2 Andres Gonzalez 2022-04-28 06:13:03 PDT
Created attachment 458523 [details]
Patch
Comment 3 Tyler Wilcock 2022-04-28 12:47:17 PDT
Comment on attachment 458523 [details]
Patch

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

Seems like a really nice improvement!

> Source/WebCore/accessibility/AccessibilityObject.cpp:4018
> +    if (!labelFor.size())

Could this be labelFor.isEmpty()?
Comment 4 chris fleizach 2022-04-28 13:23:02 PDT
Comment on attachment 458523 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityObject.cpp:3953
> +AXCoreObject::AccessibilityChildrenVector AccessibilityObject::activeDescendantOf() const

this feels like it should be plural
activeDescendantsOf

> Source/WebCore/accessibility/AccessibilityObject.h:307
> +    AccessibilityChildrenVector descriptionFor() const override;

I don't feel like these methods indicate they're returning elements. descriptionFor() sounds like it could be a string returning function

can we call it something like "descriptionElementsFor()" or "errorMessageElementsFor()"
Comment 5 Andres Gonzalez 2022-04-29 13:18:22 PDT
Created attachment 458604 [details]
Patch
Comment 6 Andres Gonzalez 2022-04-29 13:20:32 PDT
(In reply to Tyler Wilcock from comment #3)
> Comment on attachment 458523 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=458523&action=review
> 
> Seems like a really nice improvement!
> 
> > Source/WebCore/accessibility/AccessibilityObject.cpp:4018
> > +    if (!labelFor.size())
> 
> Could this be labelFor.isEmpty()?

Yes, using isEmpty() in more places where it makes the code more legible.
Comment 7 Andres Gonzalez 2022-04-29 13:27:18 PDT
(In reply to chris fleizach from comment #4)
> Comment on attachment 458523 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=458523&action=review
> 
> > Source/WebCore/accessibility/AccessibilityObject.cpp:3953
> > +AXCoreObject::AccessibilityChildrenVector AccessibilityObject::activeDescendantOf() const
> 
> this feels like it should be plural
> activeDescendantsOf

Renamed to activeDescendantOfObjects. ActiveDescendant is singular because it refers to this object, and the method returns the objects that "contain" this as their active descendant. Hopefully the naming now is a bit more clear. Let me know.

> 
> > Source/WebCore/accessibility/AccessibilityObject.h:307
> > +    AccessibilityChildrenVector descriptionFor() const override;
> 
> I don't feel like these methods indicate they're returning elements.
> descriptionFor() sounds like it could be a string returning function
> 
> can we call it something like "descriptionElementsFor()" or
> "errorMessageElementsFor()"

Chose Objects as part of the name to avoid confusion with DOM Elements. Notice the symmetric methods for a given relationship. For instance, we have labelledByObjects and labelForObjects. Hopefully this is a bit more clear now. Let me know. Thanks.
Comment 8 Andres Gonzalez 2022-04-29 13:59:44 PDT
Created attachment 458607 [details]
Patch

Fix for iOS build.
Comment 9 Tyler Wilcock 2022-04-29 14:31:30 PDT
Comment on attachment 458607 [details]
Patch

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

> Source/WebCore/accessibility/AccessibilityRenderObject.cpp:1084
> +    linkedUIElements = flowToObjects();

Will this overwrite existing elements in `linkedUIElements`? If so, should we concat these vectors instead?

> Source/WebCore/accessibility/AccessibilityTableRow.cpp:154
> +    if (ownedObjects.size()) {

Would this be better as !ownedObjects.isEmpty()?
Comment 10 Andres Gonzalez 2022-04-29 16:46:23 PDT
Created attachment 458618 [details]
Patch
Comment 11 Andres Gonzalez 2022-04-29 16:52:40 PDT
(In reply to Tyler Wilcock from comment #9)
> Comment on attachment 458607 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=458607&action=review
> 
> > Source/WebCore/accessibility/AccessibilityRenderObject.cpp:1084
> > +    linkedUIElements = flowToObjects();
> 
> Will this overwrite existing elements in `linkedUIElements`? If so, should
> we concat these vectors instead?

It is never used to concat linked objects. So while at it, also removed the out parameter and renamed to linkedObjects() like all the other relations methods.

> 
> > Source/WebCore/accessibility/AccessibilityTableRow.cpp:154
> > +    if (ownedObjects.size()) {
> 
> Would this be better as !ownedObjects.isEmpty()?

In this case I think either one is fine, but I opted for the shortest with no negation.
Comment 12 Andres Gonzalez 2022-04-30 13:37:11 PDT
Created attachment 458639 [details]
Patch
Comment 13 EWS 2022-04-30 19:44:09 PDT
Committed r293650 (250154@main): <https://commits.webkit.org/250154@main>

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