Changeset 245912 in webkit
- Timestamp:
- May 30, 2019 5:02:59 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245909 r245912 1 2019-05-30 Andres Gonzalez <andresg_22@apple.com> 2 3 Inserting a newline in contenteditable causes two characters to be added instead of one 4 https://bugs.webkit.org/show_bug.cgi?id=197894 5 <rdar://problem/49700998> 6 7 Reviewed by Wenson Hsieh and Chris Fleizach. 8 9 * accessibility/ios-simulator/set-selected-text-range-after-newline-expected.txt: Added. 10 * accessibility/ios-simulator/set-selected-text-range-after-newline.html: Added. 11 * accessibility/ios-simulator/text-marker-list-item-expected.txt: 12 * accessibility/set-selected-text-range-after-newline-expected.txt: Added. 13 * accessibility/set-selected-text-range-after-newline.html: Added. 14 * platform/win/TestExpectations: 15 1 16 2019-05-30 Devin Rousso <drousso@apple.com> 2 17 -
trunk/LayoutTests/accessibility/ios-simulator/text-marker-list-item-expected.txt
r187904 r245912 5 5 6 6 7 FAIL text should be 1. item 1. Was 1. . 7 PASS text is '1. item 1' 8 8 PASS successfullyParsed is true 9 9 -
trunk/LayoutTests/platform/win/TestExpectations
r245733 r245912 3395 3395 # Timeouts tracked in webkit.org/b/160447. 3396 3396 accessibility/set-selected-text-range-contenteditable.html [ Skip ] 3397 accessibility/set-selected-text-range-after-newline.html [ Skip ] 3397 3398 crypto/crypto-key-algorithm-gc.html [ Skip ] 3398 3399 crypto/crypto-key-usages-gc.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r245905 r245912 1 2019-05-30 Andres Gonzalez <andresg_22@apple.com> 2 3 Inserting a newline in contenteditable causes two characters to be added instead of one 4 https://bugs.webkit.org/show_bug.cgi?id=197894 5 <rdar://problem/49700998> 6 7 Reviewed by Wenson Hsieh and Chris Fleizach. 8 9 There were two issues with inserting a newline character at the end of 10 a line that caused problems for accessibility: 11 - the first '\n' inserted after text would result in two line breaks 12 inserted instead of one. createFragmentFromText in markup.cpp was 13 splitting the string "\n" into two empty strings and creating a <div> 14 and a <br> respectively. Then the emission code would emit a '\n' for 15 the empty div and another for the <br>. 16 - the second problem is a consequence of <rdar://problem/5192593> and 17 the workaround is the change in editing.cpp in the function 18 visiblePositionForIndexUsingCharacterIterator, similar to what is done 19 in VisibleUnits.cpp for nextBoundary. 20 The rest of the changes in this patch are accessibility changes to 21 execute the layout tests. 22 23 Tests: accessibility/ios-simulator/set-selected-text-range-after-newline.html 24 accessibility/set-selected-text-range-after-newline.html 25 26 * accessibility/AccessibilityRenderObject.cpp: 27 (WebCore::AccessibilityRenderObject::setSelectedTextRange): 28 * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: 29 (-[WebAccessibilityObjectWrapper stringForRange:]): 30 (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): 31 (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): 32 * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: 33 (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): 34 * editing/Editing.cpp: 35 (WebCore::visiblePositionForIndexUsingCharacterIterator): 36 * editing/markup.cpp: 37 (WebCore::createFragmentFromText): 38 1 39 2019-05-30 Justin Fan <justin_fan@apple.com> 2 40 -
trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp
r245823 r245912 1622 1622 textControl.setSelectionRange(range.start, range.start + range.length); 1623 1623 } else { 1624 ASSERT(node()); 1625 VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(*node(), range.start); 1626 VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(*node(), range.start + range.length); 1624 auto node = this->node(); 1625 ASSERT(node); 1626 VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(*node, range.start); 1627 VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(*node, range.start + range.length); 1627 1628 m_renderer->frame().selection().setSelection(VisibleSelection(start, end), FrameSelection::defaultSetSelectionOptions(UserTriggered)); 1628 1629 } -
trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
r244983 r245912 2498 2498 } 2499 2499 2500 2501 // A convenience method for getting the text of a NSRange. Currently used only by DRT. 2500 // A convenience method for getting the text of a NSRange. 2502 2501 - (NSString *)stringForRange:(NSRange)range 2503 2502 { 2504 return [self _stringForRange:range attributed:NO]; 2503 if (![self _prepareAccessibilityCall]) 2504 return nil; 2505 2506 return m_object->stringForRange([self _convertToDOMRange:range]); 2505 2507 } 2506 2508 … … 2526 2528 if (![self _prepareAccessibilityCall] || !m_object->isTextControl()) 2527 2529 return NSMakeRange(NSNotFound, 0); 2528 2530 2529 2531 PlainTextRange textRange = m_object->selectedTextRange(); 2530 2532 if (textRange.isNull()) 2531 2533 return NSMakeRange(NSNotFound, 0); 2532 return NSMakeRange(textRange.start, textRange.length); 2534 return NSMakeRange(textRange.start, textRange.length); 2533 2535 } 2534 2536 … … 2539 2541 2540 2542 m_object->setSelectedTextRange(PlainTextRange(range.location, range.length)); 2543 } 2544 2545 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string 2546 { 2547 if (![self _prepareAccessibilityCall]) 2548 return NO; 2549 2550 return m_object->replaceTextInRange(string, PlainTextRange(range)); 2541 2551 } 2542 2552 -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
r244983 r245912 2743 2743 if ([attributeName isEqualToString: NSAccessibilitySelectedTextRangeAttribute]) { 2744 2744 PlainTextRange textRange = m_object->selectedTextRange(); 2745 if (textRange.isNull())2746 return [NSValue valueWithRange:NSMakeRange(0, 0)];2747 2745 return [NSValue valueWithRange:NSMakeRange(textRange.start, textRange.length)]; 2748 2746 } -
trunk/Source/WebCore/editing/Editing.cpp
r243163 r245912 1122 1122 CharacterIterator it(range.get()); 1123 1123 it.advance(index - 1); 1124 1125 if (!it.atEnd() && it.text()[0] == '\n') { 1126 // FIXME: workaround for collapsed range (where only start position is correct) emitted for some emitted newlines (see rdar://5192593) 1127 auto range = it.range(); 1128 if (range->startPosition() == range->endPosition()) { 1129 it.advance(1); 1130 return VisiblePosition(it.range()->startPosition()); 1131 } 1132 } 1133 1124 1134 return { it.atEnd() ? range->endPosition() : it.range()->endPosition(), UPSTREAM }; 1125 1135 } -
trunk/Source/WebCore/editing/markup.cpp
r245637 r245912 1116 1116 string.replace('\r', '\n'); 1117 1117 1118 auto createHTMLBRElement = [&document]() { 1119 auto element = HTMLBRElement::create(document); 1120 element->setAttributeWithoutSynchronization(classAttr, AppleInterchangeNewline); 1121 return element; 1122 }; 1123 1118 1124 if (contextPreservesNewline(context)) { 1119 1125 fragment->appendChild(document.createTextNode(string)); 1120 1126 if (string.endsWith('\n')) { 1121 auto element = HTMLBRElement::create(document); 1122 element->setAttributeWithoutSynchronization(classAttr, AppleInterchangeNewline); 1123 fragment->appendChild(element); 1127 fragment->appendChild(createHTMLBRElement()); 1124 1128 } 1125 1129 return fragment; … … 1129 1133 if (string.find('\n') == notFound) { 1130 1134 fillContainerFromString(fragment, string); 1135 return fragment; 1136 } 1137 1138 if (string.length() == 1 && string[0] == '\n') { 1139 // This is a single newline char, thus just create one HTMLBRElement. 1140 fragment->appendChild(createHTMLBRElement()); 1131 1141 return fragment; 1132 1142 } … … 1150 1160 if (s.isEmpty() && i + 1 == numLines) { 1151 1161 // For last line, use the "magic BR" rather than a P. 1152 element = HTMLBRElement::create(document); 1153 element->setAttributeWithoutSynchronization(classAttr, AppleInterchangeNewline); 1162 element = createHTMLBRElement(); 1154 1163 } else if (useLineBreak) { 1155 1164 element = HTMLBRElement::create(document); -
trunk/Tools/ChangeLog
r245908 r245912 1 2019-05-30 Andres Gonzalez <andresg_22@apple.com> 2 3 Inserting a newline in contenteditable causes two characters to be added instead of one 4 https://bugs.webkit.org/show_bug.cgi?id=197894 5 <rdar://problem/49700998> 6 7 Reviewed by Wenson Hsieh and Chris Fleizach. 8 9 iOS implementation of several AccessibilityUIElement methods to execute 10 LayoutTests. 11 12 * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: 13 (WTR::AccessibilityUIElement::selectedTextRange): 14 (WTR::AccessibilityUIElement::setSelectedTextRange): 15 (WTR::AccessibilityUIElement::replaceTextInRange): 16 1 17 2019-05-30 Keith Miller <keith_miller@apple.com> 2 18 -
trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
r244059 r245912 56 56 - (CGPoint)accessibilityClickPoint; 57 57 - (void)accessibilityModifySelection:(WebCore::TextGranularity)granularity increase:(BOOL)increase; 58 - (NSRange)_accessibilitySelectedTextRange; 59 - (void)_accessibilitySetSelectedTextRange:(NSRange)range; 60 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string; 58 61 - (void)accessibilitySetPostedNotificationCallback:(AXPostedNotificationCallback)function withContext:(void*)context; 59 62 - (CGFloat)_accessibilityMinValue; … … 837 840 JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange() 838 841 { 839 return createEmptyJSString(); 842 NSRange range = [m_element _accessibilitySelectedTextRange]; 843 NSMutableString *rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)]; 844 return [rangeDescription createJSStringRef]; 840 845 } 841 846 … … 847 852 bool AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length) 848 853 { 849 return false; 854 [m_element _accessibilitySetSelectedTextRange:NSMakeRange(location, length)]; 855 return true; 850 856 } 851 857 … … 1146 1152 } 1147 1153 1148 bool AccessibilityUIElement::replaceTextInRange(JSStringRef , int, int)1149 { 1150 return false;1154 bool AccessibilityUIElement::replaceTextInRange(JSStringRef string, int location, int length) 1155 { 1156 return [m_element accessibilityReplaceRange:NSMakeRange(location, length) withText:[NSString stringWithJSStringRef:string]]; 1151 1157 } 1152 1158
Note: See TracChangeset
for help on using the changeset viewer.