Title: [294617] trunk/Source
Revision
294617
Author
wenson_hs...@apple.com
Date
2022-05-21 16:40:13 -0700 (Sat, 21 May 2022)

Log Message

REGRESSION (r290124): Unable to insert decimal point when typing in a number text field in QQ app
https://bugs.webkit.org/show_bug.cgi?id=240761
rdar://91882650

Reviewed by Chris Dumez and Tim Horton.

After the changes in r290124, we no longer treat strings that end with a full stop (e.g. "1.") as valid floating point
numbers, per section 2.5.4.3 of the HTML spec (Real numbers), which states that a decimal number that contains a full
stop character (".") must be succeeded by one or more digit characters. The HTML spec later references this when
describing how to sanitize the value of number inputs -- namely, we return the value of the input if it's a valid
floating point number, and otherwise return the empty string.

However, the QQ app still relies on the fact that strings of the form are "<n>." are valid floating point numbers; this
is because the app installs a `keyup` event handler that asks for the input's value, removes all non-digit and non-
full-stop characters, and then sets the text field's value to this new string. Because strings ending with a period are
no longer valid floating point numbers, it's now very difficult to type decimals of the form `"N.N"` into some text
fields in the QQ app, since the input is cleared out each time the user types "." at the end of the field.

This new behavior (more or less) matches Chrome and Firefox; to maintain consistent behavior with other browsers without
breaking binary compatibility, we guard this new behavior with a linked-on-or-after check.

* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WebCore/html/parser/HTMLParserIdioms.cpp:
(WebCore::parseToDoubleForNumberType):

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

Modified Paths

Diff

Modified: trunk/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h (294616 => 294617)


--- trunk/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h	2022-05-21 23:38:33 UTC (rev 294616)
+++ trunk/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h	2022-05-21 23:40:13 UTC (rev 294617)
@@ -44,6 +44,7 @@
     DefaultsToPassiveWheelListenersOnDocument,
     DisallowsSettingAnyXHRHeaderFromFileURLs,
     DoesNotDrainTheMicrotaskQueueWhenCallingObjC,
+    DoesNotParseStringEndingWithFullStopAsFloatingPointNumber,
     DOMWindowReuseRestriction,
     DownloadDelegatesCalledOnTheMainThread,
     DropToNavigateDisallowedByDefault,

Modified: trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp (294616 => 294617)


--- trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp	2022-05-21 23:38:33 UTC (rev 294616)
+++ trunk/Source/WebCore/html/parser/HTMLParserIdioms.cpp	2022-05-21 23:40:13 UTC (rev 294617)
@@ -34,6 +34,10 @@
 #include <wtf/Vector.h>
 #include <wtf/dtoa.h>
 
+#if PLATFORM(COCOA)
+#include <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
+#endif
+
 namespace WebCore {
 
 template <typename CharType>
@@ -134,7 +138,13 @@
     if (firstCharacter != '-' && firstCharacter != '.' && !isASCIIDigit(firstCharacter))
         return fallbackValue;
 
-    if (string.endsWith('.'))
+    bool allowStringsThatEndWithFullStop = false;
+#if PLATFORM(COCOA)
+    if (!linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::DoesNotParseStringEndingWithFullStopAsFloatingPointNumber))
+        allowStringsThatEndWithFullStop = true;
+#endif
+
+    if (string.endsWith('.') && !allowStringsThatEndWithFullStop)
         return fallbackValue;
 
     bool valid = false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to