Title: [228393] trunk/Source/WebKit
Revision
228393
Author
wenson_hs...@apple.com
Date
2018-02-12 14:07:10 -0800 (Mon, 12 Feb 2018)

Log Message

[Extra zoom mode] Add support for <input type='time'> using time picker UI
https://bugs.webkit.org/show_bug.cgi?id=182683
<rdar://problem/35143162>

Reviewed by Tim Horton.

Adds support for showing a time picker when an input of type time is focused in extra zoomed mode.

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

Add helpers to dismiss and present the time picker view controller.

(-[WKContentView presentViewControllerForAssistedNode:]):

When focusing InputType::Time, present a time picker. Additionally, tweak the logic here to use the generic text
input view controller as a fallback when the other input view controllers (number pads, select menus and time
pickers thus far) are not relevant. This prevents us from completely being unable to edit form controls that are
currently unsupported.

(-[WKContentView textInputController:didCommitText:]):
(-[WKContentView textInputControllerDidRequestDismissal:]):

Tweak WKContentView for changes to WKTextFormControlViewControllerDelegate.

(-[WKContentView actionNameForFocusedFormControlController:]):

Adjust this implementation to hide the focused form control "Go" button for selects and time inputs. This
currently doesn't work for these form controls because it relies on implicit form submission; this should be
fixed by future changes, after which we should revert this adjustment.

(-[WKContentView _wheelChangedWithEvent:]):

Delegate wheel events to the time picker if needed.

(-[WKContentView textInputController:didRequestDismissalWithAction:]): Deleted.

Renamed to -textInputControllerDidRequestDismissal:.

* UIProcess/ios/forms/WKTimePickerViewController.h: Added.
* UIProcess/ios/forms/WKTimePickerViewController.mm: Added.
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (228392 => 228393)


--- trunk/Source/WebKit/ChangeLog	2018-02-12 21:57:15 UTC (rev 228392)
+++ trunk/Source/WebKit/ChangeLog	2018-02-12 22:07:10 UTC (rev 228393)
@@ -1,3 +1,51 @@
+2018-02-12  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Extra zoom mode] Add support for <input type='time'> using time picker UI
+        https://bugs.webkit.org/show_bug.cgi?id=182683
+        <rdar://problem/35143162>
+
+        Reviewed by Tim Horton.
+
+        Adds support for showing a time picker when an input of type time is focused in extra zoomed mode.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _stopAssistingNode]):
+        (-[WKContentView presentTimePickerViewController:]):
+        (-[WKContentView dismissTimePickerViewController:]):
+
+        Add helpers to dismiss and present the time picker view controller.
+
+        (-[WKContentView presentViewControllerForAssistedNode:]):
+
+        When focusing InputType::Time, present a time picker. Additionally, tweak the logic here to use the generic text
+        input view controller as a fallback when the other input view controllers (number pads, select menus and time
+        pickers thus far) are not relevant. This prevents us from completely being unable to edit form controls that are
+        currently unsupported.
+
+        (-[WKContentView textInputController:didCommitText:]):
+        (-[WKContentView textInputControllerDidRequestDismissal:]):
+
+        Tweak WKContentView for changes to WKTextFormControlViewControllerDelegate.
+
+        (-[WKContentView actionNameForFocusedFormControlController:]):
+
+        Adjust this implementation to hide the focused form control "Go" button for selects and time inputs. This
+        currently doesn't work for these form controls because it relies on implicit form submission; this should be
+        fixed by future changes, after which we should revert this adjustment.
+
+        (-[WKContentView _wheelChangedWithEvent:]):
+
+        Delegate wheel events to the time picker if needed.
+
+        (-[WKContentView textInputController:didRequestDismissalWithAction:]): Deleted.
+
+        Renamed to -textInputControllerDidRequestDismissal:.
+
+        * UIProcess/ios/forms/WKTimePickerViewController.h: Added.
+        * UIProcess/ios/forms/WKTimePickerViewController.mm: Added.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-02-11  Michael Catanzaro  <mcatanz...@igalia.com>
 
         [GTK] Unify builds for platform-specific files in WebKit layer

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (228392 => 228393)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-02-12 21:57:15 UTC (rev 228392)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-02-12 22:07:10 UTC (rev 228393)
@@ -88,6 +88,7 @@
 @class WKNumberPadViewController;
 @class WKSelectMenuViewController;
 @class WKTextInputViewController;
+@class WKTimePickerViewController;
 #endif
 
 typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
@@ -249,6 +250,7 @@
     RetainPtr<WKFocusedFormControlViewController> _focusedFormControlViewController;
     RetainPtr<WKNumberPadViewController> _numberPadViewController;
     RetainPtr<WKSelectMenuViewController> _selectMenuViewController;
+    RetainPtr<WKTimePickerViewController> _timePickerViewController;
 #endif
 }
 

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (228392 => 228393)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-02-12 21:57:15 UTC (rev 228392)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-02-12 22:07:10 UTC (rev 228393)
@@ -53,6 +53,7 @@
 #import "WKPreviewElementInfoInternal.h"
 #import "WKSelectMenuViewController.h"
 #import "WKTextInputViewController.h"
