WebKit Bugzilla
Attachment 369892 Details for
Bug 197894
: Inserting a newline in contenteditable causes two characters to be added instead of one
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-197894-20190514142421.patch (text/plain), 9.35 KB, created by
Andres Gonzalez
on 2019-05-14 14:24:22 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Andres Gonzalez
Created:
2019-05-14 14:24:22 PDT
Size:
9.35 KB
patch
obsolete
>Subversion Revision: 245007 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 26177d0480c0ee5f982bbef8fd38d16ff051bbee..74630b9b48609139aa95f26a392771c4fb7a0b6e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2019-05-14 Andres Gonzalez <andresg_22@apple.com> >+ >+ Inserting a newline in contenteditable causes two chars to be added instead of one. >+ https://bugs.webkit.org/show_bug.cgi?id=197894 >+ <rdar://problem/49700998> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * accessibility/AccessibilityRenderObject.cpp: minor change to avoid calling node() multiple times unnecessarily. >+ (WebCore::AccessibilityRenderObject::setSelectedTextRange): >+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: implementated a couple of methods to be exposed to JS. >+ (-[WebAccessibilityObjectWrapper _accessibilitySelectedTextRange]): >+ (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): >+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: >+ (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]): removed unnecessary check. >+ * editing/markup.cpp: >+ (WebCore::createFragmentFromText): Fix for the double newline inserted into contenteditable. >+ > 2019-05-07 Antti Koivisto <antti@apple.com> > > <body> with overflow:hidden CSS is scrollable on iOS >diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >index de2a0052b8345088f4cc1c7b572382b19f847a4c..221fb77dfccdc77602711ee8014471d2e784db05 100644 >--- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >+++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp >@@ -1621,9 +1621,10 @@ void AccessibilityRenderObject::setSelectedTextRange(const PlainTextRange& range > HTMLTextFormControlElement& textControl = downcast<RenderTextControl>(*m_renderer).textFormControlElement(); > textControl.setSelectionRange(range.start, range.start + range.length); > } else { >- ASSERT(node()); >- VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(*node(), range.start); >- VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(*node(), range.start + range.length); >+ Node* node = this->node(); >+ ASSERT(node); >+ VisiblePosition start = visiblePositionForIndexUsingCharacterIterator(*node, range.start); >+ VisiblePosition end = visiblePositionForIndexUsingCharacterIterator(*node, range.start + range.length); > m_renderer->frame().selection().setSelection(VisibleSelection(start, end), FrameSelection::defaultSetSelectionOptions(UserTriggered)); > } > >diff --git a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm >index c2009186ce53342a9996412d04ca697f19e27519..6ff4644122cd383be9c59413a1ada8a1eef0b84a 100644 >--- a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm >+++ b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm >@@ -2525,11 +2525,11 @@ - (NSRange)_accessibilitySelectedTextRange > { > if (![self _prepareAccessibilityCall] || !m_object->isTextControl()) > return NSMakeRange(NSNotFound, 0); >- >+ > PlainTextRange textRange = m_object->selectedTextRange(); > if (textRange.isNull()) > return NSMakeRange(NSNotFound, 0); >- return NSMakeRange(textRange.start, textRange.length); >+ return NSMakeRange(textRange.start, textRange.length); > } > > - (void)_accessibilitySetSelectedTextRange:(NSRange)range >@@ -2540,6 +2540,14 @@ - (void)_accessibilitySetSelectedTextRange:(NSRange)range > m_object->setSelectedTextRange(PlainTextRange(range.location, range.length)); > } > >+- (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string >+{ >+ if (![self _prepareAccessibilityCall]) >+ return NO; >+ >+ return m_object->replaceTextInRange(string, PlainTextRange(range)); >+} >+ > // A convenience method for getting the accessibility objects of a NSRange. Currently used only by DRT. > - (NSArray *)elementsForRange:(NSRange)range > { >diff --git a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >index 23229cb53009e58d82588f9f340ff98fc677295c..0e0dcc45d597872c36c4cdca2918674cb5ba846d 100644 >--- a/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >+++ b/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm >@@ -2742,8 +2742,6 @@ IGNORE_WARNINGS_END > } > if ([attributeName isEqualToString: NSAccessibilitySelectedTextRangeAttribute]) { > PlainTextRange textRange = m_object->selectedTextRange(); >- if (textRange.isNull()) >- return [NSValue valueWithRange:NSMakeRange(0, 0)]; > return [NSValue valueWithRange:NSMakeRange(textRange.start, textRange.length)]; > } > // TODO: Get actual visible range. <rdar://problem/4712101> >diff --git a/Source/WebCore/editing/markup.cpp b/Source/WebCore/editing/markup.cpp >index 00cb4e98f3070d54fad03ed407fb15a3494da85b..069882bfe9411021db6d82fc750b9cbaaaa5fe5c 100644 >--- a/Source/WebCore/editing/markup.cpp >+++ b/Source/WebCore/editing/markup.cpp >@@ -1130,6 +1130,14 @@ Ref<DocumentFragment> createFragmentFromText(Range& context, const String& text) > return fragment; > } > >+ if (string.length() == 1 && string[0] == '\n') { >+ // This is a single newline char, thus just create one HTMLBRElement. >+ auto element = HTMLBRElement::create(document); >+ element->setAttributeWithoutSynchronization(classAttr, AppleInterchangeNewline); >+ fragment->appendChild(element); >+ return fragment; >+ } >+ > // Break string into paragraphs. Extra line breaks turn into empty paragraphs. > Node* blockNode = enclosingBlock(context.firstNode()); > Element* block = downcast<Element>(blockNode); >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 4fe89f7c75b2930a3b94933930b85c551474096b..bb4ef9a7d07f7adf4577f38f301fa836fd21abc1 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,16 @@ >+2019-05-14 Andres Gonzalez <andresg_22@apple.com> >+ >+ Inserting a newline in contenteditable causes 2two chars to be added instead of one. >+ https://bugs.webkit.org/show_bug.cgi?id=197894 >+ <rdar://problem/49700998> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: implemented methods to expose to JS. >+ (WTR::AccessibilityUIElement::selectedTextRange): >+ (WTR::AccessibilityUIElement::setSelectedTextRange): >+ (WTR::AccessibilityUIElement::replaceTextInRange): >+ > 2019-05-07 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][WPE] MiniBrowser: load about:blank for new web views in automation mode >diff --git a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >index 7ed6cbd445eb993577cfeed4a76e8a41e26058a4..c60640e375f30cd250dff8fc4ef870b37c68804e 100644 >--- a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >+++ b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >@@ -55,6 +55,9 @@ - (NSArray *)elementsForRange:(NSRange)range; > - (NSString *)selectionRangeString; > - (CGPoint)accessibilityClickPoint; > - (void)accessibilityModifySelection:(WebCore::TextGranularity)granularity increase:(BOOL)increase; >+- (NSRange)_accessibilitySelectedTextRange; >+- (void)_accessibilitySetSelectedTextRange:(NSRange)range; >+- (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string; > - (void)accessibilitySetPostedNotificationCallback:(AXPostedNotificationCallback)function withContext:(void*)context; > - (CGFloat)_accessibilityMinValue; > - (CGFloat)_accessibilityMaxValue; >@@ -836,7 +839,9 @@ void AccessibilityUIElement::scrollToMakeVisibleWithSubFocus(int x, int y, int w > > JSRetainPtr<JSStringRef> AccessibilityUIElement::selectedTextRange() > { >- return createEmptyJSString(); >+ NSRange range = [m_element _accessibilitySelectedTextRange]; >+ NSMutableString *rangeDescription = [NSMutableString stringWithFormat:@"{%lu, %lu}", static_cast<unsigned long>(range.location), static_cast<unsigned long>(range.length)]; >+ return [rangeDescription createJSStringRef]; > } > > bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarkerRange*) >@@ -846,7 +851,8 @@ bool AccessibilityUIElement::setSelectedVisibleTextRange(AccessibilityTextMarker > > bool AccessibilityUIElement::setSelectedTextRange(unsigned location, unsigned length) > { >- return false; >+ [m_element _accessibilitySetSelectedTextRange:NSMakeRange(location, length)]; >+ return true; > } > > void AccessibilityUIElement::increment() >@@ -1145,9 +1151,9 @@ RefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForBounds > return nullptr; > } > >-bool AccessibilityUIElement::replaceTextInRange(JSStringRef, int, int) >+bool AccessibilityUIElement::replaceTextInRange(JSStringRef string, int location, int length) > { >- return false; >+ return [m_element accessibilityReplaceRange:NSMakeRange(location, length) withText:[NSString stringWithJSStringRef:string]]; > } > > RefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForPoint(int x, int y)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197894
:
369892
|
369907
|
370014
|
370023
|
370028
|
370032
|
370116
|
370120
|
370121
|
370419
|
370435
|
370575
|
370964
|
370981
|
371007
|
371071