Bug 238184 - AccessibilityRenderObject::nextSibling should allow parent differences in the presence of display: contents
Summary: AccessibilityRenderObject::nextSibling should allow parent differences in the...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-03-21 21:15 PDT by Tyler Wilcock
Modified: 2022-03-23 10:01 PDT (History)
10 users (show)

See Also:


Attachments
Patch (14.13 KB, patch)
2022-03-21 21:23 PDT, Tyler Wilcock
no flags 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-03-21 21:15:56 PDT
AccessibilityRenderObject::nextSibling currently has this logic to return nullptr if the computed sibling has a parent different from `this`:

    // Make sure next sibling has the same parent.
    auto* nextObject = objectCache->getOrCreate(nextSibling);
    if (nextObject && nextObject->parentObject() != this->parentObject())
        return nullptr;

This is problematic in the presence of display: contents since we expect parent object differences due to the way this property affects the render tree.

Concretely, this breaks the firstChild(), nextSibling() iteration we do throughout WebKit, as when we get to an element with display: contents we get a parent mismatch and iteration stops unnecessarily.
Comment 1 Radar WebKit Bug Importer 2022-03-21 21:16:05 PDT
<rdar://problem/90611872>
Comment 2 Tyler Wilcock 2022-03-21 21:23:30 PDT
Created attachment 455328 [details]
Patch
Comment 3 Andres Gonzalez 2022-03-22 05:37:42 PDT
(In reply to Tyler Wilcock from comment #2)
> Created attachment 455328 [details]
> Patch

We need to maintain a consistent parent-child hierarchy in the AX tree. That includes that an object and its siblings have the same parent. display: contents should affect the way AX Objects are added to the AX tree, but not mess up the parent-child relationship. 

Instead, we may need to add a new kind of AX object for display: contents that encapsulates the appropriate parent-child relationships for these objects.
Comment 4 EWS 2022-03-23 10:01:48 PDT
Committed r291747 (248779@main): <https://commits.webkit.org/248779@main>

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