Changeset 139865 in webkit


Ignore:
Timestamp:
Jan 16, 2013 3:04:36 AM (11 years ago)
Author:
tkent@chromium.org
Message:

INPUT_MULTIPLE_FIELDS_UI: Unable to edit a time field with step=86400, and confusing appearance
https://bugs.webkit.org/show_bug.cgi?id=106983

Reviewed by Kentaro Hara.

Source/WebCore:

For example, we show a read-only hour field and a read-only minutes
field for <input type=time min="17:00" step=86400> because the step
value is 24 hours and the hour field can be only 17. However, we need to
provide a way to clear the value of the time field in such case. We
shouldn't make the hour field read-only if no other fields are editable.

  • We don't make hour fields read-only for input[type=time].
  • We make hour fields read-only for input[type=datetime-local] only if year, month, or day field is editable. e.g. <input type=datetime-local min=2013-01-16T17:00 step=86400>:

The hour field is read-only, and year/month/day fields are editable.

<input type=datetime-local min=2013-01-16T17:00 max=2013-01-16T18:00 step=86400>:

The hour field is editable, and year/month/day fields are read-only.

Test: fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html

  • html/shadow/DateTimeEditElement.cpp:

(DateTimeEditBuilder): Declare new functions.
(WebCore::DateTimeEditBuilder::getRangeOfDayOfMonthField):
Added a function by extracting some code from visitField.
(WebCore::DateTimeEditBuilder::visitField):
(WebCore::DateTimeEditBuilder::shouldDayOfMonthFieldReadOnly):
Added a function by extracting some code from visitField.
(WebCore::DateTimeEditBuilder::shouldHourFieldReadOnly):
If the type is "time", we don't make hour fields read-only.
Otherwise, we don't make hour fields read-only if year/month/day fields
are read-only. Note that we don't need to check read-only status of year
and month fields explicitly here because a day field can be read-only
only if the year field and the month field are read-only.

LayoutTests:

Note: We don't add tests for input[type=datetime] now because the WHATWG
specification might be changed.

  • fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield-expected.txt: Added.
  • fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html: Added.
  • fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield-expected.txt:
  • fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield.html:

