Title: [291396] trunk
Revision
291396
Author
[email protected]
Date
2022-03-17 02:19:29 -0700 (Thu, 17 Mar 2022)

Log Message

[Selection] Fixes selection range settings for TEXTAREA
https://bugs.webkit.org/show_bug.cgi?id=237641

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Updating test expectations as some sub-tests are now passing.
* web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-extra-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt:
* web-platform-tests/html/semantics/forms/textfieldselection/textarea-selection-while-parsing-expected.txt:

Source/WebCore:

This CL is to fix the settings of SelectionStart/SelectionEnd for TEXTAREA for non-focused Element. It sets the
caret to the end of the text value except for initializing in most cases. For the case of updating defaultValue
for a non-dirty TEXTAREA, we should following the clamping steps as per spec and it will be addressed in a
follow-up patch.

This CL refers and imports part of the changes in chromium CL at
https://codereview.chromium.org/392573002

TextArea only calls setSelectionRange() for focused element. While for non-focused element, we need to update the caret
except for initializing. Since we are not change text selection for text area in this case, we only cache the selections.
It would be ideal to have a unified function call for both focused and non-focused cases. However, the selectionRange()
function changes focus of the element and the approach we are having here is to avoid the impacts on a good number of
exisiting tests.

This CL also introduces a unified setValue() API in HTMLFormControlElement for HTMLTextAreaElement and HTMLInputElement.

* html/BaseButtonInputType.cpp:
(WebCore::BaseButtonInputType::setValue):
* html/BaseButtonInputType.h:
* html/BaseCheckableInputType.cpp:
(WebCore::BaseCheckableInputType::setValue):
* html/BaseCheckableInputType.h:
* html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::setValue):
(WebCore::BaseDateAndTimeInputType::didChangeValueFromControl):
* html/BaseDateAndTimeInputType.h:
* html/ColorInputType.cpp:
(WebCore::ColorInputType::setValue):
* html/ColorInputType.h:
* html/FileInputType.cpp:
(WebCore::FileInputType::setValue):
* html/FileInputType.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setValue):
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::childrenChanged):
(WebCore::HTMLTextAreaElement::reset):
(WebCore::HTMLTextAreaElement::setValue):
(WebCore::HTMLTextAreaElement::setNonDirtyValue):
(WebCore::HTMLTextAreaElement::setValueCommon):
(WebCore::HTMLTextAreaElement::copyNonAttributePropertiesFromElement):
* html/HTMLTextAreaElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setRangeText):
* html/HTMLTextFormControlElement.h:
* html/HiddenInputType.cpp:
(WebCore::HiddenInputType::setValue):
* html/HiddenInputType.h:
* html/InputType.cpp:
(WebCore::InputType::setValue):
* html/InputType.h:
* html/NumberInputType.cpp:
(WebCore::NumberInputType::setValue):
* html/NumberInputType.h:
* html/RangeInputType.cpp:
(WebCore::RangeInputType::setValue):
* html/RangeInputType.h:
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::setValue):
* html/TextFieldInputType.h:

LayoutTests:

Updated two tests that expect resetting value of textarea to change selection to 0.
These changes are in line with changes made in Chromium.
* editing/pasteboard/paste-into-textarea-with-new-line.html:
* fast/spatial-navigation/snav-textarea.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (291395 => 291396)


--- trunk/LayoutTests/ChangeLog	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/ChangeLog	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1,3 +1,15 @@
+2022-03-17  Ziran Sun  <[email protected]>
+
+        [Selection] Fixes selection range settings for TEXTAREA
+        https://bugs.webkit.org/show_bug.cgi?id=237641
+
+        Reviewed by Chris Dumez.
+
+        Updated two tests that expect resetting value of textarea to change selection to 0.
+        These changes are in line with changes made in Chromium.
+        * editing/pasteboard/paste-into-textarea-with-new-line.html:
+        * fast/spatial-navigation/snav-textarea.html:
+
 2022-03-17  Youenn Fablet  <[email protected]>
 
         AudioContext is suspended on iOS when page is backgrounded

Modified: trunk/LayoutTests/editing/pasteboard/paste-into-textarea-with-new-line.html (291395 => 291396)


