Title: [254782] trunk
- Revision
- 254782
- Author
- commit-qu...@webkit.org
- Date
- 2020-01-17 16:48:31 -0800 (Fri, 17 Jan 2020)
Log Message
AX: Unable to use AccessibilityObject::replaceTextInRange to insert text at first time when the text fields are empty
https://bugs.webkit.org/show_bug.cgi?id=206093
<rdar://problem/58491448>
Patch by Canhai Chen <canhai_c...@apple.com> on 2020-01-17
Reviewed by Chris Fleizach.
Source/WebCore:
When we are trying to insert text in an empty text field with (0, 0) range, the frame selection will create a
new VisibleSelection in FrameSelection::setSelectedRange, and the container node that this new VisibleSelection
returns is the parent node of the text field element, which could be a HTMLDivElement or HTMLBodyElement.
Because the container node is not editable, it failed to insert text in Editor::replaceSelectionWithText later.
Return nullptr if the range is (0, 0) and the text length is 0 in AccessibilityObject::rangeForPlainTextRange,
so that when the frame selection is trying to setSelectedRange before replacing text, instead of creating an
uneditable VisibleSelection, it will just return and later in Editor::replaceSelectionWithText, it will use
the default VisibleSelection, of which the container node is an editable TextControlInnerTextElement.
This change does not affect the existing behaviors of text replacement. Add a new test for text replacement
with empty range in editable div, text input, and textarea.
Test: accessibility/mac/replace-text-with-empty-range.html
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::rangeForPlainTextRange const):
LayoutTests:
Test text replacement with empty range in editable div, text input, and textarea.
* accessibility/mac/replace-text-with-empty-range-expected.txt: Added.
* accessibility/mac/replace-text-with-empty-range.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (254781 => 254782)
--- trunk/LayoutTests/ChangeLog 2020-01-18 00:43:00 UTC (rev 254781)
+++ trunk/LayoutTests/ChangeLog 2020-01-18 00:48:31 UTC (rev 254782)
@@ -1,3 +1,16 @@
+2020-01-17 Canhai Chen <canhai_c...@apple.com>
+
+ AX: Unable to use AccessibilityObject::replaceTextInRange to insert text at first time when the text fields are empty
+ https://bugs.webkit.org/show_bug.cgi?id=206093
+ <rdar://problem/58491448>
+
+ Reviewed by Chris Fleizach.
+
+ Test text replacement with empty range in editable div, text input, and textarea.
+
+ * accessibility/mac/replace-text-with-empty-range-expected.txt: Added.
+ * accessibility/mac/replace-text-with-empty-range.html: Added.
+
2020-01-17 Jer Noble <jer.no...@apple.com>
[MSE] Decode glitches when watching videos on CNN.com
Added: trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range-expected.txt (0 => 254782)
--- trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range-expected.txt 2020-01-18 00:48:31 UTC (rev 254782)
@@ -0,0 +1,15 @@
+This tests that when we are adding text to empty text fields, the accessibility replace with range API functions as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS axContentEditableDiv.replaceTextInRange('Hello', 0, 0) is true
+PASS axContentEditableDiv.stringValue is 'AXValue: Hello'
+PASS axText.replaceTextInRange('Hello', 0, 0) is true
+PASS axText.stringValue is 'AXValue: Hello'
+PASS axTextarea.replaceTextInRange('Hello', 0, 0) is true
+PASS axTextarea.stringValue is 'AXValue: Hello'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range.html (0 => 254782)
--- trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range.html (rev 0)
+++ trunk/LayoutTests/accessibility/mac/replace-text-with-empty-range.html 2020-01-18 00:48:31 UTC (rev 254782)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="content">
+ <div id="content-editable-div" contenteditable="true" role="textbox"></div>
+ <input id="text" type="text" value="">
+ <textarea id="textarea"></textarea>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+ description("This tests that when we are adding text to empty text fields, the accessibility replace with range API functions as expected.");
+
+ if (window.accessibilityController) {
+ var axContentEditableDiv = accessibilityController.accessibleElementById("content-editable-div");
+ var contentEditableDiv = document.getElementById("content-editable-div");
+ contentEditableDiv.focus();
+ shouldBeTrue("axContentEditableDiv.replaceTextInRange('Hello', 0, 0)");
+ shouldBe("axContentEditableDiv.stringValue", "'AXValue: Hello'");
+ contentEditableDiv.blur();
+
+ var axText = accessibilityController.accessibleElementById("text");
+ var text = document.getElementById("text");
+ text.focus();
+ shouldBeTrue("axText.replaceTextInRange('Hello', 0, 0)");
+ shouldBe("axText.stringValue", "'AXValue: Hello'");
+ text.blur();
+
+ var axTextarea = accessibilityController.accessibleElementById("textarea");
+ var textarea = document.getElementById("textarea");
+ textarea.focus();
+ shouldBeTrue("axTextarea.replaceTextInRange('Hello', 0, 0)");
+ shouldBe("axTextarea.stringValue", "'AXValue: Hello'");
+ textarea.blur();
+
+ document.getElementById("content").style.visibility = "hidden";
+ }
+</script>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (254781 => 254782)
--- trunk/Source/WebCore/ChangeLog 2020-01-18 00:43:00 UTC (rev 254781)
+++ trunk/Source/WebCore/ChangeLog 2020-01-18 00:48:31 UTC (rev 254782)
@@ -1,3 +1,29 @@
+2020-01-17 Canhai Chen <canhai_c...@apple.com>
+
+ AX: Unable to use AccessibilityObject::replaceTextInRange to insert text at first time when the text fields are empty
+ https://bugs.webkit.org/show_bug.cgi?id=206093
+ <rdar://problem/58491448>
+
+ Reviewed by Chris Fleizach.
+
+ When we are trying to insert text in an empty text field with (0, 0) range, the frame selection will create a
+ new VisibleSelection in FrameSelection::setSelectedRange, and the container node that this new VisibleSelection
+ returns is the parent node of the text field element, which could be a HTMLDivElement or HTMLBodyElement.
+ Because the container node is not editable, it failed to insert text in Editor::replaceSelectionWithText later.
+
+ Return nullptr if the range is (0, 0) and the text length is 0 in AccessibilityObject::rangeForPlainTextRange,
+ so that when the frame selection is trying to setSelectedRange before replacing text, instead of creating an
+ uneditable VisibleSelection, it will just return and later in Editor::replaceSelectionWithText, it will use
+ the default VisibleSelection, of which the container node is an editable TextControlInnerTextElement.
+
+ This change does not affect the existing behaviors of text replacement. Add a new test for text replacement
+ with empty range in editable div, text input, and textarea.
+
+ Test: accessibility/mac/replace-text-with-empty-range.html
+
+ * accessibility/AccessibilityObject.cpp:
+ (WebCore::AccessibilityObject::rangeForPlainTextRange const):
+
2020-01-17 Zalan Bujtas <za...@apple.com>
[LFC][IFC] Do not construct a dedicated run for the trailing (fully) collapsed whitespace.
Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (254781 => 254782)
--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2020-01-18 00:43:00 UTC (rev 254781)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp 2020-01-18 00:48:31 UTC (rev 254782)
@@ -1189,6 +1189,9 @@
unsigned textLength = getLengthForTextRange();
if (range.start + range.length > textLength)
return nullptr;
+ // Avoid setting selection to uneditable parent node in FrameSelection::setSelectedRange. See webkit.org/b/206093.
+ if (range.isNull() && !textLength)
+ return nullptr;
if (AXObjectCache* cache = axObjectCache()) {
CharacterOffset start = cache->characterOffsetForIndex(range.start, this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes