Title: [294476] trunk
Revision
294476
Author
[email protected]
Date
2022-05-19 04:42:02 -0700 (Thu, 19 May 2022)

Log Message

Fix input type email visible value update.

This is an import of Chromium CL at
https://chromium-review.googlesource.com/c/chromium/src/+/3299014
For email type, when the visible value is different from the sanitized value, we need to update it.

https://bugs.webkit.org/show_bug.cgi?id=235522

Reviewed by Chris Dumez.

* LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/email-set-value-expected.txt:
* Source/WebCore/html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::setValue):

Canonical link: https://commits.webkit.org/250735@main

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/email-set-value-expected.txt (294475 => 294476)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/email-set-value-expected.txt	2022-05-19 11:37:11 UTC (rev 294475)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/email-set-value-expected.txt	2022-05-19 11:42:02 UTC (rev 294476)
@@ -1,4 +1,4 @@
 
 
-FAIL setValue(sanitizedValue) is reflected in visible text field content assert_equals: visible value is sanitized after setValue(sanitized) expected "foo@bar" but got " foo@bar   "
+PASS setValue(sanitizedValue) is reflected in visible text field content
 

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (294475 => 294476)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-05-19 11:37:11 UTC (rev 294475)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2022-05-19 11:42:02 UTC (rev 294476)
@@ -140,11 +140,14 @@
     // TextFieldInputType dispatches events different way from InputType.
     InputType::setValue(sanitizedValue, valueChanged, DispatchNoEvent, selection);
 
+    // Visible value needs update if it differs from sanitized value, if it was set with setValue().
+    // event_behavior == DispatchNoEvent usually means this call is not a user edit.
+    bool needsTextUpdate = valueChanged || (eventBehavior == TextFieldEventBehavior::DispatchNoEvent && sanitizedValue != element()->innerTextValue());
+    if (needsTextUpdate)
+        updateInnerTextValue();
     if (!valueChanged)
         return;
 
-    updateInnerTextValue();
-
     if (selection == TextControlSetValueSelection::SetSelectionToEnd) {
         auto max = visibleValue().length();
         if (input->focused())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to