--- trunk/LayoutTests/editing/pasteboard/paste-into-textarea-with-new-line.html	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/editing/pasteboard/paste-into-textarea-with-new-line.html	2022-03-17 09:19:29 UTC (rev 291396)
@@ -11,6 +11,7 @@
 textarea.rows = 10;
 document.body.appendChild(textarea);
 textarea.focus();
+textarea.setSelectionRange(0, 0);
 shouldBe("document.execCommand('InsertHTML', false, 'first<br><br>third'); textarea.value", "'first\\n\\nthird\\n'");
 
 var successfullyParsed = true;

Modified: trunk/LayoutTests/fast/spatial-navigation/snav-textarea.html (291395 => 291396)


--- trunk/LayoutTests/fast/spatial-navigation/snav-textarea.html	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/fast/spatial-navigation/snav-textarea.html	2022-03-17 09:19:29 UTC (rev 291396)
@@ -66,7 +66,10 @@
 
       // starting the test itself: get to a known place.
       document.getElementById("start").focus();
+      textarea.focus();
+      textarea.setSelectionRange(0, 0);
 
+
       initTest(resultMap, testCompleted);
     }
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291395 => 291396)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1,3 +1,17 @@
+2022-03-17  Ziran Sun  <[email protected]>
+
+        [Selection] Fixes selection range settings for TEXTAREA
+        https://bugs.webkit.org/show_bug.cgi?id=237641
+
+        Reviewed by Chris Dumez.
+
+        Updating test expectations as some sub-tests are now passing.
+        * web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-extra-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt:
+        * web-platform-tests/html/semantics/forms/textfieldselection/textarea-selection-while-parsing-expected.txt:
+
 2022-03-16  Rob Buis  <[email protected]>
 
         Sync css/css-contain from WPT

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/defaultSelection-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -2,7 +2,7 @@
 
 PASS Default selectionStart and selectionEnd for [object HTMLTextAreaElement]
 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 selectionStart and selectionEnd change when value changed to upper case for [object HTMLTextAreaElement]
 PASS Default selectionStart and selectionEnd for [object HTMLInputElement]
 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-start-end-expected.txt (291395 => 291396)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -6,18 +6,18 @@
 PASS Initial .value set on input-not-appended should set selectionStart to end of value
 PASS Initial .value set on input-appended-prefocused should set selectionStart to end of value
 PASS Initial .value set on input-not-appended-prefocused should set selectionStart to end of value
-FAIL Initial .value set on textarea-appended should set selectionStart to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-not-appended should set selectionStart to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-appended-prefocused should set selectionStart to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-not-appended-prefocused should set selectionStart to end of value assert_equals: expected 10 but got 0
+PASS Initial .value set on textarea-appended should set selectionStart to end of value
+PASS Initial .value set on textarea-not-appended should set selectionStart to end of value
+PASS Initial .value set on textarea-appended-prefocused should set selectionStart to end of value
+PASS Initial .value set on textarea-not-appended-prefocused should set selectionStart to end of value
 PASS Initial .value set on input-appended should set selectionEnd to end of value
 PASS Initial .value set on input-not-appended should set selectionEnd to end of value
 PASS Initial .value set on input-appended-prefocused should set selectionEnd to end of value
 PASS Initial .value set on input-not-appended-prefocused should set selectionEnd to end of value
-FAIL Initial .value set on textarea-appended should set selectionEnd to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-not-appended should set selectionEnd to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-appended-prefocused should set selectionEnd to end of value assert_equals: expected 10 but got 0
-FAIL Initial .value set on textarea-not-appended-prefocused should set selectionEnd to end of value assert_equals: expected 10 but got 0
+PASS Initial .value set on textarea-appended should set selectionEnd to end of value
+PASS Initial .value set on textarea-not-appended should set selectionEnd to end of value
+PASS Initial .value set on textarea-appended-prefocused should set selectionEnd to end of value
+PASS Initial .value set on textarea-not-appended-prefocused should set selectionEnd to end of value
 PASS onselect should fire when selectionStart is changed
 NOTRUN onselect should fire when selectionStart is changed on input-appended
 NOTRUN onselect should fire when selectionStart is changed on input-not-appended

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-extra-expected.txt (291395 => 291396)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-extra-expected.txt	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-extra-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1,12 +1,12 @@
 
 PASS Setting defaultValue in a textarea should NOT move the cursor to the end
