[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9
tkent at chromium.org
tkent at chromium.org
Thu Feb 4 21:26:49 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 9e918c9f87ccdaca98e040107617ac0647418b1a
Author: tkent at chromium.org <tkent at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon Jan 25 02:15:58 2010 +0000
2010-01-24 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
HTMLInputElement::valueAsDate setter support for type=week.
https://bugs.webkit.org/show_bug.cgi?id=33986
Add setter tests to input-valueasdate-datetime.js, and update the
expectation.
* fast/forms/input-valueasdate-week-expected.txt:
* fast/forms/script-tests/input-valueasdate-week.js:
2010-01-24 Kent Tamura <tkent at chromium.org>
Reviewed by Darin Adler.
HTMLInputElement::valueAsDate setter support for type=week.
https://bugs.webkit.org/show_bug.cgi?id=33986
Introduce ISODateTime::setMillisecondsSinceEpochForWeek() and add
Week type support to ISODateTime::toString().
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::valueAsDate): Avoid default:.
(WebCore::HTMLInputElement::setValueAsDate):
Add WEEK type handling and avoid default:.
* html/ISODateTime.cpp:
(WebCore::offsetTo1stWeekStart):
(WebCore::ISODateTime::setMillisecondsSinceEpochForWeek):
(WebCore::ISODateTime::millisecondsSinceEpoch):
(WebCore::ISODateTime::toString):
Add Week type support and avoid default:.
* html/ISODateTime.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53787 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 95b9dcf..8200378 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2010-01-24 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ HTMLInputElement::valueAsDate setter support for type=week.
+ https://bugs.webkit.org/show_bug.cgi?id=33986
+
+ Add setter tests to input-valueasdate-datetime.js, and update the
+ expectation.
+
+ * fast/forms/input-valueasdate-week-expected.txt:
+ * fast/forms/script-tests/input-valueasdate-week.js:
+
2010-01-24 Eric Carlson <eric.carlson at apple.com>
No review, build fix.
diff --git a/LayoutTests/fast/forms/input-valueasdate-week-expected.txt b/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
index a4e9c8b..21e7028 100644
--- a/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
+++ b/LayoutTests/fast/forms/input-valueasdate-week-expected.txt
@@ -11,6 +11,28 @@ PASS valueAsDateFor("2004-W01").getTime() is Date.UTC(2003, 11, 29, 0, 0, 0, 0)
PASS valueAsDateFor("2010-W01").getTime() is Date.UTC(2010, 0, 4)
PASS valueAsDateFor("2005-W01").getTime() is Date.UTC(2005, 0, 3)
PASS valueAsDateFor("2006-W01").getTime() is Date.UTC(2006, 0, 2)
+Various January 1st:
+PASS setValueAsDateAndGetValue(2007, 0, 1) is "2007-W01"
+PASS setValueAsDateAndGetValue(2008, 0, 1) is "2008-W01"
+PASS setValueAsDateAndGetValue(2003, 0, 1) is "2003-W01"
+PASS setValueAsDateAndGetValue(2004, 0, 1) is "2004-W01"
+PASS setValueAsDateAndGetValue(2010, 0, 1) is "2009-W53"
+PASS setValueAsDateAndGetValue(2005, 0, 1) is "2004-W53"
+PASS setValueAsDateAndGetValue(2006, 0, 1) is "2005-W52"
+Normal cases:
+PASS setValueAsDateAndGetValue(2010, 0, 3) is "2009-W53"
+PASS setValueAsDateAndGetValue(2010, 0, 4) is "2010-W01"
+PASS setValueAsDateAndGetValue(2010, 0, 10) is "2010-W01"
+PASS setValueAsDateAndGetValue(2010, 0, 11) is "2010-W02"
+PASS setValueAsDateAndGetValue(2010, 0, 17) is "2010-W02"
+PASS setValueAsDateAndGetValue(2010, 11, 31) is "2010-W52"
+Around Gregorian calendar starting year:
+PASS setValueAsDateAndGetValue(1582, 9, 14) is ""
+PASS setValueAsDateAndGetValue(1582, 9, 15) is ""
+PASS setValueAsDateAndGetValue(1582, 11, 31) is ""
+PASS setValueAsDateAndGetValue(1583, 0, 1) is ""
+PASS setValueAsDateAndGetValue(1583, 0, 2) is ""
+PASS setValueAsDateAndGetValue(1583, 0, 3) is "1583-W01"
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js b/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
index f9c469e..fd9b6ca 100644
--- a/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
+++ b/LayoutTests/fast/forms/script-tests/input-valueasdate-week.js
@@ -8,6 +8,13 @@ function valueAsDateFor(stringValue) {
return input.valueAsDate;
}
+function setValueAsDateAndGetValue(year, month, day) {
+ var date = new Date();
+ date.setTime(Date.UTC(year, month, day));
+ input.valueAsDate = date;
+ return input.value;
+}
+
shouldBe('valueAsDateFor("")', 'null');
// January 1st is Monday. W01 starts on January 1nd.
shouldBe('valueAsDateFor("2007-W01").getTime()', 'Date.UTC(2007, 0, 1)');
@@ -24,4 +31,31 @@ shouldBe('valueAsDateFor("2005-W01").getTime()', 'Date.UTC(2005, 0, 3)');
// January 1st is Sunday. W01 starts on January 2nd.
shouldBe('valueAsDateFor("2006-W01").getTime()', 'Date.UTC(2006, 0, 2)');
+debug('Various January 1st:');
+shouldBe('setValueAsDateAndGetValue(2007, 0, 1)', '"2007-W01"');
+shouldBe('setValueAsDateAndGetValue(2008, 0, 1)', '"2008-W01"');
+shouldBe('setValueAsDateAndGetValue(2003, 0, 1)', '"2003-W01"');
+shouldBe('setValueAsDateAndGetValue(2004, 0, 1)', '"2004-W01"');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 1)', '"2009-W53"');
+shouldBe('setValueAsDateAndGetValue(2005, 0, 1)', '"2004-W53"');
+shouldBe('setValueAsDateAndGetValue(2006, 0, 1)', '"2005-W52"');
+
+debug('Normal cases:');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 3)', '"2009-W53"');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 4)', '"2010-W01"');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 10)', '"2010-W01"');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 11)', '"2010-W02"');
+shouldBe('setValueAsDateAndGetValue(2010, 0, 17)', '"2010-W02"');
+shouldBe('setValueAsDateAndGetValue(2010, 11, 31)', '"2010-W52"');
+
+debug('Around Gregorian calendar starting year:');
+// Gregorian calendar started in 1582. We don't support that year.
+shouldBe('setValueAsDateAndGetValue(1582, 9, 14)', '""');
+shouldBe('setValueAsDateAndGetValue(1582, 9, 15)', '""');
+shouldBe('setValueAsDateAndGetValue(1582, 11, 31)', '""');
+// January 1st is Saturday. W01 starts on January 3rd.
+shouldBe('setValueAsDateAndGetValue(1583, 0, 1)', '""');
+shouldBe('setValueAsDateAndGetValue(1583, 0, 2)', '""');
+shouldBe('setValueAsDateAndGetValue(1583, 0, 3)', '"1583-W01"');
+
var successfullyParsed = true;
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index b9e05fd..84ec645 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-01-24 Kent Tamura <tkent at chromium.org>
+
+ Reviewed by Darin Adler.
+
+ HTMLInputElement::valueAsDate setter support for type=week.
+ https://bugs.webkit.org/show_bug.cgi?id=33986
+
+ Introduce ISODateTime::setMillisecondsSinceEpochForWeek() and add
+ Week type support to ISODateTime::toString().
+
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::valueAsDate): Avoid default:.
+ (WebCore::HTMLInputElement::setValueAsDate):
+ Add WEEK type handling and avoid default:.
+ * html/ISODateTime.cpp:
+ (WebCore::offsetTo1stWeekStart):
+ (WebCore::ISODateTime::setMillisecondsSinceEpochForWeek):
+ (WebCore::ISODateTime::millisecondsSinceEpoch):
+ (WebCore::ISODateTime::toString):
+ Add Week type support and avoid default:.
+ * html/ISODateTime.h:
+
2010-01-24 Oliver Hunt <oliver at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/html/HTMLInputElement.cpp b/WebCore/html/HTMLInputElement.cpp
index 78d1784..a1ffb3f 100644
--- a/WebCore/html/HTMLInputElement.cpp
+++ b/WebCore/html/HTMLInputElement.cpp
@@ -1377,7 +1377,6 @@ void HTMLInputElement::setValue(const String& value, bool sendChangeEvent)
double HTMLInputElement::valueAsDate() const
{
switch (inputType()) {
- // valueAsDate doesn't work for the DATETIMELOCAL type according to the standard.
case DATE:
case DATETIME:
case MONTH:
@@ -1388,9 +1387,29 @@ double HTMLInputElement::valueAsDate() const
return ISODateTime::invalidMilliseconds();
return dateTime.millisecondsSinceEpoch();
}
- default:
+ case BUTTON:
+ case CHECKBOX:
+ case COLOR:
+ case DATETIMELOCAL: // valueAsDate doesn't work for the DATETIMELOCAL type according to the standard.
+ case EMAIL:
+ case FILE:
+ case HIDDEN:
+ case IMAGE:
+ case ISINDEX:
+ case NUMBER:
+ case PASSWORD:
+ case RADIO:
+ case RANGE:
+ case RESET:
+ case SEARCH:
+ case SUBMIT:
+ case TELEPHONE:
+ case TEXT:
+ case URL:
return ISODateTime::invalidMilliseconds();
}
+ ASSERT_NOT_REACHED();
+ return ISODateTime::invalidMilliseconds();
}
void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
@@ -1410,10 +1429,33 @@ void HTMLInputElement::setValueAsDate(double value, ExceptionCode& ec)
case TIME:
success = dateTime.setMillisecondsSinceMidnight(value);
break;
- // FIXME: implementations for other supported types.
- default:
+ case WEEK:
+ success = dateTime.setMillisecondsSinceEpochForWeek(value);
+ break;
+ case BUTTON:
+ case CHECKBOX:
+ case COLOR:
+ case DATETIMELOCAL: // valueAsDate doesn't work for the DATETIMELOCAL type according to the standard.
+ case EMAIL:
+ case FILE:
+ case HIDDEN:
+ case IMAGE:
+ case ISINDEX:
+ case NUMBER:
+ case PASSWORD:
+ case RADIO:
+ case RANGE:
+ case RESET:
+ case SEARCH:
+ case SUBMIT:
+ case TELEPHONE:
+ case TEXT:
+ case URL:
ec = INVALID_STATE_ERR;
return;
+ default:
+ ASSERT_NOT_REACHED();
+ success = false;
}
if (!success) {
setValue(String());
diff --git a/WebCore/html/ISODateTime.cpp b/WebCore/html/ISODateTime.cpp
index f9b45b0..a19e507 100644
--- a/WebCore/html/ISODateTime.cpp
+++ b/WebCore/html/ISODateTime.cpp
@@ -528,6 +528,47 @@ bool ISODateTime::setMillisecondsSinceMidnight(double ms)
return true;
}
+// Offset from January 1st to Monday of the ISO 8601's first week.
+// ex. If January 1st is Friday, such Monday is 3 days later. Returns 3.
+static int offsetTo1stWeekStart(int year)
+{
+ int offsetTo1stWeekStart = 1 - dayOfWeek(year, 0, 1);
+ if (offsetTo1stWeekStart <= -4)
+ offsetTo1stWeekStart += 7;
+ return offsetTo1stWeekStart;
+}
+
+bool ISODateTime::setMillisecondsSinceEpochForWeek(double ms)
+{
+ m_type = Invalid;
+ if (!isfinite(ms))
+ return false;
+ ms = round(ms);
+
+ m_year = msToYear(ms);
+ // We don't support gregorianStartYear. Week numbers are undefined in that year.
+ if (m_year <= gregorianStartYear)
+ return false;
+
+ int yearDay = dayInYear(ms, m_year);
+ int offset = offsetTo1stWeekStart(m_year);
+ if (yearDay < offset) {
+ // The day belongs to the last week of the previous year.
+ m_year--;
+ if (m_year <= gregorianStartYear)
+ return false;
+ m_week = maxWeekNumberInYear();
+ } else {
+ m_week = ((yearDay - offset) / 7) + 1;
+ if (m_week > maxWeekNumberInYear()) {
+ m_year++;
+ m_week = 1;
+ }
+ }
+ m_type = Week;
+ return true;
+}
+
double ISODateTime::millisecondsSinceEpochForTime() const
{
ASSERT(m_type == Time || m_type == DateTime);
@@ -546,14 +587,8 @@ double ISODateTime::millisecondsSinceEpoch() const
return dateToDaysFrom1970(m_year, m_month, 1) * msPerDay;
case Time:
return millisecondsSinceEpochForTime();
- case Week: {
- // Offset from January 1st to Monday of the ISO 8601's first week.
- // ex. If January 1st is Friday, such Monday is 3 days later.
- int offsetTo1stWeekStart = 1 - dayOfWeek(m_year, 0, 1);
- if (offsetTo1stWeekStart <= -4)
- offsetTo1stWeekStart += 7;
- return (dateToDaysFrom1970(m_year, 0, 1) + offsetTo1stWeekStart + (m_week - 1) * 7) * msPerDay;
- }
+ case Week:
+ return (dateToDaysFrom1970(m_year, 0, 1) + offsetTo1stWeekStart(m_year) + (m_week - 1) * 7) * msPerDay;
case Invalid:
break;
}
@@ -595,9 +630,10 @@ String ISODateTime::toString(SecondFormat format) const
return String::format("%04d-%02d", m_year, m_month + 1);
case Time:
return toStringForTime(format);
-
- // FIXME: implementations for other types.
- default:
+ case Week:
+ return String::format("%04d-W%02d", m_year, m_week);
+ case DateTimeLocal:
+ case Invalid:
break;
}
ASSERT_NOT_REACHED();
diff --git a/WebCore/html/ISODateTime.h b/WebCore/html/ISODateTime.h
index e526eb9..82e3848 100644
--- a/WebCore/html/ISODateTime.h
+++ b/WebCore/html/ISODateTime.h
@@ -116,7 +116,8 @@ public:
bool setMillisecondsSinceEpochForDateTime(double ms);
// For Month type. Updates m_year and m_month.
bool setMillisecondsSinceEpochForMonth(double ms);
- // FIXME: Add setMillisecondsSinceEpochFor*() for other types.
+ // For Week type. Updates m_year and m_week.
+ bool setMillisecondsSinceEpochForWeek(double ms);
// For Time type. Updates m_hour, m_minute, m_second and m_millisecond.
bool setMillisecondsSinceMidnight(double ms);
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list