Changeset 53598 in webkit
- Timestamp:
- Jan 20, 2010 8:39:06 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r53597 r53598 1 2010-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 1 14 2010-01-20 Ben Murdoch <benm@google.com> 2 15 -
trunk/LayoutTests/fast/forms/input-valueasdate-date-expected.txt
r52524 r53598 8 8 PASS valueAsDateFor("1970-01-01").getTime() is Date.UTC(1970, 0, 1) 9 9 PASS valueAsDateFor("2009-12-22").getTime() is Date.UTC(2009, 11, 22) 10 PASS setValueAsDateAndGetValue(1969, 11, 1) is "1969-12-01" 11 PASS setValueAsDateAndGetValue(1970, 0, 1) is "1970-01-01" 12 PASS setValueAsDateAndGetValue(2009, 11, 31) is "2009-12-31" 13 PASS setValueAsDateAndGetValue(10000, 0, 1) is "10000-01-01" 14 PASS setValueAsDateAndGetValue(794, 9, 22) is "" 15 PASS setValueAsDateAndGetValue(1582, 8, 30) is "" 16 FAIL setValueAsDateAndGetValue(1582, 9, 1) should be 1582-10-01. Was . 17 PASS setValueAsDateAndGetValue(1582, 9, 31) is "1582-10-31" 18 PASS setValueAsDateAndGetValue(275760, 8, 13) is "275760-09-13" 19 PASS setValueAsDateAndGetValue(275760, 8, 14) is "" 20 Invalid objects: 21 PASS input.value = "2010-01-01"; input.valueAsDate = document; input.value is "" 22 PASS input.value = "2010-01-01"; input.valueAsDate = null; input.value is "" 10 23 PASS successfullyParsed is true 11 24 -
trunk/LayoutTests/fast/forms/script-tests/input-valueasdate-date.js
r52524 r53598 9 9 } 10 10 11 function 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 11 18 shouldBe('valueAsDateFor("")', 'null'); 12 19 shouldBe('valueAsDateFor("1969-12-31").getTime()', 'Date.UTC(1969, 11, 31)'); … … 14 21 shouldBe('valueAsDateFor("2009-12-22").getTime()', 'Date.UTC(2009, 11, 22)'); 15 22 23 shouldBe('setValueAsDateAndGetValue(1969, 11, 1)', '"1969-12-01"'); 24 shouldBe('setValueAsDateAndGetValue(1970, 0, 1)', '"1970-01-01"'); 25 shouldBe('setValueAsDateAndGetValue(2009, 11, 31)', '"2009-12-31"'); 26 shouldBe('setValueAsDateAndGetValue(10000, 0, 1)', '"10000-01-01"'); 27 28 shouldBe('setValueAsDateAndGetValue(794, 9, 22)', '""'); 29 shouldBe('setValueAsDateAndGetValue(1582, 8, 30)', '""'); 30 shouldBe('setValueAsDateAndGetValue(1582, 9, 1)', '"1582-10-01"'); 31 shouldBe('setValueAsDateAndGetValue(1582, 9, 31)', '"1582-10-31"'); 32 shouldBe('setValueAsDateAndGetValue(275760, 8, 13)', '"275760-09-13"'); 33 shouldBe('setValueAsDateAndGetValue(275760, 8, 14)', '""'); // Date of JavaScript can't represent this. 34 35 debug('Invalid objects:'); 36 shouldBe('input.value = "2010-01-01"; input.valueAsDate = document; input.value', '""'); 37 shouldBe('input.value = "2010-01-01"; input.valueAsDate = null; input.value', '""'); 38 16 39 var successfullyParsed = true; -
trunk/WebCore/ChangeLog
r53597 r53598 1 2010-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 1 18 2010-01-20 Ben Murdoch <benm@google.com> 2 19 -
trunk/WebCore/html/HTMLInputElement.cpp
r53551 r53598 1399 1399 bool success; 1400 1400 switch (inputType()) { 1401 case DATE: 1402 success = dateTime.setMillisecondsSinceEpochForDate(value); 1403 break; 1401 1404 case MONTH: 1402 1405 success = dateTime.setMillisecondsSinceEpochForMonth(value); -
trunk/WebCore/html/ISODateTime.cpp
r53551 r53598 477 477 } 478 478 479 bool 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 479 491 bool ISODateTime::setMillisecondsSinceEpochForMonth(double ms) 480 492 { … … 557 569 { 558 570 switch (m_type) { 571 case Date: 572 return String::format("%04d-%02d-%02d", m_year, m_month + 1, m_monthDay); 559 573 case Month: 560 574 return String::format("%04d-%02d", m_year, m_month + 1); -
trunk/WebCore/html/ISODateTime.h
r53551 r53598 101 101 bool parseDateTime(const UChar* src, unsigned length, unsigned start, unsigned& end); 102 102 103 // The following setMillisecondsSinceEpochFor*() function takes103 // The following setMillisecondsSinceEpochFor*() functions take 104 104 // the number of milliseconds since 1970-01-01 00:00:00.000 UTC as 105 105 // the argument, and update all fields for the corresponding 106 // ISODateTime type. The function returnstrue if it succeeds, and107 // false if it fails.106 // ISODateTime type. The functions return true if it succeeds, and 107 // false if they fail. 108 108 109 // For Date type. Updates m_year, m_month and m_monthDay. 110 bool setMillisecondsSinceEpochForDate(double ms); 109 111 // For Month type. Updates m_year and m_month. 110 112 bool setMillisecondsSinceEpochForMonth(double ms);
Note: See TracChangeset
for help on using the changeset viewer.