Bug 236273 - AX: When updating the isolated tree with a remove and add of the same object, the wrapper is not re-attached
Summary: AX: When updating the isolated tree with a remove and add of the same object,...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-07 16:53 PST by Tyler Wilcock
Modified: 2022-02-08 08:09 PST (History)
10 users (show)

See Also:


Attachments
Patch (3.53 KB, patch)
2022-02-07 17:00 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (4.15 KB, patch)
2022-02-07 20:53 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (4.17 KB, patch)
2022-02-07 21:10 PST, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2022-02-07 16:53:22 PST
In AXIsolatedTree::applyPendingChanges, we process node and subtree removals before tree additions. When doing these removals, we detach the object and wrapper from each other. This is fine unless that same object is slated to be added again (e.g. it was moved in the DOM), as we don't always re-attach a wrapper. [WebAccessibilityObjectWrapperBase axBackingObject] will always return nil for objects in this state.
Comment 1 Radar WebKit Bug Importer 2022-02-07 16:53:36 PST
<rdar://problem/88601894>
Comment 2 Tyler Wilcock 2022-02-07 17:00:41 PST
Created attachment 451175 [details]
Patch
Comment 3 Andres Gonzalez 2022-02-07 18:20:25 PST
(In reply to Tyler Wilcock from comment #2)
> Created attachment 451175 [details]
> Patch

-        if (!item.isolatedObject->wrapper()) {
-            // The new object hasn't been attached a wrapper yet, so attach it.
+        // If the new object hasn't been attached to a wrapper yet, or if it was detached from
+        // the wrapper when processing removals above, we must attach / re-attach it.
+        if (!item.isolatedObject->wrapper() || detachedObjectIDs.contains(axID))
             item.isolatedObject->attachPlatformWrapper(wrapper.get());

Good catch! I think though that it would be a better solution to check for whether the wrapper has an isolatedObject, and if not, attach the isolated object to the wrapper, instead of creating this new collection and looking up the AXID.
Comment 4 Tyler Wilcock 2022-02-07 20:53:40 PST
Created attachment 451204 [details]
Patch
Comment 5 Tyler Wilcock 2022-02-07 21:10:54 PST
Created attachment 451206 [details]
Patch
Comment 6 EWS 2022-02-08 05:26:30 PST
Committed r289368 (246956@main): <https://commits.webkit.org/246956@main>

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