Title: [137733] trunk
Revision
137733
Author
commit-qu...@webkit.org
Date
2012-12-14 01:32:28 -0800 (Fri, 14 Dec 2012)

Log Message

Hours field of date/time input UI should respect step attribute
https://bugs.webkit.org/show_bug.cgi?id=104993

Patch by Kunihiko Sakamoto <ksakam...@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.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137732 => 137733)


--- trunk/LayoutTests/ChangeLog	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/LayoutTests/ChangeLog	2012-12-14 09:32:28 UTC (rev 137733)
@@ -1,3 +1,14 @@
+2012-12-14  Kunihiko Sakamoto  <ksakam...@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  <shin...@chromium.org>
 
         [Shadow DOM] ShadowRoot.getElementById() should work outside document.

Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt (137732 => 137733)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt	2012-12-14 09:32:28 UTC (rev 137733)
@@ -82,6 +82,59 @@
 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
 

Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html (137732 => 137733)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html	2012-12-14 09:32:28 UTC (rev 137733)
@@ -2,10 +2,13 @@
 <html>
 <head>
 <script src=""
+<script src=""
 </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, "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>

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (137732 => 137733)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-12-14 09:32:28 UTC (rev 137733)
@@ -4086,7 +4086,9 @@
 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 ]
 
 webkit.org/b/101618 http/tests/inspector/indexeddb/database-data.html [ Pass Crash ]

Modified: trunk/Source/WebCore/ChangeLog (137732 => 137733)


--- trunk/Source/WebCore/ChangeLog	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/Source/WebCore/ChangeLog	2012-12-14 09:32:28 UTC (rev 137733)
@@ -1,3 +1,22 @@
+2012-12-14  Kunihiko Sakamoto  <ksakam...@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  <yu...@chromium.org>
 
         Unreviewed. Windows compilation fix after r137728.

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (137732 => 137733)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-12-14 09:32:28 UTC (rev 137733)
@@ -109,7 +109,8 @@
         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 @@
     }
 
     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 @@
     }
 
     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 @@
     }
 
     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);

Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp (137732 => 137733)


--- trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp	2012-12-14 09:32:28 UTC (rev 137733)
@@ -112,17 +112,17 @@
 
 // ----------------------------
 
-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();
 }

Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h (137732 => 137733)


--- trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h	2012-12-14 09:30:22 UTC (rev 137732)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h	2012-12-14 09:32:28 UTC (rev 137733)
@@ -72,10 +72,10 @@
     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;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to