Title: [137712] trunk
Revision
137712
Author
[email protected]
Date
2012-12-13 20:56:22 -0800 (Thu, 13 Dec 2012)

Log Message

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

Patch by Kunihiko Sakamoto <[email protected]> on 2012-12-13
Reviewed by Kent Tamura.

Source/WebCore:

This patch makes step-up/-down UI of the seconds and minutes fields respect
step attribute when possible.

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

* html/shadow/DateTimeEditElement.cpp:
(DateTimeEditBuilder):
(WebCore::DateTimeEditBuilder::visitField): Compute step parameters for seconds and minutes fields, and pass it to the field element constructors.
(WebCore::DateTimeEditBuilder::createNumericFieldParameters): Added.
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement): Use Parameters instead of step and stepBase.
(WebCore::DateTimeMillisecondFieldElement::create): Ditto.
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement): Add Parameters argument.
(WebCore::DateTimeMinuteFieldElement::create): Ditto.
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement): Ditto.
(WebCore::DateTimeSecondFieldElement::create): Ditto.
* html/shadow/DateTimeFieldElements.h:
(DateTimeMillisecondFieldElement): Use Parameters instead of step and stepBase.
(DateTimeMinuteFieldElement): Add Parameters argument.
(DateTimeSecondFieldElement): Ditto.
* html/shadow/DateTimeNumericFieldElement.cpp:
(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement): Use Parameters instead of step and stepBase.
* html/shadow/DateTimeNumericFieldElement.h:
(DateTimeNumericFieldElement):
(WebCore::DateTimeNumericFieldElement::Parameters::Parameters):
(Parameters): Added.

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 seconds and minutes fields.
Update an expectation for milliseconds: value=07:13:00.500, step=0 should round to 07:13:00.000
(setInputAttributes): Set value attribute first to avoid the focused field becomes read-only and unfocused.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (137711 => 137712)


--- trunk/LayoutTests/ChangeLog	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/LayoutTests/ChangeLog	2012-12-14 04:56:22 UTC (rev 137712)
@@ -1,3 +1,16 @@
+2012-12-13  Kunihiko Sakamoto  <[email protected]>
+
+        Seconds/Minutes field of date/time input UI should respect step attribute
+        https://bugs.webkit.org/show_bug.cgi?id=104985
+
+        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 seconds and minutes fields.
+        Update an expectation for milliseconds: value=07:13:00.500, step=0 should round to 07:13:00.000
+        (setInputAttributes): Set value attribute first to avoid the focused field becomes read-only and unfocused.
+
 2012-12-13  Ian Vollick  <[email protected]>
 
         [chromium] Add a virtual test suite for enabling opt-in to composited scrolling

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


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer-expected.txt	2012-12-14 04:56:22 UTC (rev 137712)
@@ -22,14 +22,66 @@
 PASS stepDown("07:13:00.101", 0.100, null, null) is "07:13:00.100"
 PASS stepUp("07:13:00.500", 0.0001, null, null) is "07:13:00.501"
 PASS stepDown("07:13:00.500", 0.0001, null, null) is "07:13:00.499"
-PASS stepUp("07:13:00.500", 0, null, null) is "07:13:00.501"
-PASS stepDown("07:13:00.500", 0, null, null) is "07:13:00.499"
+PASS stepUp("07:13:00.500", 0, null, null) is "07:13"
+PASS stepDown("07:13:00.500", 0, null, null) is "07:13"
+PASS stepUp("07:13:00.500", 60, null, null) is "07:13"
+PASS stepDown("07:13:00.500", 60, null, null) is "07:13"
 PASS stepUp("07:13:00.500", 0.100, "00:00:00.050", null) is "07:13:00.550"
 PASS stepDown("07:13:00.500", 0.100, "00:00:00.050", null) is "07:13:00.450"
 PASS test("07:13:00.500", 0.100, null, null, ["delete", "upArrow"]) is "07:13"
 PASS test("07:13:00.500", 0.100, null, null, ["delete", "downArrow"]) is "07:13:00.900"
 PASS test("07:13:00.500", 0.100, "00:00:00.050", null, ["delete", "upArrow"]) is "07:13:00.050"
 PASS test("07:13:00.500", 0.100, "00:00:00.050", null, ["delete", "downArrow"]) is "07:13:00.950"