-FAIL Setting defaultValue in a textarea with a value should NOT make any difference assert_equals: expected 6 but got 0
+PASS Setting defaultValue in a textarea with a value should NOT make any difference
 PASS Setting textContent in a textarea should NOT move selection{Start,End} to the end
 PASS Adding children to a textarea should NOT move selection{Start,End} to the end
 PASS Removing children from a textarea should NOT update selection{Start,End}
 PASS Setting the same value (with different newlines) in a textarea should NOT update selection{Start,End}
 FAIL Removing child nodes in non-dirty textarea should make selection{Start,End} 0 assert_equals: selectionStart after node removal expected 0 but got 3
-FAIL Setting value to a shorter string than defaultValue should correct the cursor position assert_equals: expected 2 but got 3
+PASS Setting value to a shorter string than defaultValue should correct the cursor position
 PASS Shortening value by turning the input type into 'url' should correct selection{Start,End}
 FAIL Shortening value by turning the input type into 'color' and back to 'text' should correct selection{Start,End} assert_equals: expected 0 but got 9
 PASS Resetting a value to a shorter string than defaultValue should correct the cursor position

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-value-interactions-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -11,6 +11,6 @@
 PASS value dirty flag behavior after setRangeText on focused then blurred input
 PASS selection is collapsed to the end after changing values on input
 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 collapsed to the end after changing values on textarea
 PASS selection is not collapsed to the end when value is set to its existing value on textarea
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/textarea-selection-while-parsing-expected.txt (291395 => 291396)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/textarea-selection-while-parsing-expected.txt	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/textarea-selection-while-parsing-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1,4 +1,4 @@
 
 
-FAIL Value setter while parsing textarea children should move selection{Start,End} to the end assert_equals: expected 3 but got 0
+PASS Value setter while parsing textarea children should move selection{Start,End} to the end
 

Added: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt (0 => 291396)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -0,0 +1,21 @@
+
+
+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
+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
+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
+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
+PASS textarea out of document: selection must change when setting a different value
+PASS textarea out of document: selection must not change when setting the same normalized value
+PASS textarea in document: selection must not change when setting the same value
+PASS textarea in document: selection must change when setting a different value
+PASS textarea in document: selection must not change when setting the same normalized value
+PASS textarea in document, with focus: selection must not change when setting the same value
+PASS textarea in document, with focus: selection must change when setting a different value
+PASS textarea in document, with focus: selection must not change when setting the same normalized value
+

Added: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt (0 => 291396)


--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -0,0 +1,21 @@
+
+
+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
+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
+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
+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
+PASS textarea out of document: selection must change when setting a different value
+PASS textarea out of document: selection must not change when setting the same normalized value
+PASS textarea in document: selection must not change when setting the same value
+PASS textarea in document: selection must change when setting a different value
+PASS textarea in document: selection must not change when setting the same normalized value
+PASS textarea in document, with focus: selection must not change when setting the same value
+PASS textarea in document, with focus: selection must change when setting a different value
+PASS textarea in document, with focus: selection must not change when setting the same normalized value
+

Added: trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt (0 => 291396)


--- trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-after-content-change-expected.txt	2022-03-17 09:19:29 UTC (rev 291396)
@@ -0,0 +1,21 @@
+
+
+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
+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
+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
+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
+PASS textarea out of document: selection must change when setting a different value
+PASS textarea out of document: selection must not change when setting the same normalized value
+PASS textarea in document: selection must not change when setting the same value
+PASS textarea in document: selection must change when setting a different value
+PASS textarea in document: selection must not change when setting the same normalized value
+PASS textarea in document, with focus: selection must not change when setting the same value
+PASS textarea in document, with focus: selection must change when setting a different value
+PASS textarea in document, with focus: selection must not change when setting the same normalized value
+

Modified: trunk/Source/WebCore/ChangeLog (291395 => 291396)


