Bug 260174 - AX: Fix multiple-label-input test in ITM mode
Summary: AX: Fix multiple-label-input test in ITM mode
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-08-14 14:18 PDT by Joshua Hoffman
Modified: 2023-08-15 11:00 PDT (History)
11 users (show)

See Also:


Attachments
Patch (5.59 KB, patch)
2023-08-14 14:55 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff
Patch (6.45 KB, patch)
2023-08-14 20:33 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Hoffman 2023-08-14 14:18:00 PDT
The accessibility/multiple-label-input test times out in isolated tree mode when using innerText.
Comment 1 Radar WebKit Bug Importer 2023-08-14 14:18:11 PDT
<rdar://problem/113872525>
Comment 2 Joshua Hoffman 2023-08-14 14:55:48 PDT
Created attachment 467272 [details]
Patch
Comment 3 Tyler Wilcock 2023-08-14 16:38:53 PDT
Comment on attachment 467272 [details]
Patch

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

> Source/WebCore/accessibility/AXObjectCache.cpp:4091
> +            if (auto* axParent = notification.first->parentObject()) {
> +                if (axParent->isLabel() && axParent->correspondingControlForLabelElement())
> +                    updateNode(axParent->correspondingControlForLabelElement());

Let's use a RefPtr to protect usage of `axParent`, since we call axParent->correspondingControlForLabelElement() which does non-trivial work that could potentially destroy it. We can also use C++17-style multi-condition if-statements to make this more concise:

if (RefPtr axParent = notification.first->parentObject(); axParent && axParent->isLabel()) {
    if (RefPtr correspondingControl = axParent->correspondingControlForLabelElement())
        updateNode(axParent->correspondingControl.get());
}
break;

> Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:615
> +    if (axObject.isLabel() && axObject.correspondingControlForLabelElement())
> +        updateNode(*axObject.correspondingControlForLabelElement());

correspondingControlForLabelElement does a bit of work, so let's only call it once. Something like this might work:

if (RefPtr correspondingControl = axObject.isLabel() ? axObject.correspondingControlForLabelElement() : nullptr)
    updateNode(*correspondingControl);
Comment 4 Joshua Hoffman 2023-08-14 20:33:35 PDT
Created attachment 467276 [details]
Patch
Comment 5 Andres Gonzalez 2023-08-15 08:18:18 PDT
(In reply to Joshua Hoffman from comment #4)
> Created attachment 467276 [details]
> Patch

--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ b/Source/WebCore/accessibility/AXObjectCache.cpp

+        case AXTextChanged:
+            updateNode(notification.first);
+            if (RefPtr axParent = notification.first->parentObject(); axParent && axParent->isLabel()) {
+                if (RefPtr correspondingControl = axParent->correspondingControlForLabelElement())
+                    updateNode(correspondingControl.get());
+            }
+            break;

The update of the related nodes and properties should happen in AXIsolatedTree::updateNode. So I would leave this as before and move this additional logic to AXIsolatedTree.

--- a/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
+++ b/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp

+    if (RefPtr correspondingControl = axObject.isLabel() ? axObject.correspondingControlForLabelElement() : nullptr)
+        updateNode(*correspondingControl);

I see that you are already doing part of it in in here, so do the whole thing here.
Comment 6 Joshua Hoffman 2023-08-15 10:36:24 PDT
(In reply to Andres Gonzalez from comment #5)
> (In reply to Joshua Hoffman from comment #4)
> > Created attachment 467276 [details]
> > Patch
> 
> 
> The update of the related nodes and properties should happen in
> AXIsolatedTree::updateNode. So I would leave this as before and move this
> additional logic to AXIsolatedTree.

We want to do this update when AXTextChanged, but AXIsolatedTree::updateNode doesn't know which notification was sent—so this allows us to conditionally do the update.
Comment 7 EWS 2023-08-15 11:00:30 PDT
Committed 266919@main (28bfc960f4a1): <https://commits.webkit.org/266919@main>

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