Title: [282898] trunk
Revision
282898
Author
jh718.p...@samsung.com
Date
2021-09-22 17:40:13 -0700 (Wed, 22 Sep 2021)

Log Message

Fix the behavior that setting text field input's value content attribute to the same value moves caret to the end of the input.
https://bugs.webkit.org/show_bug.cgi?id=191255

Reviewed by Simon Fraser.

This patch changes the behavior specified above to make WebKit's behavior interoperable
according to the spec below at
https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-value.

'4. If the new API value is different from oldAPIValue,
then move the text entry cursor position to the end of the text control,
unselecting any selected text and resetting the selection direction to "none".'

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt:

Source/WebCore:

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::setValue):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (282897 => 282898)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-23 00:40:13 UTC (rev 282898)
@@ -1,3 +1,22 @@
+2021-09-22  Joonghun Park  <jh718.p...@samsung.com>
+
+        Fix the behavior that setting text field input's value content attribute to the same value moves caret to the end of the input.
+        https://bugs.webkit.org/show_bug.cgi?id=191255
+
+        Reviewed by Simon Fraser.
+
+        This patch changes the behavior specified above to make WebKit's behavior interoperable
+        according to the spec below at
+        https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-value.
+
+        '4. If the new API value is different from oldAPIValue,
+        then move the text entry cursor position to the end of the text control,
+        unselecting any selected text and resetting the selection direction to "none".'
+
+        * web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt:
+
 2021-09-21  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Parsing support for font-palette

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt (282897 => 282898)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt	2021-09-23 00:40:13 UTC (rev 282898)
@@ -4,6 +4,6 @@
 PASS selectionStart and selectionEnd do not change when same value set again for [object HTMLTextAreaElement]
 FAIL selectionStart and selectionEnd change when value changed to upper case for [object HTMLTextAreaElement] assert_equals: expected 3 but got 0
 PASS Default selectionStart and selectionEnd for [object HTMLInputElement]
-FAIL selectionStart and selectionEnd do not change when same value set again for [object HTMLInputElement] assert_equals: expected 0 but got 3
+PASS selectionStart and selectionEnd do not change when same value set again for [object HTMLInputElement]
 PASS selectionStart and selectionEnd change when value changed to upper case for [object HTMLInputElement]
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt (282897 => 282898)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	2021-09-23 00:40:13 UTC (rev 282898)
@@ -1,14 +1,14 @@
 
 
-FAIL input out of document: selection must not change when setting the same value assert_equals: selectionStart must not change expected 1 but got 5
+PASS input out of document: selection must not change when setting the same value
 PASS input out of document: selection must change when setting a different value
-FAIL input out of document: selection must not change when setting a value that becomes the same after the value sanitization algorithm assert_equals: selectionStart must not change expected 1 but got 5
-FAIL input in document: selection must not change when setting the same value assert_equals: selectionStart must not change expected 1 but got 5
+PASS input out of document: selection must not change when setting a value that becomes the same after the value sanitization algorithm
+PASS input in document: selection must not change when setting the same value
 PASS input in document: selection must change when setting a different value
-FAIL input in document: selection must not change when setting a value that becomes the same after the value sanitization algorithm assert_equals: selectionStart must not change expected 1 but got 5
-FAIL input in document, with focus: selection must not change when setting the same value assert_equals: selectionStart must not change expected 1 but got 5
+PASS input in document: selection must not change when setting a value that becomes the same after the value sanitization algorithm
+PASS input in document, with focus: selection must not change when setting the same value
 PASS input in document, with focus: selection must change when setting a different value
-FAIL input in document, with focus: selection must not change when setting a value that becomes the same after the value sanitization algorithm assert_equals: selectionStart must not change expected 1 but got 5
+PASS input in document, with focus: selection must not change when setting a value that becomes the same after the value sanitization algorithm
 PASS textarea out of document: selection must not change when setting the same value
 FAIL textarea out of document: selection must change when setting a different value assert_equals: selectionStart must be reset to the end expected 6 but got 1
 PASS textarea out of document: selection must not change when setting the same normalized value

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt (282897 => 282898)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt	2021-09-23 00:40:13 UTC (rev 282898)
@@ -10,7 +10,7 @@
 PASS value dirty flag behavior after setRangeText on focused then blurred textarea
 PASS value dirty flag behavior after setRangeText on focused then blurred input
 PASS selection is collapsed to the end after changing values on input
-FAIL selection is not collapsed to the end when value is set to its existing value on input assert_equals: element.selectionStart should be unchanged expected 2 but got 6
+PASS selection is not collapsed to the end when value is set to its existing value on input
 FAIL selection is collapsed to the end after changing values on textarea assert_equals: element.selectionStart should be value.length expected 3 but got 0
 PASS selection is not collapsed to the end when value is set to its existing value on textarea
 

Modified: trunk/Source/WebCore/ChangeLog (282897 => 282898)


--- trunk/Source/WebCore/ChangeLog	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/Source/WebCore/ChangeLog	2021-09-23 00:40:13 UTC (rev 282898)
@@ -1,3 +1,21 @@
+2021-09-22  Joonghun Park  <jh718.p...@samsung.com>
+
+        Fix the behavior that setting text field input's value content attribute to the same value moves caret to the end of the input.
+        https://bugs.webkit.org/show_bug.cgi?id=191255
+
+        Reviewed by Simon Fraser.
+
+        This patch changes the behavior specified above to make WebKit's behavior interoperable
+        according to the spec below at
+        https://html.spec.whatwg.org/multipage/form-elements.html#dom-textarea-value.
+
+        '4. If the new API value is different from oldAPIValue,
+        then move the text entry cursor position to the end of the text control,
+        unselecting any selected text and resetting the selection direction to "none".'
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::setValue):
+
 2021-09-22  Simon Fraser  <simon.fra...@apple.com>
 
         Don't exempt WebXR source files from unified sources

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (282897 => 282898)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2021-09-23 00:39:19 UTC (rev 282897)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2021-09-23 00:40:13 UTC (rev 282898)
@@ -133,9 +133,11 @@
     // TextFieldInputType dispatches events different way from InputType.
     InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent);
 
-    if (valueChanged)
-        updateInnerTextValue();
+    if (!valueChanged)
+        return;
 
+    updateInnerTextValue();
+
     unsigned max = visibleValue().length();
     if (input->focused())
         input->setSelectionRange(max, max);
@@ -142,9 +144,6 @@
     else
         input->cacheSelectionInResponseToSetValue(max);
 
-    if (!valueChanged)
-        return;
-
     switch (eventBehavior) {
     case DispatchChangeEvent:
         // If the user is still editing this field, dispatch an input event rather than a change event.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to