--- trunk/Source/WebCore/ChangeLog	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/ChangeLog	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1,3 +1,72 @@
+2022-03-17  Ziran Sun  <[email protected]>
+
+        [Selection] Fixes selection range settings for TEXTAREA
+        https://bugs.webkit.org/show_bug.cgi?id=237641
+
+        Reviewed by Chris Dumez.
+
+        This CL is to fix the settings of SelectionStart/SelectionEnd for TEXTAREA for non-focused Element. It sets the
+        caret to the end of the text value except for initializing in most cases. For the case of updating defaultValue
+        for a non-dirty TEXTAREA, we should following the clamping steps as per spec and it will be addressed in a 
+        follow-up patch.        
+
+        This CL refers and imports part of the changes in chromium CL at
+        https://codereview.chromium.org/392573002
+
+        TextArea only calls setSelectionRange() for focused element. While for non-focused element, we need to update the caret
+        except for initializing. Since we are not change text selection for text area in this case, we only cache the selections.
+        It would be ideal to have a unified function call for both focused and non-focused cases. However, the selectionRange()
+        function changes focus of the element and the approach we are having here is to avoid the impacts on a good number of
+        exisiting tests.
+
+        This CL also introduces a unified setValue() API in HTMLFormControlElement for HTMLTextAreaElement and HTMLInputElement.
+
+        * html/BaseButtonInputType.cpp:
+        (WebCore::BaseButtonInputType::setValue):
+        * html/BaseButtonInputType.h:
+        * html/BaseCheckableInputType.cpp:
+        (WebCore::BaseCheckableInputType::setValue):
+        * html/BaseCheckableInputType.h:
+        * html/BaseDateAndTimeInputType.cpp:
+        (WebCore::BaseDateAndTimeInputType::setValue):
+        (WebCore::BaseDateAndTimeInputType::didChangeValueFromControl):
+        * html/BaseDateAndTimeInputType.h:
+        * html/ColorInputType.cpp:
+        (WebCore::ColorInputType::setValue):
+        * html/ColorInputType.h:
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::setValue):
+        * html/FileInputType.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setValue):
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::childrenChanged):
+        (WebCore::HTMLTextAreaElement::reset):
+        (WebCore::HTMLTextAreaElement::setValue):
+        (WebCore::HTMLTextAreaElement::setNonDirtyValue):
+        (WebCore::HTMLTextAreaElement::setValueCommon):
+        (WebCore::HTMLTextAreaElement::copyNonAttributePropertiesFromElement):
+        * html/HTMLTextAreaElement.h:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setRangeText):
+        * html/HTMLTextFormControlElement.h:
+        * html/HiddenInputType.cpp:
+        (WebCore::HiddenInputType::setValue):
+        * html/HiddenInputType.h:
+        * html/InputType.cpp:
+        (WebCore::InputType::setValue):
+        * html/InputType.h:
+        * html/NumberInputType.cpp:
+        (WebCore::NumberInputType::setValue):
+        * html/NumberInputType.h:
+        * html/RangeInputType.cpp:
+        (WebCore::RangeInputType::setValue):
+        * html/RangeInputType.h:
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::setValue):
+        * html/TextFieldInputType.h:
+
 2022-03-17  Antoine Quint  <[email protected]>
 
         [model] some tests under model-element crash on Big Sur bots

Modified: trunk/Source/WebCore/html/BaseButtonInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/BaseButtonInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseButtonInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -62,7 +62,7 @@
     return false;
 }
 
-void BaseButtonInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior)
+void BaseButtonInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior, TextControlSetValueSelection)
 {
     ASSERT(element());
     element()->setAttributeWithoutSynchronization(valueAttr, sanitizedValue);

Modified: trunk/Source/WebCore/html/BaseButtonInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/BaseButtonInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseButtonInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -44,7 +44,7 @@
     bool appendFormData(DOMFormData&) const override;
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) override;
     bool storesValueSeparateFromAttribute() override;
-    void setValue(const String&, bool, TextFieldEventBehavior) override;
+    void setValue(const String&, bool, TextFieldEventBehavior, TextControlSetValueSelection) override;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -108,7 +108,7 @@
     return false;
 }
 
