Changeset 72884 in webkit


Ignore:
Timestamp:
Nov 29, 2010 10:11:08 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

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.
Location:
trunk
Files:
4 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r72853 r72884  
     12010-11-29  Dai Mikurube  <dmikurube@google.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        when empty, clicking "down" on outer-spin-button returns "max value"
     6        https://bugs.webkit.org/show_bug.cgi?id=45491
     7
     8        It is required to calculate UTC/DST offsets to retrieve the current local milliseconds for
     9        date/time type inputs. WTF::currentTimeMS() returns a UTC time, and WTF::getLocalTime()
     10        returns a struct tm, not milliseconds.
     11
     12        Calculating milliseconds from a struct tm is not simple since timegm() cannot be used in all
     13        environments. This calculation is already done in calculateUTCOffset(), and complicated.
     14        Duplicating this complicated calculation is unreasonable because of maintainability.
     15        To achieve this without duplication, we must call calculate{UTC|DST}Offset in some way.
     16
     17        * JavaScriptCore.exp:
     18        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
     19        * wtf/DateMath.cpp: Changed calculateUTCOffset() and calculateDSTOffset() to external functions.
     20        (WTF::calculateUTCOffset):
     21        (WTF::calculateDSTOffset):
     22        * wtf/DateMath.h:
     23
    1242010-11-29  Chris Rogers  <crogers@google.com>
    225
  • trunk/JavaScriptCore/JavaScriptCore.exp

    r72477 r72884  
    405405__ZN3WTF17equalIgnoringCaseEPNS_10StringImplEPKc
    406406__ZN3WTF17equalIgnoringCaseEPNS_10StringImplES1_
     407__ZN3WTF18calculateDSTOffsetEdd
     408__ZN3WTF18calculateUTCOffsetEv
    407409__ZN3WTF18charactersToDoubleEPKtmPb
    408410__ZN3WTF18dateToDaysFrom1970Eiii
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r72134 r72884  
    6060    ?bufferLengthForStringDecimal@DecimalNumber@WTF@@QBEIXZ
    6161    ?calculatedFunctionName@DebuggerCallFrame@JSC@@QBE?AVUString@2@XZ
     62    ?calculateUTCOffset@WTF@@YAHXZ
     63    ?calculateDSTOffset@WTF@@YANNN@Z
    6264    ?call@JSC@@YA?AVJSValue@1@PAVExecState@1@V21@W4CallType@1@ABTCallData@1@1ABVArgList@1@@Z
    6365    ?callOnMainThread@WTF@@YAXP6AXPAX@Z0@Z
  • trunk/JavaScriptCore/wtf/DateMath.cpp

    r70427 r72884  
    380380}
    381381
    382 static int32_t calculateUTCOffset()
     382int32_t calculateUTCOffset()
    383383{
    384384#if PLATFORM(BREWMP)
     
    450450
    451451// Get the DST offset, given a time in UTC
    452 static double calculateDSTOffset(double ms, double utcOffset)
     452double calculateDSTOffset(double ms, double utcOffset)
    453453{
    454454    // On Mac OS X, the call to localtime (see calculateDSTOffsetSimple) will return historically accurate
  • trunk/JavaScriptCore/wtf/DateMath.h

    r69920 r72884  
    8585int dayInMonthFromDayInYear(int dayInYear, bool leapYear);
    8686
     87// Returns offset milliseconds for UTC and DST.
     88int32_t calculateUTCOffset();
     89double calculateDSTOffset(double ms, double utcOffset);
     90
    8791} // namespace WTF
    8892
     
    9397using WTF::monthFromDayInYear;
    9498using WTF::msPerDay;
     99using WTF::msPerMinute;
    95100using WTF::msPerSecond;
    96101using WTF::msToYear;
    97102using WTF::secondsPerMinute;
    98103using WTF::parseDateFromNullTerminatedCharacters;
     104using WTF::calculateUTCOffset;
     105using WTF::calculateDSTOffset;
    99106
    100107#if USE(JSC)
  • trunk/LayoutTests/ChangeLog

    r72883 r72884  
     12010-11-29  Dai Mikurube  <dmikurube@google.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        when empty, clicking "down" on outer-spin-button returns "max value"
     6        https://bugs.webkit.org/show_bug.cgi?id=45491
     7
     8        * fast/forms/input-stepup-stepdown-from-renderer-expected.txt: Added.
     9        * fast/forms/input-stepup-stepdown-from-renderer.html: Added.
     10        * fast/forms/script-tests/input-stepup-stepdown-from-renderer.js: Added.
     11        ():
     12        (setInputAttributes):
     13        (stepUp):
     14        (stepDown):
     15        (stepUpExplicitBounds):
     16        (stepDownExplicitBounds):
     17
    1182010-11-29  Ojan Vafai  <ojan@chromium.org>
    219
  • trunk/WebCore/ChangeLog

    r72876 r72884  
     12010-11-29  Dai Mikurube  <dmikurube@google.com>
     2
     3        Reviewed by Kent Tamura.
     4
     5        when empty, clicking "down" on outer-spin-button returns "max value"
     6        https://bugs.webkit.org/show_bug.cgi?id=45491
     7
     8        Modified stepping-up/down from renderer
     9        - to clamp steps,
     10        - to handle empty values (described below), and
     11        - to apply them for range type inputs.
     12
     13        Stepping-up/down for empty values are handled "the empty as 0."
     14        For example :
     15        * If 0 is in-range, and matches to step value
     16          "down" -> -step
     17          "up" -> +step
     18          If -step or +step is out of range, new value should be 0.
     19
     20        * If 0 is smaller than the minimum value
     21          "down" -> the minimum value
     22          "up" -> the minimum value
     23
     24        * If 0 is larger than the maximum value
     25          "down" -> the maximum value
     26          "up" -> the maximum value
     27
     28        * If 0 is in-range, but not matched to step value
     29          "down" -> smaler matched value nearest to 0.
     30            e.g. <input type=number min=-100 step=3> -> -1
     31          "up" -> larger matched value nearest to 0.
     32            e.g. <input type=number min=-100 step=3> -> 2
     33
     34        As for date/datetime-local/month/time/week types, the empty is assumed as "current local date/time".
     35        As for datetime type, the empty is assumed as "current date/time in UTC".
     36
     37        As for range input types, changed stepping from renderer to use stepUpFromRenderer().
     38        It was calculated with stepUp() from RangeInputType::handleKeydownEvent().
     39
     40        Test: fast/forms/input-stepup-stepdown-from-renderer.html
     41
     42        * html/BaseDateAndTimeInputType.cpp:
     43        (WebCore::BaseDateAndTimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local time
     44        * html/BaseDateAndTimeInputType.h:
     45        * html/DateTimeInputType.cpp:
     46        (WebCore::DateTimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current UTC time
     47        * html/DateTimeInputType.h:
     48        * html/HTMLInputElement.cpp:
     49        (WebCore::HTMLInputElement::stepUpFromRenderer): Modified it to clamp steps, support empty values and support range type inputs
     50        * html/HTMLInputElement.h:
     51        (WebCore::HTMLInputElement::isRangeControl):
     52        * html/InputType.cpp:
     53        (WebCore::InputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns 0
     54        * html/InputType.h:
     55        * html/MonthInputType.cpp:
     56        (WebCore::MonthInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local month
     57        * html/MonthInputType.h:
     58        * html/RangeInputType.cpp:
     59        (WebCore::RangeInputType::handleKeydownEvent): Added comments and modified it to use stepUpFromRenderer()
     60        * html/TimeInputType.cpp:
     61        (WebCore::TimeInputType::defaultValueForStepUp): Added defaultValueForStepUp() which returns the current local time
     62        * html/TimeInputType.h:
     63        * 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.
     64
    1652010-11-29  Adam Barth  <abarth@webkit.org>
    266
  • trunk/WebCore/html/BaseDateAndTimeInputType.cpp

    r72059 r72884  
    3636#include "HTMLNames.h"
    3737#include <limits>
     38#include <wtf/CurrentTime.h>
     39#include <wtf/DateMath.h>
    3840#include <wtf/MathExtras.h>
    3941#include <wtf/PassOwnPtr.h>
     
    9092    double doubleValue = parseToDouble(value, nan);
    9193    return isfinite(doubleValue) && doubleValue > maximum();
     94}
     95
     96double BaseDateAndTimeInputType::defaultValueForStepUp() const
     97{
     98    double ms = currentTimeMS();
     99    double utcOffset = calculateUTCOffset();
     100    double dstOffset = calculateDSTOffset(ms, utcOffset);
     101    int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
     102    return ms + (offset * msPerMinute);
    92103}
    93104
  • trunk/WebCore/html/BaseDateAndTimeInputType.h

    r72059 r72884  
    5656    virtual bool rangeUnderflow(const String&) const;
    5757    virtual bool rangeOverflow(const String&) const;
     58    virtual double defaultValueForStepUp() const;
    5859    virtual bool stepMismatch(const String&, double) const;
    5960    virtual double stepBase() const;
  • trunk/WebCore/html/DateTimeInputType.cpp

    r69378 r72884  
    3535#include "HTMLInputElement.h"
    3636#include "HTMLNames.h"
     37#include <wtf/CurrentTime.h>
    3738#include <wtf/PassOwnPtr.h>
    3839
     
    5253{
    5354    return InputTypeNames::datetime();
     55}
     56
     57double DateTimeInputType::defaultValueForStepUp() const
     58{
     59    return currentTimeMS();
    5460}
    5561
  • trunk/WebCore/html/DateTimeInputType.h

    r69378 r72884  
    4343    DateTimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual double defaultValueForStepUp() const;
    4546    virtual double minimum() const;
    4647    virtual double maximum() const;
  • trunk/WebCore/html/HTMLInputElement.cpp

    r72780 r72884  
    18601860{
    18611861    // The differences from stepUp()/stepDown():
    1862     // If the current value is not a number, the value will be
    1863     //  - The value should be the minimum value if n > 0
    1864     //  - The value should be the maximum value if n < 0
     1862    //
     1863    // Difference 1: the current value
     1864    // If the current value is not a number, including empty, the current value is assumed as 0.
     1865    //   * If 0 is in-range, and matches to step value
     1866    //     - The value should be the +step if n > 0
     1867    //     - The value should be the -step if n < 0
     1868    //     If -step or +step is out of range, new value should be 0.
     1869    //   * If 0 is smaller than the minimum value
     1870    //     - The value should be the minimum value for any n
     1871    //   * If 0 is larger than the maximum value
     1872    //     - The value should be the maximum value for any n
     1873    //   * If 0 is in-range, but not matched to step value
     1874    //     - The value should be the larger matched value nearest to 0 if n > 0
     1875    //       e.g. <input type=number min=-100 step=3> -> 2
     1876    //     - The value should be the smaler matched value nearest to 0 if n < 0
     1877    //       e.g. <input type=number min=-100 step=3> -> -1
     1878    //   As for date/datetime-local/month/time/week types, the current value is assumed as "the current local date/time".
     1879    //   As for datetime type, the current value is assumed as "the current date/time in UTC".
    18651880    // If the current value is smaller than the minimum value:
    18661881    //  - The value should be the minimum value if n > 0
     
    18691884    //  - The value should be the maximum value if n < 0
    18701885    //  - Nothing should happen if n > 0
    1871 
    1872     ASSERT(hasSpinButton());
    1873     if (!hasSpinButton())
     1886    //
     1887    // Difference 2: clamping steps
     1888    // If the current value is not matched to step value:
     1889    // - The value should be the larger matched value nearest to 0 if n > 0
     1890    //   e.g. <input type=number value=3 min=-100 step=3> -> 5
     1891    // - The value should be the smaler matched value nearest to 0 if n < 0
     1892    //   e.g. <input type=number value=3 min=-100 step=3> -> 2
     1893    //
     1894    // n is assumed as -n if step < 0.
     1895
     1896    ASSERT(hasSpinButton() || m_inputType->isRangeControl());
     1897    if (!hasSpinButton() && !m_inputType->isRangeControl())
    18741898        return;
    18751899    ASSERT(n);
     
    18771901        return;
    18781902
     1903    unsigned stepDecimalPlaces, baseDecimalPlaces;
     1904    double step, base;
     1905    // The value will be the default value after stepping for <input value=(empty/invalid) step="any" />
     1906    // FIXME: Not any changes after stepping, even if it is an invalid value, may be better.
     1907    // (e.g. Stepping-up for <input type="number" value="foo" step="any" /> => "foo")
     1908    if (equalIgnoringCase(getAttribute(stepAttr), "any"))
     1909        step = 0;
     1910    else if (!getAllowedValueStepWithDecimalPlaces(&step, &stepDecimalPlaces))
     1911        return;
     1912    base = m_inputType->stepBaseWithDecimalPlaces(&baseDecimalPlaces);
     1913    baseDecimalPlaces = min(baseDecimalPlaces, 16u);
     1914
     1915    int sign;
     1916    if (step > 0)
     1917        sign = n;
     1918    else if (step < 0)
     1919        sign = -n;
     1920    else
     1921        sign = 0;
     1922
    18791923    const double nan = numeric_limits<double>::quiet_NaN();
    18801924    String currentStringValue = value();
    18811925    double current = m_inputType->parseToDouble(currentStringValue, nan);
    1882     if (!isfinite(current) || (n > 0 && current < m_inputType->minimum()) || (n < 0 && current > m_inputType->maximum()))
    1883         setValue(m_inputType->serialize(n > 0 ? m_inputType->minimum() : m_inputType->maximum()));
     1926    if (!isfinite(current)) {
     1927        ExceptionCode ec;
     1928        current = m_inputType->defaultValueForStepUp();
     1929        setValueAsNumber(current, ec);
     1930    }
     1931    if ((sign > 0 && current < m_inputType->minimum()) || (sign < 0 && current > m_inputType->maximum()))
     1932        setValue(m_inputType->serialize(sign > 0 ? m_inputType->minimum() : m_inputType->maximum()));
    18841933    else {
    18851934        ExceptionCode ec;
    1886         stepUp(n, ec);
     1935        if (stepMismatch(currentStringValue)) {
     1936            ASSERT(step);
     1937            double newValue;
     1938            double scale = pow(10.0, static_cast<double>(max(stepDecimalPlaces, baseDecimalPlaces)));
     1939
     1940            if (sign < 0)
     1941                newValue = round((base + floor((current - base) / step) * step) * scale) / scale;
     1942            else if (sign > 0)
     1943                newValue = round((base + ceil((current - base) / step) * step) * scale) / scale;
     1944            else
     1945                newValue = current;
     1946
     1947            if (newValue < m_inputType->minimum())
     1948                newValue = m_inputType->minimum();
     1949            if (newValue > m_inputType->maximum())
     1950                newValue = m_inputType->maximum();
     1951
     1952            setValueAsNumber(newValue, ec);
     1953            current = newValue;
     1954            if (n > 1)
     1955                applyStep(n - 1, ec);
     1956            else if (n < -1)
     1957                applyStep(n + 1, ec);
     1958        } else
     1959            applyStep(n, ec);
    18871960    }
    18881961
     
    18901963        if (renderer() && renderer()->isTextField())
    18911964            toRenderTextControl(renderer())->setChangedSinceLastChangeEvent(true);
    1892         dispatchEvent(Event::create(eventNames().inputEvent, true, false));
     1965        if (m_inputType->isRangeControl())
     1966            dispatchFormControlChangeEvent();
     1967        else
     1968            dispatchEvent(Event::create(eventNames().inputEvent, true, false));
    18931969    }
    18941970}
  • trunk/WebCore/html/HTMLInputElement.h

    r72591 r72884  
    2828#include "HTMLFormElement.h"
    2929#include "InputElement.h"
     30#include "InputType.h"
    3031#include <wtf/OwnPtr.h>
    3132
  • trunk/WebCore/html/InputType.cpp

    r72363 r72884  
    126126}
    127127
     128bool InputType::isRangeControl() const
     129{
     130    return false;
     131}
     132
    128133bool InputType::saveFormControlState(String& result) const
    129134{
     
    214219}
    215220
     221double InputType::defaultValueForStepUp() const
     222{
     223    return 0;
     224}
     225
    216226double InputType::minimum() const
    217227{
  • trunk/WebCore/html/InputType.h

    r72363 r72884  
    6161    virtual bool isTextField() const;
    6262    virtual bool isTextType() const;
     63    virtual bool isRangeControl() const;
    6364    virtual const AtomicString& formControlType() const = 0;
    6465
     
    9091    virtual bool rangeUnderflow(const String&) const;
    9192    virtual bool rangeOverflow(const String&) const;
     93    virtual double defaultValueForStepUp() const;
    9294    virtual double minimum() const;
    9395    virtual double maximum() const;
  • trunk/WebCore/html/MonthInputType.cpp

    r69378 r72884  
    3535#include "HTMLInputElement.h"
    3636#include "HTMLNames.h"
     37#include <wtf/CurrentTime.h>
     38#include <wtf/DateMath.h>
    3739#include <wtf/MathExtras.h>
    3840#include <wtf/PassOwnPtr.h>
     
    7375    }
    7476    element()->setValue(date.toString());
     77}
     78
     79double MonthInputType::defaultValueForStepUp() const
     80{
     81    double current = currentTimeMS();
     82    double utcOffset = calculateUTCOffset();
     83    double dstOffset = calculateDSTOffset(current, utcOffset);
     84    int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
     85    current += offset * msPerMinute;
     86
     87    DateComponents date;
     88    date.setMillisecondsSinceEpochForMonth(current);
     89    double months = date.monthsSinceEpoch();
     90    ASSERT(isfinite(months));
     91    return months;
    7592}
    7693
  • trunk/WebCore/html/MonthInputType.h

    r69378 r72884  
    4646    virtual void setValueAsDate(double, ExceptionCode&) const;
    4747    virtual double parseToDouble(const String&, double) const;
     48    virtual double defaultValueForStepUp() const;
    4849    virtual double minimum() const;
    4950    virtual double maximum() const;
  • trunk/WebCore/html/RangeInputType.cpp

    r72059 r72884  
    5454{
    5555    return adoptPtr(new RangeInputType(element));
     56}
     57
     58bool RangeInputType::isRangeControl() const
     59{
     60    return true;
    5661}
    5762
     
    144149        double current = parseToDouble(element()->value(), numeric_limits<double>::quiet_NaN());
    145150        ASSERT(isfinite(current));
     151        // Stepping-up and -down for step="any" are special cases for type="range" from renderer for convenient.
     152        // No stepping normally for step="any". They cannot be handled by stepUp()/stepDown()/stepUpFromRenderer().
     153        // So calculating values stepped-up or -down here.
    146154        double newValue;
    147155        if (key == "Up" || key == "Right") {
     
    160168    } else {
    161169        int stepMagnification = (key == "Up" || key == "Right") ? 1 : -1;
    162         String lastStringValue = element()->value();
    163         element()->stepUp(stepMagnification, ec);
    164         if (lastStringValue != element()->value())
    165             element()->dispatchFormControlChangeEvent();
     170        // Reasonable stepping-up/-down by stepUpFromRenderer() unless step="any"
     171        element()->stepUpFromRenderer(stepMagnification);
    166172    }
    167173    event->setDefaultHandled();
  • trunk/WebCore/html/RangeInputType.h

    r72059 r72884  
    4242private:
    4343    RangeInputType(HTMLInputElement* element) : InputType(element) { }
     44    virtual bool isRangeControl() const;
    4445    virtual const AtomicString& formControlType() const;
    4546    virtual double valueAsNumber() const;
  • trunk/WebCore/html/TimeInputType.cpp

    r69378 r72884  
    3535#include "HTMLInputElement.h"
    3636#include "HTMLNames.h"
     37#include <wtf/CurrentTime.h>
     38#include <wtf/DateMath.h>
    3739#include <wtf/PassOwnPtr.h>
    3840
     
    5254{
    5355    return InputTypeNames::time();
     56}
     57
     58double TimeInputType::defaultValueForStepUp() const
     59{
     60    double current = currentTimeMS();
     61    double utcOffset = calculateUTCOffset();
     62    double dstOffset = calculateDSTOffset(current, utcOffset);
     63    int offset = static_cast<int>((utcOffset + dstOffset) / msPerMinute);
     64    current += offset * msPerMinute;
     65
     66    DateComponents date;
     67    date.setMillisecondsSinceMidnight(current);
     68    double milliseconds = date.millisecondsSinceEpoch();
     69    ASSERT(isfinite(milliseconds));
     70    return milliseconds;
    5471}
    5572
  • trunk/WebCore/html/TimeInputType.h

    r69378 r72884  
    4343    TimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
    4444    virtual const AtomicString& formControlType() const;
     45    virtual double defaultValueForStepUp() const;
    4546    virtual double minimum() const;
    4647    virtual double maximum() const;
Note: See TracChangeset for help on using the changeset viewer.