[Extra zoom mode] Adopt list view controller UI for select menus
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 20:47:19 +0000 (20:47 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Mar 2018 20:47:19 +0000 (20:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183944
<rdar://problem/38799062>

Reviewed by Andy Estes.

Rename WKSelectMenuViewController to WKSelectMenuListViewController, and also rename the relevant
WebKitAdditions harness files. See corresponding changes for more details.

* UIProcess/WKSelectMenuListViewController.h: Renamed from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.h.
* UIProcess/WKSelectMenuListViewController.mm: Renamed from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.mm.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView presentSelectMenuViewController:]):
(-[WKContentView dismissSelectMenuViewController:]):
(-[WKContentView selectMenu:didSelectItemAtIndex:]):
(-[WKContentView numberOfItemsInSelectMenu:]):
(-[WKContentView selectMenu:displayTextForItemAtIndex:]):
(-[WKContentView selectMenu:didCheckItemAtIndex:checked:]):
(-[WKContentView selectMenuUsesMultipleSelection:]):
(-[WKContentView selectMenu:hasSelectedOptionAtIndex:]):
(-[WKContentView _wheelChangedWithEvent:]):

Overriding wheel events and re-dispatching them is no longer needed after r229437, so we can just remove special
handling for select menus here.

(-[WKContentView didCancelSelectionInSelectMenu:]): Deleted.
(-[WKContentView selectMenuSupportsMultipleSelection:]): Deleted.
(-[WKContentView selectMenu:hasCheckedOptionAtIndex:]): Deleted.
(-[WKContentView startingIndexForSelectMenu:]): Deleted.

The starting index for a select menu is no longer relevant when using list view controllers for input, so we can
just remove this delegate hook altogether.

* WebKit.xcodeproj/project.pbxproj:

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WKSelectMenuListViewController.h [moved from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.h with 95% similarity]
Source/WebKit/UIProcess/WKSelectMenuListViewController.mm [moved from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.mm with 92% similarity]
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj

index 22795e3..c390725 100644 (file)
@@ -1,3 +1,41 @@
+2018-03-23  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [Extra zoom mode] Adopt list view controller UI for select menus
+        https://bugs.webkit.org/show_bug.cgi?id=183944
+        <rdar://problem/38799062>
+
+        Reviewed by Andy Estes.
+
+        Rename WKSelectMenuViewController to WKSelectMenuListViewController, and also rename the relevant
+        WebKitAdditions harness files. See corresponding changes for more details.
+
+        * UIProcess/WKSelectMenuListViewController.h: Renamed from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.h.
+        * UIProcess/WKSelectMenuListViewController.mm: Renamed from Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.mm.
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView presentSelectMenuViewController:]):
+        (-[WKContentView dismissSelectMenuViewController:]):
+        (-[WKContentView selectMenu:didSelectItemAtIndex:]):
+        (-[WKContentView numberOfItemsInSelectMenu:]):
+        (-[WKContentView selectMenu:displayTextForItemAtIndex:]):
+        (-[WKContentView selectMenu:didCheckItemAtIndex:checked:]):
+        (-[WKContentView selectMenuUsesMultipleSelection:]):
+        (-[WKContentView selectMenu:hasSelectedOptionAtIndex:]):
+        (-[WKContentView _wheelChangedWithEvent:]):
+
+        Overriding wheel events and re-dispatching them is no longer needed after r229437, so we can just remove special
+        handling for select menus here.
+
+        (-[WKContentView didCancelSelectionInSelectMenu:]): Deleted.
+        (-[WKContentView selectMenuSupportsMultipleSelection:]): Deleted.
+        (-[WKContentView selectMenu:hasCheckedOptionAtIndex:]): Deleted.
+        (-[WKContentView startingIndexForSelectMenu:]): Deleted.
+
+        The starting index for a select menu is no longer relevant when using list view controllers for input, so we can
+        just remove this delegate hook altogether.
+
+        * WebKit.xcodeproj/project.pbxproj:
+
 2018-03-23  Youenn Fablet  <youenn@apple.com>
 
         CacheStorage::Caches should clear m_caches when clearing its representation even though it is not yet initialized
@@ -26,5 +26,5 @@
 #pragma once
 
 #if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKSelectMenuViewControllerAdditions.h>
+#import <WebKitAdditions/WKSelectMenuListViewControllerAdditions.h>
 #endif
@@ -24,8 +24,8 @@
  */
 
 #import "config.h"
-#import "WKSelectMenuViewController.h"
+#import "WKSelectMenuListViewController.h"
 
 #if USE(APPLE_INTERNAL_SDK)