-void BaseCheckableInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior)
+void BaseCheckableInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior, TextControlSetValueSelection)
 {
     ASSERT(element());
     element()->setAttributeWithoutSynchronization(valueAttr, sanitizedValue);

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/BaseCheckableInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -50,7 +50,7 @@
     bool accessKeyAction(bool sendMouseEvents) override;
     String fallbackValue() const override;
     bool storesValueSeparateFromAttribute() override;
-    void setValue(const String&, bool, TextFieldEventBehavior) override;
+    void setValue(const String&, bool, TextFieldEventBehavior, TextControlSetValueSelection) override;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -277,9 +277,9 @@
         || !stepRange.step().remainder(msecPerSecond).isZero();
 }
 
-void BaseDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void BaseDateAndTimeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
-    InputType::setValue(value, valueChanged, eventBehavior);
+    InputType::setValue(value, valueChanged, eventBehavior, selection);
     if (valueChanged)
         updateInnerTextValue();
 }
@@ -470,7 +470,7 @@
 void BaseDateAndTimeInputType::didChangeValueFromControl()
 {
     String value = sanitizeValue(m_dateTimeEditElement->value());
-    InputType::setValue(value, value != element()->value(), DispatchInputAndChangeEvent);
+    InputType::setValue(value, value != element()->value(), DispatchInputAndChangeEvent, DoNotSet);
 
     DateTimeChooserParameters parameters;
     if (!setupDateTimeChooserParameters(parameters))

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -101,7 +101,7 @@
     // InputType functions:
     String visibleValue() const final;
     String sanitizeValue(const String&) const override;
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
     WallTime valueAsDate() const override;
     ExceptionOr<void> setValueAsDate(WallTime) const override;
     double valueAsDouble() const final;

Modified: trunk/Source/WebCore/html/ColorInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/ColorInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/ColorInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -153,9 +153,9 @@
     updateColorSwatch();
 }
 
-void ColorInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void ColorInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
-    InputType::setValue(value, valueChanged, eventBehavior);
+    InputType::setValue(value, valueChanged, eventBehavior, selection);
 
     if (!valueChanged)
         return;

Modified: trunk/Source/WebCore/html/ColorInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/ColorInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/ColorInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -63,7 +63,7 @@
     String fallbackValue() const final;
     String sanitizeValue(const String&) const final;
     void createShadowSubtree() final;
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
     void attributeChanged(const QualifiedName&) final;
     void handleDOMActivateEvent(Event&) final;
     void detach() final;

Modified: trunk/Source/WebCore/html/FileInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/FileInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -253,7 +253,7 @@
     return true;
 }
 
-void FileInputType::setValue(const String&, bool, TextFieldEventBehavior)
+void FileInputType::setValue(const String&, bool, TextFieldEventBehavior, TextControlSetValueSelection)
 {
     // FIXME: Should we clear the file list, or replace it with a new empty one here? This is observable from _javascript_ through custom properties.
     m_fileList->clear();

Modified: trunk/Source/WebCore/html/FileInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/FileInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/FileInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -69,7 +69,7 @@
     String displayString() const final;
     bool canSetValue(const String&) final;
     bool getTypeSpecificValue(String&) final; // Checked first, before internal storage or the value attribute.
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
 
 #if ENABLE(DRAG_SUPPORT)
     bool receiveDroppedFilesWithImageTranscoding(const Vector<String>& paths);

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -1064,7 +1064,7 @@
     setValue(value, DispatchChangeEvent);
 }
 
-ExceptionOr<void> HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior)
+ExceptionOr<void> HTMLInputElement::setValue(const String& value, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
     if (isFileUpload() && !value.isEmpty())
         return Exception { InvalidStateError };
@@ -1079,7 +1079,7 @@
 
     setLastChangeWasNotUserEdit();
     setFormControlValueMatchesRenderer(false);
-    m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior);
+    m_inputType->setValue(sanitizedValue, valueChanged, eventBehavior, selection);
 
     bool wasModifiedProgrammatically = eventBehavior == DispatchNoEvent;
     if (wasModifiedProgrammatically)

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -171,7 +171,7 @@
     WEBCORE_EXPORT void setType(const AtomString&);
 
     WEBCORE_EXPORT String value() const final;
