<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[281955] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/281955">281955</a></dd>
<dt>Author</dt> <dd>akeerthi@apple.com</dd>
<dt>Date</dt> <dd>2021-09-02 14:49:25 -0700 (Thu, 02 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Simplify date picker logic for datetime-local inputs
https://bugs.webkit.org/show_bug.cgi?id=229773

Reviewed by Darin Adler.

Source/WebCore:

* platform/DateComponents.cpp:

Add comments pointing to the specification for parsing date/time information.

Source/WebKit:

Currently, the date picker logic for getting/setting the value of a
datetime-local input relies on the numeric value of input. This
logic differs from logic for date, time, and month inputs, where we use
the string value of the input. This patch simplifies the code by using
string values for all the date/time input types.

* UIProcess/WebPageProxy.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
* UIProcess/ios/WebPageProxyIOS.mm:
* UIProcess/ios/forms/WKDateTimeInputControl.mm:
(-[WKDateTimePicker initWithView:datePickerMode:]):

Set the format string for datetime-local inputs, matching the spec.

(-[WKDateTimePicker _sanitizeInputValueForFormatter:]):

Sanitize datetime-local values to remove seconds and milliseconds
information. UIKit does not support anything beyond minute granularity.

(-[WKDateTimePicker dateFormatterForPicker]):
(-[WKDateTimePicker _dateChanged]):

Always use setValueAsString, matching the other date/time inputs.

Time zone conversion before sending the date back to the web process
is no longer needed.

(-[WKDateTimePicker setDateTimePickerToInitialValue]):

Time zone conversion when retrieving the date from the web process is no
longer needed.

(-[WKDateTimePicker controlBeginEditing]):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformDateComponentscpp">trunk/Source/WebCore/platform/DateComponents.cpp</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionh">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosformsWKDateTimeInputControlmm">trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebCore/ChangeLog      2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2021-09-02  Aditya Keerthi  <akeerthi@apple.com>
+
+        [iOS] Simplify date picker logic for datetime-local inputs
+        https://bugs.webkit.org/show_bug.cgi?id=229773
+
+        Reviewed by Darin Adler.
+
+        * platform/DateComponents.cpp:
+
+        Add comments pointing to the specification for parsing date/time information.
+
</ins><span class="cx"> 2021-09-02  Myles C. Maxfield  <mmaxfield@apple.com>
</span><span class="cx"> 
</span><span class="cx">         FontFaceSet.add() needs to throw when called on a CSS-connected font
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformDateComponentscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/DateComponents.cpp (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/DateComponents.cpp 2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebCore/platform/DateComponents.cpp    2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -136,6 +136,7 @@
</span><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#months
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseYear(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     unsigned digitsLength = countDigits(buffer);
</span><span class="lines">@@ -337,6 +338,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
</ins><span class="cx"> // Parses a timezone part, and adjust year, month, monthDay, hour, minute, second, millisecond.
</span><span class="cx"> template<typename CharacterType> bool DateComponents::parseTimeZone(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="lines">@@ -373,6 +375,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#months
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseMonth(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     if (!parseYear(buffer))
</span><span class="lines">@@ -394,6 +397,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseDate(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     if (!parseMonth(buffer))
</span><span class="lines">@@ -414,6 +418,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseWeek(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     if (!parseYear(buffer))
</span><span class="lines">@@ -436,6 +441,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseTime(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     auto hour = parseIntWithinLimits(buffer, 2, 0, 23);
</span><span class="lines">@@ -496,6 +502,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#local-dates-and-times
</ins><span class="cx"> template<typename CharacterType> bool DateComponents::parseDateTimeLocal(StringParsingBuffer<CharacterType>& buffer)
</span><span class="cx"> {
</span><span class="cx">     if (!parseDate(buffer))
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/ChangeLog       2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2021-09-02  Aditya Keerthi  <akeerthi@apple.com>
+
+        [iOS] Simplify date picker logic for datetime-local inputs
+        https://bugs.webkit.org/show_bug.cgi?id=229773
+
+        Reviewed by Darin Adler.
+
+        Currently, the date picker logic for getting/setting the value of a
+        datetime-local input relies on the numeric value of input. This
+        logic differs from logic for date, time, and month inputs, where we use
+        the string value of the input. This patch simplifies the code by using
+        string values for all the date/time input types.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        * UIProcess/ios/forms/WKDateTimeInputControl.mm:
+        (-[WKDateTimePicker initWithView:datePickerMode:]):
+
+        Set the format string for datetime-local inputs, matching the spec.
+
+        (-[WKDateTimePicker _sanitizeInputValueForFormatter:]):
+
+        Sanitize datetime-local values to remove seconds and milliseconds
+        information. UIKit does not support anything beyond minute granularity.
+
+        (-[WKDateTimePicker dateFormatterForPicker]):
+        (-[WKDateTimePicker _dateChanged]):
+
+        Always use setValueAsString, matching the other date/time inputs.
+
+        Time zone conversion before sending the date back to the web process
+        is no longer needed.
+
+        (-[WKDateTimePicker setDateTimePickerToInitialValue]):
+
+        Time zone conversion when retrieving the date from the web process is no
+        longer needed.
+
+        (-[WKDateTimePicker controlBeginEditing]):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+
</ins><span class="cx"> 2021-09-02  Peng Liu  <peng.liu6@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [MSE][GPUP] SourceBufferPrivateAVFObjC does not work properly when audio and video exchange their track IDs
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -840,7 +840,6 @@
</span><span class="cx">     void saveImageToLibrary(const SharedMemory::IPCHandle& imageHandle);
</span><span class="cx">     void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&& = [] { });
</span><span class="cx">     void setFocusedElementValue(const WebCore::ElementContext&, const String&);
</span><del>-    void setFocusedElementValueAsNumber(const WebCore::ElementContext&, double);
</del><span class="cx">     void setFocusedElementSelectedIndex(const WebCore::ElementContext&, uint32_t index, bool allowMultipleSelection = false);
</span><span class="cx">     void applicationDidEnterBackground();
</span><span class="cx">     void applicationDidFinishSnapshottingAfterEnteringBackground();
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h     2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h        2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -667,7 +667,6 @@
</span><span class="cx"> - (void)accessoryOpen;
</span><span class="cx"> 
</span><span class="cx"> - (void)updateFocusedElementValueAsColor:(UIColor *)value;
</span><del>-- (void)updateFocusedElementValueAsNumber:(double)value;
</del><span class="cx"> - (void)updateFocusedElementValue:(NSString *)value;
</span><span class="cx"> - (void)updateFocusedElementSelectedIndex:(uint32_t)index allowsMultipleSelection:(bool)allowsMultipleSelection;
</span><span class="cx"> - (void)updateFocusedElementFocusedWithDataListDropdown:(BOOL)value;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -4827,12 +4827,6 @@
</span><span class="cx">     _page->setIsShowingInputViewForFocusedElement(false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)updateFocusedElementValueAsNumber:(double)value
-{
-    _page->setFocusedElementValueAsNumber(_focusedElementInformation.elementContext, value);
-    _focusedElementInformation.valueAsNumber = value;
-}
-
</del><span class="cx"> - (void)updateFocusedElementValue:(NSString *)value
</span><span class="cx"> {
</span><span class="cx">     _page->setFocusedElementValue(_focusedElementInformation.elementContext, value);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm     2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm        2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -967,11 +967,6 @@
</span><span class="cx">     send(Messages::WebPage::SetFocusedElementValue(context, value));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::setFocusedElementValueAsNumber(const WebCore::ElementContext& context, double value)
-{
-    send(Messages::WebPage::SetFocusedElementValueAsNumber(context, value));
-}
-
</del><span class="cx"> void WebPageProxy::setFocusedElementSelectedIndex(const WebCore::ElementContext& context, uint32_t index, bool allowMultipleSelection)
</span><span class="cx"> {
</span><span class="cx">     send(Messages::WebPage::SetFocusedElementSelectedIndex(context, index, allowMultipleSelection));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosformsWKDateTimeInputControlmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm        2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm   2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -229,8 +229,6 @@
</span><span class="cx"> > {
</span><span class="cx">     NSString *_formatString;
</span><span class="cx">     RetainPtr<NSString> _initialValue;
</span><del>-    NSTimeInterval _initialValueAsNumber;
-    BOOL _shouldRemoveTimeZoneInformation;
</del><span class="cx">     WKContentView *_view;
</span><span class="cx">     CGPoint _interactionPoint;
</span><span class="cx">     RetainPtr<UIDatePicker> _datePicker;
</span><span class="lines">@@ -259,6 +257,7 @@
</span><span class="cx"> static NSString * const kDateFormatString = @"yyyy-MM-dd"; // "2011-01-27".
</span><span class="cx"> static NSString * const kMonthFormatString = @"yyyy-MM"; // "2011-01".
</span><span class="cx"> static NSString * const kTimeFormatString = @"HH:mm"; // "13:45".
</span><ins>+static NSString * const kDateTimeFormatString = @"yyyy-MM-dd'T'HH:mm"; // "2011-01-27T13:45"
</ins><span class="cx"> static const NSTimeInterval kMillisecondsPerSecond = 1000;
</span><span class="cx"> 
</span><span class="cx"> static const CGFloat kDateTimePickerControlMargin = 6;
</span><span class="lines">@@ -270,7 +269,6 @@
</span><span class="cx"> 
</span><span class="cx">     _view = view;
</span><span class="cx">     _interactionPoint = [_view lastInteractionLocation];
</span><del>-    _shouldRemoveTimeZoneInformation = NO;
</del><span class="cx"> 
</span><span class="cx">     switch (view.focusedElementInformation.elementType) {
</span><span class="cx">     case WebKit::InputType::Date:
</span><span class="lines">@@ -283,7 +281,7 @@
</span><span class="cx">         _formatString = kTimeFormatString;
</span><span class="cx">         break;
</span><span class="cx">     case WebKit::InputType::DateTimeLocal:
</span><del>-        _shouldRemoveTimeZoneInformation = YES;
</del><ins>+        _formatString = kDateTimeFormatString;
</ins><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="lines">@@ -553,21 +551,22 @@
</span><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (NSInteger)_timeZoneOffsetFromGMT:(NSDate *)date
</del><ins>+- (NSString *)_sanitizeInputValueForFormatter:(NSString *)value
</ins><span class="cx"> {
</span><del>-    if (!_shouldRemoveTimeZoneInformation)
-        return 0;
</del><ins>+    ASSERT([value length]);
</ins><span class="cx"> 
</span><del>-    return [[_datePicker timeZone] secondsFromGMTForDate:date];
-}
</del><ins>+    // Times may have seconds and milliseconds information which we just
+    // ignore. For example: "01:56:20.391" is shortened to just "01:56".
</ins><span class="cx"> 
</span><del>-- (NSString *)_sanitizeInputValueForFormatter:(NSString *)value
-{
-    // The "time" input type may have seconds and milliseconds information which we
-    // just ignore. For example: "01:56:20.391" is shortened to just "01:56".
</del><span class="cx">     if (_view.focusedElementInformation.elementType == WebKit::InputType::Time)
</span><span class="cx">         return [value substringToIndex:[kTimeFormatString length]];
</span><span class="cx"> 
</span><ins>+    if (_view.focusedElementInformation.elementType == WebKit::InputType::DateTimeLocal) {
+        NSString *timeString = [[value componentsSeparatedByString:@"T"] objectAtIndex:1];
+        NSString *sanitizedTimeString = [timeString substringToIndex:[kTimeFormatString length]];
+        return [value stringByReplacingOccurrencesOfString:timeString withString:sanitizedTimeString];
+    }
+
</ins><span class="cx">     return value;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -577,52 +576,27 @@
</span><span class="cx">     RetainPtr<NSDateFormatter> dateFormatter = adoptNS([[NSDateFormatter alloc] init]);
</span><span class="cx">     [dateFormatter setTimeZone:[_datePicker timeZone]];
</span><span class="cx">     [dateFormatter setDateFormat:_formatString];
</span><ins>+    // Force English locale because that is what HTML5 value parsing expects.
</ins><span class="cx">     [dateFormatter setLocale:englishLocale.get()];
</span><span class="cx">     return dateFormatter;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_dateChangedSetAsNumber
</del><ins>+- (void)_dateChanged
</ins><span class="cx"> {
</span><del>-    NSDate *date = [_datePicker date];
-    [_view updateFocusedElementValueAsNumber:(date.timeIntervalSince1970 + [self _timeZoneOffsetFromGMT:date]) * kMillisecondsPerSecond];
-}
-
-- (void)_dateChangedSetAsString
-{
-    // Force English locale because that is what HTML5 value parsing expects.
</del><span class="cx">     RetainPtr<NSDateFormatter> dateFormatter = [self dateFormatterForPicker];
</span><span class="cx">     [_view updateFocusedElementValue:[dateFormatter stringFromDate:[_datePicker date]]];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_dateChanged
-{
-    // Internally, DOMHTMLInputElement setValueAs* each take different values for
-    // different date types. It is sometimes easier to set the date in different ways:
-    //   - use setValueAsString for "date", "month", and "time".
-    //   - use setValueAsNumber for "datetime-local".
-    if (_formatString)
-        [self _dateChangedSetAsString];
-    else
-        [self _dateChangedSetAsNumber];
-}
-
</del><span class="cx"> - (void)setDateTimePickerToInitialValue
</span><span class="cx"> {
</span><del>-    if ([_initialValue isEqual: @""]) {
</del><ins>+    if (![_initialValue length]) {
</ins><span class="cx">         [_datePicker setDate:[NSDate date]];
</span><span class="cx">         [self _dateChanged];
</span><del>-    } else if (_formatString) {
-        // Convert the string value to a date object for the fields where we have a format string.
-        RetainPtr<NSDateFormatter> dateFormatter = [self dateFormatterForPicker];
-        NSDate *parsedDate = [dateFormatter dateFromString:[self _sanitizeInputValueForFormatter:_initialValue.get()]];
-        [_datePicker setDate:parsedDate ? parsedDate : [NSDate date]];
-    } else {
-        // Convert the number value to a date object for the fields affected by timezones.
-        NSTimeInterval secondsSince1970 = _initialValueAsNumber / kMillisecondsPerSecond;
-        NSInteger timeZoneOffset = [self _timeZoneOffsetFromGMT:[NSDate dateWithTimeIntervalSince1970:secondsSince1970]];
-        NSTimeInterval adjustedSecondsSince1970 = secondsSince1970 - timeZoneOffset;
-        [_datePicker setDate:[NSDate dateWithTimeIntervalSince1970:adjustedSecondsSince1970]];
</del><ins>+        return;
</ins><span class="cx">     }
</span><ins>+
+    NSDate *parsedDate = [[self dateFormatterForPicker] dateFromString:[self _sanitizeInputValueForFormatter:_initialValue.get()]];
+    [_datePicker setDate:parsedDate ? parsedDate : [NSDate date]];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (UIView *)controlView
</span><span class="lines">@@ -642,7 +616,6 @@
</span><span class="cx">     // Currently no value for the <input>. Start the picker with the current time.
</span><span class="cx">     // Also, update the actual <input> value.
</span><span class="cx">     _initialValue = _view.focusedElementInformation.value;
</span><del>-    _initialValueAsNumber = _view.focusedElementInformation.valueAsNumber;
</del><span class="cx">     [self setDateTimePickerToInitialValue];
</span><span class="cx"> 
</span><span class="cx">     [self showDateTimePicker];
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -793,7 +793,6 @@
</span><span class="cx">     void focusNextFocusedElement(bool isForward, CompletionHandler<void()>&&);
</span><span class="cx">     void autofillLoginCredentials(const String&, const String&);
</span><span class="cx">     void setFocusedElementValue(const WebCore::ElementContext&, const String&);
</span><del>-    void setFocusedElementValueAsNumber(const WebCore::ElementContext&, double);
</del><span class="cx">     void setFocusedElementSelectedIndex(const WebCore::ElementContext&, uint32_t index, bool allowMultipleSelection);
</span><span class="cx">     void setIsShowingInputViewForFocusedElement(bool);
</span><span class="cx">     bool isShowingInputViewForFocusedElement() const { return m_isShowingInputViewForFocusedElement; }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -95,7 +95,6 @@
</span><span class="cx">     FocusNextFocusedElement(bool isForward) -> () Async
</span><span class="cx">     AutofillLoginCredentials(String username, String password)
</span><span class="cx">     SetFocusedElementValue(struct WebCore::ElementContext context, String value)
</span><del>-    SetFocusedElementValueAsNumber(struct WebCore::ElementContext context, double value)
</del><span class="cx">     SetFocusedElementSelectedIndex(struct WebCore::ElementContext context, uint32_t index, bool allowMultipleSelection)
</span><span class="cx">     ApplicationWillResignActive()
</span><span class="cx">     ApplicationDidEnterBackground(bool isSuspendedUnderLock)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (281954 => 281955)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2021-09-02 21:36:34 UTC (rev 281954)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm    2021-09-02 21:49:25 UTC (rev 281955)
</span><span class="lines">@@ -1257,13 +1257,6 @@
</span><span class="cx">         downcast<HTMLInputElement>(*element).setValue(value, DispatchInputAndChangeEvent);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::setFocusedElementValueAsNumber(const WebCore::ElementContext& context, double value)
-{
-    RefPtr<Element> element = elementForContext(context);
-    if (is<HTMLInputElement>(element))
-        downcast<HTMLInputElement>(*element).setValueAsNumber(value, DispatchInputAndChangeEvent);
-}
-
</del><span class="cx"> void WebPage::setFocusedElementSelectedIndex(const WebCore::ElementContext& context, uint32_t index, bool allowMultipleSelection)
</span><span class="cx"> {
</span><span class="cx">     RefPtr<Element> element = elementForContext(context);
</span></span></pre>
</div>
</div>

</body>
</html>