Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update input[type=*]'s step base handling to match spec #22889

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Jan 18, 2024

5b73f8e

Update input[type=*]'s step base handling to match spec

https://bugs.webkit.org/show_bug.cgi?id=254761
rdar://problem/107721910

Reviewed by Aditya Keerthi.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge [1]: https://chromium.googlesource.com/chromium/src.git/+/0f836e3f330abbd76df604090db47c6e8fccd5b1

Determine the step base for an input element per spec:

Spec: https://html.spec.whatwg.org/#concept-input-min-zero

That is, consult the 'value' attribute if 'min' is not present, and
then fallback to the default step base for the input type if that
isn't present either. Previously, 'value' was not considered.

Merge [2]: https://chromium.googlesource.com/chromium/src.git/+/f0af3d9cd0b5e0b05f20cd8c4f20103f572f14ef

The HTML spec recently shifted to using 'value' as the first fallback
option for an input element's "step base" (if no 'min' attribute):

Spec: https://html.spec.whatwg.org/#concept-input-min-zero

Also bring type=range elements into line with that, including using
that step base when clamping values to the supported range.

Merge [3]: https://chromium.googlesource.com/chromium/src.git/+/807ab32fd2e5accda8c5cef2678e0e0af23158b0

According to the specification, we should not resolve step-mismatch if there are
no step-matched values in the range. So, StepRange::clampValue() should return
the minimum value or the maximum value.

Spec: https://html.spec.whatwg.org/multipage/input.html#range-state-(type%3Drange)

Merge [4]: chromium/chromium@fb67b32

The spec for stepUp()/stepDown():

Spec: https://html.spec.whatwg.org/#dom-input-stepdown

requires that out-of-step values snap to step, just like the UI
implementation will do. Hence, bring the required clamping/snapping
handling into scope.

NOTE - It matches Blink from top of tree to avoid stack overflow issue:

Stack Overflow: https://source.chromium.org/chromium/chromium/src/+/ebc1f01b3fdba6c8b1b2b1075e029cd317c685ee

* Source/WebCore/html/InputType.cpp:
(InputType::findStepBase): Add Helping function
(InputType::applyStep): Update to spec
* Source/WebCore/html/InputType.h: Helper function definition
* Source/WebCore/html/MonthInputType.cpp:
(MonthInputType::defaultValueForStepUp): Use ’findStepBase’
* Source/WebCore/html/NumberInputType.cpp:
(NumberInputType::createStepRange): Use ’findStepBase’ and remove already covered ‘NaN’ handling
* Source/WebCore/html/TimeInputType.cpp:
(TimeInputType:: createStepRange): Use ’findStepBase’
* Source/WebCore/html/WeekInputType.cpp:
(WeekInputType:: createStepRange): Use ’findStepBase’
* Source/WebCore/html/RangeInputType.cpp:
(RangeInputType::createStepRange): Use 'findStepBase'
* Source/WebCore/html/StepRange.cpp:
(StepRange::clampValue): clampValue but respect 'stepBase'
* LayoutTests/fast/forms/week/week-stepup-stepdown.html:
* LayoutTests/fast/forms/time/time-stepup-stepdown.html:
* LayoutTests/fast/forms/range/range-stepup-stepdown.html: Removed duplicate tests as well
* LayoutTests/fast/forms/number/number-stepup-stepdown.html: Ditto
* LayoutTests/fast/forms/month/month-stepup-stepdown.html:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown.html:
* LayoutTests/fast/forms/date/date-stepup-stepdown.html:
* LayoutTests/fast/forms/date/date-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/month/month-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/range/range-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/time/time-stepup-stepdown-expected.txt: Fail Tests also fail in Blink
* LayoutTests/fast/forms/week/week-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/date/input-date-validation-message.html: Rebaselined

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

0749912

Misc iOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 wincairo
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 wincairo-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
⏳ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 tv ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 tv-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 watch
✅ 🛠 watch-sim

@Ahmad-S792 Ahmad-S792 self-assigned this Jan 18, 2024
@Ahmad-S792 Ahmad-S792 changed the title [WIP] Update input[type=*]'s step base handling to match spec Update input[type=*]'s step base handling to match spec Jan 18, 2024
@webkit-early-warning-system

This comment was marked as outdated.

@Ahmad-S792 Ahmad-S792 added the Forms For bugs specific to form elements (checkboxes, buttons, text fields, etc.) label Jan 18, 2024
@webkit-early-warning-system

This comment was marked as outdated.

@Ahmad-S792 Ahmad-S792 marked this pull request as ready for review January 18, 2024 14:36
@Ahmad-S792 Ahmad-S792 marked this pull request as draft January 18, 2024 14:45
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jan 18, 2024
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label May 22, 2024
@webkit-early-warning-system

This comment was marked as duplicate.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 23, 2024
@webkit-early-warning-system

This comment was marked as outdated.

@webkit-early-warning-system

This comment was marked as outdated.

@webkit-early-warning-system

This comment was marked as outdated.

@webkit-early-warning-system

This comment was marked as outdated.

@webkit-early-warning-system

This comment was marked as outdated.

