-
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.
AX: NULL attributed string returned for text markers that contain unc…
…onnected nodes https://bugs.webkit.org/show_bug.cgi?id=270499 rdar://122451549 Reviewed by Tyler Wilcock. If a node is unconnected and we queue up a node change for it, nothing will happen, since shouldCreateNodeChange will return false. This means that if we request a text marker range that points to a stale, unconnected node, we may get a null attributed string since the range being requested is invalid. This change adds a new condition to shouldCreateNodeChange for unconnected nodes, and adds a new test to verify this behavior. * LayoutTests/accessibility/mac/selected-text-range-unconnected-object.html: Added. * LayoutTests/platform/mac/accessibility/mac/selected-text-range-unconnected-object-expected.txt: Added. * Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp: (WebCore::AXIsolatedTree::shouldCreateNodeChange): (WebCore::AXIsolatedTree::addUnconnectedNode): (WebCore::AXIsolatedTree::removeSubtreeFromNodeMap): (WebCore::shouldCreateNodeChange): Deleted. * Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h: Canonical link: https://commits.webkit.org/275694@main
- Loading branch information
1 parent
c0414c4
commit a8f281f
Showing
4 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
LayoutTests/accessibility/mac/selected-text-range-unconnected-object.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,61 @@ | ||
<html> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
<body> | ||
|
||
<input type="text" id="input" value="Hello" style="font-family: sans-serif"> | ||
|
||
<script> | ||
var output = "This tests that the selected text marker range is valid when it references an unconnected node that changes.\n\n" | ||
|
||
function textMarkerRangeString(textMarkerRange, root) { | ||
const startMarker = root.startTextMarkerForTextMarkerRange(textMarkerRange); | ||
const endMarker = root.endTextMarkerForTextMarkerRange(textMarkerRange); | ||
|
||
const startElement = root.accessibilityElementForTextMarker(startMarker); | ||
const endElement = root.accessibilityElementForTextMarker(endMarker); | ||
|
||
return `Text Marker: [Length: ${root.textMarkerRangeLength(textMarkerRange)}]\n\tSTART: ${startElement ? startElement.role : "NULL"}\n\tEND: ${endElement ? endElement.role : "NULL"}\n\n`; | ||
} | ||
|
||
if (window.accessibilityController && window.textInputController) { | ||
window.jsTestIsAsync = true; | ||
let input = document.getElementById("input"); | ||
input.focus(); | ||
|
||
let root = accessibilityController.rootElement.childAtIndex(0); | ||
|
||
var selectedTextMarkerRange; | ||
let textInput = accessibilityController.focusedElement; | ||
setTimeout(async function() { | ||
input.select(); | ||
await waitFor(() => { | ||
selectedTextMarkerRange = textInput.selectedTextMarkerRange(); | ||
return root.textMarkerRangeLength(selectedTextMarkerRange) == 5; | ||
|
||
}); | ||
output += textMarkerRangeString(selectedTextMarkerRange, root); | ||
output += `Text Marker Range Attributed Text: ${textInput.attributedStringForTextMarkerRange(selectedTextMarkerRange)}\n\n`; | ||
|
||
input.focus(); | ||
output += "Inserting 'world'\n"; | ||
|
||
// Move insertion point to end of input to append text without creating a new static text object. | ||
input.setSelectionRange(5, 5); | ||
textInput.insertText(' world'); | ||
|
||
input.select(); | ||
await waitFor(() => { | ||
selectedTextMarkerRange = textInput.selectedTextMarkerRange(); | ||
return root.textMarkerRangeLength(selectedTextMarkerRange) == 11; | ||
}); | ||
output += textMarkerRangeString(selectedTextMarkerRange, root); | ||
output += `Text Marker Range Attributed Text: ${textInput.attributedStringForTextMarkerRange(selectedTextMarkerRange)}\n\n`; | ||
|
||
debug(output); | ||
finishJSTest(); | ||
}, 0); | ||
} | ||
</script> | ||
</body> | ||
</html> |
28 changes: 28 additions & 0 deletions
28
...tTests/platform/mac/accessibility/mac/selected-text-range-unconnected-object-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,28 @@ | ||
This tests that the selected text marker range is valid when it references an unconnected node that changes. | ||
|
||
Text Marker: [Length: 5] | ||
START: AXRole: AXStaticText | ||
END: AXRole: AXStaticText | ||
|
||
Text Marker Range Attributed Text: AXFont - { | ||
AXFontFamily = Helvetica; | ||
AXFontName = Helvetica; | ||
AXFontSize = 11; | ||
}, Hello | ||
|
||
Inserting 'world' | ||
Text Marker: [Length: 11] | ||
START: AXRole: AXStaticText | ||
END: AXRole: AXStaticText | ||
|
||
Text Marker Range Attributed Text: AXFont - { | ||
AXFontFamily = Helvetica; | ||
AXFontName = Helvetica; | ||
AXFontSize = 11; | ||
}, Hello world | ||
|
||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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
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