[webkit-changes] [WebKit/WebKit] 9cb30c: [iOS] Refactor date/time form controls on iOS to u...

Wenson Hsieh noreply at github.com
Sun Sep 17 16:14:43 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9cb30cccf0a67a38b4af90fedca01e85b2def3c1
      https://github.com/WebKit/WebKit/commit/9cb30cccf0a67a38b4af90fedca01e85b2def3c1
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-09-17 (Sun, 17 Sep 2023)

  Changed paths:
    M LayoutTests/fast/forms/ios/input-peripherals-with-validation-message.html
    M LayoutTests/resources/ui-helper.js
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/SourcesCocoa.txt
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
    A Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h
    A Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm
    M Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm
    M Source/WebKit/UIProcess/mac/WKImmediateActionController.h
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [iOS] Refactor date/time form controls on iOS to use a popover presentation
https://bugs.webkit.org/show_bug.cgi?id=261627
rdar://115581849

Reviewed by Aditya Keerthi.

Change date and time inputs on iOS to use a `UIDatePicker` view hosted inside of
`UIPopoverPresentationController`, rather than `_UIDatePickerOverlayPresentation`. This also
changes the behavior and appearance of the form accessory view, such that it presents with an arrow
pointing to the source rect in the content view, instead of a context-menu-like appearance. See
comments below for more information.

* LayoutTests/fast/forms/ios/input-peripherals-with-validation-message.html:

Adjust this test to use the new `UIHelper.isShowingFormValidationBubble()` method; this is necessary
because the current method, `isShowingPopover()`, returns `true` when *either* the date picker or
validation bubble is presented (due to adopting `UIPopoverPresentationController`), but the test
expects it to be `true` only when the validation bubble is presented.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.isShowingFormValidationBubble):
(window.UIHelper.isShowingPopover): Deleted.

See above for more details; we can also just remove `isShowingPopover()` here, since the test above
was the only caller.

* Source/WTF/wtf/PlatformHave.h:

Remove the now-unnecessary `HAVE(UIDATEPICKER_OVERLAY_PRESENTATION)` compile-time flag.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h: Added.
* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm: Added.
(-[WKDatePickerPopoverView initWithDatePicker:]):
(-[WKDatePickerPopoverView datePicker]):

Add a `WKDatePickerPopoverView` to encapsulate and help manage the toolbar (accessory view), date
picker view, and backdrop view in the background.

(-[WKDatePickerPopoverView accessoryView]):
(-[WKDatePickerPopoverController initWithDatePicker:delegate:]):
(-[WKDatePickerPopoverController resetDatePicker]):
(-[WKDatePickerPopoverController dismissDatePicker]):
(-[WKDatePickerPopoverController viewDidLoad]):
(-[WKDatePickerPopoverController presentInView:sourceRect:interactionBounds:completion:]):
(-[WKDatePickerPopoverController adaptivePresentationStyleForPresentationController:traitCollection:]):
(-[WKDatePickerPopoverController presentationControllerDidDismiss:]):

Add a new `WKDatePickerPopoverController` that takes a date picker and delegate, knows how to
present the date picker, and also calls back into the `WKDateTimePicker` via delegate methods.

* Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm:
(-[WKDateTimePicker initWithView:datePickerMode:]):
(-[WKDateTimePicker datePickerPopoverControllerDidDismiss:]):
(-[WKDateTimePicker datePickerPopoverControllerDidReset:]):
(-[WKDateTimePicker handleDatePickerPresentationDismissal]):
(-[WKDateTimePicker removeDatePickerPresentation]):
(-[WKDateTimePicker showDateTimePicker]):

Replace `_UIDatePickerOverlayPresentation` with this new `WKDatePickerPopoverController`.

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

Make a slight adjustment here for Catalyst, so that we always relinquish first responder to the
imminently-presenting popover when focusing a date/time input. With the new popover (but without
this change), we'll immediately dismiss the popover upon focus because the popover causes the web
view to resign first responder, which would otherwise cause us to hide the popover.

Note that this new design *also* generally fixes date time inputs in Catalyst; while we don't run
into the problem described above, we currently have a different serious bug, wherein the contents of
the date picker don't respond to clicks until switching to a different window and switching back.
This patch makes date pickers work without this weird caveat.

(-[WKDateTimePicker controlEndEditing]):
(-[WKDateTimeInputControl initWithView:]):
(-[WKDateTimePicker datePickerChanged:]): Deleted.
(-[WKDateTimePicker reset:]): Deleted.
(-[WKDateTimePicker done:]): Deleted.

Replace these action selectors with `WKDatePickerPopoverControllerDelegate` method implementations
instead.

* Source/WebKit/UIProcess/mac/WKImmediateActionController.h:

Fix a unified-source build failure that's surfaced by the new file in this patch.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::isShowingFormValidationBubble const):

Add support for a new testing hook; see above for more details.

* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView initWithFrame:configuration:]):
(-[TestRunnerWKWebView _willPresentPopover:]):
(-[TestRunnerWKWebView _didDismissPopover]):

Adjust the test harness to set `showingFormValidationBubble` when observing a popover presentation
notification, only if the object's delegate is a `WebValidationBubbleDelegate`. While a bit hacky,
I opted for this approach since it keeps all the testing code within the test harness, and doesn't
require additional (intrusive) test-only code in the engine itself.

(-[TestRunnerWKWebView _willPresentPopover]): Deleted.
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::isShowingFormValidationBubble const):

Canonical link: https://commits.webkit.org/268069@main




More information about the webkit-changes mailing list