+#import "WKTimePickerViewController.h"
 #import "WKUIDelegatePrivate.h"
 #import "WKWebViewConfiguration.h"
 #import "WKWebViewConfigurationPrivate.h"
@@ -4091,6 +4092,7 @@
     [self dismissTextInputViewController:YES];
     [self dismissNumberPadViewController:YES];
     [self dismissSelectMenuViewController:YES];
+    [self dismissTimePickerViewController:YES];
     if (!_isChangingFocus)
         [self dismissFocusedFormControlViewController:[_focusedFormControlViewController isVisible]];
 #endif
@@ -4104,6 +4106,25 @@
 
 #if ENABLE(EXTRA_ZOOM_MODE)
 
+- (void)presentTimePickerViewController:(BOOL)animated
+{
+    if (_timePickerViewController)
+        return;
+
+    _timePickerViewController = adoptNS([[WKTimePickerViewController alloc] initWithText:_assistedNodeInformation.value textSuggestions:@[ ]]);
+    [_timePickerViewController setDelegate:self];
+    [_focusedFormControlViewController presentViewController:_timePickerViewController.get() animated:animated completion:nil];
+}
+
+- (void)dismissTimePickerViewController:(BOOL)animated
+{
+    if (!_timePickerViewController)
+        return;
+
+    auto timePickerViewController = WTFMove(_timePickerViewController);
+    [timePickerViewController dismissViewControllerAnimated:animated completion:nil];
+}
+
 - (void)presentSelectMenuViewController:(BOOL)animated
 {
     if (_selectMenuViewController)
@@ -4164,15 +4185,6 @@
 - (void)presentViewControllerForAssistedNode:(const AssistedNodeInformation&)info
 {
     switch (info.elementType) {
-    case InputType::ContentEditable:
-    case InputType::Text:
-    case InputType::Password:
-    case InputType::TextArea:
-    case InputType::Search:
-    case InputType::Email:
-    case InputType::URL:
-        [self presentTextInputViewController:YES];
-        break;
     case InputType::Number:
     case InputType::NumberPad:
     case InputType::Phone:
@@ -4181,7 +4193,13 @@
     case InputType::Select:
         [self presentSelectMenuViewController:YES];
         break;
+    case InputType::Time:
+        [self presentTimePickerViewController:YES];
+        break;
+    case InputType::None:
+        break;
     default:
+        [self presentTextInputViewController:YES];
         break;
     }
 }
@@ -4209,16 +4227,8 @@
 {
     // FIXME: Update cached AssistedNodeInformation state in the UI process.
     _page->setTextAsync(text);
-}
 
-- (void)textInputController:(WKTextFormControlViewController *)controller didRequestDismissalWithAction:(WKFormControlAction)action
-{
-    if (action == WKFormControlActionCancel) {
-        _page->blurAssistedNode();
-        return;
-    }
-
-    if (_assistedNodeInformation.formAction.isEmpty() && !_assistedNodeInformation.hasNextNode && !_assistedNodeInformation.hasPreviousNode) {
+    if (![self actionNameForFocusedFormControlController:_focusedFormControlViewController.get()] && !_assistedNodeInformation.hasNextNode && !_assistedNodeInformation.hasPreviousNode) {
         // In this case, there's no point in collapsing down to the form control focus UI because there's nothing the user could potentially do
         // besides dismiss the UI, so we just automatically dismiss the focused form control UI.
         _page->blurAssistedNode();
@@ -4228,8 +4238,14 @@
     [_focusedFormControlViewController show:NO];
     [self dismissTextInputViewController:YES];
     [self dismissNumberPadViewController:YES];
+    [self dismissTimePickerViewController:YES];
 }
 
+- (void)textInputControllerDidRequestDismissal:(WKTextFormControlViewController *)controller
+{
+    _page->blurAssistedNode();
+}
+
 - (void)focusedFormControlControllerDidSubmit:(WKFocusedFormControlViewController *)controller
 {
     [self insertText:@"\n"];
@@ -4256,7 +4272,16 @@
     if (_assistedNodeInformation.formAction.isEmpty())
         return nil;
 
-    return _assistedNodeInformation.elementType == InputType::Search ? formControlSearchButtonTitle() : formControlGoButtonTitle();
+    switch (_assistedNodeInformation.elementType) {
+    case InputType::Select:
+    case InputType::Time:
+    case InputType::Date:
+        return nil;
+    case InputType::Search:
+        return formControlSearchButtonTitle();
+    default:
+        return formControlGoButtonTitle();
+    }
 }
 
 - (void)focusedFormControlControllerDidRequestNextNode:(WKFocusedFormControlViewController *)controller
@@ -4371,6 +4396,9 @@
     if ([_selectMenuViewController handleWheelEvent:event])
         return;
 
+    if ([_timePickerViewController handleWheelEvent:event])
+        return;
+
     if ([_focusedFormControlViewController handleWheelEvent:event])
         return;
 #endif

Added: trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.h (0 => 228393)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.h	2018-02-12 22:07:10 UTC (rev 228393)
@@ -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) && __has_include(<WebKitAdditions/WKTimePickerViewControllerAdditions.h>)
+#import <WebKitAdditions/WKTimePickerViewControllerAdditions.h>
+#endif

Added: trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.mm (0 => 228393)


--- trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.mm	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKTimePickerViewController.mm	2018-02-12 22:07:10 UTC (rev 228393)
@@ -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 "WKTimePickerViewController.h"
+
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WKTimePickerViewControllerAdditions.mm>)
+#import <WebKitAdditions/WKTimePickerViewControllerAdditions.mm>
+#endif

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (228392 => 228393)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-02-12 21:57:15 UTC (rev 228392)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2018-02-12 22:07:10 UTC (rev 228393)
@@ -740,6 +740,8 @@
 		2EA7B3D22026CEF8009CE5AC /* WKNumberPadViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EA7B3D02026CEF8009CE5AC /* WKNumberPadViewController.mm */; };
 		2EA7B3D52026CF23009CE5AC /* WKNumberPadView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA7B3D32026CF23009CE5AC /* WKNumberPadView.h */; };
 		2EA7B3D62026CF23009CE5AC /* WKNumberPadView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EA7B3D42026CF23009CE5AC /* WKNumberPadView.mm */; };
