haikuwebkit/ManualTests/input-type-datetime-default...

81 lines
3.6 KiB
HTML
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/63343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72884 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-11-30 06:11:08 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head><title>Default values for date/time input (type= date, datetime, datetime-local, month, time, week)</title></head>
<p>Enter Up or Down, or click the spin buttons for each input field.</p>
<form>
<ul>
<li>Emtpy values, no steps
<ul>
<li>date: <input type="date" size="32" value="" />
<li>datetime: <input type="datetime" size="32" value="" />
<li>datetime-local: <input type="datetime-local" size="32" value="" />
<li>month: <input type="month" size="32" value="" />
<li>time: <input type="time" size="32" value="" />
<li>week <input type="week" size="32" value="" />
</ul>
<li>Invalid values, no steps
<ul>
<li>date: <input type="date" size="32" value="foo" />
<li>datetime: <input type="datetime" size="32" value="foo" />
<li>datetime-local: <input type="datetime-local" size="32" value="foo" />
<li>month: <input type="month" size="32" value="foo" />
<li>time: <input type="time" size="32" value="foo" />
<li>week <input type="week" size="32" value="foo" />
</ul>
<li>Emtpy values, invalid steps
<ul>
<li>date: <input type="date" size="32" value="" step="foo" />
<li>datetime: <input type="datetime" size="32" value="" step="foo" />
<li>datetime-local: <input type="datetime-local" size="32" value="" step="foo" />
<li>month: <input type="month" size="32" value="" step="foo" />
<li>time: <input type="time" size="32" value="" step="foo" />
<li>week <input type="week" size="32" value="" step="foo" />
</ul>
<li>Invalid values, invalid steps
<ul>
<li>date: <input type="date" size="32" value="foo" step="foo" />
<li>datetime: <input type="datetime" size="32" value="foo" step="foo" />
<li>datetime-local: <input type="datetime-local" size="32" value="foo" step="foo" />
<li>month: <input type="month" size="32" value="foo" step="foo" />
<li>time: <input type="time" size="32" value="foo" step="foo" />
<li>week <input type="week" size="32" value="foo" step="foo" />
</ul>
<li>Emtpy values, step=any
<ul>s
<li>date: <input type="date" size="32" value="" step="any" />
<li>datetime: <input type="datetime" size="32" value="" step="any" />
<li>datetime-local: <input type="datetime-local" size="32" value="" step="any" />
<li>month: <input type="month" size="32" value="" step="any" />
<li>time: <input type="time" size="32" value="" step="any" />
<li>week <input type="week" size="32" value="" step="any" />
</ul>
<li>Invalid values, step=any
<ul>
<li>date: <input type="date" size="32" value="foo" step="any" />
<li>datetime: <input type="datetime" size="32" value="foo" step="any" />
<li>datetime-local: <input type="datetime-local" size="32" value="foo" step="any" />
<li>month: <input type="month" size="32" value="foo" step="any" />
<li>time: <input type="time" size="32" value="foo" step="any" />
<li>week <input type="week" size="32" value="foo" step="any" />
</ul>
</ul>
</form>
<p>The input fields should show the current local/UTC date/time (with + or - a unit date/time described below except for step=any).</p>
<p>Unit dates/times</p>
<ul>
<li>date: 1 day (local time)
<li>datetime: 1 minute (UTC)
<li>datetime-local: 1 minute (local time)
<li>month: 1 month (local time)
<li>time: 1 minute (local time)
<li>week: 1 week (local time)
</ul>
<p>As for step=any, the values don't change by stepping-up/-down.<p>
</body></html>