@webkit-early-warning-system

This comment was marked as outdated.

@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label May 25, 2024
@Ahmad-S792 Ahmad-S792 marked this pull request as ready for review May 25, 2024 23:24
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label May 26, 2024
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label May 26, 2024
@pxlcoder
Copy link
Member

@Ahmad-S792 Are there any WPTs that cover this spec behavior?

@Ahmad-S792
Copy link
Contributor Author

Ahmad-S792 commented May 28, 2024

@Ahmad-S792 Are there any WPTs that cover this spec behavior?

Unfortunately not - at least, I couldn't find one.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 14, 2024
@Ahmad-S792 Ahmad-S792 removed the merging-blocked Applied to prevent a change from being merged label Jun 15, 2024
@Ahmad-S792 Ahmad-S792 added the merge-queue Applied to send a pull request to merge-queue label Jun 18, 2024
https://bugs.webkit.org/show_bug.cgi?id=254761
rdar://problem/107721910

Reviewed by Aditya Keerthi.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

Merge [1]: https://chromium.googlesource.com/chromium/src.git/+/0f836e3f330abbd76df604090db47c6e8fccd5b1

Determine the step base for an input element per spec:

Spec: https://html.spec.whatwg.org/#concept-input-min-zero

That is, consult the 'value' attribute if 'min' is not present, and
then fallback to the default step base for the input type if that
isn't present either. Previously, 'value' was not considered.

Merge [2]: https://chromium.googlesource.com/chromium/src.git/+/f0af3d9cd0b5e0b05f20cd8c4f20103f572f14ef

The HTML spec recently shifted to using 'value' as the first fallback
option for an input element's "step base" (if no 'min' attribute):

Spec: https://html.spec.whatwg.org/#concept-input-min-zero

Also bring type=range elements into line with that, including using
that step base when clamping values to the supported range.

Merge [3]: https://chromium.googlesource.com/chromium/src.git/+/807ab32fd2e5accda8c5cef2678e0e0af23158b0

According to the specification, we should not resolve step-mismatch if there are
no step-matched values in the range. So, StepRange::clampValue() should return
the minimum value or the maximum value.

Spec: https://html.spec.whatwg.org/multipage/input.html#range-state-(type%3Drange)

Merge [4]: chromium/chromium@fb67b32

The spec for stepUp()/stepDown():

Spec: https://html.spec.whatwg.org/#dom-input-stepdown

requires that out-of-step values snap to step, just like the UI
implementation will do. Hence, bring the required clamping/snapping
handling into scope.

NOTE - It matches Blink from top of tree to avoid stack overflow issue:

Stack Overflow: https://source.chromium.org/chromium/chromium/src/+/ebc1f01b3fdba6c8b1b2b1075e029cd317c685ee

* Source/WebCore/html/InputType.cpp:
(InputType::findStepBase): Add Helping function
(InputType::applyStep): Update to spec
* Source/WebCore/html/InputType.h: Helper function definition
* Source/WebCore/html/MonthInputType.cpp:
(MonthInputType::defaultValueForStepUp): Use ’findStepBase’
* Source/WebCore/html/NumberInputType.cpp:
(NumberInputType::createStepRange): Use ’findStepBase’ and remove already covered ‘NaN’ handling
* Source/WebCore/html/TimeInputType.cpp:
(TimeInputType:: createStepRange): Use ’findStepBase’
* Source/WebCore/html/WeekInputType.cpp:
(WeekInputType:: createStepRange): Use ’findStepBase’
* Source/WebCore/html/RangeInputType.cpp:
(RangeInputType::createStepRange): Use 'findStepBase'
* Source/WebCore/html/StepRange.cpp:
(StepRange::clampValue): clampValue but respect 'stepBase'
* LayoutTests/fast/forms/week/week-stepup-stepdown.html:
* LayoutTests/fast/forms/time/time-stepup-stepdown.html:
* LayoutTests/fast/forms/range/range-stepup-stepdown.html: Removed duplicate tests as well
* LayoutTests/fast/forms/number/number-stepup-stepdown.html: Ditto
* LayoutTests/fast/forms/month/month-stepup-stepdown.html:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown.html:
* LayoutTests/fast/forms/date/date-stepup-stepdown.html:
* LayoutTests/fast/forms/date/date-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/datetimelocal/datetimelocal-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/month/month-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/range/range-stepup-stepdown-expected.txt: Ditto
* LayoutTests/fast/forms/time/time-stepup-stepdown-expected.txt: Fail Tests also fail in Blink
* LayoutTests/fast/forms/week/week-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt: Rebaselined
* LayoutTests/fast/forms/date/input-date-validation-message.html: Rebaselined

Canonical link: https://commits.webkit.org/280127@main
@webkit-commit-queue
Copy link
Collaborator

Committed 280127@main (5b73f8e): https://commits.webkit.org/280127@main

Reviewed commits have been landed. Closing PR #22889 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 18, 2024
@webkit-commit-queue webkit-commit-queue merged commit 5b73f8e into WebKit:main Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Forms For bugs specific to form elements (checkboxes, buttons, text fields, etc.)
Projects
None yet
5 participants