-#import <WebKitAdditions/WKSelectMenuViewControllerAdditions.mm>
+#import <WebKitAdditions/WKSelectMenuListViewControllerAdditions.mm>
 #endif
index 940ed2f..5c99b26 100644 (file)
@@ -87,7 +87,7 @@ class WebPageProxy;
 @class WKDatePickerViewController;
 @class WKFocusedFormControlViewController;
 @class WKNumberPadViewController;
-@class WKSelectMenuViewController;
+@class WKSelectMenuListViewController;
 @class WKTextInputListViewController;
 @class WKTimePickerViewController;
 #endif
@@ -254,7 +254,7 @@ struct WKAutoCorrectionData {
     RetainPtr<WKTextInputListViewController> _textInputListViewController;
     RetainPtr<WKFocusedFormControlViewController> _focusedFormControlViewController;
     RetainPtr<WKNumberPadViewController> _numberPadViewController;
-    RetainPtr<WKSelectMenuViewController> _selectMenuViewController;
+    RetainPtr<WKSelectMenuListViewController> _selectMenuListViewController;
     RetainPtr<WKTimePickerViewController> _timePickerViewController;
 
     BOOL _shouldRestoreFirstResponderStatusAfterLosingFocus;
index 8752881..9268c4c 100644 (file)
@@ -53,7 +53,7 @@
 #import "WKPreviewActionItemIdentifiers.h"
 #import "WKPreviewActionItemInternal.h"
 #import "WKPreviewElementInfoInternal.h"
-#import "WKSelectMenuViewController.h"
+#import "WKSelectMenuListViewController.h"
 #import "WKTextInputListViewController.h"
 #import "WKTimePickerViewController.h"
 #import "WKUIDelegatePrivate.h"
 
 #if ENABLE(EXTRA_ZOOM_MODE)
 
-@interface WKContentView (ExtraZoomMode) <WKTextFormControlViewControllerDelegate, WKFocusedFormControlViewControllerDelegate, WKSelectMenuViewControllerDelegate, WKFormControlListViewControllerDelegate>
+@interface WKContentView (ExtraZoomMode) <WKTextFormControlViewControllerDelegate, WKFocusedFormControlViewControllerDelegate, WKSelectMenuListViewControllerDelegate, WKTextFormControlListViewControllerDelegate>
 @end
 
 #endif
@@ -4214,21 +4214,20 @@ static bool isAssistableInputType(InputType type)
 
 - (void)presentSelectMenuViewController:(BOOL)animated
 {
-    if (_selectMenuViewController)
+    if (_selectMenuListViewController)
         return;
 
-    _selectMenuViewController = adoptNS([[WKSelectMenuViewController alloc] init]);
-    [_selectMenuViewController setDelegate:self];
-    [_focusedFormControlViewController presentViewController:_selectMenuViewController.get() animated:animated completion:nil];
+    _selectMenuListViewController = adoptNS([[WKSelectMenuListViewController alloc] initWithDelegate:self]);
+    [_focusedFormControlViewController presentViewController:_selectMenuListViewController.get() animated:animated completion:nil];
 }
 
 - (void)dismissSelectMenuViewController:(BOOL)animated
 {
-    if (!_selectMenuViewController)
+    if (!_selectMenuListViewController)
         return;
 
-    auto selectMenuViewController = WTFMove(_selectMenuViewController);
-    [selectMenuViewController dismissViewControllerAnimated:animated completion:nil];
+    auto selectMenuListViewController = WTFMove(_selectMenuListViewController);
+    [_selectMenuListViewController dismissViewControllerAnimated:animated completion:nil];
 }
 
 - (void)presentFocusedFormControlViewController:(BOOL)animated
@@ -4427,27 +4426,20 @@ static bool isAssistableInputType(InputType type)
         [_textInputListViewController reloadTextSuggestions];
 }
 
-#pragma mark - WKSelectMenuViewControllerDelegate
+#pragma mark - WKSelectMenuListViewControllerDelegate
 
-- (void)selectMenu:(WKSelectMenuViewController *)selectMenu didSelectItemAtIndex:(NSUInteger)index
+- (void)selectMenu:(WKSelectMenuListViewController *)selectMenu didSelectItemAtIndex:(NSUInteger)index
 {
-    if (!_assistedNodeInformation.isMultiSelect)
-        _page->setAssistedNodeSelectedIndex(index, false);
-
-    _page->blurAssistedNode();
-}
-
-- (void)didCancelSelectionInSelectMenu:(WKSelectMenuViewController *)selectMenu
-{
-    _page->blurAssistedNode();
+    ASSERT(!_assistedNodeInformation.isMultiSelect);
+    _page->setAssistedNodeSelectedIndex(index, false);
 }
 
