AX: Move node-dependent role computation to AccessibilityNodeObject from Accessibilit...
commit61fa281b35e2454d3495a0a22a57c23b95d010e2
authortyler_w@apple.com <tyler_w@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2022 00:22:19 +0000 (8 00:22 +0000)
committertyler_w@apple.com <tyler_w@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 Feb 2022 00:22:19 +0000 (8 00:22 +0000)
treed012177686bc6d15932b1bce3ab7bbb7280afbfc
parentff26d706c82b426c33d20644d92173f9ec8747b3
AX: Move node-dependent role computation to AccessibilityNodeObject from AccessibilityRenderObject
https://bugs.webkit.org/show_bug.cgi?id=236166

Reviewed by Chris Fleizach.

Source/WebCore:

AccessibilityRenderObject::determineAccessibilityRole has a lot of
logic for computing the object's role that depends only on the node
associated with the object, not the renderer. This means that objects
that typically have renderers but sometimes don't (e.g. objects with
`hidden` + `aria-hidden="false"`, objects with `display: contents`)
can't have these roles, which is wrong.

This patch improves this by moving these node-dependent role
calcuations to a new determineAccessibilityRoleFromNode function, and
changing AccessibilityRenderObject to use that.

Test: accessibility/aria-visible-element-roles.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::determineAccessibilityRole):
(WebCore::AccessibilityNodeObject::determineAccessibilityRoleFromNode const):
Added.
(WebCore::AccessibilityNodeObject::isDescendantOfElementType const):
(WebCore::AccessibilityNodeObject::isFileUploadButton const):
Moved to AccessibilityObject.
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isButton const):
Remove unnecessary whitespace.
(WebCore::AccessibilityObject::isFileUploadButton const):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
If properties of m_renderer don't yield a role, fallback to
determineAccessibilityRoleFromNode.
(WebCore::AccessibilityRenderObject::isDescendantOfElementType const):
Moved to AccessibilityNodeObject.
* accessibility/AccessibilityRenderObject.h:

LayoutTests:

Add test to verify ARIA visible objects (e.g. those with `hidden` and
`aria-hidden="false"`) compute their role and subrole properly based
on their DOM element.

* accessibility/aria-visible-element-roles.html: Added.
* platform/glib/accessibility/aria-visible-element-roles-expected.txt: Added.
* platform/mac-wk1/accessibility/aria-visible-element-roles-expected.txt: Added.
* platform/mac-wk2/accessibility/aria-visible-element-roles-expected.txt: Added.
* platform/win/accessibility/aria-visible-element-roles-expected.txt: Added.

* platform/mac-wk2/accessibility/roles-exposed-expected.txt:
This patch results in a progression in computing the role of these
inputs, which before were all consided to be AXGroup:
  - input[type='date']
  - input[type='datetime-local']
  - input[type='month']
  - input[type='time']
  - input[type='week']

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@289248 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/aria-visible-element-roles.html [new file with mode: 0644]
LayoutTests/platform/glib/accessibility/aria-visible-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk1/accessibility/aria-visible-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/accessibility/aria-visible-element-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-wk2/accessibility/roles-exposed-expected.txt
LayoutTests/platform/win/accessibility/aria-visible-element-roles-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityNodeObject.h
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.h