INPUT_MULTIPLE_FIELDS_UI: Step-up/-down of hour field should respect min/max attributes
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 06:44:41 +0000 (06:44 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 06:44:41 +0000 (06:44 +0000)
commitfae8e4049ccacfa5f9cc55fecedc0847b649d7c1
tree30992ae8cb71f14070c191c8779e78068105377f
parente7718553eb5ad5f9f967c7a1df9be5bcabb30ed2
INPUT_MULTIPLE_FIELDS_UI: Step-up/-down of hour field should respect min/max attributes
https://bugs.webkit.org/show_bug.cgi?id=109555

Patch by Kunihiko Sakamoto <ksakamoto@chromium.org> on 2013-02-27
Reviewed by Kent Tamura.

Source/WebCore:

Make step-up/-down of the hour field respect the min/max attributes of the element.
Note that it still accepts any keyboard inputs (the element
becomes 'invalid' state when out-of-range values entered).
Also, disable the hour field and/or the AMPM field when there is only single possible value.

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

* html/TimeInputType.cpp:
(WebCore::TimeInputType::setupLayoutParameters): Populates layoutParameters.{minimum,maximum}.
* html/shadow/DateTimeEditElement.cpp:
(DateTimeEditBuilder): Add data fields for min/max of day and hour fields.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder): Set newly added data members.
(WebCore::DateTimeEditBuilder::visitField): Pass minimum/maximum value to the month field constructors.
(WebCore::DateTimeEditBuilder::shouldAMPMFieldDisabled): Added.
(WebCore::DateTimeEditBuilder::shouldDayOfMonthFieldDisabled):
(WebCore::DateTimeEditBuilder::shouldHourFieldDisabled):
Disables the hour field when min, max, and value have the same hour, except when the minute
field is disabled (by step attribute), because we need to leave at least one field editable.
* html/shadow/DateTimeFieldElements.cpp:
(WebCore::DateTimeHourFieldElementBase::DateTimeHourFieldElementBase):
(WebCore::DateTimeHourFieldElementBase::initialize):
(WebCore::DateTimeHourFieldElementBase::setValueAsDate):
(WebCore::DateTimeHourFieldElementBase::setValueAsDateTimeFieldsState):
(WebCore::DateTimeHour11FieldElement::DateTimeHour11FieldElement):
(WebCore::DateTimeHour11FieldElement::create):
(WebCore::DateTimeHour11FieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHour11FieldElement::setValueAsInteger):
(WebCore::DateTimeHour11FieldElement::clampValueForHardLimits):
(WebCore::DateTimeHour12FieldElement::DateTimeHour12FieldElement):
(WebCore::DateTimeHour12FieldElement::create):
(WebCore::DateTimeHour12FieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHour12FieldElement::setValueAsInteger):
(WebCore::DateTimeHour12FieldElement::clampValueForHardLimits):
(WebCore::DateTimeHour23FieldElement::DateTimeHour23FieldElement):
(WebCore::DateTimeHour23FieldElement::create):
(WebCore::DateTimeHour23FieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHour23FieldElement::setValueAsInteger):
(WebCore::DateTimeHour23FieldElement::clampValueForHardLimits):
(WebCore::DateTimeHour24FieldElement::DateTimeHour24FieldElement):
(WebCore::DateTimeHour24FieldElement::create):
(WebCore::DateTimeHour24FieldElement::populateDateTimeFieldsState):
(WebCore::DateTimeHour24FieldElement::setValueAsInteger):
(WebCore::DateTimeHour24FieldElement::clampValueForHardLimits):
* html/shadow/DateTimeFieldElements.h: Splitted DateTimeHourFieldElement into a base class and four derived classes that represents different hour formats.
(DateTimeHourFieldElementBase): Added.
(DateTimeHour11FieldElement): Added. Represents 0-11 hour format.
(DateTimeHour12FieldElement): Added. Represents 1-12 hour format.
(DateTimeHour23FieldElement): Added. Represents 0-23 hour format.
(DateTimeHour24FieldElement): Added. Represents 1-24 hour format.

LayoutTests:

Added test cases with min/max attributes.

* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield-expected.txt:
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html:
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-stepup-stepdown-from-renderer-expected.txt: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-stepup-stepdown-from-renderer.html: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield-expected.txt:
* fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield.html:
* 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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144263 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield-expected.txt
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-readonly-subfield.html
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-stepup-stepdown-from-renderer-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-stepup-stepdown-from-renderer.html [new file with mode: 0644]
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield-expected.txt
LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-readonly-subfield.html
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
Source/WebCore/ChangeLog
Source/WebCore/html/TimeInputType.cpp
Source/WebCore/html/shadow/DateTimeEditElement.cpp
Source/WebCore/html/shadow/DateTimeFieldElements.cpp
Source/WebCore/html/shadow/DateTimeFieldElements.h