-- (NSUInteger)numberOfItemsInSelectMenu:(WKSelectMenuViewController *)selectMenu
+- (NSUInteger)numberOfItemsInSelectMenu:(WKSelectMenuListViewController *)selectMenu
 {
     return self.assistedNodeSelectOptions.size();
 }
 
-- (NSString *)selectMenu:(WKSelectMenuViewController *)selectMenu displayTextForItemAtIndex:(NSUInteger)index
+- (NSString *)selectMenu:(WKSelectMenuListViewController *)selectMenu displayTextForItemAtIndex:(NSUInteger)index
 {
     auto& options = self.assistedNodeSelectOptions;
     if (index >= options.size()) {
@@ -4458,7 +4450,7 @@ static bool isAssistableInputType(InputType type)
     return options[index].text;
 }
 
-- (void)selectMenu:(WKSelectMenuViewController *)selectMenu didCheckItemAtIndex:(NSUInteger)index checked:(BOOL)checked
+- (void)selectMenu:(WKSelectMenuListViewController *)selectMenu didCheckItemAtIndex:(NSUInteger)index checked:(BOOL)checked
 {
     ASSERT(_assistedNodeInformation.isMultiSelect);
     if (index >= self.assistedNodeSelectOptions.size()) {
@@ -4476,12 +4468,12 @@ static bool isAssistableInputType(InputType type)
     option.isSelected = checked;
 }
 
-- (BOOL)selectMenuSupportsMultipleSelection:(WKSelectMenuViewController *)selectMenu
+- (BOOL)selectMenuUsesMultipleSelection:(WKSelectMenuListViewController *)selectMenu
 {
     return _assistedNodeInformation.isMultiSelect;
 }
 
-- (BOOL)selectMenu:(WKSelectMenuViewController *)selectMenu hasCheckedOptionAtIndex:(NSUInteger)index
+- (BOOL)selectMenu:(WKSelectMenuListViewController *)selectMenu hasSelectedOptionAtIndex:(NSUInteger)index
 {
     if (index >= self.assistedNodeSelectOptions.size()) {
         ASSERT_NOT_REACHED();
@@ -4491,18 +4483,6 @@ static bool isAssistableInputType(InputType type)
     return self.assistedNodeSelectOptions[index].isSelected;
 }
 
-- (NSUInteger)startingIndexForSelectMenu:(WKSelectMenuViewController *)selectMenu
-{
-    if (_assistedNodeInformation.isMultiSelect)
-        return 0;
-
-    auto firstSelectedIndex = self.assistedNodeSelectOptions.findMatching([&] (auto& option) {
-        return option.isSelected;
-    });
-
-    return firstSelectedIndex == notFound ? 0 : firstSelectedIndex;
-}
-
 #endif // ENABLE(EXTRA_ZOOM_MODE)
 
 - (void)_wheelChangedWithEvent:(UIEvent *)event
@@ -4511,9 +4491,6 @@ static bool isAssistableInputType(InputType type)
     if ([_numberPadViewController handleWheelEvent:event])
         return;
 
-    if ([_selectMenuViewController handleWheelEvent:event])
-        return;
-
     if ([_timePickerViewController handleWheelEvent:event])
         return;
 
index 985c988..bdb83c0 100644 (file)
                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 */; };
                2F8336861FA139DF00C6E080 /* TouchBarMenuData.h in Headers */ = {isa = PBXBuildFile; fileRef = 2FD43B911FA006A10083F51C /* TouchBarMenuData.h */; };
                2F8336871FA13A1E00C6E080 /* TouchBarMenuData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2FD43B921FA006A30083F51C /* TouchBarMenuData.cpp */; };
                F44291961FA5942A002CC93E /* _WKAttachmentInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F44291951FA5942A002CC93E /* _WKAttachmentInternal.h */; };
                F44DFEB21E9E752F0038D196 /* WebIconUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */; };
                F44DFEB31E9E752F0038D196 /* WebIconUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */; };
