Hours field of date/time input UI should respect step attribute
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 09:32:28 +0000 (09:32 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2012 09:32:28 +0000 (09:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104993

Patch by Kunihiko Sakamoto <ksakamoto@chromium.org> on 2012-12-14
Reviewed by Kent Tamura.

Source/WebCore:

This patch makes step-up/-down UI of the hours field respect step attribute when possible.

Test: fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html

* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Pass step parameters to the hour field constructor.
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement): Add Parameters argument.
(WebCore::DateTimeHourFieldElement::create): Ditto.
* html/shadow/DateTimeFieldElements.h:
(DateTimeHourFieldElement): Ditto.

LayoutTests:

* fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html:
Added test cases for hour field.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/shadow/DateTimeEditElement.cpp
Source/WebCore/html/shadow/DateTimeFieldElements.cpp
Source/WebCore/html/shadow/DateTimeFieldElements.h

index 2f4432b..40cb35a 100644 (file)
@@ -1,3 +1,14 @@
+2012-12-14  Kunihiko Sakamoto  <ksakamoto@chromium.org>
+
+        Hours field of date/time input UI should respect step attribute
+        https://bugs.webkit.org/show_bug.cgi?id=104993
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt:
+        * fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html:
+        Added test cases for hour field.
+
 2012-12-14  Shinya Kawanaka  <shinyak@chromium.org>
 
         [Shadow DOM] ShadowRoot.getElementById() should work outside document.
index 3fe39d6..0fb2e81 100644 (file)
@@ -82,6 +82,59 @@ PASS test("07:13", 600, null, null, ["delete", "upArrow"]) is "07:00"
 PASS test("07:13", 600, null, null, ["delete", "downArrow"]) is "07:50"
 PASS test("07:13", 600, "00:05", null, ["delete", "upArrow"]) is "07:05"
 PASS test("07:13", 600, "00:05", null, ["delete", "downArrow"]) is "07:55"
+Hours, 1-12
+PASS stepUp("07:00", 1, null, null) is "08:00"
+PASS stepDown("07:00", 1, null, null) is "06:00"
+PASS stepUp("11:00", 1, null, null) is "00:00"
+PASS stepDown("00:00", 1, null, null) is "11:00"
+PASS stepUp("06:00", 7200, null, null) is "08:00"
+PASS stepDown("06:00", 7200, null, null) is "04:00"
+PASS stepUp("10:00", 7200, null, null) is "00:00"
+PASS stepDown("00:00", 7200, null, null) is "10:00"
+PASS stepUp("07:00", 7200, null, null) is "08:00"
+PASS stepDown("07:00", 7200, null, null) is "06:00"
+PASS stepUp("06:00", 3601, null, null) is "07:00"
+PASS stepDown("06:00", 3601, null, null) is "05:00"
+PASS stepUp("06:00", 0, null, null) is "07:00"
+PASS stepDown("06:00", 0, null, null) is "05:00"
+PASS stepUp("06:00", 86400, null, null) is "00:00"
+PASS stepDown("06:00", 86400, null, null) is "00:00"
+PASS stepUp("06:00", 36000, null, null) is "07:00"
+PASS stepDown("06:00", 36000, null, null) is "05:00"
+PASS stepUp("06:00", 7200, "01:00", null) is "07:00"
+PASS stepDown("06:00", 7200, "01:00", null) is "05:00"
+PASS test("06:00", 7200, null, null, ["delete", "upArrow"]) is "02:00"
+PASS test("06:00", 7200, null, null, ["delete", "downArrow"]) is "00:00"
+PASS getUserAgentShadowTextContent(input) is "12:00 AM"
+PASS test("06:00", 7200, "01:00", null, ["delete", "upArrow"]) is "01:00"
+PASS test("06:00", 7200, "01:00", null, ["delete", "downArrow"]) is "11:00"
+Hours, 0-23
+The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.
+PASS stepUp("07:00", 1, null, null) is "08:00"
+PASS stepDown("07:00", 1, null, null) is "06:00"
+PASS stepUp("23:00", 1, null, null) is "00:00"
+PASS stepDown("00:00", 1, null, null) is "23:00"
+PASS stepUp("06:00", 7200, null, null) is "08:00"
+PASS stepDown("06:00", 7200, null, null) is "04:00"
+PASS stepUp("22:00", 7200, null, null) is "00:00"
+PASS stepDown("00:00", 7200, null, null) is "22:00"
+PASS stepUp("07:00", 7200, null, null) is "08:00"
+PASS stepDown("07:00", 7200, null, null) is "06:00"
+PASS stepUp("06:00", 3601, null, null) is "07:00"
+PASS stepDown("06:00", 3601, null, null) is "05:00"
+PASS stepUp("06:00", 0, null, null) is "07:00"
+PASS stepDown("06:00", 0, null, null) is "05:00"
+PASS stepUp("06:00", 86400, null, null) is "00:00"
+PASS stepDown("06:00", 86400, null, null) is "00:00"
+PASS stepUp("06:00", 36000, null, null) is "07:00"
+PASS stepDown("06:00", 36000, null, null) is "05:00"
+PASS stepUp("06:00", 7200, "01:00", null) is "07:00"
+PASS stepDown("06:00", 7200, "01:00", null) is "05:00"
+PASS test("06:00", 7200, null, null, ["delete", "upArrow"]) is "00:00"
+PASS getUserAgentShadowTextContent(input) is "00:00"
+PASS test("06:00", 7200, null, null, ["delete", "downArrow"]) is "22:00"
+PASS test("06:00", 7200, "01:00", null, ["delete", "upArrow"]) is "01:00"
+PASS test("06:00", 7200, "01:00", null, ["delete", "downArrow"]) is "23:00"
 
 PASS successfullyParsed is true
 
index 2e8a81e..81a3fdd 100644 (file)
@@ -2,10 +2,13 @@
 <html>
 <head>
 <script src="../../js/resources/js-test-pre.js"></script>
+<script src="../resources/common.js"></script>
 </head>
 <body>
 <script>
 description('Check stepping-up and -down for time input fields from renderer. No cases of empty initial values.');
+if (window.internals)
+    internals.settings.setLangAttributeAwareFormControlUIEnabled(true);
 
 var input = document.createElement('input');
 var invalidStateErr = '"Error: InvalidStateError: DOM Exception 11"';
@@ -132,6 +135,64 @@ shouldBeEqualToString('test("07:13", 600, null, null, ["delete", "downArrow"])',
 shouldBeEqualToString('test("07:13", 600, "00:05", null, ["delete", "upArrow"])', '07:05');
 shouldBeEqualToString('test("07:13", 600, "00:05", null, ["delete", "downArrow"])', '07:55');
 
+debug('Hours, 1-12');
+keyDown('leftArrow');
+shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00');
+shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00');
+shouldBeEqualToString('stepUp("11:00", 1, null, null)', '00:00');
+shouldBeEqualToString('stepDown("00:00", 1, null, null)', '11:00');
+shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00');
+shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00');
+shouldBeEqualToString('stepUp("10:00", 7200, null, null)', '00:00');
+shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '10:00');
+shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00');
+shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00');
+shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00');
+shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00');
+shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00');
+shouldBeEqualToString('test("06:00", 7200, null, null, ["delete", "upArrow"])', '02:00');
+shouldBeEqualToString('test("06:00", 7200, null, null, ["delete", "downArrow"])', '00:00');
+shouldBeEqualToString('getUserAgentShadowTextContent(input)', '12:00 AM');
+shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["delete", "upArrow"])', '01:00');
+shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["delete", "downArrow"])', '11:00');
+
+debug('Hours, 0-23');
+debug('The tests in this block fail on platforms without the lang-attribute-aware-form-control-UI feature.');
+input.setAttribute('lang', 'ja');
+shouldBeEqualToString('stepUp("07:00", 1, null, null)', '08:00');
+shouldBeEqualToString('stepDown("07:00", 1, null, null)', '06:00');
+shouldBeEqualToString('stepUp("23:00", 1, null, null)', '00:00');
+shouldBeEqualToString('stepDown("00:00", 1, null, null)', '23:00');
+shouldBeEqualToString('stepUp("06:00", 7200, null, null)', '08:00');
+shouldBeEqualToString('stepDown("06:00", 7200, null, null)', '04:00');
+shouldBeEqualToString('stepUp("22:00", 7200, null, null)', '00:00');
+shouldBeEqualToString('stepDown("00:00", 7200, null, null)', '22:00');
+shouldBeEqualToString('stepUp("07:00", 7200, null, null)', '08:00');
+shouldBeEqualToString('stepDown("07:00", 7200, null, null)', '06:00');
+shouldBeEqualToString('stepUp("06:00", 3601, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 3601, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 0, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 0, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 86400, null, null)', '00:00');
+shouldBeEqualToString('stepDown("06:00", 86400, null, null)', '00:00');
+shouldBeEqualToString('stepUp("06:00", 36000, null, null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 36000, null, null)', '05:00');
+shouldBeEqualToString('stepUp("06:00", 7200, "01:00", null)', '07:00');
+shouldBeEqualToString('stepDown("06:00", 7200, "01:00", null)', '05:00');
+shouldBeEqualToString('test("06:00", 7200, null, null, ["delete", "upArrow"])', '00:00');
+shouldBeEqualToString('getUserAgentShadowTextContent(input)', '00:00');
+shouldBeEqualToString('test("06:00", 7200, null, null, ["delete", "downArrow"])', '22:00');
+shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["delete", "upArrow"])', '01:00');
+shouldBeEqualToString('test("06:00", 7200, "01:00", null, ["delete", "downArrow"])', '23:00');
+input.removeAttribute('lang');
+
 debug('');
 document.body.removeChild(input);
 </script>