+Seconds
+PASS stepUp("07:13:00", 1, null, null) is "07:13:01"
+PASS stepDown("07:13:01", 1, null, null) is "07:13"
+PASS stepUp("07:13:59", 0.001, null, null) is "07:13"
+PASS stepDown("07:13:00", 0.001, null, null) is "07:13:59"
+PASS stepUp("07:13:00", 10, null, null) is "07:13:10"
+PASS stepDown("07:13:30", 10, null, null) is "07:13:20"
+PASS stepUp("07:13:50", 10, null, null) is "07:13"
+PASS stepDown("07:13:00", 10, null, null) is "07:13:50"
+PASS stepUp("07:13:09", 10, null, null) is "07:13:10"
+PASS stepDown("07:13:11", 10, null, null) is "07:13:10"
+PASS stepUp("07:13:30", 2.5, null, null) is "07:13:31"
+PASS stepDown("07:13:30", 2.5, null, null) is "07:13:29"
+PASS stepUp("07:13:30", 0, null, null) is "07:13"
+PASS stepDown("07:13:30", 0, null, null) is "07:13"
+PASS stepUp("07:13:30", 3600, null, null) is "07:13"
+PASS stepDown("07:13:30", 3600, null, null) is "07:13"
+PASS stepUp("07:13:30", 11, null, null) is "07:13:31"
+PASS stepDown("07:13:30", 11, null, null) is "07:13:29"
+PASS stepUp("07:13:30", 10, "00:00:05", null) is "07:13:35"
+PASS stepDown("07:13:30", 10, "00:00:05", null) is "07:13:25"
+PASS test("07:13:30", 10, null, null, ["delete", "upArrow"]) is "07:13"
+PASS test("07:13:30", 10, null, null, ["delete", "downArrow"]) is "07:13:50"
+PASS test("07:13:30", 10, "00:00:05", null, ["delete", "upArrow"]) is "07:13:05"
+PASS test("07:13:30", 10, "00:00:05", null, ["delete", "downArrow"]) is "07:13:55"
+Minutes
+PASS stepUp("07:13", 1, null, null) is "07:14"
+PASS stepDown("07:13", 1, null, null) is "07:12"
+PASS stepUp("07:59", 0.001, null, null) is "07:00"
+PASS stepDown("07:00", 0.001, null, null) is "07:59"
+PASS stepUp("07:00", 600, null, null) is "07:10"
+PASS stepDown("07:10", 600, null, null) is "07:00"
+PASS stepUp("07:50", 600, null, null) is "07:00"
+PASS stepDown("07:00", 600, null, null) is "07:50"
+PASS stepUp("07:13", 600, null, null) is "07:20"
+PASS stepDown("07:13", 600, null, null) is "07:10"
+PASS stepUp("07:13", 150, null, null) is "07:14"
+PASS stepDown("07:13", 150, null, null) is "07:12"
+PASS stepUp("07:13", 0, null, null) is "07:14"
+PASS stepDown("07:13", 0, null, null) is "07:12"
+PASS stepUp("07:13", 36000, null, null) is "07:00"
+PASS stepDown("07:13", 36000, null, null) is "07:00"
+PASS stepUp("07:13", 660, null, null) is "07:14"
+PASS stepDown("07:13", 660, null, null) is "07:12"
+PASS stepUp("07:13", 600, "00:05", null) is "07:15"
+PASS stepDown("07:13", 600, "00:05", null) is "07:05"
+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"
 
 PASS successfullyParsed is true
 

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


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html	2012-12-14 04:56:22 UTC (rev 137712)
@@ -19,26 +19,26 @@
     eventSender.keyDown(key, modifiers);
 }
 
