Calendar picker should use zero as default step base
authorkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2012 02:37:27 +0000 (02:37 +0000)
committerkeishi@webkit.org <keishi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2012 02:37:27 +0000 (02:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=97976

Reviewed by Kent Tamura.

.:

* ManualTests/forms/calendar-picker.html: Added stepBase parameters.

Source/WebCore:

Calendar picker should be using zero as default step base for input type=date.
The spec says to use zero unless specified otherwise.
Since input type=week has another default step base, I am adding step base
to DateTimeChooserParameters.

Test: fast/forms/date/calendar-picker-with-step.html

* Resources/pagepopups/calendarPicker.js:
(handleArgumentsTimeout):
(CalendarPicker):
(CalendarPicker.prototype.stepMismatch): Use the new this.stepBase.
* html/shadow/PickerIndicatorElement.cpp:
(WebCore::PickerIndicatorElement::openPopup): Gets step base from step range.
* platform/DateTimeChooser.h:
(DateTimeChooserParameters): Added stepBase.

Source/WebKit/chromium:

* src/DateTimeChooserImpl.cpp:
(WebKit::DateTimeChooserImpl::writeDocument): stepBase needs 11 digits of precision when setting maximum possible date.

LayoutTests:

* fast/forms/date/calendar-picker-with-step-expected.txt: Renamed from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step-expected.txt.
* fast/forms/date/calendar-picker-with-step.html: Renamed from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step.html. Renamed because this does not test apeparance.

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

ChangeLog
LayoutTests/ChangeLog
LayoutTests/fast/forms/date/calendar-picker-with-step-expected.txt [moved from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step-expected.txt with 74% similarity]
LayoutTests/fast/forms/date/calendar-picker-with-step.html [moved from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step.html with 97% similarity]
ManualTests/forms/calendar-picker.html
Source/WebCore/ChangeLog
Source/WebCore/Resources/pagepopups/calendarPicker.js
Source/WebCore/html/shadow/PickerIndicatorElement.cpp
Source/WebCore/platform/DateTimeChooser.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/DateTimeChooserImpl.cpp

index ab1a84f..7a42fa9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-10-01  Keishi Hattori  <keishi@webkit.org>
+
+        Calendar picker should use zero as default step base
+        https://bugs.webkit.org/show_bug.cgi?id=97976
+
+        Reviewed by Kent Tamura.
+
+        * ManualTests/forms/calendar-picker.html: Added stepBase parameters.
+
 2012-09-28  Mariusz Grzegorczyk  <mariusz.g@samsung.com>
 
         [WK2][GTK][EFL] Share WebKit2-GTK plugin process implementation with EFL port
index 41ba7a2..a54bc87 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-01  Keishi Hattori  <keishi@webkit.org>
+
+        Calendar picker should use zero as default step base
+        https://bugs.webkit.org/show_bug.cgi?id=97976
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/date/calendar-picker-with-step-expected.txt: Renamed from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step-expected.txt.
+        * fast/forms/date/calendar-picker-with-step.html: Renamed from LayoutTests/fast/forms/date/calendar-picker-appearance-with-step.html. Renamed because this does not test apeparance.
+
 2012-10-01  Roger Fong  <roger_fong@apple.com>
 
         Unreviewed. Fix expected result name.
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Step without min.
-PASS availableDatesInCurrentMonth().join(",") is ["2011-05-09", "2011-05-18", "2011-05-27"].join(",")
+PASS availableDatesInCurrentMonth().join(",") is ["2011-05-08", "2011-05-17", "2011-05-26"].join(",")
 Step when min is set.
 PASS availableDatesInCurrentMonth().join(",") is ["2011-05-01", "2011-05-10", "2011-05-19", "2011-05-28"].join(",")
  
@@ -29,7 +29,7 @@ function sendKey(input, keyName) {
 
 function test1() {
     debug("Step without min.");
-    shouldBe('availableDatesInCurrentMonth().join(",")', '["2011-05-09", "2011-05-18", "2011-05-27"].join(",")');
+    shouldBe('availableDatesInCurrentMonth().join(",")', '["2011-05-08", "2011-05-17", "2011-05-26"].join(",")');
     pickerWindow.removeEventListener('resize', test1);
 
     // Close popup
index 5352b50..1f94ee4 100644 (file)
@@ -45,7 +45,8 @@ var englishArguments = {
     clearLabel : 'Clear',
     cancelLabel : 'Cancel',
     weekStartDay : 0,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2099-12-31',
 };
 var japaneseArguments = {
@@ -57,7 +58,8 @@ var japaneseArguments = {
     clearLabel : 'クリア',
     cancelLabel : '取り消し',
     weekStartDay : 0,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2099-03-15',
 };
 var arabicArguments = {
@@ -69,7 +71,8 @@ var arabicArguments = {
     todayLabel : 'اليوم',
     clearLabel : 'مسح',
     weekStartDay : 5,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2020-05-15',
 };
 var datalistArguments = {
@@ -81,7 +84,8 @@ var datalistArguments = {
     clearLabel : 'Clear',
     cancelLabel : 'Cancel',
     weekStartDay : 0,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2099-12-31',
     suggestionValues : ['2012-01-01', '2012-06-03', '2012-09-06', '2012-12-24'],
     localizedSuggestionValues : ['1/1/12', '6/3/12', '9/6/12', '12/24/12'],
@@ -101,7 +105,8 @@ var longDatalistArguments = {
     clearLabel : 'Clear',
     cancelLabel : 'Cancel',
     weekStartDay : 0,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2099-12-31',
     suggestionValues: ["2012-01-01", "2012-01-02", "2012-01-03", "2012-01-04",
         "2012-01-05", "2012-01-06", "2012-01-07", "2012-01-08", "2012-01-09",
@@ -159,7 +164,8 @@ var arabicDatalistArguments = {
     todayLabel : 'اليوم',
     clearLabel : 'مسح',
     weekStartDay : 5,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2020-05-15',
     suggestionValues : ['2012-01-01', '2012-06-03', '2012-09-06', '2012-12-24'],
     localizedSuggestionValues : ['1/1/12', '6/3/12', '9/6/12', '12/24/12'],
@@ -180,7 +186,8 @@ var arabicLongDatalistArguments = {
     todayLabel : 'اليوم',
     clearLabel : 'مسح',
     weekStartDay : 5,
-    step : 1,
+    step : "86400000",
+    stepBase: "0",
     max : '2020-05-15',
     suggestionValues: ["2012-01-01", "2012-01-02", "2012-01-03", "2012-01-04",
         "2012-01-05", "2012-01-06", "2012-01-07", "2012-01-08", "2012-01-09",
index b49425e..cf4bd90 100644 (file)
@@ -1,3 +1,26 @@
+2012-10-01  Keishi Hattori  <keishi@webkit.org>
+
+        Calendar picker should use zero as default step base
+        https://bugs.webkit.org/show_bug.cgi?id=97976
+
+        Reviewed by Kent Tamura.
+
+        Calendar picker should be using zero as default step base for input type=date.
+        The spec says to use zero unless specified otherwise.
+        Since input type=week has another default step base, I am adding step base
+        to DateTimeChooserParameters.
+
+        Test: fast/forms/date/calendar-picker-with-step.html
+
+        * Resources/pagepopups/calendarPicker.js:
+        (handleArgumentsTimeout):
+        (CalendarPicker):
+        (CalendarPicker.prototype.stepMismatch): Use the new this.stepBase.
+        * html/shadow/PickerIndicatorElement.cpp:
+        (WebCore::PickerIndicatorElement::openPopup): Gets step base from step range.
+        * platform/DateTimeChooser.h:
+        (DateTimeChooserParameters): Added stepBase.
+
 2012-10-01  Tony Chang  <tony@chromium.org>
 
         flexbox does wrong baseline item alignment in columns
index bd2a1c9..f7315b3 100644 (file)
@@ -234,7 +234,8 @@ function handleArgumentsTimeout() {
         cancelLabel : "Cancel",
         currentValue : "",
         weekStartDay : 0,
-        step : 1
+        step : CalendarPicker.DefaultStepScaleFactor,
+        stepBase: CalendarPicker.DefaultStepBase
     };
     initialize(args);
 }
@@ -313,7 +314,8 @@ function CalendarPicker(element, config) {
     this.minimumDate = (typeof this._config.min !== "undefined") ? parseDateString(this._config.min) : CalendarPicker.MinimumPossibleDate;
     // We assume this._config.max is a valid date.
     this.maximumDate = (typeof this._config.max !== "undefined") ? parseDateString(this._config.max) : CalendarPicker.MaximumPossibleDate;
-    this.step = (typeof this._config.step !== undefined) ? this._config.step : CalendarPicker.BaseStep;
+    this.step = (typeof this._config.step !== undefined) ? Number(this._config.step) : CalendarPicker.DefaultStepScaleFactor;
+    this.stepBase = (typeof this._config.stepBase !== "undefined") ? Number(this._config.stepBase) : CalendarPicker.DefaultStepBase;
     this.yearMonthController = new YearMonthController(this);
     this.daysTable = new DaysTable(this);
     this._hadKeyEvent = false;
@@ -334,7 +336,8 @@ CalendarPicker.prototype = Object.create(Picker.prototype);
 CalendarPicker.MinimumPossibleDate = new Date(-62135596800000.0);
 CalendarPicker.MaximumPossibleDate = new Date(8640000000000000.0);
 // See WebCore/html/DateInputType.cpp.
-CalendarPicker.BaseStep = 86400000;
+CalendarPicker.DefaultStepScaleFactor = 86400000;
+CalendarPicker.DefaultStepBase = 0.0;
 
 CalendarPicker.prototype.cleanup = function() {
     document.body.removeEventListener("keydown", this._handleBodyKeyDownBound, false);
@@ -864,7 +867,7 @@ DaysTable.prototype.attachTo = function(element) {
  * @return {!boolean}
  */
 CalendarPicker.prototype.stepMismatch = function(time) {
-    return (time - this.minimumDate.getTime()) % this.step != 0;
+    return (time - this.stepBase) % this.step != 0;
 }
 
 /**
index bcad5d8..fa25bd6 100644 (file)
@@ -135,11 +135,16 @@ void PickerIndicatorElement::openPopup()
     parameters.minimum = input->minimum();
     parameters.maximum = input->maximum();
     parameters.required = input->required();
-    Decimal step;
-    if (hostInput()->getAllowedValueStep(&step))
-        parameters.step = step.toDouble();
-    else
+
+    StepRange stepRange = input->createStepRange(RejectAny);
+    if (stepRange.hasStep()) {
+        parameters.step = stepRange.step().toDouble();
+        parameters.stepBase = stepRange.stepBase().toDouble();
+    } else {
         parameters.step = 1.0;
+        parameters.stepBase = 0;
+    }
+
     parameters.anchorRectInRootView = document()->view()->contentsToRootView(hostInput()->pixelSnappedBoundingBox());
     parameters.currentValue = input->value();
     parameters.isAnchorElementRTL = input->computedStyle()->direction() == RTL;
index be6709c..86ab13c 100644 (file)
@@ -46,6 +46,7 @@ struct DateTimeChooserParameters {
     double minimum;
     double maximum;
     double step;
+    double stepBase;
     bool required;
     bool isAnchorElementRTL;
 };
index 655f01e..d00332e 100644 (file)
@@ -1,3 +1,13 @@
+2012-10-01  Keishi Hattori  <keishi@webkit.org>
+
+        Calendar picker should use zero as default step base
+        https://bugs.webkit.org/show_bug.cgi?id=97976
+
+        Reviewed by Kent Tamura.
+
+        * src/DateTimeChooserImpl.cpp:
+        (WebKit::DateTimeChooserImpl::writeDocument): stepBase needs 11 digits of precision when setting maximum possible date.
+
 2012-10-01  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Move onSuccess(IDBDatabaseBackendInterface) to IDBOpenDBRequest
index c300e58..cbd0fd6 100644 (file)
@@ -87,6 +87,7 @@ void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer)
     date.setMillisecondsSinceEpochForDate(m_parameters.maximum);
     String maxString = date.toString();
     String stepString = String::number(m_parameters.step);
+    String stepBaseString = String::number(m_parameters.stepBase, 11, WTF::TruncateTrailingZeros);
     OwnPtr<Localizer> localizer = Localizer::create(nullAtom);
 
     addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);
@@ -101,6 +102,7 @@ void DateTimeChooserImpl::writeDocument(WebCore::DocumentWriter& writer)
     addProperty("min", minString, writer);
     addProperty("max", maxString, writer);
     addProperty("step", stepString, writer);
+    addProperty("stepBase", stepBaseString, writer);
     addProperty("required", m_parameters.required, writer);
     addProperty("currentValue", m_parameters.currentValue, writer);
     addProperty("locale", WebCore::defaultLanguage(), writer);