[Extra zoom mode] Implement multiple and single select menus
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Feb 2018 23:07:02 +0000 (23:07 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Feb 2018 23:07:02 +0000 (23:07 +0000)
commite84d1c2d4d1504bcbeed6f63415ae7213a9f16ce
tree2efbeb06ffa5b66c4d21182c9b169db060696cb3
parent5e14646f36438fb6544602de458a1d0c9b601f6c
[Extra zoom mode] Implement multiple and single select menus
https://bugs.webkit.org/show_bug.cgi?id=182525
<rdar://problem/35143016>

Reviewed by Tim Horton.

Add support for presenting picker views when focusing single or multiple select elements. See changes below for
additional detail.

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

Move logic for presenting view controllers when focusing elements out of _startAssistingKeyboard, and into
_startAssistingNode:(...). This is because _startAssistingKeyboard is only invoked for certain types of focused
element types; importantly, this set excludes select elements. Putting the call to present the focused view
controller there also didn't make much since, considering that these new view controllers are not tied to
keyboards in any way.

(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
(-[WKContentView _stopAssistingNode]):

Dismiss any select menu that is being presented.

(-[WKContentView presentSelectMenuViewController:]):
(-[WKContentView dismissSelectMenuViewController:]):

Introduce idempotent helpers for presenting and dismissing the select menu view controller.

(-[WKContentView presentViewControllerForAssistedNode:]):
(-[WKContentView selectMenu:didSelectItemAtIndex:]):

For single select menus. Called when the user selects a row.

(-[WKContentView didCancelSelectionInSelectMenu:]):
(-[WKContentView numberOfItemsInSelectMenu:]):
(-[WKContentView selectMenu:displayTextForItemAtIndex:]):

Indicates the text value to show at a given index.

(-[WKContentView selectMenu:didCheckItemAtIndex:checked:]):

For multiple select menus, invoked when an item is checked. The `checked` parameter indicates whether or not the
item is now checked.

(-[WKContentView selectMenuSupportsMultipleSelection:]):

Indicates whether this select menu is single-item-only, or allows multiple items to be selected (checked).

(-[WKContentView selectMenu:hasCheckedOptionAtIndex:]):

For multiple select menus. Determines whether an option at the given index is checked.

(-[WKContentView startingIndexForSelectMenu:]):

Determines the index to instantly scroll to when presenting the select menu.

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

Add new harness files for WKSelectMenuViewController's header and implementation (see WebKitAdditions).

* WebKit.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.h [new file with mode: 0644]
Source/WebKit/UIProcess/ios/forms/WKSelectMenuViewController.mm [new file with mode: 0644]
Source/WebKit/WebKit.xcodeproj/project.pbxproj