-function setInputAttributes(min, max, step, value) {
+function setInputAttributes(value, min, max, step) {
+    input.value = value;
     input.min = min;
     input.max = max;
     input.step = step;
-    input.value = value;
 }
 
 function test(value, step, min, max, keySequence) {
-    setInputAttributes(min, max, step, value);
+    setInputAttributes(value, min, max, step);
     for (var i = 0; i < keySequence.length; i++)
         keyDown(keySequence[i]);
     return input.value;
 }
 
 function stepUp(value, step, min, max) {
-    return test(value,step, min, max, ['upArrow']);
+    return test(value, step, min, max, ['upArrow']);
 }
 
 function stepDown(value, step, min, max) {
-    return test(value,step, min, max, ['downArrow']);
+    return test(value, step, min, max, ['downArrow']);
 }
 
 input.type = 'time';
@@ -67,8 +67,10 @@
 shouldBeEqualToString('stepDown("07:13:00.101", 0.100, null, null)', '07:13:00.100');
 shouldBeEqualToString('stepUp("07:13:00.500", 0.0001, null, null)', '07:13:00.501');
 shouldBeEqualToString('stepDown("07:13:00.500", 0.0001, null, null)', '07:13:00.499');
-shouldBeEqualToString('stepUp("07:13:00.500", 0, null, null)', '07:13:00.501');
-shouldBeEqualToString('stepDown("07:13:00.500", 0, null, null)', '07:13:00.499');
+shouldBeEqualToString('stepUp("07:13:00.500", 0, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:00.500", 0, null, null)', '07:13');
+shouldBeEqualToString('stepUp("07:13:00.500", 60, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:00.500", 60, null, null)', '07:13');
 shouldBeEqualToString('stepUp("07:13:00.500", 0.100, "00:00:00.050", null)', '07:13:00.550');
 shouldBeEqualToString('stepDown("07:13:00.500", 0.100, "00:00:00.050", null)', '07:13:00.450');
 shouldBeEqualToString('test("07:13:00.500", 0.100, null, null, ["delete", "upArrow"])', '07:13');
@@ -76,6 +78,60 @@
 shouldBeEqualToString('test("07:13:00.500", 0.100, "00:00:00.050", null, ["delete", "upArrow"])', '07:13:00.050');
 shouldBeEqualToString('test("07:13:00.500", 0.100, "00:00:00.050", null, ["delete", "downArrow"])', '07:13:00.950');
 
+debug('Seconds');
+keyDown('leftArrow');
+shouldBeEqualToString('stepUp("07:13:00", 1, null, null)', '07:13:01');
+shouldBeEqualToString('stepDown("07:13:01", 1, null, null)', '07:13');
+shouldBeEqualToString('stepUp("07:13:59", 0.001, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:00", 0.001, null, null)', '07:13:59');
+shouldBeEqualToString('stepUp("07:13:00", 10, null, null)', '07:13:10');
+shouldBeEqualToString('stepDown("07:13:30", 10, null, null)', '07:13:20');
+shouldBeEqualToString('stepUp("07:13:50", 10, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:00", 10, null, null)', '07:13:50');
+shouldBeEqualToString('stepUp("07:13:09", 10, null, null)', '07:13:10');
+shouldBeEqualToString('stepDown("07:13:11", 10, null, null)', '07:13:10');
+shouldBeEqualToString('stepUp("07:13:30", 2.5, null, null)', '07:13:31');
+shouldBeEqualToString('stepDown("07:13:30", 2.5, null, null)', '07:13:29');
+shouldBeEqualToString('stepUp("07:13:30", 0, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:30", 0, null, null)', '07:13');
+shouldBeEqualToString('stepUp("07:13:30", 3600, null, null)', '07:13');
+shouldBeEqualToString('stepDown("07:13:30", 3600, null, null)', '07:13');
+shouldBeEqualToString('stepUp("07:13:30", 11, null, null)', '07:13:31');
+shouldBeEqualToString('stepDown("07:13:30", 11, null, null)', '07:13:29');
+shouldBeEqualToString('stepUp("07:13:30", 10, "00:00:05", null)', '07:13:35');
+shouldBeEqualToString('stepDown("07:13:30", 10, "00:00:05", null)', '07:13:25');
+shouldBeEqualToString('test("07:13:30", 10, null, null, ["delete", "upArrow"])', '07:13');
+shouldBeEqualToString('test("07:13:30", 10, null, null, ["delete", "downArrow"])', '07:13:50');
+shouldBeEqualToString('test("07:13:30", 10, "00:00:05", null, ["delete", "upArrow"])', '07:13:05');
+shouldBeEqualToString('test("07:13:30", 10, "00:00:05", null, ["delete", "downArrow"])', '07:13:55');
+
+debug('Minutes');
+keyDown('leftArrow');
+shouldBeEqualToString('stepUp("07:13", 1, null, null)', '07:14');
+shouldBeEqualToString('stepDown("07:13", 1, null, null)', '07:12');
+shouldBeEqualToString('stepUp("07:59", 0.001, null, null)', '07:00');
+shouldBeEqualToString('stepDown("07:00", 0.001, null, null)', '07:59');
+shouldBeEqualToString('stepUp("07:00", 600, null, null)', '07:10');
+shouldBeEqualToString('stepDown("07:10", 600, null, null)', '07:00');
+shouldBeEqualToString('stepUp("07:50", 600, null, null)', '07:00');
+shouldBeEqualToString('stepDown("07:00", 600, null, null)', '07:50');
+shouldBeEqualToString('stepUp("07:13", 600, null, null)', '07:20');
+shouldBeEqualToString('stepDown("07:13", 600, null, null)', '07:10');
+shouldBeEqualToString('stepUp("07:13", 150, null, null)', '07:14');
+shouldBeEqualToString('stepDown("07:13", 150, null, null)', '07:12');
+shouldBeEqualToString('stepUp("07:13", 0, null, null)', '07:14');
+shouldBeEqualToString('stepDown("07:13", 0, null, null)', '07:12');
+shouldBeEqualToString('stepUp("07:13", 36000, null, null)', '07:00');
+shouldBeEqualToString('stepDown("07:13", 36000, null, null)', '07:00');
+shouldBeEqualToString('stepUp("07:13", 660, null, null)', '07:14');
+shouldBeEqualToString('stepDown("07:13", 660, null, null)', '07:12');
+shouldBeEqualToString('stepUp("07:13", 600, "00:05", null)', '07:15');
+shouldBeEqualToString('stepDown("07:13", 600, "00:05", null)', '07:05');
+shouldBeEqualToString('test("07:13", 600, null, null, ["delete", "upArrow"])', '07:00');
+shouldBeEqualToString('test("07:13", 600, null, null, ["delete", "downArrow"])', '07:50');
+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('');
 document.body.removeChild(input);
 </script>

Modified: trunk/Source/WebCore/ChangeLog (137711 => 137712)


--- trunk/Source/WebCore/ChangeLog	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/ChangeLog	2012-12-14 04:56:22 UTC (rev 137712)
@@ -1,3 +1,37 @@
+2012-12-13  Kunihiko Sakamoto  <[email protected]>
+
+        Seconds/Minutes field of date/time input UI should respect step attribute
+        https://bugs.webkit.org/show_bug.cgi?id=104985
+
+        Reviewed by Kent Tamura.
+
+        This patch makes step-up/-down UI of the seconds and minutes fields respect
+        step attribute when possible.
+
+        Test: fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html
+
+        * html/shadow/DateTimeEditElement.cpp:
+        (DateTimeEditBuilder):
+        (WebCore::DateTimeEditBuilder::visitField): Compute step parameters for seconds and minutes fields, and pass it to the field element constructors.
+        (WebCore::DateTimeEditBuilder::createNumericFieldParameters): Added.
+        * html/shadow/DateTimeFieldElements.cpp:
+        (WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement): Use Parameters instead of step and stepBase.
+        (WebCore::DateTimeMillisecondFieldElement::create): Ditto.
+        (WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement): Add Parameters argument.
+        (WebCore::DateTimeMinuteFieldElement::create): Ditto.
+        (WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement): Ditto.
+        (WebCore::DateTimeSecondFieldElement::create): Ditto.
+        * html/shadow/DateTimeFieldElements.h:
+        (DateTimeMillisecondFieldElement): Use Parameters instead of step and stepBase.
+        (DateTimeMinuteFieldElement): Add Parameters argument.
+        (DateTimeSecondFieldElement): Ditto.
+        * html/shadow/DateTimeNumericFieldElement.cpp:
+        (WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement): Use Parameters instead of step and stepBase.
+        * html/shadow/DateTimeNumericFieldElement.h:
+        (DateTimeNumericFieldElement):
+        (WebCore::DateTimeNumericFieldElement::Parameters::Parameters):
+        (Parameters): Added.
+
 2012-12-13  Filip Pizlo  <[email protected]>
 
         Attempt to rationalize and simplify WTF::binarySearch

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (137711 => 137712)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-12-14 04:56:22 UTC (rev 137712)
@@ -65,6 +65,7 @@
     bool shouldMinuteFieldReadOnly() const;
     bool shouldSecondFieldReadOnly() const;
     inline const StepRange& stepRange() const { return m_parameters.stepRange; }
+    DateTimeNumericFieldElement::Parameters createNumericFieldParameters(const Decimal& msPerFieldUnit, const Decimal& msPerFieldSize) const;
 
     // DateTimeFormat::TokenHandler functions.
     virtual void visitField(DateTimeFormat::FieldType, int) OVERRIDE FINAL;
@@ -148,7 +149,8 @@
     }
 
     case DateTimeFormat::FieldTypeMinute: {
-        RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::create(document, m_editElement);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerMinute), static_cast<int>(msPerHour));
+        RefPtr<DateTimeNumericFieldElement> field = DateTimeMinuteFieldElement::create(document, m_editElement, parameters);
         m_editElement.addField(field);
         if (shouldMinuteFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -198,7 +200,8 @@
     }
 
     case DateTimeFormat::FieldTypeSecond: {
-        RefPtr<DateTimeNumericFieldElement> field = DateTimeSecondFieldElement::create(document, m_editElement);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(static_cast<int>(msPerSecond), static_cast<int>(msPerMinute));
+        RefPtr<DateTimeNumericFieldElement> field = DateTimeSecondFieldElement::create(document, m_editElement, parameters);
         m_editElement.addField(field);
         if (shouldSecondFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -213,16 +216,8 @@
     }
 
     case DateTimeFormat::FieldTypeFractionalSecond: {
-        ASSERT(!m_parameters.stepRange.step().isZero());
-        int step = 1;
-        int stepBase = 0;
-        const Decimal decimalMsPerSecond(static_cast<int>(msPerSecond));
-
-        if (decimalMsPerSecond.remainder(m_parameters.stepRange.step()).isZero() && m_parameters.stepRange.step().remainder(Decimal(1)).isZero()) {
-            step = static_cast<int>(m_parameters.stepRange.step().toDouble());
-            stepBase = static_cast<int>(m_parameters.stepRange.stepBase().remainder(decimalMsPerSecond).toDouble());
-        }
-        RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElement::create(document, m_editElement, step, stepBase);
+        DateTimeNumericFieldElement::Parameters parameters = createNumericFieldParameters(1, static_cast<int>(msPerSecond));
+        RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElement::create(document, m_editElement, parameters);
         m_editElement.addField(field);
         if (shouldMillisecondFieldReadOnly()) {
             field->setValueAsDate(m_dateValue);
@@ -307,6 +302,25 @@
     m_editElement.appendChild(element);
 }
 
+DateTimeNumericFieldElement::Parameters DateTimeEditBuilder::createNumericFieldParameters(const Decimal& msPerFieldUnit, const Decimal& msPerFieldSize) const
+{
+    ASSERT(!msPerFieldUnit.isZero());
+    ASSERT(!msPerFieldSize.isZero());
+    Decimal stepMilliseconds = stepRange().step();
+    ASSERT(!stepMilliseconds.isZero());
+
+    DateTimeNumericFieldElement::Parameters parameters(1, 0);
+
+    if (stepMilliseconds.remainder(msPerFieldSize).isZero())
+        stepMilliseconds = msPerFieldSize;
+
+    if (msPerFieldSize.remainder(stepMilliseconds).isZero() && stepMilliseconds.remainder(msPerFieldUnit).isZero()) {
+        parameters.step = static_cast<int>((stepMilliseconds / msPerFieldUnit).toDouble());
+        parameters.stepBase = static_cast<int>((stepRange().stepBase() / msPerFieldUnit).floor().remainder(msPerFieldSize / msPerFieldUnit).toDouble());
+    }
+    return parameters;
+}
+
 // ----------------------------
 
 DateTimeEditElement::EditControlOwner::~EditControlOwner()

Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp (137711 => 137712)


--- trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp	2012-12-14 04:56:22 UTC (rev 137712)
@@ -217,15 +217,15 @@
 
 // ----------------------------
 
-DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement(Document* document, FieldOwner& fieldOwner, int step, int stepBase)
-    : DateTimeNumericFieldElement(document, fieldOwner, 0, 999, "---", step, stepBase)
+DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
+    : DateTimeNumericFieldElement(document, fieldOwner, 0, 999, "---", parameters)
 {
 }
 
-PassRefPtr<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::create(Document* document, FieldOwner& fieldOwner, int step, int stepBase)
+PassRefPtr<DateTimeMillisecondFieldElement> DateTimeMillisecondFieldElement::create(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
 {
     DEFINE_STATIC_LOCAL(AtomicString, millisecondPsuedoId, ("-webkit-datetime-edit-millisecond-field", AtomicString::ConstructFromLiteral));
-    RefPtr<DateTimeMillisecondFieldElement> field = adoptRef(new DateTimeMillisecondFieldElement(document, fieldOwner, step, stepBase));
+    RefPtr<DateTimeMillisecondFieldElement> field = adoptRef(new DateTimeMillisecondFieldElement(document, fieldOwner, parameters));
     field->initialize(millisecondPsuedoId, AXMillisecondFieldText());
     return field.release();
 }
@@ -258,15 +258,15 @@
 
 // ----------------------------
 
-DateTimeMinuteFieldElement::DateTimeMinuteFieldElement(Document* document, FieldOwner& fieldOwner)
-    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--")
+DateTimeMinuteFieldElement::DateTimeMinuteFieldElement(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
+    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--", parameters)
 {
 }
 
-PassRefPtr<DateTimeMinuteFieldElement> DateTimeMinuteFieldElement::create(Document* document, FieldOwner& fieldOwner)
+PassRefPtr<DateTimeMinuteFieldElement> DateTimeMinuteFieldElement::create(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
 {
     DEFINE_STATIC_LOCAL(AtomicString, minutePsuedoId, ("-webkit-datetime-edit-minute-field", AtomicString::ConstructFromLiteral));
-    RefPtr<DateTimeMinuteFieldElement> field = adoptRef(new DateTimeMinuteFieldElement(document, fieldOwner));
+    RefPtr<DateTimeMinuteFieldElement> field = adoptRef(new DateTimeMinuteFieldElement(document, fieldOwner, parameters));
     field->initialize(minutePsuedoId, AXMinuteFieldText());
     return field.release();
 }
@@ -340,15 +340,15 @@
 
 // ----------------------------
 
-DateTimeSecondFieldElement::DateTimeSecondFieldElement(Document* document, FieldOwner& fieldOwner)
-    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--")
+DateTimeSecondFieldElement::DateTimeSecondFieldElement(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
+    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--", parameters)
 {
 }
 
-PassRefPtr<DateTimeSecondFieldElement> DateTimeSecondFieldElement::create(Document* document, FieldOwner& fieldOwner)
+PassRefPtr<DateTimeSecondFieldElement> DateTimeSecondFieldElement::create(Document* document, FieldOwner& fieldOwner, const DateTimeNumericFieldElement::Parameters& parameters)
 {
     DEFINE_STATIC_LOCAL(AtomicString, secondPsuedoId, ("-webkit-datetime-edit-second-field", AtomicString::ConstructFromLiteral));
-    RefPtr<DateTimeSecondFieldElement> field = adoptRef(new DateTimeSecondFieldElement(document, fieldOwner));
+    RefPtr<DateTimeSecondFieldElement> field = adoptRef(new DateTimeSecondFieldElement(document, fieldOwner, parameters));
     field->initialize(secondPsuedoId, AXSecondFieldText());
     return field.release();
 }

Modified: trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h (137711 => 137712)


--- trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/html/shadow/DateTimeFieldElements.h	2012-12-14 04:56:22 UTC (rev 137712)
@@ -91,10 +91,10 @@
     WTF_MAKE_NONCOPYABLE(DateTimeMillisecondFieldElement);
 
 public:
-    static PassRefPtr<DateTimeMillisecondFieldElement> create(Document*, FieldOwner&, int step, int stepBase);
+    static PassRefPtr<DateTimeMillisecondFieldElement> create(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
 private:
-    DateTimeMillisecondFieldElement(Document*, FieldOwner&, int step, int stepBase);
+    DateTimeMillisecondFieldElement(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
     // DateTimeFieldElement functions.
     virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
@@ -106,10 +106,10 @@
     WTF_MAKE_NONCOPYABLE(DateTimeMinuteFieldElement);
 
 public:
-    static PassRefPtr<DateTimeMinuteFieldElement> create(Document*, FieldOwner&);
+    static PassRefPtr<DateTimeMinuteFieldElement> create(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
 private:
-    DateTimeMinuteFieldElement(Document*, FieldOwner&);
+    DateTimeMinuteFieldElement(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
     // DateTimeFieldElement functions.
     virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
@@ -136,10 +136,10 @@
     WTF_MAKE_NONCOPYABLE(DateTimeSecondFieldElement);
 
 public:
-    static PassRefPtr<DateTimeSecondFieldElement> create(Document*, FieldOwner&);
+    static PassRefPtr<DateTimeSecondFieldElement> create(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
 private:
-    DateTimeSecondFieldElement(Document*, FieldOwner&);
+    DateTimeSecondFieldElement(Document*, FieldOwner&, const DateTimeNumericFieldElement::Parameters&);
 
     // DateTimeFieldElement functions.
     virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;

Modified: trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp (137711 => 137712)


--- trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp	2012-12-14 04:56:22 UTC (rev 137712)
@@ -59,15 +59,15 @@
 
 // ----------------------------
 
-DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const String& placeholder, int step, int stepBase)
+DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const String& placeholder, const DateTimeNumericFieldElement::Parameters& parameters)
     : DateTimeFieldElement(document, fieldOwner)
     , m_lastDigitCharTime(0)
     , m_placeholder(placeholder)
     , m_range(minimum, maximum)
     , m_value(0)
     , m_hasValue(false)
-    , m_step(step)
-    , m_stepBase(stepBase)
+    , m_step(parameters.step)
+    , m_stepBase(parameters.stepBase)
 {
     ASSERT(m_step);
 

Modified: trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h (137711 => 137712)


--- trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h	2012-12-14 04:52:43 UTC (rev 137711)
+++ trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h	2012-12-14 04:56:22 UTC (rev 137712)
@@ -41,6 +41,13 @@
 class DateTimeNumericFieldElement : public DateTimeFieldElement {
     WTF_MAKE_NONCOPYABLE(DateTimeNumericFieldElement);
 
+public:
+    struct Parameters {
+        Parameters(int step = 1, int stepBase = 0) : step(step), stepBase(stepBase) { }
+        int step;
+        int stepBase;
+    };
+
 protected:
     struct Range {
         Range(int minimum, int maximum);
@@ -51,7 +58,7 @@
         int minimum;
     };
 
-    DateTimeNumericFieldElement(Document*, FieldOwner&, int minimum, int maximum, const String& placeholder, int step = 1, int stepBase = 0);
+    DateTimeNumericFieldElement(Document*, FieldOwner&, int minimum, int maximum, const String& placeholder, const Parameters& = Parameters());
 
     int clampValue(int value) const { return m_range.clampValue(value); }
     virtual int clampValueForHardLimits(int) const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to