Changeset 140385 in webkit


Ignore:
Timestamp:
Jan 21, 2013 10:17:21 PM (11 years ago)
Author:
tkent@chromium.org
Message:

Date selection from calendar picker should dispatch 'input' event in addition to 'change' event
https://bugs.webkit.org/show_bug.cgi?id=107427

Reviewed by Kentaro Hara.

Source/WebCore:

According to the specification and Opera's behavior, we should dispatch
not only 'change' event but also 'input' event when a user chooses a
date from the calender picker.

http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#common-event-behaviors

When the user agent changes the element's value on behalf of the user
(e.g. as part of a form prefilling feature), the user agent must follow
these steps:

  1. If the input event applies, queue a task to fire a simple event

that bubbles named input at the input element.

  1. If the change event applies, queue a task to fire a simple event

that bubbles named change at the input element.

Tests: platform/chromium/fast/forms/calendar-picker/date-picker-events.html

platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events.html

  • html/InputType.cpp:

(WebCore::InputType::setValue): Add DispatchInputAndChangeEvent support.

  • html/BaseChooserOnlyDateAndTimeInputType.cpp:

(WebCore::BaseChooserOnlyDateAndTimeInputType::didChooseValue):
Use DispatchInputAndChangeEvent, not DispatchChangeEvent.

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

(WebCore::BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorChooseValue):
Ditto.

LayoutTests:

  • platform/chromium/fast/forms/calendar-picker/date-picker-events-expected.txt: Added.
  • platform/chromium/fast/forms/calendar-picker/date-picker-events.html: Added.
  • platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events-expected.txt: Added.
  • platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140378 r140385  
     12013-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        Date selection from calendar picker should dispatch 'input' event in addition to 'change' event
     4        https://bugs.webkit.org/show_bug.cgi?id=107427
     5
     6        Reviewed by Kentaro Hara.
     7
     8        * platform/chromium/fast/forms/calendar-picker/date-picker-events-expected.txt: Added.
     9        * platform/chromium/fast/forms/calendar-picker/date-picker-events.html: Added.
     10        * platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events-expected.txt: Added.
     11        * platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events.html: Added.
     12
    1132013-01-21  Noel Gordon  <noel.gordon@gmail.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r140384 r140385  
     12013-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        Date selection from calendar picker should dispatch 'input' event in addition to 'change' event
     4        https://bugs.webkit.org/show_bug.cgi?id=107427
     5
     6        Reviewed by Kentaro Hara.
     7
     8        According to the specification and Opera's behavior, we should dispatch
     9        not only 'change' event but also 'input' event when a user chooses a
     10        date from the calender picker.
     11
     12        http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#common-event-behaviors
     13        > When the user agent changes the element's value on behalf of the user
     14        > (e.g. as part of a form prefilling feature), the user agent must follow
     15        > these steps:
     16        > 1. If the input event applies, queue a task to fire a simple event
     17        > that bubbles named input at the input element.
     18        > 2. If the change event applies, queue a task to fire a simple event
     19        > that bubbles named change at the input element.
     20
     21        Tests: platform/chromium/fast/forms/calendar-picker/date-picker-events.html
     22               platform/chromium/fast/forms/calendar-picker/datetimelocal-picker-events.html
     23
     24        * html/InputType.cpp:
     25        (WebCore::InputType::setValue): Add DispatchInputAndChangeEvent support.
     26        * html/BaseChooserOnlyDateAndTimeInputType.cpp:
     27        (WebCore::BaseChooserOnlyDateAndTimeInputType::didChooseValue):
     28        Use DispatchInputAndChangeEvent, not DispatchChangeEvent.
     29        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     30        (WebCore::BaseMultipleFieldsDateAndTimeInputType::pickerIndicatorChooseValue):
     31        Ditto.
     32
    1332013-01-21  Justin Schuh  <jschuh@chromium.org>
    234
  • trunk/Source/WebCore/html/BaseChooserOnlyDateAndTimeInputType.cpp

    r139424 r140385  
    9797void BaseChooserOnlyDateAndTimeInputType::didChooseValue(const String& value)
    9898{
    99     element()->setValue(value, DispatchChangeEvent);
     99    element()->setValue(value, DispatchInputAndChangeEvent);
    100100}
    101101
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r140324 r140385  
    141141{
    142142    if (element()->isValidValue(value)) {
    143         element()->setValue(value, DispatchChangeEvent);
     143        element()->setValue(value, DispatchInputAndChangeEvent);
    144144        return;
    145145    }
  • trunk/Source/WebCore/html/InputType.cpp

    r139410 r140385  
    675675    element()->setValueInternal(sanitizedValue, eventBehavior);
    676676    element()->setNeedsStyleRecalc();
    677     if (valueChanged && eventBehavior != DispatchNoEvent)
     677    if (!valueChanged)
     678        return;
     679    switch (eventBehavior) {
     680    case DispatchChangeEvent:
    678681        element()->dispatchFormControlChangeEvent();
     682        break;
     683    case DispatchInputAndChangeEvent:
     684        element()->dispatchFormControlInputEvent();
     685        element()->dispatchFormControlChangeEvent();
     686        break;
     687    case DispatchNoEvent:
     688        break;
     689    }
    679690}
    680691
Note: See TracChangeset for help on using the changeset viewer.