Changeset 53598 in webkit


Ignore:
Timestamp:
Jan 20, 2010 8:39:06 PM (14 years ago)
Author:
eric@webkit.org
Message:

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

Reviewed by Darin Adler.

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

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

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

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

Reviewed by Darin Adler.

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

Introduce ISODateTime::setMillisecondsSinceEpochForDate() and add Date
type support to ISODateTime::toString().

  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setValueAsDate):
  • html/ISODateTime.cpp: (WebCore::ISODateTime::setMillisecondsSinceEpochForDate): (WebCore::ISODateTime::toString):
  • html/ISODateTime.h:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53597 r53598  
     12010-01-20  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        HTMLInputElement::valueAsDate setter support for type=date.
     6        https://bugs.webkit.org/show_bug.cgi?id=33911
     7
     8        Add setter tests to input-valueasdate-date.js, and update the
     9        expectation.
     10
     11        * fast/forms/input-valueasdate-date-expected.txt:
     12        * fast/forms/script-tests/input-valueasdate-date.js:
     13
    1142010-01-20  Ben Murdoch  <benm@google.com>
    215
  • trunk/LayoutTests/fast/forms/input-valueasdate-date-expected.txt

    r52524 r53598  
    88PASS valueAsDateFor("1970-01-01").getTime() is Date.UTC(1970, 0, 1)
    99PASS valueAsDateFor("2009-12-22").getTime() is Date.UTC(2009, 11, 22)
     10PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12-01"
     11PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01-01"
     12PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12-31"
     13PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01-01"
     14PASS setValueAsDateAndGetValue(794, 9, 22) is ""
     15PASS setValueAsDateAndGetValue(1582, 8, 30) is ""
     16FAIL setValueAsDateAndGetValue(1582, 9, 1) should be 1582-10-01. Was .
     17PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10-31"
     18PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09-13"
     19PASS setValueAsDateAndGetValue(275760, 8, 14) is ""
     20Invalid objects:
     21PASS input.value = "2010-01-01"; input.valueAsDate = document; input.value is ""
     22PASS input.value = "2010-01-01"; input.valueAsDate = null; input.value is ""
    1023PASS successfullyParsed is true
    1124
  • trunk/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js

    r52524 r53598  
    99}
    1010
     11function setValueAsDateAndGetValue(year, month, day) {
     12    var date = new Date();
     13    date.setTime(Date.UTC(year, month, day));
     14    input.valueAsDate = date;
     15    return input.value;
     16}
     17
    1118shouldBe('valueAsDateFor("")', 'null');
    1219shouldBe('valueAsDateFor("1969-12-31").getTime()', 'Date.UTC(1969, 11, 31)');
     
    1421shouldBe('valueAsDateFor("2009-12-22").getTime()', 'Date.UTC(2009, 11, 22)');
    1522
     23shouldBe('setValueAsDateAndGetValue(1969, 11, 1)', '"1969-12-01"');
     24shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01-01"');
     25shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12-31"');
     26shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01-01"');
     27
     28shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""');
     29shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""');
     30shouldBe('setValueAsDateAndGetValue(1582, 9, 1)', '"1582-10-01"');
     31shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10-31"');
     32shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09-13"');
     33shouldBe('setValueAsDateAndGetValue(275760, 8, 14)', '""'); // Date of JavaScript can't represent this.
     34
     35debug('Invalid objects:');
     36shouldBe('input.value = "2010-01-01"; input.valueAsDate = document; input.value', '""');
     37shouldBe('input.value = "2010-01-01"; input.valueAsDate = null; input.value', '""');
     38
    1639var successfullyParsed = true;
  • trunk/WebCore/ChangeLog

    r53597 r53598  
     12010-01-20  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        HTMLInputElement::valueAsDate setter support for type=date.
     6        https://bugs.webkit.org/show_bug.cgi?id=33911
     7
     8        Introduce ISODateTime::setMillisecondsSinceEpochForDate() and add Date
     9        type support to ISODateTime::toString().
     10
     11        * html/HTMLInputElement.cpp:
     12        (WebCore::HTMLInputElement::setValueAsDate):
     13        * html/ISODateTime.cpp:
     14        (WebCore::ISODateTime::setMillisecondsSinceEpochForDate):
     15        (WebCore::ISODateTime::toString):
     16        * html/ISODateTime.h:
     17
    1182010-01-20  Ben Murdoch  <benm@google.com>
    219
  • trunk/WebCore/html/HTMLInputElement.cpp

    r53551 r53598  
    13991399    bool success;
    14001400    switch (inputType()) {
     1401    case DATE:
     1402        success = dateTime.setMillisecondsSinceEpochForDate(value);
     1403        break;
    14011404    case MONTH:
    14021405        success = dateTime.setMillisecondsSinceEpochForMonth(value);
  • trunk/WebCore/html/ISODateTime.cpp

    r53551 r53598  
    477477}
    478478
     479bool ISODateTime::setMillisecondsSinceEpochForDate(double ms)
     480{
     481    if (!isfinite(ms))
     482        return false;
     483    if (!setMillisecondsSinceEpochForDateInternal(ms))
     484        return false;
     485    if (beforeGregorianStartDate(m_year, m_month, m_monthDay))
     486        return false;
     487    m_type = Date;
     488    return true;
     489}
     490
    479491bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms)
    480492{
     
    557569{
    558570    switch (m_type) {
     571    case Date:
     572        return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay);
    559573    case Month:
    560574        return String::format("%04d-%02d", m_year, m_month + 1);
  • trunk/WebCore/html/ISODateTime.h

    r53551 r53598  
    101101    bool parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end);
    102102
    103     // The following setMillisecondsSinceEpochFor*() function takes
     103    // The following setMillisecondsSinceEpochFor*() functions take
    104104    // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as
    105105    // the argument, and update all fields for the corresponding
    106     // ISODateTime type. The function returns true if it succeeds, and
    107     // false if it fails.
     106    // ISODateTime type. The functions return true if it succeeds, and
     107    // false if they fail.
    108108
     109    // For Date type. Updates m_year, m_month and m_monthDay.
     110    bool setMillisecondsSinceEpochForDate(double ms);
    109111    // For Month type. Updates m_year and m_month.
    110112    bool setMillisecondsSinceEpochForMonth(double ms);
Note: See TracChangeset for help on using the changeset viewer.