index e23a002..e5bfcae 100644 (file)
@@ -4086,6 +4086,8 @@ webkit.org/b/101377 [ Linux MountainLion ] platform/chromium-linux/fast/text/int
 webkit.org/b/101408 [ Mac ] platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html [ Failure ]
 webkit.org/b/101408 platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html [ Failure Pass ]
 
+webkit.org/b/104993 [ XP ] fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html [ Failure ]
+
 
 webkit.org/b/101539 [ Linux Win ] editing/execCommand/switch-list-type-with-orphaned-li.html [ Failure ]
 
index 1a835ab..8667c0f 100644 (file)
@@ -1,3 +1,22 @@
+2012-12-14  Kunihiko Sakamoto  <ksakamoto@chromium.org>
+
+        Hours field of date/time input UI should respect step attribute
+        https://bugs.webkit.org/show_bug.cgi?id=104993
+
+        Reviewed by Kent Tamura.
+
+        This patch makes step-up/-down UI of the hours field respect step attribute when possible.
+
+        Test: fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html
+
+        * html/shadow/DateTimeEditElement.cpp:
+        (WebCore::DateTimeEditBuilder::visitField): Pass step parameters to the hour field constructor.
+        * html/shadow/DateTimeFieldElements.cpp:
+        (WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement): Add Parameters argument.
+        (WebCore::DateTimeHourFieldElement::create): Ditto.
+        * html/shadow/DateTimeFieldElements.h:
+        (DateTimeHourFieldElement): Ditto.
+
 2012-12-14  Yury Semikhatsky  <yurys@chromium.org>
 
         Unreviewed. Windows compilation fix after r137728.
