[webkit-changes] [WebKit/WebKit] f53f66: [iOS] Displayed values for date controls may cause...
lilyspiniolas
noreply at github.com
Thu Mar 20 13:32:26 PDT 2025
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f53f6698c4254d602172dfe68a25279f77901c9d
https://github.com/WebKit/WebKit/commit/f53f6698c4254d602172dfe68a25279f77901c9d
Author: Lily Spiniolas <lily_spiniolas at apple.com>
Date: 2025-03-20 (Thu, 20 Mar 2025)
Changed paths:
A LayoutTests/fast/forms/ios/initial-size-for-date-time-related-controls-expected.txt
A LayoutTests/fast/forms/ios/initial-size-for-date-time-related-controls.html
M LayoutTests/platform/ios/fast/forms/time/time-input-rendering-basic-expected.txt
M Source/WebCore/platform/text/cocoa/LocalizedDateCache.h
M Source/WebCore/platform/text/cocoa/LocalizedDateCache.mm
M Source/WebCore/rendering/ios/RenderThemeIOS.mm
Log Message:
-----------
[iOS] Displayed values for date controls may cause overflow onto multiple lines
https://bugs.webkit.org/show_bug.cgi?id=290080
rdar://146902737
Reviewed by Aditya Keerthi.
Certain wide values for date controls could cause the displayed string to overflow onto
a second line. This was caused by incorrect logic in `LocalizedDateCache::calculateMaximumWidth`
which returned the width of an arbitrary date based on the assumption numbers typically have equal
width, which is not true. The method has been updated to estimate the maximum width based on the
width of each number 0-9. It includes logic to handle localized numerals and a variety of different
date and time formats. The name of the method and its caller were update to reflect the fact that
this is just an estimation as factors such as kerning are not taken into account.
The value returned by this method is now used as the `min-width` for the date/time controls
instead of setting `width` to the value. This is done so that, even in the case where the
estimated maximum width is incorrect, the displayed value will still be on one line as the
control will now expand.
Updated the name of `LocalizedDateCache::calculatedMaximumWidthForWeek` to
`estimatedMaximumWidthForWeek` to reflect that kerning is not accounted for. Removed
an unnecessary `adoptNS()` from the method. Added logic so that it too considers the
width of localized numerals rather than only Arabic numerals.
Added a layout test which ensures that the estimated maximum width is always correct for
the system font at the default size, and that the displayed value is always displayed on
a single line.
Updated iOS test expectations for fast/forms/ios/initial-size-for-date-time-related-controls.html
since the control width has changed slightly since its width is based on estimatedMaximumWidth,
which is no longer using an arbitrary time.
* LayoutTests/fast/forms/ios/initial-size-for-date-time-related-controls-expected.txt: Added.
* LayoutTests/fast/forms/ios/initial-size-for-date-time-related-controls.html: Added.
* LayoutTests/platform/ios/fast/forms/time/time-input-rendering-basic-expected.txt:
* Source/WebCore/platform/text/cocoa/LocalizedDateCache.h:
* Source/WebCore/platform/text/cocoa/LocalizedDateCache.mm:
(WebCore::LocalizedDateCache::estimatedMaximumWidthForDateType):
(WebCore::estimateMaximumWidthForWeek):
(WebCore::LocalizedDateCache::estimateMaximumWidth):
(WebCore::LocalizedDateCache::maximumWidthForDateType): Deleted.
(WebCore::calculateMaximumWidthForWeek): Deleted.
(WebCore::LocalizedDateCache::calculateMaximumWidth): Deleted.
* Source/WebCore/rendering/ios/RenderThemeIOS.mm:
(WebCore::adjustInputElementButtonStyle):
Canonical link: https://commits.webkit.org/292441@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list