Title: [290635] trunk
- Revision
- 290635
- Author
- [email protected]
- Date
- 2022-03-01 01:01:13 -0800 (Tue, 01 Mar 2022)
Log Message
[Selection] Selection Range should be clamped by the current value length
https://bugs.webkit.org/show_bug.cgi?id=237210
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Update the test expectations as some sub-tests are now passing.
* web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt:
Source/WebCore:
As per https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#set-the-selection-range,
if start or end "is greater than the length of the relevant value of the text control, then set it to
the length of the relevant value of the text control".
This CL makes selection range clamp to the current value length.
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setSelectionRange):
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290634 => 290635)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-01 08:55:07 UTC (rev 290634)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-03-01 09:01:13 UTC (rev 290635)
@@ -1,3 +1,13 @@
+2022-03-01 Ziran Sun <[email protected]>
+
+ [Selection] Selection Range should be clamped by the current value length
+ https://bugs.webkit.org/show_bug.cgi?id=237210
+
+ Reviewed by Darin Adler.
+
+ Update the test expectations as some sub-tests are now passing.
+ * web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt:
+
2022-02-28 Antoine Quint <[email protected]>
[web-animations] web-animations/interfaces/Animatable/getAnimations.html is a unique failure
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt (290634 => 290635)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt 2022-03-01 08:55:07 UTC (rev 290634)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/textfieldselection/selection-start-end-expected.txt 2022-03-01 09:01:13 UTC (rev 290635)
@@ -42,8 +42,8 @@
PASS Setting selectionEnd to a value smaller than selectionStart should decrease selectionStart
FAIL selectionStart edge-case values assert_equals: selectionStart setter on input-appended should convert -1 to 2^32-1 expected 10 but got 0
FAIL selectionEnd edge-case values assert_equals: selectionEnd setter on input-appended should convert -1 to 2^32-1 expected 10 but got 0
-FAIL selectionStart should be clamped by the current value length assert_equals: expected 10 but got 200
-FAIL selectionEnd should be clamped by the current value length assert_equals: expected 10 but got 300
-FAIL setSelectionRange should be clamped by the current value length assert_equals: expected 10 but got 200
+PASS selectionStart should be clamped by the current value length
+PASS selectionEnd should be clamped by the current value length
+PASS setSelectionRange should be clamped by the current value length
PASS selectionStart and selectionEnd should remain the same when selectionDirection is changed
Modified: trunk/Source/WebCore/ChangeLog (290634 => 290635)
--- trunk/Source/WebCore/ChangeLog 2022-03-01 08:55:07 UTC (rev 290634)
+++ trunk/Source/WebCore/ChangeLog 2022-03-01 09:01:13 UTC (rev 290635)
@@ -1,3 +1,19 @@
+2022-03-01 Ziran Sun <[email protected]>
+
+ [Selection] Selection Range should be clamped by the current value length
+ https://bugs.webkit.org/show_bug.cgi?id=237210
+
+ Reviewed by Darin Adler.
+
+ As per https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#set-the-selection-range,
+ if start or end "is greater than the length of the relevant value of the text control, then set it to
+ the length of the relevant value of the text control".
+
+ This CL makes selection range clamp to the current value length.
+
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::HTMLTextFormControlElement::setSelectionRange):
+
2022-03-01 Matt Woodrow <[email protected]>
Handle perpendicular containing blocks when computing available logical height.
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (290634 => 290635)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-03-01 08:55:07 UTC (rev 290634)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2022-03-01 09:01:13 UTC (rev 290635)
@@ -306,8 +306,9 @@
if (!isTextField())
return;
- end = std::max(end, 0);
- start = std::min(std::max(start, 0), end);
+ // Clamps to the current value length.
+ end = std::clamp(end, 0, clampTo<int>(innerTextValue().length()));
+ start = std::clamp(start, 0, end);
auto innerText = innerTextElement();
bool hasFocus = document().focusedElement() == this;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes