[Extra zoom mode] Add basic support for <input type='date'> using date picker UI
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Feb 2018 14:35:49 +0000 (14:35 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Feb 2018 14:35:49 +0000 (14:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182847
<rdar://problem/35143111>

Reviewed by Tim Horton.

Source/WebCore:

Add new localized strings for "month", "day" and "year" as they appear in the date picker.

* English.lproj/Localizable.strings:
* platform/LocalizedStrings.cpp:
(WebCore::textInputModeWriteButtonTitle):
(WebCore::textInputModeSpeechButtonTitle):
(WebCore::datePickerDayLabelTitle):
(WebCore::datePickerMonthLabelTitle):
(WebCore::datePickerYearLabelTitle):
(WebCore::textInputModeWriteButton): Deleted.
(WebCore::textInputModeSpeechButton): Deleted.
* platform/LocalizedStrings.h:

Source/WebKit:

Add support for presenting date pickers when focusing a date input.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _stopAssistingNode]):
(-[WKContentView dismissAllInputViewControllers]):

Pull logic to dismiss input view controllers into a single helper.

(-[WKContentView presentDatePickerViewController:]):
(-[WKContentView dismissDatePickerViewController:]):
(-[WKContentView presentViewControllerForAssistedNode:]):
(-[WKContentView textInputController:didCommitText:]):
(-[WKContentView _wheelChangedWithEvent:]):

Delegate wheel events to the date picker.

* UIProcess/ios/forms/WKDatePickerViewController.h: Added.
* UIProcess/ios/forms/WKDatePickerViewController.mm: Added.

Add harness files for the WKDatePickerViewController implementation in WebKitAdditions.

* WebKit.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228557 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index e701cad..c2af361 100644 (file)
@@ -1,3 +1,24 @@
+2018-02-16  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] Add basic support for <input type='date'> using date picker UI
+        https://bugs.webkit.org/show_bug.cgi?id=182847
+        <rdar://problem/35143111>
+
+        Reviewed by Tim Horton.
+
+        Add new localized strings for "month", "day" and "year" as they appear in the date picker.
+
+        * English.lproj/Localizable.strings:
+        * platform/LocalizedStrings.cpp:
+        (WebCore::textInputModeWriteButtonTitle):
+        (WebCore::textInputModeSpeechButtonTitle):
+        (WebCore::datePickerDayLabelTitle):
+        (WebCore::datePickerMonthLabelTitle):
+        (WebCore::datePickerYearLabelTitle):
+        (WebCore::textInputModeWriteButton): Deleted.
+        (WebCore::textInputModeSpeechButton): Deleted.
+        * platform/LocalizedStrings.h:
+
 2018-02-16  Zan Dobersek  <zdobersek@igalia.com>
 
         HarfBuzzFace should operate with a FontPlatformData reference
index eb41473..e6e3ef1 100644 (file)
 /* Undo action name */
 "Cut (Undo action name)" = "Cut";
 
+/* Day label in date picker */
+"Day label in date picker" = "Day";
+
 /* Default writing direction context menu item */
 "Default" = "Default";
 
 /* Label text to be used when a plugin is missing */
 "Missing Plug-in" = "Missing Plug-in";
 
+/* Month label in date picker */
+"Month label in date picker" = "Month";
+
 /* Media Mute context menu item */
 "Mute" = "Mute";
 
 /* Title of the writing button for zoomed form controls. */
 "Write" = "Write";
 
+/* Year label in date picker */
+"Year label in date picker" = "Year";
+
 /* message in authentication panel */
 "Your login information will be sent securely." = "Your login information will be sent securely.";
 
index 0f9f698..ee9317b 100644 (file)
@@ -1056,16 +1056,31 @@ String formControlSearchButtonTitle()
     return WEB_UI_STRING("Search", "Title of the Search button for zoomed form controls.");
 }
 
-String textInputModeWriteButton()
+String textInputModeWriteButtonTitle()
 {
     return WEB_UI_STRING("Write", "Title of the writing button for zoomed form controls.");
 }
 
-String textInputModeSpeechButton()
+String textInputModeSpeechButtonTitle()
 {
     return WEB_UI_STRING("Speak", "Title of the dictation button for zoomed form controls.");
 }
 
+String datePickerDayLabelTitle()
+{
+    return WEB_UI_STRING("Day label in date picker", "Day label in date picker");
+}
+
+String datePickerMonthLabelTitle()
+{
+    return WEB_UI_STRING("Month label in date picker", "Month label in date picker");
+}
+
+String datePickerYearLabelTitle()
+{
+    return WEB_UI_STRING("Year label in date picker", "Year label in date picker");
+}
+
 #endif
 
 } // namespace WebCore
index 0e2fb0c..3fa7d6b 100644 (file)
@@ -321,8 +321,11 @@ namespace WebCore {
     WEBCORE_EXPORT String formControlHideButtonTitle();
     WEBCORE_EXPORT String formControlGoButtonTitle();
     WEBCORE_EXPORT String formControlSearchButtonTitle();
-    WEBCORE_EXPORT String textInputModeWriteButton();
-    WEBCORE_EXPORT String textInputModeSpeechButton();
+    WEBCORE_EXPORT String textInputModeWriteButtonTitle();
+    WEBCORE_EXPORT String textInputModeSpeechButtonTitle();
+    WEBCORE_EXPORT String datePickerDayLabelTitle();
+    WEBCORE_EXPORT String datePickerMonthLabelTitle();
+    WEBCORE_EXPORT String datePickerYearLabelTitle();
 #endif
 
 #if USE(GLIB) && defined(GETTEXT_PACKAGE)
index 51348ca..af5ff90 100644 (file)
@@ -1,3 +1,35 @@
+2018-02-16  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] Add basic support for <input type='date'> using date picker UI
+        https://bugs.webkit.org/show_bug.cgi?id=182847
+        <rdar://problem/35143111>
+
+        Reviewed by Tim Horton.
+
+        Add support for presenting date pickers when focusing a date input.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _stopAssistingNode]):
+        (-[WKContentView dismissAllInputViewControllers]):
+
+        Pull logic to dismiss input view controllers into a single helper.
+
+        (-[WKContentView presentDatePickerViewController:]):
+        (-[WKContentView dismissDatePickerViewController:]):
+        (-[WKContentView presentViewControllerForAssistedNode:]):
+        (-[WKContentView textInputController:didCommitText:]):
+        (-[WKContentView _wheelChangedWithEvent:]):
+
+        Delegate wheel events to the date picker.
+
+        * UIProcess/ios/forms/WKDatePickerViewController.h: Added.
+        * UIProcess/ios/forms/WKDatePickerViewController.mm: Added.
+
+        Add harness files for the WKDatePickerViewController implementation in WebKitAdditions.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-02-15  Youenn Fablet  <youenn@apple.com>
 
         Resources loaded from service workers are not downloadable
index 047716a..4ec7ca7 100644 (file)
@@ -84,6 +84,7 @@ class WebPageProxy;
 @class _UIWebHighlightLongPressGestureRecognizer;
 
 #if ENABLE(EXTRA_ZOOM_MODE)
+@class WKDatePickerViewController;
 @class WKFocusedFormControlViewController;
 @class WKNumberPadViewController;
 @class WKSelectMenuViewController;
