-
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: Move AXSelectedTextMarkerRange off of the main thread
https://bugs.webkit.org/show_bug.cgi?id=262433 rdar://116128660 Reviewed by Chris Fleizach. This patch moves the AXSelectedTextMarkerRange attribute off of the main thread in isolated tree mode, by caching the relevant text marker data. When selection changes on the web, the AXObjectCache is notified through a call to postTextStateChangeNotification from FrameSelection::notifyAccessibilityForSelectionChange. From there, a new method, onSelectedTextChanged, handles updating the isolated tree's m_selectedTextMarkerRange with the relevant text markers for the start and end of the selection. These are stored in a pair of TextMarkerData structs. An important piece of this is that we need the nodes of the start and end text markers to exist in the isolated tree. So, if one or both of these nodes are ignored, they are added to the isolated tree as unconnected nodes. This is handled in onSelectedTextChanged. Finally, when the range is requested via AXIsolatedObject::selectedTextMarkerRange(), an AXTextMarkerRange is constructed from the cached TextMarkerData pair. This patch also modifies previous tests to make them asynchronous for this new behavior. * LayoutTests/accessibility/mac/doctype-node-in-text-marker-crash-expected.txt: * LayoutTests/accessibility/mac/doctype-node-in-text-marker-crash.html: * LayoutTests/accessibility/mac/replace-text-with-range-expected.txt: * LayoutTests/accessibility/mac/replace-text-with-range-value-change-notification.html: * LayoutTests/accessibility/mac/replace-text-with-range.html: * LayoutTests/accessibility/mac/text-marker-p-tags-expected.txt: * LayoutTests/accessibility/mac/text-marker-p-tags.html: * Source/WebCore/accessibility/AXCoreObject.h: * Source/WebCore/accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::postTextStateChangeNotification): * Source/WebCore/accessibility/AXObjectCache.h: * Source/WebCore/accessibility/AccessibilityObject.cpp: (WebCore::AccessibilityObject::selectedTextMarkerRange): * Source/WebCore/accessibility/AccessibilityObject.h: (WebCore::AccessibilityObject::selectedVisiblePositionRange const): * Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp: (WebCore::AXIsolatedObject::selectedTextMarkerRange): (WebCore::AXIsolatedObject::selectedVisiblePositionRange const): Deleted. * Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h: * Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp: * Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h: (WebCore::AXIsolatedTree::selectedTextMarkerRange): (WebCore::AXIsolatedTree::setSelectedTextMarkerRange): * Source/WebCore/accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::onSelectedTextChanged): * Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper selectedTextMarkerRange]): Canonical link: https://commits.webkit.org/268821@main
- Loading branch information
1 parent
f399a5e
commit a1746d7
Showing
18 changed files
with
224 additions
and
140 deletions.
There are no files selected for viewing
9 changes: 2 additions & 7 deletions
9
LayoutTests/accessibility/mac/doctype-node-in-text-marker-crash-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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
text | ||
This tests that creating a text marker range with a text marker that associated to a doctype node won't lead to crash. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
This tests that creating a text marker range with a text marker that is associated to a doctype node won't lead to crash. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
||
text |
95 changes: 51 additions & 44 deletions
95
LayoutTests/accessibility/mac/doctype-node-in-text-marker-crash.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 |
---|---|---|
@@ -1,59 +1,66 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test-pre.js"></script> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body id="body"> | ||
|
||
<div id="container" role="group" contenteditablt="true">text<iframe id="frame" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" height="100%" width="100%" style="padding: 0px; margin: 0px; border: 0px; height: 100%; width: 100%;"></iframe></div> | ||
|
||
<p id="description"></p> | ||
<div id="console"></div> | ||
|
||
<script> | ||
var result = "This tests that creating a text marker range with a text marker that is associated to a doctype node won't lead to crash."; | ||
|
||
function selectElementContents(el) { | ||
var range = document.createRange(); | ||
range.selectNodeContents(el); | ||
var sel = window.getSelection(); | ||
sel.removeAllRanges(); | ||
sel.addRange(range); | ||
} | ||
|
||
if (window.accessibilityController) { | ||
window.jsTestIsAsync = true; | ||
|
||
accessibilityController.enableEnhancedAccessibility(true); | ||
var webArea = accessibilityController.rootElement.childAtIndex(0); | ||
webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true); | ||
|
||
// Make sure the iframe has a doctype node | ||
var iframe = document.getElementById("frame"); | ||
var idocument = iframe.contentDocument; | ||
idocument.open(); | ||
idocument.write("<!DOCTYPE html>"); | ||
idocument.write("<html>"); | ||
idocument.write("<head></head>"); | ||
idocument.write("<body></body>"); | ||
idocument.write("</html>"); | ||
idocument.close(); | ||
|
||
// Select all the contents in the container, and get the selection range. | ||
var container = accessibilityController.accessibleElementById("container"); | ||
var containerElement = document.getElementById("container"); | ||
selectElementContents(containerElement); | ||
|
||
setTimeout(async function() { | ||
selectionRange = null; | ||
var startMarker = null; | ||
var endMarker = null; | ||
await waitFor(() => { | ||
selectionRange = container.selectedTextMarkerRange(); | ||
startMarker = container.startTextMarkerForTextMarkerRange(selectionRange); | ||
endMarker = container.endTextMarkerForTextMarkerRange(selectionRange); | ||
return startMarker != null && endMarker != null; | ||
}) | ||
|
||
description("This tests that creating a text marker range with a text marker that associated to a doctype node won't lead to crash."); | ||
|
||
function selectElementContents(el) { | ||
var range = document.createRange(); | ||
range.selectNodeContents(el); | ||
var sel = window.getSelection(); | ||
sel.removeAllRanges(); | ||
sel.addRange(range); | ||
} | ||
|
||
if (window.accessibilityController) { | ||
|
||
accessibilityController.enableEnhancedAccessibility(true); | ||
var webArea = accessibilityController.rootElement.childAtIndex(0); | ||
webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true); | ||
|
||
// Make sure the iframe has a doctype node | ||
var iframe = document.getElementById("frame"); | ||
var idocument = iframe.contentDocument; | ||
idocument.open(); | ||
idocument.write("<!DOCTYPE html>"); | ||
idocument.write("<html>"); | ||
idocument.write("<head></head>"); | ||
idocument.write("<body></body>"); | ||
idocument.write("</html>"); | ||
idocument.close(); | ||
|
||
// Select all the contents in the container, and get the selection range. | ||
var container = accessibilityController.accessibleElementById("container"); | ||
var containerElement = document.getElementById("container"); | ||
selectElementContents(containerElement); | ||
var selectionRange = container.selectedTextMarkerRange(); | ||
|
||
var startMarker = container.startTextMarkerForTextMarkerRange(selectionRange); | ||
var endMarker = container.endTextMarkerForTextMarkerRange(selectionRange); | ||
|
||
// endMarker is now associated with a doctype node, make sure it won't lead to a crash. | ||
var markerRange = container.textMarkerRangeForMarkers(endMarker, startMarker); | ||
} | ||
// endMarker is now associated with a doctype node, make sure it won't lead to a crash. | ||
var markerRange = container.textMarkerRangeForMarkers(endMarker, startMarker); | ||
debug(result); | ||
finishJSTest(); | ||
}, 0); | ||
|
||
} | ||
</script> | ||
|
||
<script src="../../resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
18 changes: 8 additions & 10 deletions
18
LayoutTests/accessibility/mac/replace-text-with-range-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
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
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
Oops, something went wrong.