Day of week labels are wrong if WebCore::firstDayOfWeek() is not 0
authortkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Apr 2012 03:31:43 +0000 (03:31 +0000)
committertkent@chromium.org <tkent@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 15 Apr 2012 03:31:43 +0000 (03:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83990

Reviewed by Kentaro Hara.

We passed the "weekStartDay" property value as a
string. CalendarPickerElement::writeDocument() created:
    weekStartDay: "1",
and the JavaScript code used it in the following code:
    dayLabels[(weekStartDay + i) % 7]
If weekStartDay was "1", the expression (weekStartDay + i)
produced "10", "11", "12", ... We expected "1", "2", "3", ...

We need to pass the "weekStartDay" property as a number.

No new tests because we have no ways to test this for now. We'll
introduce tests for the calendar picker later.

* html/shadow/CalendarPickerElement.cpp:
(WebCore::addProperty): Add addProperty() function for a number.
(WebCore::CalendarPickerElement::writeDocument):
Pass a number, not a serialized number.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114210 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/shadow/CalendarPickerElement.cpp

index 00b9b7e..0ec7b8d 100644 (file)
@@ -1,3 +1,28 @@
+2012-04-14  Kent Tamura  <tkent@chromium.org>
+
+        Day of week labels are wrong if WebCore::firstDayOfWeek() is not 0
+        https://bugs.webkit.org/show_bug.cgi?id=83990
+
+        Reviewed by Kentaro Hara.
+
+        We passed the "weekStartDay" property value as a
+        string. CalendarPickerElement::writeDocument() created:
+            weekStartDay: "1",
+        and the JavaScript code used it in the following code:
+            dayLabels[(weekStartDay + i) % 7]
+        If weekStartDay was "1", the expression (weekStartDay + i)
+        produced "10", "11", "12", ... We expected "1", "2", "3", ...
+
+        We need to pass the "weekStartDay" property as a number.
+
+        No new tests because we have no ways to test this for now. We'll
+        introduce tests for the calendar picker later.
+
+        * html/shadow/CalendarPickerElement.cpp:
+        (WebCore::addProperty): Add addProperty() function for a number.
+        (WebCore::CalendarPickerElement::writeDocument):
+        Pass a number, not a serialized number.
+
 2012-04-14  Joe Thomas  <joethomas@motorola.com>
 
         Viewport-percentage Length units does not work for Replaced elements size
index f4adbcb..43ec19d 100644 (file)
@@ -160,6 +160,14 @@ static void addProperty(const char* name, const String& value, DocumentWriter& w
     addLiteral(",\n", writer);
 }
 
+static void addProperty(const char* name, unsigned value, DocumentWriter& writer)
+{
+    writer.addData(name, strlen(name));
+    addLiteral(": ", writer);
+    addString(String::number(value), writer);
+    addLiteral(",\n", writer);
+}
+
 static void addProperty(const char* name, const Vector<String>& values, DocumentWriter& writer)
 {
     writer.addData(name, strlen(name));
@@ -197,7 +205,7 @@ void CalendarPickerElement::writeDocument(DocumentWriter& writer)
     addProperty("locale", defaultLanguage(), writer);
     addProperty("todayLabel", calendarTodayText(), writer);
     addProperty("clearLabel", calendarClearText(), writer);
-    addProperty("weekStartDay", String::number(firstDayOfWeek()), writer);
+    addProperty("weekStartDay", firstDayOfWeek(), writer);
     addProperty("monthLabels", monthLabels(), writer);
     addProperty("dayLabels", weekDayShortLabels(), writer);
     addLiteral("}\n", writer);