@@ -246,6 +247,7 @@ struct WKAutoCorrectionData {
 #endif
 
 #if ENABLE(EXTRA_ZOOM_MODE)
+    RetainPtr<WKDatePickerViewController> _datePickerViewController;
     RetainPtr<WKTextInputViewController> _textInputViewController;
     RetainPtr<WKFocusedFormControlViewController> _focusedFormControlViewController;
     RetainPtr<WKNumberPadViewController> _numberPadViewController;
index 43e93c9..29381ca 100644 (file)
@@ -40,6 +40,7 @@
 #import "TextInputSPI.h"
 #import "UIKitSPI.h"
 #import "WKActionSheetAssistant.h"
+#import "WKDatePickerViewController.h"
 #import "WKError.h"
 #import "WKFocusedFormControlViewController.h"
 #import "WKFormInputControl.h"
@@ -4088,10 +4089,7 @@ static bool isAssistableInputType(InputType type)
     [_webSelectionAssistant resignedFirstResponder];
 
 #if ENABLE(EXTRA_ZOOM_MODE)
-    [self dismissTextInputViewController:YES];
-    [self dismissNumberPadViewController:YES];
-    [self dismissSelectMenuViewController:YES];
-    [self dismissTimePickerViewController:YES];
+    [self dismissAllInputViewControllers];
     if (!_isChangingFocus)
         [self dismissFocusedFormControlViewController:[_focusedFormControlViewController isVisible]];
 #endif
@@ -4105,6 +4103,34 @@ static bool isAssistableInputType(InputType type)
 
 #if ENABLE(EXTRA_ZOOM_MODE)
 
+- (void)dismissAllInputViewControllers
+{
+    [self dismissTextInputViewController:YES];
+    [self dismissNumberPadViewController:YES];
+    [self dismissSelectMenuViewController:YES];
+    [self dismissTimePickerViewController:YES];
+    [self dismissDatePickerViewController:YES];
+}
+
+- (void)presentDatePickerViewController:(BOOL)animated
+{
+    if (_datePickerViewController)
+        return;
+
+    _datePickerViewController = adoptNS([[WKDatePickerViewController alloc] initWithText:_assistedNodeInformation.value textSuggestions:@[ ]]);
+    [_datePickerViewController setDelegate:self];
+    [_focusedFormControlViewController presentViewController:_datePickerViewController.get() animated:animated completion:nil];
+}
+
+- (void)dismissDatePickerViewController:(BOOL)animated
+{
+    if (!_datePickerViewController)
+        return;
+
+    auto datePickerViewController = WTFMove(_datePickerViewController);
+    [datePickerViewController dismissViewControllerAnimated:animated completion:nil];
+}
+
 - (void)presentTimePickerViewController:(BOOL)animated
 {
     if (_timePickerViewController)
@@ -4195,6 +4221,9 @@ static bool isAssistableInputType(InputType type)
     case InputType::Time:
         [self presentTimePickerViewController:YES];
         break;
+    case InputType::Date:
+        [self presentDatePickerViewController:YES];
+        break;
     case InputType::None:
         break;
     default:
@@ -4235,9 +4264,7 @@ static bool isAssistableInputType(InputType type)
     }
 
     [_focusedFormControlViewController show:NO];
-    [self dismissTextInputViewController:YES];
-    [self dismissNumberPadViewController:YES];
-    [self dismissTimePickerViewController:YES];
+    [self dismissAllInputViewControllers];
 }
 
 - (void)textInputControllerDidRequestDismissal:(WKTextFormControlViewController *)controller
@@ -4398,6 +4425,9 @@ static bool isAssistableInputType(InputType type)
     if ([_timePickerViewController handleWheelEvent:event])
         return;
 
+    if ([_datePickerViewController handleWheelEvent:event])
+        return;
+
     if ([_focusedFormControlViewController handleWheelEvent:event])
         return;
 #endif
diff --git a/Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.h b/Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.h
new file mode 100644 (file)
index 0000000..8e47642
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKDatePickerViewControllerAdditions.h>
+#endif
diff --git a/Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.mm b/Source/WebKit/UIProcess/ios/forms/WKDatePickerViewController.mm
new file mode 100644 (file)
index 0000000..9964e18
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WKDatePickerViewController.h"
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <WebKitAdditions/WKDatePickerViewControllerAdditions.mm>
+#endif
index 8ec5ea7..edf4a09 100644 (file)
                2E5C770E1FA7D429005932C3 /* APIAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E5C770C1FA7D429005932C3 /* APIAttachment.h */; };
                2E5C770F1FA7D429005932C3 /* APIAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E5C770D1FA7D429005932C3 /* APIAttachment.cpp */; };
                2E7A944A1BBD97C300945547 /* _WKFocusedElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2E94FC1620351A6D00974BA0 /* WKDatePickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94FC1420351A6D00974BA0 /* WKDatePickerViewController.h */; };
