[webkit-changes] [WebKit/WebKit] 6d76fb: AX: No accessibility label is exposed for display:...

Tyler Wilcock noreply at github.com
Sun Sep 10 00:14:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6d76fb13fc78d7d48176ad6cb3f3ecd08c8a24b0
      https://github.com/WebKit/WebKit/commit/6d76fb13fc78d7d48176ad6cb3f3ecd08c8a24b0
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2023-09-10 (Sun, 10 Sep 2023)

  Changed paths:
    M LayoutTests/accessibility/display-contents/tree-and-treeitems-expected.txt
    M LayoutTests/accessibility/display-contents/tree-and-treeitems.html
    M Source/WebCore/accessibility/AXLogger.cpp
    M Source/WebCore/accessibility/AccessibilityNodeObject.cpp
    M Source/WebCore/accessibility/AccessibilityObjectInterface.h

  Log Message:
  -----------
  AX: No accessibility label is exposed for display:contents role="treeitem" elements that have a newline before their child text
https://bugs.webkit.org/show_bug.cgi?id=261376
rdar://problem/115226509

Reviewed by Chris Fleizach.

This patch fixes two bugs:

  1. No accessibility label is exposed for display:contents role="treeitem" elements that have a newline before their child text

  2. Some display:contents role="treeitem" expose text for other
     elements, resulting in that text being doubly-exposed

The first was caused by a lack of resilience in AccessibilityNodeObject::firstChild.
AccessibilityNodeObject::textUnderElement relies on iterating through its accessible children like so:

for (RefPtr child = firstChild(); child; child = child->nextSibling()) {
   ... compute AX text ...
}

However, for elements that AXObjectCache::getOrCreate fails to create an
object for, we would never iterate because firstChild returned nullptr,
thus resulting in no AX text being gathered. AccessibilityNodeObject::firstChild
now detects this, and iterates until it finds the first accessible child.

The second bug was caused by AccessibilityNodeObject::textUnderElement
recursively calling and textUnderElement for an element that was not
it's child. With this patch, we detect this and continue the loop when
it happens.

New testcases added to accessibility/display-contents/tree-and-treeitems.html.

* LayoutTests/accessibility/display-contents/tree-and-treeitems-expected.txt:
* LayoutTests/accessibility/display-contents/tree-and-treeitems.html:
* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::operator<<):
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::firstChild const):
(WebCore::AccessibilityNodeObject::textUnderElement const):
* Source/WebCore/accessibility/AccessibilityObjectInterface.h:

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




More information about the webkit-changes mailing list