Changeset 140324 in webkit


Ignore:
Timestamp:
Jan 21, 2013 4:50:30 AM (11 years ago)
Author:
tkent@chromium.org
Message:

INPUT_MULTIPLE_FIELDS_UI: should not dispatch 'input' events if the element value is not updated
https://bugs.webkit.org/show_bug.cgi?id=107429

Reviewed by Kentaro Hara.

Source/WebCore:

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

any time the user causes the element's value to change, the user agent
must queue a task to fire a simple event that bubbles named input at the
input element.

Tests:
fast/forms/time-multiple-fields/time-multiple-fields-keyboard-event.html
is updated to cover this change.

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

(WebCore::BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged):
If the new value is equivalent to the old value, don't dispatch events.
However we should recalculate validity and call notifyFormStateChanged
because input.validity.badInput state might be changed.

LayoutTests:

  • fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
  • fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r140321 r140324  
     12013-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: should not dispatch 'input' events if the element value is not updated
     4        https://bugs.webkit.org/show_bug.cgi?id=107429
     5
     6        Reviewed by Kentaro Hara.
     7
     8        * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt:
     9        * fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html:
     10
    1112013-01-21  Alexander Pavlov  <apavlov@chromium.org>
    212
  • trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events-expected.txt

    r138365 r140324  
    1414 
    1515== Digit keys ==
     16PASS eventsCounter.input is undefined.
     17PASS eventsCounter.change is undefined.
    1618PASS input.value is "07:56"
     19PASS eventsCounter.input is 1
     20PASS eventsCounter.change is 1
    1721== Digit keys starting with zero ==
    1822PASS input.value is "14:03"
     
    2630PASS input.value is "03:56"
    2731== Up/Down keys on empty value ==
     32PASS eventsCounter.input is undefined.
     33PASS eventsCounter.change is undefined.
    2834PASS input.value is "14:58"
     35PASS eventsCounter.input is 1
     36PASS eventsCounter.change is 1
    2937== Tab key ==
    3038PASS input.value is "03:05"
  • trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-keyboard-events.html

    r138365 r140324  
    4242}
    4343
     44var eventsCounter = {};
     45function countEvents(event)
     46{
     47    if (eventsCounter[event.type] === undefined)
     48        eventsCounter[event.type] = 0;
     49    eventsCounter[event.type]++;
     50}
     51input.addEventListener('input', countEvents, false);
     52input.addEventListener('change', countEvents, false);
     53
    4454beginTest('Digit keys');
    45 keyDown('7');
    46 keyDown('5');
    47 keyDown('6');
    48 keyDown('A');
     55keyDown('7'); // -> 07:[--] --
     56keyDown('5'); // -> 07:[05] --
     57keyDown('6'); // -> 07:56 [--]
     58shouldBeUndefined('eventsCounter.input');
     59shouldBeUndefined('eventsCounter.change');
     60keyDown('A'); // -> 07:56 [AM]
    4961shouldBeEqualToString('input.value', '07:56');
     62shouldBe('eventsCounter.input', '1');
     63shouldBe('eventsCounter.change', '1');
    5064
    5165beginTest('Digit keys starting with zero');
     
    98112
    99113beginTest('Up/Down keys on empty value', '');
    100 keyDown('upArrow');
    101 keyDown('upArrow');
    102 keyDown('rightArrow');
    103 keyDown('downArrow');
    104 keyDown('downArrow');
    105 keyDown('rightArrow');
    106 keyDown('downArrow');
     114eventsCounter = {};
     115keyDown('upArrow');    // -> [01]:-- --
     116keyDown('upArrow');    // -> [02]:-- --
     117keyDown('rightArrow'); // -> 02:[--] --
     118keyDown('downArrow');  // -> 02:[59] --
     119keyDown('downArrow');  // -> 02:[58] --
     120keyDown('rightArrow'); // -> 02:58 [--]
     121shouldBeUndefined('eventsCounter.input');
     122shouldBeUndefined('eventsCounter.change');
     123keyDown('downArrow');  // -> 02:58 [PM]
    107124shouldBeEqualToString('input.value', '14:58');
     125shouldBe('eventsCounter.input', '1');
     126shouldBe('eventsCounter.change', '1');
    108127
    109128beginTest('Tab key', '03:00');
  • trunk/Source/WebCore/ChangeLog

    r140321 r140324  
     12013-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: should not dispatch 'input' events if the element value is not updated
     4        https://bugs.webkit.org/show_bug.cgi?id=107429
     5
     6        Reviewed by Kentaro Hara.
     7
     8        http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#common-event-behaviors
     9        > any time the user causes the element's value to change, the user agent
     10        > must queue a task to fire a simple event that bubbles named input at the
     11        > input element.
     12
     13        Tests:
     14        fast/forms/time-multiple-fields/time-multiple-fields-keyboard-event.html
     15        is updated to cover this change.
     16
     17        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     18        (WebCore::BaseMultipleFieldsDateAndTimeInputType::editControlValueChanged):
     19        If the new value is equivalent to the old value, don't dispatch events.
     20        However we should recalculate validity and call notifyFormStateChanged
     21        because input.validity.badInput state might be changed.
     22
    1232013-01-21  Alexander Pavlov  <apavlov@chromium.org>
    224
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r139424 r140324  
    7474{
    7575    RefPtr<HTMLInputElement> input(element());
    76     input->setValueInternal(sanitizeValue(m_dateTimeEditElement->value()), DispatchNoEvent);
    77     input->setNeedsStyleRecalc();
    78     input->dispatchFormControlInputEvent();
    79     input->dispatchFormControlChangeEvent();
     76    String oldValue = input->value();
     77    String newValue = sanitizeValue(m_dateTimeEditElement->value());
     78    // Even if oldValue is null and newValue is "", we should assume they are same.
     79    if ((oldValue.isEmpty() && newValue.isEmpty()) || oldValue == newValue)
     80        input->setNeedsValidityCheck();
     81    else {
     82        input->setValueInternal(newValue, DispatchNoEvent);
     83        input->setNeedsStyleRecalc();
     84        input->dispatchFormControlInputEvent();
     85        input->dispatchFormControlChangeEvent();
     86    }
    8087    input->notifyFormStateChanged();
    8188}
Note: See TracChangeset for help on using the changeset viewer.