index ee11aa4..a1441d1 100644 (file)
@@ -109,7 +109,8 @@ void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
         return;
 
     case DateTimeFormat::FieldTypeHour11: {
-        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 0, 11);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerHour), static_cast<int>(msPerHour * 12));
+        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 0, 11, parameters);
         m_editElement.addField(field);
         if (shouldHourFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -119,7 +120,8 @@ void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
     }
 
     case DateTimeFormat::FieldTypeHour12: {
-        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 1, 12);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerHour), static_cast<int>(msPerHour * 12));
+        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 1, 12, parameters);
         m_editElement.addField(field);
         if (shouldHourFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -129,7 +131,8 @@ void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
     }
 
     case DateTimeFormat::FieldTypeHour23: {
-        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 0, 23);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerHour), static_cast<int>(msPerDay));
+        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 0, 23, parameters);
         m_editElement.addField(field);
         if (shouldHourFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -139,7 +142,8 @@ void DateTimeEditBuilder::visitField(DateTimeFormat::FieldType fieldType, int co
     }
 
     case DateTimeFormat::FieldTypeHour24: {
-        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 1, 24);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerHour), static_cast<int>(msPerDay));
+        RefPtr<DateTimeFieldElement> field = DateTimeHourFieldElement::create(document, m_editElement, 1, 24, parameters);
         m_editElement.addField(field);
         if (shouldHourFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
index be8b0f4..3100d80 100644 (file)
@@ -112,17 +112,17 @@ void DateTimeDayFieldElement::setValueAsDateTimeFieldsState(const DateTimeFields
 
 // ----------------------------
 
-DateTimeHourFieldElement::DateTimeHourFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum)
-    : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum, "--")
+DateTimeHourFieldElement::DateTimeHourFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const DateTimeNumericFieldElement::Parameters& parameters)
+    : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum, "--", parameters)
     , m_alignment(maximum + maximum % 2)
 {
     ASSERT((!minimum && (maximum == 11 || maximum == 23)) || (minimum == 1 && (maximum == 12 || maximum == 24)));
 }
 
-PassRefPtr<DateTimeHourFieldElement> DateTimeHourFieldElement::create(Document* document, FieldOwner& fieldOwner, int minimum, int maximum)
+PassRefPtr<DateTimeHourFieldElement> DateTimeHourFieldElement::create(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const DateTimeNumericFieldElement::Parameters& parameters)
 {
     DEFINE_STATIC_LOCAL(AtomicString, hourPsuedoId, ("-webkit-datetime-edit-hour-field", AtomicString::ConstructFromLiteral));
-    RefPtr<DateTimeHourFieldElement> field = adoptRef(new DateTimeHourFieldElement(document, fieldOwner, minimum, maximum));
+    RefPtr<DateTimeHourFieldElement> field = adoptRef(new DateTimeHourFieldElement(document, fieldOwner, minimum, maximum, parameters));
     field->initialize(hourPsuedoId, AXHourFieldText());
     return field.release();
 }
index 5bf6a6b..ca3bcc5 100644 (file)
@@ -72,10 +72,10 @@ class DateTimeHourFieldElement : public DateTimeNumericFieldElement {
     WTF_MAKE_NONCOPYABLE(DateTimeHourFieldElement);
 
 public:
-    static PassRefPtr<DateTimeHourFieldElement> create(Document*, FieldOwner&, int minimum, int maximum);
+    static PassRefPtr<DateTimeHourFieldElement> create(Document*, FieldOwner&, int minimum, int maximum, const DateTimeNumericFieldElement::Parameters&);
 
 private:
-    DateTimeHourFieldElement(Document*, FieldOwner&, int minimum, int maximum);
+    DateTimeHourFieldElement(Document*, FieldOwner&, int minimum, int maximum, const DateTimeNumericFieldElement::Parameters&);
 
     // DateTimeFieldElement functions.
     virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;