-    WEBCORE_EXPORT ExceptionOr<void> setValue(const String&, TextFieldEventBehavior = DispatchNoEvent);
+    WEBCORE_EXPORT ExceptionOr<void> setValue(const String&, TextFieldEventBehavior = DispatchNoEvent, TextControlSetValueSelection = TextControlSetValueSelection::SetSelectionToEnd) final;
     WEBCORE_EXPORT void setValueForUser(const String&);
     // Checks if the specified string would be a valid value.
     // We should not call this for types with no string value such as CHECKBOX and RADIO.

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -136,7 +136,7 @@
     if (m_isDirty)
         setInnerTextValue(value());
     else
-        setNonDirtyValue(defaultValue());
+        setNonDirtyValue(defaultValue(),  TextControlSetValueSelection::DoNotSet);
 }
 
 bool HTMLTextAreaElement::hasPresentationalHintsForAttribute(const QualifiedName& name) const
@@ -241,7 +241,7 @@
 
 void HTMLTextAreaElement::reset()
 {
-    setNonDirtyValue(defaultValue());
+    setNonDirtyValue(defaultValue(), TextControlSetValueSelection::SetSelectionToEnd);
 }
 
 bool HTMLTextAreaElement::hasCustomFocusLogic() const
@@ -374,21 +374,22 @@
     return m_value;
 }
 
-void HTMLTextAreaElement::setValue(const String& value)
+ExceptionOr<void> HTMLTextAreaElement::setValue(const String& value, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
-    setValueCommon(value);
+    setValueCommon(value, eventBehavior, selection);
     m_isDirty = true;
     updateValidity();
+    return { };
 }
 
-void HTMLTextAreaElement::setNonDirtyValue(const String& value)
+void HTMLTextAreaElement::setNonDirtyValue(const String& value, TextControlSetValueSelection selection)
 {
-    setValueCommon(value);
+    setValueCommon(value, TextFieldEventBehavior::DispatchNoEvent, selection);
     m_isDirty = false;
     updateValidity();
 }
 