+               2E94FC1720351A6D00974BA0 /* WKDatePickerViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E94FC1520351A6D00974BA0 /* WKDatePickerViewController.mm */; };
                2EA7B3D12026CEF8009CE5AC /* WKNumberPadViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA7B3CF2026CEF8009CE5AC /* WKNumberPadViewController.h */; };
                2EA7B3D22026CEF8009CE5AC /* WKNumberPadViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EA7B3D02026CEF8009CE5AC /* WKNumberPadViewController.mm */; };
                2EA7B3D52026CF23009CE5AC /* WKNumberPadView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA7B3D32026CF23009CE5AC /* WKNumberPadView.h */; };
                2E5C770C1FA7D429005932C3 /* APIAttachment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIAttachment.h; sourceTree = "<group>"; };
                2E5C770D1FA7D429005932C3 /* APIAttachment.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = APIAttachment.cpp; sourceTree = "<group>"; };
                2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKFocusedElementInfo.h; sourceTree = "<group>"; };
+               2E94FC1420351A6D00974BA0 /* WKDatePickerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKDatePickerViewController.h; path = ios/forms/WKDatePickerViewController.h; sourceTree = "<group>"; };
+               2E94FC1520351A6D00974BA0 /* WKDatePickerViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKDatePickerViewController.mm; path = ios/forms/WKDatePickerViewController.mm; sourceTree = "<group>"; };
                2EA7B3CF2026CEF8009CE5AC /* WKNumberPadViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKNumberPadViewController.h; path = ios/forms/WKNumberPadViewController.h; sourceTree = "<group>"; };
                2EA7B3D02026CEF8009CE5AC /* WKNumberPadViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKNumberPadViewController.mm; path = ios/forms/WKNumberPadViewController.mm; sourceTree = "<group>"; };
                2EA7B3D32026CF23009CE5AC /* WKNumberPadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKNumberPadView.h; path = ios/forms/WKNumberPadView.h; sourceTree = "<group>"; };
                        children = (
                                C5FA1ED118E1062200B3F402 /* WKAirPlayRoutePicker.h */,
                                C5FA1ED218E1062200B3F402 /* WKAirPlayRoutePicker.mm */,
+                               2E94FC1420351A6D00974BA0 /* WKDatePickerViewController.h */,
+                               2E94FC1520351A6D00974BA0 /* WKDatePickerViewController.mm */,
                                A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */,
                                A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */,
                                2E16B6CD2017B7AC008996D6 /* WKFocusedFormControlView.h */,
                                BC4075F8124FF0270068F20A /* WKData.h in Headers */,
                                37A709A71E3EA0FD00CA5969 /* WKDataDetectorTypes.h in Headers */,
                                37A709A91E3EA40C00CA5969 /* WKDataDetectorTypesInternal.h in Headers */,
+                               2E94FC1620351A6D00974BA0 /* WKDatePickerViewController.h in Headers */,
                                377EAD4517E2C51A002D193D /* WKDeclarationSpecifiers.h in Headers */,
                                8372DB2F1A677D4A00C697C5 /* WKDiagnosticLoggingResultType.h in Headers */,
                                BC4075FA124FF0270068F20A /* WKDictionary.h in Headers */,
                                A1FB68251F6E518200C43F9F /* WKCrashReporter.mm in Sources */,
                                512F58F912A88A5400629530 /* WKCredential.cpp in Sources */,
                                BC4075F7124FF0270068F20A /* WKData.cpp in Sources */,
+                               2E94FC1720351A6D00974BA0 /* WKDatePickerViewController.mm in Sources */,
                                1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */,
                                BC4075F9124FF0270068F20A /* WKDictionary.cpp in Sources */,
                                BC017D0816260FF4007054F5 /* WKDOMDocument.mm in Sources */,