Changeset 53669 in webkit


Ignore:
Timestamp:
Jan 21, 2010 7:29:30 PM (14 years ago)
Author:
tkent@chromium.org
Message:

2010-01-21 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.

HTMLInputElement::valueAsDate setter support for type=datetime.
https://bugs.webkit.org/show_bug.cgi?id=33939

Add setter tests to input-valueasdate-datetime.js, and update the
expectation.

Note: the expectation file contains some FAIL lines. They are
intentional because they test a unimplemented feature.

  • fast/forms/input-valueasdate-datetime-expected.txt:
  • fast/forms/script-tests/input-valueasdate-datetime.js:

2010-01-21 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.

HTMLInputElement::valueAsDate setter support for type=datetime.
https://bugs.webkit.org/show_bug.cgi?id=33939

Introduce ISODateTime::setMillisecondsSinceEpochForDateTime() and add
DateTime type support to ISODateTime::toString().

  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setValueAsDate):
  • html/ISODateTime.cpp: (WebCore::ISODateTime::setMillisecondsSinceEpochForDate): Set Invalid to m_type. (WebCore::ISODateTime::setMillisecondsSinceEpochForDateTime): (WebCore::ISODateTime::setMillisecondsSinceEpochForMonth): Set Invalid to m_type. (WebCore::ISODateTime::setMillisecondsSinceMidnight): Set Invalid to m_type. (WebCore::ISODateTime::toString): Support DateTime type. This always produces UTC representation.
  • html/ISODateTime.h:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53664 r53669  
     12010-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        HTMLInputElement::valueAsDate setter support for type=datetime.
     6        https://bugs.webkit.org/show_bug.cgi?id=33939
     7
     8        Add setter tests to input-valueasdate-datetime.js, and update the
     9        expectation.
     10
     11        Note: the expectation file contains some FAIL lines. They are
     12        intentional because they test a unimplemented feature.
     13
     14        * fast/forms/input-valueasdate-datetime-expected.txt:
     15        * fast/forms/script-tests/input-valueasdate-datetime.js:
     16
    1172010-01-21  Shinichiro Hamaji  <hamaji@chromium.org>
    218
  • trunk/LayoutTests/fast/forms/input-valueasdate-datetime-expected.txt

    r52524 r53669  
    88PASS valueAsDateFor("1970-01-01T00:00:00.000Z").getTime() is Date.UTC(1970, 0, 1, 0, 0, 0)
    99PASS valueAsDateFor("2009-12-22T11:32:11Z").getTime() is Date.UTC(2009, 11, 22, 11, 32, 11)
     10PASS setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0) is "1969-12-01T00:00Z"
     11PASS setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100) is "1970-01-01T10:01:00.100Z"
     12PASS setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999) is "2009-12-31T23:59:59.999Z"
     13PASS setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0) is "10000-01-01T12:00:01Z"
     14PASS setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0) is ""
     15PASS setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999) is ""
     16PASS setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0) is "1582-10-15T00:00Z"
     17PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0) is "275760-09-13T00:00Z"
     18PASS setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1) is ""
     19Invalid objects:
     20PASS input.value = "2010-01-01T00:00Z"; input.valueAsDate = document; input.value is ""
     21PASS input.value = "2010-01-01T00:00Z"; input.valueAsDate = null; input.value is ""
     22Step attribute value and string representation:
     23FAIL input.step = "1"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0) should be 2010-01-21T00:00:00. Was 2010-01-21T00:00Z.
     24FAIL input.step = "0.001"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0) should be 2010-01-21T00:00:00.000. Was 2010-01-21T00:00Z.
    1025PASS successfullyParsed is true
    1126
  • trunk/LayoutTests/fast/forms/script-tests/input-valueasdate-datetime.js

    r52524 r53669  
    99}
    1010
     11function setValueAsDateAndGetValue(year, month, day, hour, minute, second, msec) {
     12    var date = new Date();
     13    date.setTime(Date.UTC(year, month, day, hour, minute, second, msec));
     14    input.valueAsDate = date;
     15    return input.value;
     16}
     17
    1118shouldBe('valueAsDateFor("")', 'null');
    1219shouldBe('valueAsDateFor("1969-12-31T12:34:56.789Z").getTime()', 'Date.UTC(1969, 11, 31, 12, 34, 56, 789)');
     
    1421shouldBe('valueAsDateFor("2009-12-22T11:32:11Z").getTime()', 'Date.UTC(2009, 11, 22, 11, 32, 11)');
    1522
     23shouldBe('setValueAsDateAndGetValue(1969, 11, 1, 0, 0, 0, 0)', '"1969-12-01T00:00Z"');
     24shouldBe('setValueAsDateAndGetValue(1970, 0, 1, 10, 1, 0, 100)', '"1970-01-01T10:01:00.100Z"');
     25shouldBe('setValueAsDateAndGetValue(2009, 11, 31, 23, 59, 59, 999)', '"2009-12-31T23:59:59.999Z"');
     26shouldBe('setValueAsDateAndGetValue(10000, 0, 1, 12, 0, 1, 0)', '"10000-01-01T12:00:01Z"');
     27
     28shouldBe('setValueAsDateAndGetValue(794, 9, 22, 0, 0, 0, 0)', '""');
     29shouldBe('setValueAsDateAndGetValue(1582, 9, 14, 23, 59, 59, 999)', '""');
     30shouldBe('setValueAsDateAndGetValue(1582, 9, 15, 0, 0, 0, 0)', '"1582-10-15T00:00Z"');
     31shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 0)', '"275760-09-13T00:00Z"');
     32shouldBe('setValueAsDateAndGetValue(275760, 8, 13, 0, 0, 0, 1)', '""'); // Date of JavaScript can't represent this.
     33
     34debug('Invalid objects:');
     35shouldBe('input.value = "2010-01-01T00:00Z"; input.valueAsDate = document; input.value', '""');
     36shouldBe('input.value = "2010-01-01T00:00Z"; input.valueAsDate = null; input.value', '""');
     37
     38debug('Step attribute value and string representation:');
     39// If the step attribute value is 1 second and the second part is 0, we should show the second part.
     40shouldBe('input.step = "1"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00:00"');
     41// If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part.
     42shouldBe('input.step = "0.001"; setValueAsDateAndGetValue(2010, 0, 21, 0, 0, 0, 0)', '"2010-01-21T00:00:00.000"');
     43
    1644var successfullyParsed = true;
  • trunk/WebCore/ChangeLog

    r53668 r53669  
     12010-01-21  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        HTMLInputElement::valueAsDate setter support for type=datetime.
     6        https://bugs.webkit.org/show_bug.cgi?id=33939
     7
     8        Introduce ISODateTime::setMillisecondsSinceEpochForDateTime() and add
     9        DateTime type support to ISODateTime::toString().
     10
     11        * html/HTMLInputElement.cpp:
     12        (WebCore::HTMLInputElement::setValueAsDate):
     13        * html/ISODateTime.cpp:
     14        (WebCore::ISODateTime::setMillisecondsSinceEpochForDate):
     15         Set Invalid to m_type.
     16        (WebCore::ISODateTime::setMillisecondsSinceEpochForDateTime):
     17        (WebCore::ISODateTime::setMillisecondsSinceEpochForMonth):
     18         Set Invalid to m_type.
     19        (WebCore::ISODateTime::setMillisecondsSinceMidnight):
     20         Set Invalid to m_type.
     21        (WebCore::ISODateTime::toString):
     22         Support DateTime type. This always produces UTC representation.
     23        * html/ISODateTime.h:
     24
    1252010-01-21  Geoffrey Garen  <ggaren@apple.com>
    226
  • trunk/WebCore/html/HTMLInputElement.cpp

    r53598 r53669  
    14011401    case DATE:
    14021402        success = dateTime.setMillisecondsSinceEpochForDate(value);
     1403        break;
     1404    case DATETIME:
     1405        success = dateTime.setMillisecondsSinceEpochForDateTime(value);
    14031406        break;
    14041407    case MONTH:
  • trunk/WebCore/html/ISODateTime.cpp

    r53598 r53669  
    479479bool ISODateTime::setMillisecondsSinceEpochForDate(double ms)
    480480{
     481    m_type = Invalid;
    481482    if (!isfinite(ms))
    482483        return false;
     484    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
     485        return false;
     486    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
     487        return false;
     488    m_type = Date;
     489    return true;
     490}
     491
     492bool ISODateTime::setMillisecondsSinceEpochForDateTime(double ms)
     493{
     494    m_type = Invalid;
     495    if (!isfinite(ms))
     496        return false;
     497    ms = round(ms);
     498    setMillisecondsSinceMidnightInternal(positiveFmod(ms, msPerDay));
    483499    if (!setMillisecondsSinceEpochForDateInternal(ms))
    484500        return false;
    485501    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
    486502        return false;
    487     m_type = Date;
     503    m_type = DateTime;
    488504    return true;
    489505}
     
    491507bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms)
    492508{
     509    m_type = Invalid;
    493510    if (!isfinite(ms))
    494511        return false;
    495     if (!setMillisecondsSinceEpochForDateInternal(ms))
     512    if (!setMillisecondsSinceEpochForDateInternal(round(ms)))
    496513        return false;
    497514    // Ignore m_monthDay updated by setMillisecondsSinceEpochForDateInternal().
     
    504521bool ISODateTime::setMillisecondsSinceMidnight(double ms)
    505522{
     523    m_type = Invalid;
    506524    if (!isfinite(ms))
    507525        return false;
     
    571589    case Date:
    572590        return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
     591    case DateTime:
     592        return String::format("%04d-%02d-%02dT", m_year, m_month + 1, m_monthDay)
     593            + toStringForTime(format) + String("Z");
    573594    case Month:
    574595        return String::format("%04d-%02d", m_year, m_month + 1);
  • trunk/WebCore/html/ISODateTime.h

    r53598 r53669  
    7979    String toString(SecondFormat format = None) const;
    8080
     81    // parse*() and setMillisecondsSince*() functions are initializers for an
     82    // ISODateTime instance. If these functions return false, the instance
     83    // might be invalid.
     84
    8185    // The following six functions parse the input 'src' whose length is
    8286    // 'length', and updates some fields of this instance. The parsing starts at
     
    109113    // For Date type. Updates m_year, m_month and m_monthDay.
    110114    bool setMillisecondsSinceEpochForDate(double ms);
     115    // For DateTime type. Updates m_year, m_month, m_monthDay, m_hour, m_minute, m_second and m_millisecond.
     116    bool setMillisecondsSinceEpochForDateTime(double ms);
    111117    // For Month type. Updates m_year and m_month.
    112118    bool setMillisecondsSinceEpochForMonth(double ms);
Note: See TracChangeset for help on using the changeset viewer.