Bug 104628 - Milliseconds field of date/time input UI should respect step attribute
Summary: Milliseconds field of date/time input UI should respect step attribute
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-10 21:40 PST by Kunihiko Sakamoto
Modified: 2012-12-12 19:03 PST (History)
3 users (show)

See Also:


Attachments
WIP Patch (8.33 KB, patch)
2012-12-10 21:49 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch (16.44 KB, patch)
2012-12-11 21:46 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff
Patch 2 (19.04 KB, patch)
2012-12-12 18:12 PST, Kunihiko Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kunihiko Sakamoto 2012-12-10 21:40:58 PST
This is the first step toward supporting min/max/step attributes in multiple fields UI.
For example, if step attribute is 0.25 (250ms), the milliseconds field should be selectable only from 000, 250, 500, 750.
Comment 1 Kunihiko Sakamoto 2012-12-10 21:49:49 PST
Created attachment 178709 [details]
WIP Patch
Comment 2 Kunihiko Sakamoto 2012-12-10 21:50:39 PST
Kent-san, could you look at this patch to see if the approach is right?
Comment 3 Kent Tamura 2012-12-10 22:09:58 PST
Comment on attachment 178709 [details]
WIP Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178709&action=review

The approach looks good.

> Source/WebCore/html/shadow/DateTimeEditElement.cpp:220
> +        ASSERT(!m_parameters.stepRange.step().isZero());
> +        int step = 1;
> +        if (Decimal(static_cast<int>(msPerSecond)).remainder(m_parameters.stepRange.step()).isZero())
> +            step = static_cast<int>(m_parameters.stepRange.step().toDouble());
> +        RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElement::create(document, m_editElement, step);

We should take account of non-zero step-base value.  e.g. <input type=time step=0.100 min=00:00:00.050>
We need to pass step-base value (the milliseconds part of the min), or stop step-aware behavior if step-base is not zero.

> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:71
> +    , m_step(step)
>  {
>      // We show a direction-neutral string such as "--" as a placeholder. It

We should have ASSERT(m_step).

> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:199
>          setValueAsInteger(defaultValueForStepDown(), DispatchEvent);

defaultValueForStepDown() needs to be aligned to m_step.

> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:212
>          setValueAsInteger(defaultValueForStepUp(), DispatchEvent);

defaultValueForStepUp() needs to be aligned to m_step.
Comment 4 Kunihiko Sakamoto 2012-12-11 21:46:13 PST
Created attachment 178961 [details]
Patch
Comment 5 Kunihiko Sakamoto 2012-12-11 21:48:57 PST
Comment on attachment 178709 [details]
WIP Patch

Thanks for the review.
Updated patch with tests. Please take another look.

View in context: https://bugs.webkit.org/attachment.cgi?id=178709&action=review

>> Source/WebCore/html/shadow/DateTimeEditElement.cpp:220
>> +        RefPtr<DateTimeNumericFieldElement> field = DateTimeMillisecondFieldElement::create(document, m_editElement, step);
> 
> We should take account of non-zero step-base value.  e.g. <input type=time step=0.100 min=00:00:00.050>
> We need to pass step-base value (the milliseconds part of the min), or stop step-aware behavior if step-base is not zero.

Changed to pass step-base value.

>> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:71
>>      // We show a direction-neutral string such as "--" as a placeholder. It
> 
> We should have ASSERT(m_step).

Done.

>> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:199
>>          setValueAsInteger(defaultValueForStepDown(), DispatchEvent);
> 
> defaultValueForStepDown() needs to be aligned to m_step.

Done.

>> Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp:212
>>          setValueAsInteger(defaultValueForStepUp(), DispatchEvent);
> 
> defaultValueForStepUp() needs to be aligned to m_step.

Done.
Comment 6 Kent Tamura 2012-12-11 22:29:12 PST
Comment on attachment 178961 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178961&action=review

> Source/WebCore/ChangeLog:11
> +        Test: fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html

You need to add tests for
  step=0
  step=0.00001

> Source/WebCore/html/shadow/DateTimeEditElement.cpp:221
> +        if (decimalMsPerSecond.remainder(m_parameters.stepRange.step()).isZero()) {

You need to check m_parameters.stepRange.step().remainder(Decimal(1)).isZero() too.

> Source/WebCore/html/shadow/DateTimeEditElement.cpp:223
> +            stepBase = static_cast<int>(m_parameters.stepRange.stepBase().remainder(decimalMsPerSecond).toDouble());

Why don't you subtract msPerSecond from the remainder result and assume stepBase<=0 ?  It would make roundUp/roundDown simpler.

> LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html:82
> +shouldBeEqualToString('stepDown("07:13:00.500", 0.100, "00:00:00.050", null)', '07:13:00.450');
> +

We should test rounding of defaultValeuForStepDown/Up.
Comment 7 Kunihiko Sakamoto 2012-12-12 18:12:47 PST
Created attachment 179172 [details]
Patch 2
Comment 8 Kunihiko Sakamoto 2012-12-12 18:15:36 PST
Comment on attachment 178961 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178961&action=review

>> Source/WebCore/ChangeLog:11
>> +        Test: fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html
> 
> You need to add tests for
>   step=0
>   step=0.00001

Done.

>> Source/WebCore/html/shadow/DateTimeEditElement.cpp:221
>> +        if (decimalMsPerSecond.remainder(m_parameters.stepRange.step()).isZero()) {
> 
> You need to check m_parameters.stepRange.step().remainder(Decimal(1)).isZero() too.

Done.

>> Source/WebCore/html/shadow/DateTimeEditElement.cpp:223
>> +            stepBase = static_cast<int>(m_parameters.stepRange.stepBase().remainder(decimalMsPerSecond).toDouble());
> 
> Why don't you subtract msPerSecond from the remainder result and assume stepBase<=0 ?  It would make roundUp/roundDown simpler.

But roundDown still has to handle n=-1 when stepped down from zero.
I'd prefer to keep roundUp/roundDown capable of handling general cases.

>> LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-stepup-stepdown-from-renderer.html:82
>> +
> 
> We should test rounding of defaultValeuForStepDown/Up.

Done.
Comment 9 Kent Tamura 2012-12-12 18:18:32 PST
Comment on attachment 179172 [details]
Patch 2

ok, looks good.
Comment 10 WebKit Review Bot 2012-12-12 19:03:06 PST
Comment on attachment 179172 [details]
Patch 2

Clearing flags on attachment: 179172

Committed r137561: <http://trac.webkit.org/changeset/137561>
Comment 11 WebKit Review Bot 2012-12-12 19:03:11 PST
All reviewed patches have been landed.  Closing bug.