2010-11-29 Dai Mikurube <dmikurube@google.com>
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2010 06:11:08 +0000 (06:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Nov 2010 06:11:08 +0000 (06:11 +0000)
commita42100a50d5d96697d9f747f81b83e709153a0cf
treee550cd67bb3001980d385e2806080305ec7a7595
parent7047dc71d33c645331165034261a09a6003fb19d
2010-11-29  Dai Mikurube  <dmikurube@google.com>

        Reviewed by Kent Tamura.

        when empty, clicking "down" on outer-spin-button returns "max value"
        https://bugs.webkit.org/show_bug.cgi?id=45491

        It is required to calculate UTC/DST offsets to retrieve the current local milliseconds for
        date/time type inputs. WTF::currentTimeMS() returns a UTC time, and WTF::getLocalTime()
        returns a struct tm, not milliseconds.

        Calculating milliseconds from a struct tm is not simple since timegm() cannot be used in all
        environments. This calculation is already done in calculateUTCOffset(), and complicated.
        Duplicating this complicated calculation is unreasonable because of maintainability.
        To achieve this without duplication, we must call calculate{UTC|DST}Offset in some way.

        * JavaScriptCore.exp:
        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
        * wtf/DateMath.cpp: Changed calculateUTCOffset() and calculateDSTOffset() to external functions.
        (WTF::calculateUTCOffset):
        (WTF::calculateDSTOffset):
        * wtf/DateMath.h:
2010-11-29  Dai Mikurube  <dmikurube@google.com>

        Reviewed by Kent Tamura.

        when empty, clicking "down" on outer-spin-button returns "max value"
        https://bugs.webkit.org/show_bug.cgi?id=45491

        * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: Added.
        * fast/forms/input-stepup-stepdown-from-renderer.html: Added.
        * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js: Added.
        ():
        (setInputAttributes):
        (stepUp):
        (stepDown):
        (stepUpExplicitBounds):
        (stepDownExplicitBounds):
2010-11-29  Dai Mikurube  <dmikurube@google.com>

        Reviewed by Kent Tamura.

        when empty, clicking "down" on outer-spin-button returns "max value"
        https://bugs.webkit.org/show_bug.cgi?id=45491

        Modified stepping-up/down from renderer
        - to clamp steps,
        - to handle empty values (described below), and
        - to apply them for range type inputs.

        Stepping-up/down for empty values are handled "the empty as 0."
        For example :
        * If 0 is in-range, and matches to step value
          "down" -> -step
          "up" -> +step
          If -step or +step is out of range, new value should be 0.

        * If 0 is smaller than the minimum value
          "down" -> the minimum value
          "up" -> the minimum value

        * If 0 is larger than the maximum value
          "down" -> the maximum value
          "up" -> the maximum value

        * If 0 is in-range, but not matched to step value
          "down" -> smaler matched value nearest to 0.
            e.g. <input type=number min=-100 step=3> -> -1
          "up" -> larger matched value nearest to 0.
            e.g. <input type=number min=-100 step=3> -> 2

        As for date/datetime-local/month/time/week types, the empty is assumed as "current local date/time".
        As for datetime type, the empty is assumed as "current date/time in UTC".

        As for range input types, changed stepping from renderer to use stepUpFromRenderer().
        It was calculated with stepUp() from RangeInputType::handleKeydownEvent().

        Test: fast/forms/input-stepup-stepdown-from-renderer.html

        * html/BaseDateAndTimeInputType.cpp:
        (WebCore::BaseDateAndTimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local time
        * html/BaseDateAndTimeInputType.h:
        * html/DateTimeInputType.cpp:
        (WebCore::DateTimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current UTC time
        * html/DateTimeInputType.h:
        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::stepUpFromRenderer): Modified it to clamp steps, support empty values and support range type inputs
        * html/HTMLInputElement.h:
        (WebCore::HTMLInputElement::isRangeControl):
        * html/InputType.cpp:
        (WebCore::InputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns 0
        * html/InputType.h:
        * html/MonthInputType.cpp:
        (WebCore::MonthInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local month
        * html/MonthInputType.h:
        * html/RangeInputType.cpp:
        (WebCore::RangeInputType::handleKeydownEvent): Added comments and modified it to use stepUpFromRenderer()
        * html/TimeInputType.cpp:
        (WebCore::TimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local time
        * html/TimeInputType.h:
        * manual-tests/input-type-datetime-default-value.html: Added manual tests for default values of date/time inputs since they are "the current local/UTC time", which cannot be tested automatically.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72884 268f45cc-cd09-0410-ab3c-d52691b4dbfc
25 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.exp
JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
JavaScriptCore/wtf/DateMath.cpp
JavaScriptCore/wtf/DateMath.h
LayoutTests/ChangeLog
LayoutTests/fast/forms/input-stepup-stepdown-from-renderer-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/input-stepup-stepdown-from-renderer.html [new file with mode: 0644]
LayoutTests/fast/forms/script-tests/input-stepup-stepdown-from-renderer.js [new file with mode: 0644]
WebCore/ChangeLog
WebCore/html/BaseDateAndTimeInputType.cpp
WebCore/html/BaseDateAndTimeInputType.h
WebCore/html/DateTimeInputType.cpp
WebCore/html/DateTimeInputType.h
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/html/InputType.cpp
WebCore/html/InputType.h
WebCore/html/MonthInputType.cpp
WebCore/html/MonthInputType.h
WebCore/html/RangeInputType.cpp
WebCore/html/RangeInputType.h
WebCore/html/TimeInputType.cpp
WebCore/html/TimeInputType.h
WebCore/manual-tests/input-type-datetime-default-value.html [new file with mode: 0644]