Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 05c27ae25006e9c39e40a712ac4bdf28611e2884
      
https://github.com/WebKit/WebKit/commit/05c27ae25006e9c39e40a712ac4bdf28611e2884
  Author: Wenson Hsieh <wenson_hs...@apple.com>
  Date:   2023-09-27 (Wed, 27 Sep 2023)

  Changed paths:
    A 
LayoutTests/fast/forms/ios/change-focus-from-text-field-to-date-input-expected.txt
    A LayoutTests/fast/forms/ios/change-focus-from-text-field-to-date-input.html
    M Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h
    M Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm
    M Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm

  Log Message:
  -----------
  REGRESSION (268069@main): Date picker fails to present when switching focus 
from a text field to a date input
https://bugs.webkit.org/show_bug.cgi?id=262144

Reviewed by Tim Horton and Aditya Keerthi.

After refactoring date pickers to use popover presentation controllers in 
268069@main, it's now
possible for the UI process to hang when presenting a date picker in the case 
where there's
insufficient space to present the popover, and autolayout code in UIKit takes 
(seemingly) forever
attempting to resize individual cells in the date picker view to make the view 
fit.

Avoid this problem by teaching `WKDatePickerPopoverController` to only present 
the popover in
directions that contain sufficient space to lay out the popover contents 
correctly. Additionally,
stop using `_contentRectForUserInteraction` when computing available space; 
this didn't really make
sense, since it considers the input view as part of the obscured inset area, 
despite the fact that
the popover can animate over the keyboard. Instead, just map the `targetRect` 
to window coordinates,
and use the containing window's bounds to compute available space.

See below for more details.

* 
LayoutTests/fast/forms/ios/change-focus-from-text-field-to-date-input-expected.txt:
 Added.
* LayoutTests/fast/forms/ios/change-focus-from-text-field-to-date-input.html: 
Added.

Add a layout test to exercise the change.

* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h:
* Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm:
(-[WKDatePickerPopoverView initWithDatePicker:]):

Use `-sizeToFit` to size the accessory view and date picker, and save the 
combined size here so that
we can estimate how much available space we need in order to present this 
popover.

(-[WKDatePickerPopoverView estimatedMaximumPopoverSize]):

Return an estimate of the maximum size of the content view when it's presented 
in a popover. Note
that we add some extra height here to ensure that the accessory view toolbar 
doesn't end up getting
clipped.

(-[WKDatePickerPopoverController presentInView:sourceRect:completion:]):
(-[WKDatePickerPopoverController 
presentInView:sourceRect:interactionBounds:completion:]): Deleted.

Use the estimated popover size above to set `permittedArrowDirections` to only 
the directions where
the popover has enough space to fully present, without either:

1. Hanging under autolayout code, or
2. Clipping the accessory view.

If there is not enough space to show the popover in *any* direction, instead of 
falling back to
`UIPopoverArrowDirectionAny`, we fall back to `0` (no permitted arrow 
directions), and set the
target rect to the entire bounds of the window, mapped into root view 
coordinates. This allows us to
simply present the popover in the center of the window with no arrow, which 
avoids the two issues
above.

* Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm:
(-[WKDateTimePicker showDateTimePicker]):

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to