+               F478E92920644EE900EE03E8 /* WKSelectMenuListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F478E92720644EE900EE03E8 /* WKSelectMenuListViewController.h */; };
+               F478E92A20644EE900EE03E8 /* WKSelectMenuListViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F478E92820644EE900EE03E8 /* WKSelectMenuListViewController.mm */; };
                F496A4311F58A272004C1757 /* DragDropInteractionState.h in Headers */ = {isa = PBXBuildFile; fileRef = F496A42F1F58A272004C1757 /* DragDropInteractionState.h */; };
                F496A4321F58A272004C1757 /* DragDropInteractionState.mm in Sources */ = {isa = PBXBuildFile; fileRef = F496A4301F58A272004C1757 /* DragDropInteractionState.mm */; };
                F4D5F51D206087A10038BBA8 /* WKTextInputListViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */; };
                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>"; };
                2F809DD91FBD1BF2005FE63A /* TouchBarMenuItemData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TouchBarMenuItemData.h; sourceTree = "<group>"; };
                2FD43B911FA006A10083F51C /* TouchBarMenuData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TouchBarMenuData.h; sourceTree = "<group>"; };
                F44291951FA5942A002CC93E /* _WKAttachmentInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKAttachmentInternal.h; sourceTree = "<group>"; };
                F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebIconUtilities.h; path = ios/WebIconUtilities.h; sourceTree = "<group>"; };
                F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebIconUtilities.mm; path = ios/WebIconUtilities.mm; sourceTree = "<group>"; };
+               F478E92720644EE900EE03E8 /* WKSelectMenuListViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKSelectMenuListViewController.h; sourceTree = "<group>"; };
+               F478E92820644EE900EE03E8 /* WKSelectMenuListViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKSelectMenuListViewController.mm; sourceTree = "<group>"; };
                F496A42F1F58A272004C1757 /* DragDropInteractionState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DragDropInteractionState.h; path = ios/DragDropInteractionState.h; sourceTree = "<group>"; };
                F496A4301F58A272004C1757 /* DragDropInteractionState.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = DragDropInteractionState.mm; path = ios/DragDropInteractionState.mm; sourceTree = "<group>"; };
                F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKTextInputListViewController.h; path = ios/forms/WKTextInputListViewController.h; sourceTree = "<group>"; };
                                2EA7B3D42026CF23009CE5AC /* WKNumberPadView.mm */,
                                2EA7B3CF2026CEF8009CE5AC /* WKNumberPadViewController.h */,
                                2EA7B3D02026CEF8009CE5AC /* WKNumberPadViewController.mm */,
-                               2EE4529C20292BD900D81777 /* WKSelectMenuViewController.h */,
-                               2EE4529B20292BD800D81777 /* WKSelectMenuViewController.mm */,
+                               F478E92720644EE900EE03E8 /* WKSelectMenuListViewController.h */,
+                               F478E92820644EE900EE03E8 /* WKSelectMenuListViewController.mm */,
                                2E16B69F2016E680008996D6 /* WKTextFormControlViewController.h */,
                                2E16B6A02016E680008996D6 /* WKTextFormControlViewController.mm */,
                                F4D5F519206087A00038BBA8 /* WKTextInputListViewController.h */,
                                51CD1C651B34B9D400142CA5 /* WKSecurityOrigin.h in Headers */,
                                51CD1C671B34B9DF00142CA5 /* WKSecurityOriginInternal.h in Headers */,
                                51CD1C5E1B3493B400142CA5 /* WKSecurityOriginRef.h in Headers */,
-                               2EE4529F20292D2A00D81777 /* WKSelectMenuViewController.h in Headers */,
+                               F478E92920644EE900EE03E8 /* WKSelectMenuListViewController.h in Headers */,
                                BC407604124FF0270068F20A /* WKSerializedScriptValue.h in Headers */,
                                1ADE46B31954EC61000F7985 /* WKSessionStateRef.h in Headers */,
                                BCDDB32B124EC2AB0048D13C /* WKSharedAPICast.h in Headers */,
                                0FCB4E5518BBE044000FCFC9 /* WKScrollView.mm in Sources */,
                                51CD1C661B34B9DC00142CA5 /* WKSecurityOrigin.mm in Sources */,
                                51CD1C5D1B3493AF00142CA5 /* WKSecurityOriginRef.cpp in Sources */,
-                               2EE452A020292D2E00D81777 /* WKSelectMenuViewController.mm in Sources */,
+                               F478E92A20644EE900EE03E8 /* WKSelectMenuListViewController.mm in Sources */,
                                BC407603124FF0270068F20A /* WKSerializedScriptValue.cpp in Sources */,
                                1ADE46B21954EC61000F7985 /* WKSessionStateRef.cpp in Sources */,
                                513E462E1AD837560016234A /* WKSharingServicePickerDelegate.mm in Sources */,