-void HTMLTextAreaElement::setValueCommon(const String& newValue)
+void HTMLTextAreaElement::setValueCommon(const String& newValue, TextFieldEventBehavior, TextControlSetValueSelection selection)
 {
     m_wasModifiedByUser = false;
     // Code elsewhere normalizes line endings added by the user via the keyboard or pasting.
@@ -409,10 +410,14 @@
     invalidateStyleForSubtree();
     setFormControlValueMatchesRenderer(true);
 
-    // Set the caret to the end of the text value.
     if (document().focusedElement() == this) {
         unsigned endOfString = m_value.length();
         setSelectionRange(endOfString, endOfString);
+    }  else if (selection == TextControlSetValueSelection::SetSelectionToEnd) {
+        // We don't change text selection here but need to update caret to
+        // the end of the text value except for initialize.
+        unsigned endOfString = m_value.length();
+        cacheSelection(endOfString, endOfString, SelectionHasNoDirection);
     }
 
     setTextAsOfLastFormControlChangeEvent(normalizedValue);
@@ -576,7 +581,7 @@
 {
     auto& sourceElement = downcast<HTMLTextAreaElement>(source);
 
-    setValueCommon(sourceElement.value());
+    setValueCommon(sourceElement.value(), DispatchNoEvent, TextControlSetValueSelection::SetSelectionToEnd);
     m_isDirty = sourceElement.m_isDirty;
     HTMLTextFormControlElement::copyNonAttributePropertiesFromElement(source);
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -44,7 +44,7 @@
     bool shouldWrapText() const { return m_wrap != NoWrap; }
 
     WEBCORE_EXPORT String value() const final;
-    WEBCORE_EXPORT void setValue(const String&);
+    WEBCORE_EXPORT ExceptionOr<void> setValue(const String&, TextFieldEventBehavior = DispatchNoEvent, TextControlSetValueSelection = TextControlSetValueSelection::SetSelectionToEnd) final;
     WEBCORE_EXPORT String defaultValue() const;
     WEBCORE_EXPORT void setDefaultValue(const String&);
     int textLength() const { return value().length(); }
@@ -83,8 +83,8 @@
     void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent&) const;
     static String sanitizeUserInputValue(const String&, unsigned maxLength);
     void updateValue() const;
-    void setNonDirtyValue(const String&);
-    void setValueCommon(const String&);
+    void setNonDirtyValue(const String&, TextControlSetValueSelection);
+    void setValueCommon(const String&, TextFieldEventBehavior, TextControlSetValueSelection);
 
     bool supportsPlaceholder() const final { return true; }
     HTMLElement* placeholderElement() const final;

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -254,8 +254,6 @@
     else
         text.insert(replacement, start);
 
-    setInnerTextValue(text);
-
     // FIXME: This shouldn't need synchronous style update, or renderer at all.
     if (!renderer())
         document().updateStyleIfNeeded();
@@ -263,7 +261,7 @@
     if (!renderer())
         return { };
 
-    subtreeHasChanged();
+    setValue(text, TextFieldEventBehavior::DispatchNoEvent, TextControlSetValueSelection::DoNotSet);
 
     if (equalLettersIgnoringASCIICase(selectionMode, "select")) {
         newSelectionStart = start;
@@ -314,6 +312,10 @@
 
     auto innerText = innerTextElementCreatingShadowSubtreeIfNeeded();
     bool hasFocus = document().focusedElement() == this;
+
+    RefPtr frame = document().frame();
+    if (direction == SelectionHasNoDirection && frame && frame->editor().behavior().shouldConsiderSelectionAsDirectional())
+        direction = SelectionHasForwardDirection;
     if (!hasFocus && innerText) {
         if (!isConnected()) {
             cacheSelection(start, end, direction);

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (291395 => 291396)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -39,6 +39,7 @@
 enum class AutoFillButtonType : uint8_t { None, Credentials, Contacts, StrongPassword, CreditCard };
 enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardDirection, SelectionHasBackwardDirection };
 enum TextFieldEventBehavior { DispatchNoEvent, DispatchChangeEvent, DispatchInputAndChangeEvent };
+enum TextControlSetValueSelection { SetSelectionToEnd, DoNotSet };
 
 class HTMLTextFormControlElement : public HTMLFormControlElementWithState {
     WTF_MAKE_ISO_ALLOCATED(HTMLTextFormControlElement);
@@ -88,6 +89,7 @@
 
     virtual String value() const = 0;
 
+    virtual ExceptionOr<void> setValue(const String&, TextFieldEventBehavior = DispatchNoEvent, TextControlSetValueSelection = TextControlSetValueSelection::SetSelectionToEnd) = 0;
     virtual RefPtr<TextControlInnerTextElement> innerTextElement() const = 0;
     virtual RefPtr<TextControlInnerTextElement> innerTextElementCreatingShadowSubtreeIfNeeded() = 0;
     virtual RenderStyle createInnerTextStyle(const RenderStyle&) = 0;

Modified: trunk/Source/WebCore/html/HiddenInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/HiddenInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HiddenInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -83,7 +83,7 @@
     return false;
 }
 
-void HiddenInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior)
+void HiddenInputType::setValue(const String& sanitizedValue, bool, TextFieldEventBehavior, TextControlSetValueSelection)
 {
     ASSERT(element());
     element()->setAttributeWithoutSynchronization(valueAttr, sanitizedValue);

Modified: trunk/Source/WebCore/html/HiddenInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/HiddenInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/HiddenInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -48,7 +48,7 @@
     bool rendererIsNeeded() override;
     bool storesValueSeparateFromAttribute() override;
     bool shouldRespectHeightAndWidthAttributes() override;
-    void setValue(const String&, bool, TextFieldEventBehavior) override;
+    void setValue(const String&, bool, TextFieldEventBehavior, TextControlSetValueSelection) override;
     bool appendFormData(DOMFormData&) const override;
 };
 

Modified: trunk/Source/WebCore/html/InputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/InputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/InputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -721,7 +721,7 @@
     return true;
 }
 
-void InputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void InputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection)
 {
     ASSERT(element());
     element()->setValueInternal(sanitizedValue, eventBehavior);

Modified: trunk/Source/WebCore/html/InputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/InputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/InputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -341,7 +341,7 @@
     virtual bool shouldSendChangeEventAfterCheckedChanged();
     virtual bool canSetValue(const String&);
     virtual bool storesValueSeparateFromAttribute();
-    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior);
+    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection);
     virtual bool shouldResetOnDocumentActivation();
     virtual bool shouldRespectListAttribute();
     virtual bool shouldRespectHeightAndWidthAttributes();

