[webkit-changes] [WebKit/WebKit] 11990f: :user-invalid triggering while typing date

Aditya Keerthi noreply at github.com
Wed Dec 20 06:59:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 11990f0a5913ec3eb25802624dfb35975fea5a64
      https://github.com/WebKit/WebKit/commit/11990f0a5913ec3eb25802624dfb35975fea5a64
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-12-20 (Wed, 20 Dec 2023)

  Changed paths:
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-input-and-change-events-expected.txt
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-input-and-change-events.html
    M LayoutTests/fast/forms/date/date-editable-components/date-editable-components-keyboard-events-expected.txt
    M LayoutTests/fast/forms/date/date-editable-components/date-editable-components-keyboard-events.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-expected.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-uncommitted-expected.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-uncommitted.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-with-empty-components-expected.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-with-empty-components.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-expected.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-uncommitted-expected.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-uncommitted.html
    A LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid.html
    M LayoutTests/fast/forms/date/date-editable-components/date-multiple-fields-choose-default-value-after-set-value.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-input-and-change-events-expected.txt
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-input-and-change-events.html
    M LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-keyboard-events-expected.txt
    M LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-keyboard-events.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-expected.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-uncommitted-expected.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-uncommitted.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-with-empty-components-expected.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-with-empty-components.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-expected.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-uncommitted-expected.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-uncommitted.html
    A LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid.html
    M LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-multiple-fields-choose-default-value-after-set-value.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-input-and-change-events-expected.txt
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-input-and-change-events.html
    M LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt
    M LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-expected.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-uncommitted-expected.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-uncommitted.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-with-empty-components-expected.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-with-empty-components.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-expected.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-uncommitted-expected.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-uncommitted.html
    A LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-input-and-change-events-expected.txt
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-input-and-change-events.html
    M LayoutTests/fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt
    M LayoutTests/fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-expected.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-uncommitted-expected.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-uncommitted.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-with-empty-components-expected.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-with-empty-components.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-expected.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-uncommitted-expected.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-uncommitted.html
    A LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid.html
    M LayoutTests/fast/forms/time/time-editable-components/time-multiple-fields-choose-default-value-after-set-value.html
    M Source/WebCore/html/BaseDateAndTimeInputType.cpp

  Log Message:
  -----------
  :user-invalid triggering while typing date
https://bugs.webkit.org/show_bug.cgi?id=257999
rdar://110687369

Reviewed by Tim Nguyen and Wenson Hsieh.

In order to dispatch input/change events for date/time inputs with multiple
editable fields, the element value is compared to the value derived from the
content of each field, every time the content of an individual field changes.

However, since the initial value of an element is a null string, and the
derived value is a sanitized string which defaults to the empty string,
comparing the two strings results in inequality. Consequently, an input event
is unexpectedly dispatched. Since the same machinery is involved in matching
`:user-invalid`, `:user-invalid` is also unexpectedly triggered as the user
types an incomplete date.

Fix by using `equalIgnoringNullity` to compare the two strings. This is correct
since `HTMLInputElement`'s value uses `LegacyNullToEmptyString`.

Additionally, `:user-invalid` and `:user-valid` apply too early for date/time
inputs with editable fields. Specifically, the apply immediately once the value
of the input changes, not after the element loses focus following a value change.
This behavior also means that the "change" event fires too early. Since this
value is modified by typing, `:user-invalid` and `:user-valid` should only apply
after the input has lost focus, when matching for the first time. Fix by
reworking the event dispatch logic when the value is changed by typing.

Add additional test coverage for `input`, `change`, `:user-invalid`, and
`:user-valid` for date/time inputs.

* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-input-and-change-events-expected.txt: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-input-and-change-events.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-keyboard-events-expected.txt:
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-keyboard-events.html:
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-expected.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-uncommitted.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-with-empty-components-expected.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid-with-empty-components.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-invalid.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-expected.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid-uncommitted.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-editable-components-user-valid.html: Added.
* LayoutTests/fast/forms/date/date-editable-components/date-multiple-fields-choose-default-value-after-set-value.html:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-input-and-change-events-expected.txt: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-input-and-change-events.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-keyboard-events-expected.txt:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-keyboard-events.html:
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-expected.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-uncommitted.htm Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-with-empty-components-expected.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid-with-empty-components.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-invalid.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-expected.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid-uncommitted.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-user-valid.html: Added.
* LayoutTests/fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-multiple-fields-choose-default-value-after-set-value.html:
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-input-and-change-events-expected.txt: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-input-and-change-events.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events-expected.txt:
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-keyboard-events.html:
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-expected.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-uncommitted.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-with-empty-components-expected.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid-with-empty-components.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-invalid.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-expected.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid-uncommitted.html: Added.
* LayoutTests/fast/forms/month/month-editable-components/month-editable-components-user-valid.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-input-and-change-events-expected.txt: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-input-and-change-events.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-keyboard-events-expected.txt:
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-keyboard-events.html:
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-expected.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-uncommitted.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-with-empty-components-expected.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid-with-empty-components.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-invalid.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-expected.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-uncommitted-expected.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid-uncommitted.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-editable-components-user-valid.html: Added.
* LayoutTests/fast/forms/time/time-editable-components/time-multiple-fields-choose-default-value-after-set-value.html:
* Source/WebCore/html/BaseDateAndTimeInputType.cpp:
(WebCore::BaseDateAndTimeInputType::didBlurFromControl):

When a date/time input with editable fields is focused, the actual focused
element will be one of it's editable fields. If one of the fields is blurred,
dispatch the "change" event if the value has changed since the previous "change"
event.

(WebCore::BaseDateAndTimeInputType::didChangeValueFromControl):

Dispatch only the input event when the input focused, following a change via
typing in one of the editable fields.

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




More information about the webkit-changes mailing list