-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick ecb40fd. rdar://118118138
AX: VoiceOver does not announce button in text if button is in shadow root https://bugs.webkit.org/show_bug.cgi?id=264410 rdar://118118138 Reviewed by Tyler Wilcock. In shadow DOM elements, if text was within nested elements, textUnderElement would not include it. This patch resolves that by adding to our logic for when we decide whether or not to skip a child's text. Instead of just checking whether the child's parent and the current node match, we also check that the elements are either both in the DOM or Shadow DOM. * LayoutTests/accessibility/custom-elements/shadow-element-text-expected.txt: Added. * LayoutTests/accessibility/custom-elements/shadow-element-text.html: Added. * LayoutTests/platform/glib/accessibility/custom-elements/shadow-element-text-expected.txt: Added. * Source/WebCore/accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::textUnderElement const): Canonical link: https://commits.webkit.org/270542@main Canonical link: https://commits.webkit.org/267815.558@safari-7617-branch
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
LayoutTests/accessibility/custom-elements/shadow-element-text-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
This test ensures that shadow dom elements return the right text. | ||
|
||
Button1 text: AXTitle: Button One | ||
AXDescription: | ||
AXHelp: | ||
Button2 text: AXTitle: Nested Button Two | ||
AXDescription: | ||
AXHelp: | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Button One | ||
Nested Button Two | ||
|
34 changes: 34 additions & 0 deletions
34
LayoutTests/accessibility/custom-elements/shadow-element-text.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
|
||
<my-button id="button1">Button One</my-button> | ||
<my-button id="button2"><div>Nested Button Two</div></my-button> | ||
|
||
<script> | ||
class MyButton extends HTMLElement { | ||
constructor() { | ||
super(); | ||
const root = this.attachShadow({ mode: 'open' }); | ||
root.innerHTML = `<button id=${this.id}><slot></slot></button>`; | ||
} | ||
} | ||
customElements.define('my-button', MyButton); | ||
|
||
let output = "This test ensures that shadow dom elements return the right text.\n\n"; | ||
|
||
if (window.accessibilityController) { | ||
var button1 = accessibilityController.accessibleElementById("button1"); | ||
output += `Button1 text: ${platformTextAlternatives(button1)}\n`; | ||
|
||
var button2 = accessibilityController.accessibleElementById("button2"); | ||
output += `Button2 text: ${platformTextAlternatives(button2)}\n`; | ||
debug(output); | ||
} | ||
</script> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
LayoutTests/platform/glib/accessibility/custom-elements/shadow-element-text-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This test ensures that shadow dom elements return the right text. | ||
|
||
Button1 text: AXTitle: Button One | ||
AXDescription: | ||
Button2 text: AXTitle: Nested Button Two | ||
AXDescription: | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
Button One | ||
Nested Button Two | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters