[webkit-changes] [WebKit/WebKit] bf0f2d: AX: display: contents is preventing items from bei...

Tyler Wilcock noreply at github.com
Thu Aug 15 08:11:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: bf0f2dcbbb3a4a8187a0428c38ff7362f3a0c6a7
      https://github.com/WebKit/WebKit/commit/bf0f2dcbbb3a4a8187a0428c38ff7362f3a0c6a7
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2024-08-15 (Thu, 15 Aug 2024)

  Changed paths:
    A LayoutTests/accessibility/display-contents/listbox-item-expected.txt
    A LayoutTests/accessibility/display-contents/listbox-item.html
    A LayoutTests/platform/glib/accessibility/display-contents/listbox-item-expected.txt
    M LayoutTests/platform/ios/TestExpectations
    A LayoutTests/platform/ios/accessibility/display-contents/listbox-item-expected.txt
    M Source/WebCore/accessibility/AccessibilityNodeObject.cpp

  Log Message:
  -----------
  AX: display: contents is preventing items from being read
https://bugs.webkit.org/show_bug.cgi?id=276899
rdar://132265522

Reviewed by Chris Fleizach.

This happened due to a hack in AccessibilityNodeObject::textUnderElement that tried to avoid grabbing the same text
twice due to the effects of `display:contents` on the way we walk between the DOM and render tree. This hack, which
tries to verify that the child being checked has the "right" parent element, has caused several bugs since its
introduction, and has thus accrued more and more conditions limiting it.

This bug is also a result of this hack, incorrectly exiting early before retrieving the text under element. Consider
this markup:

<div id="a">
    <div style="display:contents">
        <div id="b">Foo</div>
    </div>
</div>

When getting the textUnderElement for #a, which is display:block, thus has a renderer, it's render tree child is div #b
(because the the `display:contents` div is not in the render tree). And div #b knows its parent element is the `display:contents`
div, not #a, so the hack exits early, resulting in the text never being retrieved.

The fix is simple: remove this hack entirely. The problem it solves is correctly handled by the introduction of the
AXChildIterator in https://bugs.webkit.org/show_bug.cgi?id=272606, which knows how to correctly weave between the DOM
and render tree without straying outside the "correct" bounds.

Testcase accessibility/display-contents/listbox-item.html added ensuring we don't regress this.

* LayoutTests/accessibility/display-contents/listbox-item-expected.txt: Added.
* LayoutTests/accessibility/display-contents/listbox-item.html: Added.
* LayoutTests/platform/glib/accessibility/display-contents/listbox-item-expected.txt: Added.
* LayoutTests/platform/ios/TestExpectations: Enable new test.
* LayoutTests/platform/ios/accessibility/display-contents/listbox-item-expected.txt: Added.
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::textUnderElement const):

Canonical link: https://commits.webkit.org/282289@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list