Modified: trunk/Source/WebCore/html/NumberInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/NumberInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/NumberInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -94,12 +94,12 @@
     return InputTypeNames::number();
 }
 
-void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void NumberInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
     ASSERT(element());
     if (!valueChanged && sanitizedValue.isEmpty() && !element()->innerTextValue().isEmpty())
         updateInnerTextValue();
-    TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior);
+    TextFieldInputType::setValue(sanitizedValue, valueChanged, eventBehavior, selection);
 }
 
 double NumberInputType::valueAsDouble() const

Modified: trunk/Source/WebCore/html/NumberInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/NumberInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/NumberInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -42,7 +42,7 @@
 
 private:
     const AtomString& formControlType() const final;
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
     double valueAsDouble() const final;
     ExceptionOr<void> setValueAsDouble(double, TextFieldEventBehavior) const final;
     ExceptionOr<void> setValueAsDecimal(const Decimal&, TextFieldEventBehavior) const final;

Modified: trunk/Source/WebCore/html/RangeInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/RangeInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/RangeInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -345,9 +345,9 @@
     InputType::attributeChanged(name);
 }
 
-void RangeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void RangeInputType::setValue(const String& value, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
-    InputType::setValue(value, valueChanged, eventBehavior);
+    InputType::setValue(value, valueChanged, eventBehavior, selection);
 
     if (!valueChanged)
         return;

Modified: trunk/Source/WebCore/html/RangeInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/RangeInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/RangeInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -57,7 +57,7 @@
     String serialize(const Decimal&) const final;
     bool accessKeyAction(bool sendMouseEvents) final;
     void attributeChanged(const QualifiedName&) final;
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) final;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
     String fallbackValue() const final;
     String sanitizeValue(const String& proposedValue) const final;
     bool shouldRespectListAttribute() final;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (291395 => 291396)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-03-17 09:19:29 UTC (rev 291396)
@@ -127,7 +127,7 @@
     return !element()->isDisabledOrReadOnly() && element()->isRequired() && value.isEmpty();
 }
 
-void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
+void TextFieldInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
 {
     ASSERT(element());
 
@@ -137,7 +137,7 @@
 
     // We don't ask InputType::setValue to dispatch events because
     // TextFieldInputType dispatches events different way from InputType.
-    InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent);
+    InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent, selection);
 
     if (!valueChanged)
         return;
@@ -144,11 +144,13 @@
 
     updateInnerTextValue();
 
-    unsigned max = visibleValue().length();
-    if (input->focused())
-        input->setSelectionRange(max, max);
-    else
-        input->cacheSelectionInResponseToSetValue(max);
+    if (selection == TextControlSetValueSelection::SetSelectionToEnd) {
+        auto max = visibleValue().length();
+        if (input->focused())
+            input->setSelectionRange(max, max);
+        else
+            input->cacheSelectionInResponseToSetValue(max);
+    }
 
     switch (eventBehavior) {
     case DispatchChangeEvent:

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (291395 => 291396)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2022-03-17 09:01:18 UTC (rev 291395)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2022-03-17 09:19:29 UTC (rev 291396)
@@ -78,7 +78,7 @@
     bool supportsReadOnly() const final;
     void handleFocusEvent(Node* oldFocusedNode, FocusDirection) final;
     void handleBlurEvent() final;
-    void setValue(const String&, bool valueChanged, TextFieldEventBehavior) override;
+    void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) override;
     void updateInnerTextValue() final;
     String sanitizeValue(const String&) const override;
     bool valueMissing(const String&) const final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to