+		2EB6FC01203021960017E619 /* WKTimePickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */; };
+		2EB6FC02203021960017E619 /* WKTimePickerViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */; };
 		2EE4529F20292D2A00D81777 /* WKSelectMenuViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EE4529C20292BD900D81777 /* WKSelectMenuViewController.h */; };
 		2EE452A020292D2E00D81777 /* WKSelectMenuViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EE4529B20292BD800D81777 /* WKSelectMenuViewController.mm */; };
 		2F809DD71FBD1BC9005FE63A /* TouchBarMenuItemData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2F809DD51FBD1BC9005FE63A /* TouchBarMenuItemData.cpp */; };
@@ -3100,6 +3102,8 @@
 		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>"; };
 		2EA7B3D42026CF23009CE5AC /* WKNumberPadView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKNumberPadView.mm; path = ios/forms/WKNumberPadView.mm; sourceTree = "<group>"; };
+		2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKTimePickerViewController.h; path = ios/forms/WKTimePickerViewController.h; sourceTree = "<group>"; };
+		2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTimePickerViewController.mm; path = ios/forms/WKTimePickerViewController.mm; sourceTree = "<group>"; };
 		2EE4529B20292BD800D81777 /* WKSelectMenuViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSelectMenuViewController.mm; path = ios/forms/WKSelectMenuViewController.mm; sourceTree = "<group>"; };
 		2EE4529C20292BD900D81777 /* WKSelectMenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSelectMenuViewController.h; path = ios/forms/WKSelectMenuViewController.h; sourceTree = "<group>"; };
 		2F809DD51FBD1BC9005FE63A /* TouchBarMenuItemData.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TouchBarMenuItemData.cpp; sourceTree = "<group>"; };
@@ -8366,6 +8370,8 @@
 				2E16B6C92017B768008996D6 /* WKTextInputViewController.mm */,
 				2E16B6D22017BA37008996D6 /* WKTextSuggestionButton.h */,
 				2E16B6D32017BA37008996D6 /* WKTextSuggestionButton.mm */,
+				2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */,
+				2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */,
 			);
 			name = forms;
 			sourceTree = "<group>";
@@ -9550,6 +9556,7 @@
 				2E16B6CA2017B768008996D6 /* WKTextInputViewController.h in Headers */,
 				0FCB4E6818BBE3D9000FCFC9 /* WKTextInputWindowController.h in Headers */,
 				2E16B6D42017BA37008996D6 /* WKTextSuggestionButton.h in Headers */,
+				2EB6FC01203021960017E619 /* WKTimePickerViewController.h in Headers */,
 				BC407608124FF0270068F20A /* WKType.h in Headers */,
 				7CD5EBBF1746B04C000C1C45 /* WKTypeRefWrapper.h in Headers */,
 				1AD8790A18B6C38A006CAFD7 /* WKUIDelegate.h in Headers */,
@@ -11180,6 +11187,7 @@
 				2E16B6CB2017B768008996D6 /* WKTextInputViewController.mm in Sources */,
 				0FCB4E6918BBE3D9000FCFC9 /* WKTextInputWindowController.mm in Sources */,
 				2E16B6D52017BA37008996D6 /* WKTextSuggestionButton.mm in Sources */,
+				2EB6FC02203021960017E619 /* WKTimePickerViewController.mm in Sources */,
 				BC407607124FF0270068F20A /* WKType.cpp in Sources */,
 				7CD5EBBE1746B04C000C1C45 /* WKTypeRefWrapper.mm in Sources */,
 				BC407609124FF0270068F20A /* WKURL.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to