-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Date picker is clipped in landscape mode on some narrower iPhon…
…e models https://bugs.webkit.org/show_bug.cgi?id=262451 rdar://116317686 Reviewed by Aditya Keerthi and Abrar Rahman Protyasha. On iPhone models where the screen is narrower than 400 pt, focusing a date input while in landscape orientation causes the bottom of the date picker (along with the accessory view containing "Done" and "Reset" buttons) to become clipped. This is because, despite the fact that the date picker popover lays out in undocked (arrow-less) mode in the center of the window, the window still isn't tall enough to accomodate the full height of the date picker, whose layout is unable to compress vertically to fit within the height of the window. This means that even if we adjust the height constraint of the date picker and its containing view to be contained within the window, the date picker will just clip itself to fit within the new height. `_UIDatePickerOverlayPresentation` (which we stopped using in 268069@main) solved this problem by scaling the entire content view in the popover to fit within the new size by setting a transform on the content view containing the date picker and accessory view. We adopt a similar solution here, and apply a transform to the `WKDatePickerPopoverView` if needed during view layout to fit within the bounds of the view. Note that we also need to add a new width constraint that fits the popover container view to the content view to scale alongside the new `targetScale`; otherwise, the popover's view will be wider than the content view itself, which leads to unnecessary left and right margins. To test this, we: 1. Add a layout test to rotate the device to landscape orientation and tap on a date input. 2. Add a release assertion when simulating date picker dismissal by tapping on the Done button, to crash if the accessory view can't be hit-tested to (e.g. clipped). Without this fix, we'll crash in the new release assert in `-assertAccessoryViewCanBeHitTested`. * LayoutTests/fast/forms/ios/show-and-dismiss-date-input-in-landscape-expected.txt: Added. * LayoutTests/fast/forms/ios/show-and-dismiss-date-input-in-landscape.html: Added. * LayoutTests/fast/forms/ios/time-picker-value-change.html: Adjust an existing layout test to wait for the context menu to finish presenting before interacting with the accessory view's "Done" button, in order to avoid hitting the new assertion under `-dismissWithAnimation`. * Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.h: * Source/WebKit/UIProcess/ios/forms/WKDatePickerPopoverController.mm: (-[WKDatePickerPopoverView estimatedMaximumPopoverSize]): Drive-by fix: increase the extra padding before falling back to arrow-less presentation to 80 pt; I discovered that on an iPhone 12 with 60 pt, it's still possible to end up squishing (but not quite totally clipping) the accessory view in some cases. (-[WKDatePickerPopoverController assertAccessoryViewCanBeHitTestedForTesting]): Add some logic to sanity check that the accessory view can actually be hit-tested (relative to the popover's content view) when simulating tapping the "Done" button to dismiss the date picker. (-[WKDatePickerPopoverController viewDidLoad]): (-[WKDatePickerPopoverController viewWillLayoutSubviews]): (-[WKDatePickerPopoverController _scaleDownToFitHeightIfNeeded]): This is the main fix; see above for more details. * Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.h: * Source/WebKit/UIProcess/ios/forms/WKDateTimeInputControl.mm: (-[WKDateTimeInputControl dismissWithAnimationForTesting]): (-[WKDateTimeInputControl dismissWithAnimation]): Deleted. Add a `ForTesting` suffix to this testing-only method. Canonical link: https://commits.webkit.org/268753@main
- Loading branch information
Showing
8 changed files
with
134 additions
and
6 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
LayoutTests/fast/forms/ios/show-and-dismiss-date-input-in-landscape-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This test verifies that presenting a date picker in landscape orientation on an iPhone does not cause the Done button to be clipped. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS Presented date picker | ||
PASS Dismissed date picker | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
48 changes: 48 additions & 0 deletions
48
LayoutTests/fast/forms/ios/show-and-dismiss-date-input-in-landscape.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
<script src="../../../resources/js-test.js"></script> | ||
<style> | ||
body, html { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
input { | ||
width: 200px; | ||
height: 44px; | ||
position: absolute; | ||
left: calc(50% - 100px); | ||
top: calc(50% - 22px); | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<input type="datetime-local"></input> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
addEventListener("load", async () => { | ||
description("This test verifies that presenting a date picker in landscape orientation on an iPhone does not cause the Done button to be clipped."); | ||
|
||
await UIHelper.rotateDevice("landscape-right", true); | ||
await UIHelper.ensurePresentationUpdate(); | ||
|
||
await UIHelper.activateElement(document.querySelector("input")); | ||
await UIHelper.waitForContextMenuToShow(); | ||
testPassed("Presented date picker"); | ||
|
||
await UIHelper.dismissFormAccessoryView(); | ||
await UIHelper.waitForContextMenuToHide(); | ||
testPassed("Dismissed date picker"); | ||
|
||
await UIHelper.rotateDevice("portrait", true); | ||
finishJSTest(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters