haikuwebkit/LayoutTests/accessibility/set-selected-text-range-aft...

52 lines
1.7 KiB
HTML
Raw Permalink Normal View History

Inserting a newline in contenteditable causes two characters to be added instead of one https://bugs.webkit.org/show_bug.cgi?id=197894 <rdar://problem/49700998> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-05-30 Reviewed by Wenson Hsieh and Chris Fleizach. Source/WebCore: There were two issues with inserting a newline character at the end of a line that caused problems for accessibility: - the first '\n' inserted after text would result in two line breaks inserted instead of one. createFragmentFromText in markup.cpp was splitting the string "\n" into two empty strings and creating a <div> and a <br> respectively. Then the emission code would emit a '\n' for the empty div and another for the <br>. - the second problem is a consequence of <rdar://problem/5192593> and the workaround is the change in editing.cpp in the function visiblePositionForIndexUsingCharacterIterator, similar to what is done in VisibleUnits.cpp for nextBoundary. The rest of the changes in this patch are accessibility changes to execute the layout tests. Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html accessibility/set-selected-text-range-after-newline.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setSelectedTextRange): * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper stringForRange:]): (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): * editing/Editing.cpp: (WebCore::visiblePositionForIndexUsingCharacterIterator): * editing/markup.cpp: (WebCore::createFragmentFromText): Tools: iOS implementation of several AccessibilityUIElement methods to execute LayoutTests. * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::selectedTextRange): (WTR::AccessibilityUIElement::setSelectedTextRange): (WTR::AccessibilityUIElement::replaceTextInRange): LayoutTests: * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. * accessibility/ios-simulator/text-marker-list-item-expected.txt: * accessibility/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/set-selected-text-range-after-newline.html: Added. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/212417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 00:02:59 +00:00
<html>
<head>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<div id="content" contenteditable tabindex="0">helloworld</div>
<div id="console"></div>
<script>
if (window.accessibilityController) {
window.jsTestIsAsync = true;
var content = document.getElementById("content");
content.focus();
var text = accessibilityController.focusedElement;
text.setSelectedTextRange(5, 0);
shouldBecomeEqual("text.selectedTextRange", "'{5, 0}'", function() {
// Insert a linebreak between "hello" and "world".
Inserting a newline in contenteditable causes two characters to be added instead of one https://bugs.webkit.org/show_bug.cgi?id=197894 <rdar://problem/49700998> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-05-30 Reviewed by Wenson Hsieh and Chris Fleizach. Source/WebCore: There were two issues with inserting a newline character at the end of a line that caused problems for accessibility: - the first '\n' inserted after text would result in two line breaks inserted instead of one. createFragmentFromText in markup.cpp was splitting the string "\n" into two empty strings and creating a <div> and a <br> respectively. Then the emission code would emit a '\n' for the empty div and another for the <br>. - the second problem is a consequence of <rdar://problem/5192593> and the workaround is the change in editing.cpp in the function visiblePositionForIndexUsingCharacterIterator, similar to what is done in VisibleUnits.cpp for nextBoundary. The rest of the changes in this patch are accessibility changes to execute the layout tests. Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html accessibility/set-selected-text-range-after-newline.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setSelectedTextRange): * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper stringForRange:]): (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): * editing/Editing.cpp: (WebCore::visiblePositionForIndexUsingCharacterIterator): * editing/markup.cpp: (WebCore::createFragmentFromText): Tools: iOS implementation of several AccessibilityUIElement methods to execute LayoutTests. * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::selectedTextRange): (WTR::AccessibilityUIElement::setSelectedTextRange): (WTR::AccessibilityUIElement::replaceTextInRange): LayoutTests: * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. * accessibility/ios-simulator/text-marker-list-item-expected.txt: * accessibility/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/set-selected-text-range-after-newline.html: Added. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/212417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 00:02:59 +00:00
text.replaceTextInRange("\n", 5, 0);
var t = text.stringForRange(0, 11);
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
debug("There must be only one [newline] between hello and world: " + t);
text.setSelectedTextRange(6, 0);
shouldBecomeEqual("text.selectedTextRange", "'{6, 0}'", function() {
// Insert another linebreak before "world".
text.replaceTextInRange("\n", 6, 0);
var t = text.stringForRange(0, 12);
Inserting a newline in contenteditable causes two characters to be added instead of one https://bugs.webkit.org/show_bug.cgi?id=197894 <rdar://problem/49700998> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-05-30 Reviewed by Wenson Hsieh and Chris Fleizach. Source/WebCore: There were two issues with inserting a newline character at the end of a line that caused problems for accessibility: - the first '\n' inserted after text would result in two line breaks inserted instead of one. createFragmentFromText in markup.cpp was splitting the string "\n" into two empty strings and creating a <div> and a <br> respectively. Then the emission code would emit a '\n' for the empty div and another for the <br>. - the second problem is a consequence of <rdar://problem/5192593> and the workaround is the change in editing.cpp in the function visiblePositionForIndexUsingCharacterIterator, similar to what is done in VisibleUnits.cpp for nextBoundary. The rest of the changes in this patch are accessibility changes to execute the layout tests. Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html accessibility/set-selected-text-range-after-newline.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setSelectedTextRange): * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper stringForRange:]): (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): * editing/Editing.cpp: (WebCore::visiblePositionForIndexUsingCharacterIterator): * editing/markup.cpp: (WebCore::createFragmentFromText): Tools: iOS implementation of several AccessibilityUIElement methods to execute LayoutTests. * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::selectedTextRange): (WTR::AccessibilityUIElement::setSelectedTextRange): (WTR::AccessibilityUIElement::replaceTextInRange): LayoutTests: * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. * accessibility/ios-simulator/text-marker-list-item-expected.txt: * accessibility/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/set-selected-text-range-after-newline.html: Added. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/212417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 00:02:59 +00:00
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
debug("There must be two [newline] between hello and world: " + t);
text.setSelectedTextRange(7, 0);
shouldBecomeEqual("text.selectedTextRange", "'{7, 0}'", function() {
var t = text.stringForRange(7, 5);
t = t.replace(/(?:\r\n|\r|\n)/g, '[newline]');
debug("The text after the newline should be world: " + t);
Inserting a newline in contenteditable causes two characters to be added instead of one https://bugs.webkit.org/show_bug.cgi?id=197894 <rdar://problem/49700998> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-05-30 Reviewed by Wenson Hsieh and Chris Fleizach. Source/WebCore: There were two issues with inserting a newline character at the end of a line that caused problems for accessibility: - the first '\n' inserted after text would result in two line breaks inserted instead of one. createFragmentFromText in markup.cpp was splitting the string "\n" into two empty strings and creating a <div> and a <br> respectively. Then the emission code would emit a '\n' for the empty div and another for the <br>. - the second problem is a consequence of <rdar://problem/5192593> and the workaround is the change in editing.cpp in the function visiblePositionForIndexUsingCharacterIterator, similar to what is done in VisibleUnits.cpp for nextBoundary. The rest of the changes in this patch are accessibility changes to execute the layout tests. Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html accessibility/set-selected-text-range-after-newline.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setSelectedTextRange): * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper stringForRange:]): (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): * editing/Editing.cpp: (WebCore::visiblePositionForIndexUsingCharacterIterator): * editing/markup.cpp: (WebCore::createFragmentFromText): Tools: iOS implementation of several AccessibilityUIElement methods to execute LayoutTests. * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::selectedTextRange): (WTR::AccessibilityUIElement::setSelectedTextRange): (WTR::AccessibilityUIElement::replaceTextInRange): LayoutTests: * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. * accessibility/ios-simulator/text-marker-list-item-expected.txt: * accessibility/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/set-selected-text-range-after-newline.html: Added. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/212417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 00:02:59 +00:00
finishJSTest();
});
Inserting a newline in contenteditable causes two characters to be added instead of one https://bugs.webkit.org/show_bug.cgi?id=197894 <rdar://problem/49700998> Patch by Andres Gonzalez <andresg_22@apple.com> on 2019-05-30 Reviewed by Wenson Hsieh and Chris Fleizach. Source/WebCore: There were two issues with inserting a newline character at the end of a line that caused problems for accessibility: - the first '\n' inserted after text would result in two line breaks inserted instead of one. createFragmentFromText in markup.cpp was splitting the string "\n" into two empty strings and creating a <div> and a <br> respectively. Then the emission code would emit a '\n' for the empty div and another for the <br>. - the second problem is a consequence of <rdar://problem/5192593> and the workaround is the change in editing.cpp in the function visiblePositionForIndexUsingCharacterIterator, similar to what is done in VisibleUnits.cpp for nextBoundary. The rest of the changes in this patch are accessibility changes to execute the layout tests. Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html accessibility/set-selected-text-range-after-newline.html * accessibility/AccessibilityRenderObject.cpp: (WebCore::AccessibilityRenderObject::setSelectedTextRange): * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper stringForRange:]): (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): * editing/Editing.cpp: (WebCore::visiblePositionForIndexUsingCharacterIterator): * editing/markup.cpp: (WebCore::createFragmentFromText): Tools: iOS implementation of several AccessibilityUIElement methods to execute LayoutTests. * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::selectedTextRange): (WTR::AccessibilityUIElement::setSelectedTextRange): (WTR::AccessibilityUIElement::replaceTextInRange): LayoutTests: * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. * accessibility/ios-simulator/text-marker-list-item-expected.txt: * accessibility/set-selected-text-range-after-newline-expected.txt: Added. * accessibility/set-selected-text-range-after-newline.html: Added. * platform/win/TestExpectations: Canonical link: https://commits.webkit.org/212417@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245912 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-05-31 00:02:59 +00:00
});
});
}
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>