Update test cases for new behavior. We should not make hour fields
read-only for input[type=time].

  • platform/chromium-mac/fast/forms/time/time-appearance-basic-expected.png: Ditto.
  • platform/chromium/TestExpectations: Add time-appearance-basic.html.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r139863 r139865  
     12013-01-16  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: Unable to edit a time field with step=86400, and confusing appearance
     4        https://bugs.webkit.org/show_bug.cgi?id=106983
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Note: We don't add tests for input[type=datetime] now because the WHATWG
     9        specification might be changed.
     10
     11        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield-expected.txt: Added.
     12        * fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html: Added.
     13
     14        * fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield-expected.txt:
     15        * fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield.html:
     16        Update test cases for new behavior. We should not make hour fields
     17        read-only for input[type=time].
     18        * platform/chromium-mac/fast/forms/time/time-appearance-basic-expected.png: Ditto.
     19        * platform/chromium/TestExpectations: Add time-appearance-basic.html.
     20
    1212013-01-16  Nandor Huszka  <hnandor@inf.u-szeged.hu>
    222
  • trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield-expected.txt

    r134390 r139865  
    2323PASS isReadOnlyField(createTimeInput("00:00", step1hour, "00:35"), pseudoMinute) is false
    2424Hour field:
    25 PASS isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoHour) is true
    26 PASS isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoAMPM) is true
     25PASS isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoHour) is false
     26PASS isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoAMPM) is false
    2727PASS isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoMinute) is true
    28 PASS isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoHour) is true
    29 PASS isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoAMPM) is true
     28PASS isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoHour) is false
     29PASS isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoAMPM) is false
    3030PASS isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoMinute) is true
    3131PASS isReadOnlyField(createTimeInput("11:30", step1day, "12:30"), pseudoHour) is false
  • trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield.html

    r134390 r139865  
    5454
    5555debug('Hour field:');
    56 shouldBeTrue('isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoHour)');
    57 shouldBeTrue('isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoAMPM)');
     56shouldBeFalse('isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoHour)');
     57shouldBeFalse('isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoAMPM)');
    5858shouldBeTrue('isReadOnlyField(createTimeInput("11:00", step1day, ""), pseudoMinute)');
    59 shouldBeTrue('isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoHour)');
    60 shouldBeTrue('isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoAMPM)');
     59shouldBeFalse('isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoHour)');
     60shouldBeFalse('isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoAMPM)');
    6161shouldBeTrue('isReadOnlyField(createTimeInput("11:30", step1day, "11:30"), pseudoMinute)');
    6262shouldBeFalse('isReadOnlyField(createTimeInput("11:30", step1day, "12:30"), pseudoHour)');
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r139846 r139865  
    40924092webkit.org/b/104993 [ XP ] fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html [ Failure ]
    40934093
     4094# Need rebaseline
     4095webkit.org/b/106983 fast/forms/time/time-appearance-basic.html [ Failure ]
     4096
    40944097webkit.org/b/106518 compositing/iframes/iframe-content-flipping.html [ ImageOnlyFailure ]
    40954098webkit.org/b/106518 platform/chromium/virtual/softwarecompositing/iframes/iframe-content-flipping.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r139864 r139865  
     12013-01-16  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: Unable to edit a time field with step=86400, and confusing appearance
     4        https://bugs.webkit.org/show_bug.cgi?id=106983
     5
     6        Reviewed by Kentaro Hara.
     7
     8        For example, we show a read-only hour field and a read-only minutes
     9        field for <input type=time min="17:00" step=86400> because the step
     10        value is 24 hours and the hour field can be only 17. However, we need to
     11        provide a way to clear the value of the time field in such case. We
     12        shouldn't make the hour field read-only if no other fields are editable.
     13
     14        - We don't make hour fields read-only for input[type=time].
     15
     16        - We make hour fields read-only for input[type=datetime-local] only if
     17          year, month, or day field is editable. e.g.
     18          <input type=datetime-local min=2013-01-16T17:00 step=86400>:
     19            The hour field is read-only, and year/month/day fields are editable.
     20          <input type=datetime-local min=2013-01-16T17:00 max=2013-01-16T18:00 step=86400>:
     21            The hour field is editable, and year/month/day fields are read-only.
     22
     23        Test: fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html
     24
     25        * html/shadow/DateTimeEditElement.cpp:
     26        (DateTimeEditBuilder): Declare new functions.
     27        (WebCore::DateTimeEditBuilder::getRangeOfDayOfMonthField):
     28        Added a function by extracting some code from visitField.
     29        (WebCore::DateTimeEditBuilder::visitField):
     30        (WebCore::DateTimeEditBuilder::shouldDayOfMonthFieldReadOnly):
     31        Added a function by extracting some code from visitField.
     32        (WebCore::DateTimeEditBuilder::shouldHourFieldReadOnly):
     33        If the type is "time", we don't make hour fields read-only.
     34        Otherwise, we don't make hour fields read-only if year/month/day fields
     35        are read-only. Note that we don't need to check read-only status of year
     36        and month fields explicitly here because a day field can be read-only
     37        only if the year field and the month field are read-only.
     38
    1392013-01-16  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    240
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp

    r139174 r139865  
    6060
    6161private:
     62    void getRangeOfDayOfMonthField(int& minDay, int& maxDay) const;
    6263    bool needMillisecondField() const;
     64    bool shouldDayOfMonthFieldReadOnly(int minDay, int maxDay) const;
    6365    bool shouldHourFieldReadOnly() const;
    6466    bool shouldMillisecondFieldReadOnly() const;
     
    9193}
    9294
     95void DateTimeEditBuilder::getRangeOfDayOfMonthField(int& minDay, int& maxDay) const
     96{
     97    minDay = 1;
     98    maxDay = 31;
     99    if (m_parameters.minimum.type() != DateComponents::Invalid
     100        && m_parameters.maximum.type() != DateComponents::Invalid
     101        && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear()
     102        && m_parameters.minimum.month() == m_parameters.maximum.month()
     103        && m_parameters.minimum.monthDay() <= m_parameters.maximum.monthDay()) {
     104        minDay = m_parameters.minimum.monthDay();
     105        maxDay = m_parameters.maximum.monthDay();
     106    }
     107}
     108
    93109bool DateTimeEditBuilder::needMillisecondField() const
    94110{
     
    107123    switch (fieldType) {
    108124    case DateTimeFormat::FieldTypeDayOfMonth: {
    109         int minDay = 1, maxDay = 31;
    110         if (m_parameters.minimum.type() != DateComponents::Invalid
    111             && m_parameters.maximum.type() != DateComponents::Invalid
    112             && m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear()
    113             && m_parameters.minimum.month() == m_parameters.maximum.month()
    114             && m_parameters.minimum.monthDay() <= m_parameters.maximum.monthDay()) {
    115             minDay = m_parameters.minimum.monthDay();
    116             maxDay = m_parameters.maximum.monthDay();
    117         }
     125        int minDay, maxDay;
     126        getRangeOfDayOfMonthField(minDay, maxDay);
    118127        RefPtr<DateTimeFieldElement> field = DateTimeDayFieldElement::create(document, m_editElement, m_parameters.placeholderForDay, minDay, maxDay);
    119128        m_editElement.addField(field);
    120         if (minDay == maxDay && minDay == m_dateValue.monthDay() && m_dateValue.type() != DateComponents::Date) {
     129        if (shouldDayOfMonthFieldReadOnly(minDay, maxDay)) {
    121130            field->setValueAsDate(m_dateValue);
    122131            field->setReadOnly();
     
    297306}
    298307
     308bool DateTimeEditBuilder::shouldDayOfMonthFieldReadOnly(int minDay, int maxDay) const
     309{
     310    return minDay == maxDay && minDay == m_dateValue.monthDay() && m_dateValue.type() != DateComponents::Date;
     311}
     312
    299313bool DateTimeEditBuilder::shouldHourFieldReadOnly() const
    300314{
     315    if (m_dateValue.type() == DateComponents::Time)
     316        return false;
     317    ASSERT(m_dateValue.type() == DateComponents::DateTimeLocal || m_dateValue.type() == DateComponents::DateTime);
     318    int minDay, maxDay;
     319    getRangeOfDayOfMonthField(minDay, maxDay);
     320    if (shouldDayOfMonthFieldReadOnly(minDay, maxDay)) {
     321        ASSERT(m_parameters.minimum.fullYear() == m_parameters.maximum.fullYear());
     322        ASSERT(m_parameters.minimum.month() == m_parameters.maximum.month());
     323        return false;
     324    }
     325
    301326    const Decimal decimalMsPerDay(static_cast<int>(msPerDay));
    302327    Decimal hourPartOfMinimum = (stepRange().minimum().abs().remainder(decimalMsPerDay) / static_cast<int>(msPerHour)).floor();
Note: See TracChangeset for help on using the changeset viewer.