AX: Include display: contents elements in the AX tree
commit0b5434e9d4998b277338847ac941ba9eb99c27e7
authortyler_w@apple.com <tyler_w@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2022 18:48:25 +0000 (21 18:48 +0000)
committertyler_w@apple.com <tyler_w@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Mar 2022 18:48:25 +0000 (21 18:48 +0000)
tree4944ae208ce44bba38bbfc8096a1efed5525c5d8
parent0043349e4de33beb54860ae0f7d6aa12d87ca8ca
AX: Include display: contents elements in the AX tree
https://bugs.webkit.org/show_bug.cgi?id=237834

Reviewed by Chris Fleizach.

Source/WebCore:

Because display: contents intentionally prevents a render object from being
generated for the element it's applied to, we don't add it to the AX tree as
part of our normal render tree walk, making these elements inaccessible.

This patch includes these elements as part of the DOM walk that
addHiddenChildren (now renamed to addNodeOnlyChildren) already does.

Also, because display: contents moves the affected element's children up a
level in the render tree, this patch also special cases:

  1. AccessibilityRenderObject::parentObject and similar methods to
  return their display: contents parent instead of their render tree
  parent
  2. AccessibilityObject::insertChild to only insert display: contents
  children to their display: contents parent, rather than their render
  tree parent

Test: accessibility/display-contents-element-roles.html, accessibility/aria-hidden-display-contents-element.html

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::getOrCreate):
Allow creation of AX objects from display: contents `Node`s.
Also, don't create an object for a renderer that is in the process of
being destroyed (prevents display-contents-element-roles.html from crashing in ITM)
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::displayContentsParent const):
(WebCore::AccessibilityObject::insertChild):
If an object has a display: contents parent, and that parent isn't
`this`, return early.
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::parentObjectIfExists const):
(WebCore::AccessibilityRenderObject::parentObject const):
(WebCore::AccessibilityRenderObject::parentObjectUnignored const):
If an object has a display: contents parent, return that instead of
its render tree parent.
(WebCore::AccessibilityRenderObject::addNodeOnlyChildren):
Renamed from addHiddenChildren.
(WebCore::AccessibilityRenderObject::addChildren):
Don't clear m_subtreeDirty until after all children have been added.
Necessary to make aria-hidden-display-contents-element.html pass, as
we were clearing this too early, causing display: contents subtrees to
not be updated after aria-hidden changes.
(WebCore::AccessibilityRenderObject::addHiddenChildren):
Renamed to addNodeOnlyChildren.
* accessibility/AccessibilityRenderObject.h:

LayoutTests:

* accessibility/aria-hidden-display-contents-element-expected.txt: Added.
* accessibility/aria-hidden-display-contents-element.html: Added.
* accessibility/display-contents-element-roles-expected.txt: Added.
* accessibility/display-contents-element-roles.html: Added.
* platform/glib/accessibility/aria-hidden-display-contents-element-expected.txt: Added.
* platform/glib/accessibility/display-contents-element-roles-expected.txt: Added.
* platform/ios/TestExpectations: Enable new tests.
* platform/ios/accessibility/aria-hidden-display-contents-element-expected.txt: Added.
* platform/ios/accessibility/display-contents-element-roles-expected.txt: Added.
* platform/win/TestExpectations: Skip display-contents-element-roles.html.
* platform/win/accessibility/aria-hidden-display-contents-element-expected.txt: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@291570 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/aria-hidden-display-contents-element-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/aria-hidden-display-contents-element.html [new file with mode: 0644]
LayoutTests/accessibility/display-contents-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/display-contents-element-roles.html [new file with mode: 0644]
LayoutTests/platform/glib/accessibility/aria-hidden-display-contents-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/glib/accessibility/display-contents-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/ios/accessibility/aria-hidden-display-contents-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios/accessibility/display-contents-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/win/accessibility/aria-hidden-display-contents-element-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h