RESOLVED FIXED 104628
Milliseconds field of date/time input UI should respect step attribute
https://bugs.webkit.org/show_bug.cgi?id=104628
Summary Milliseconds field of date/time input UI should respect step attribute
Kunihiko Sakamoto
Reported 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.
Attachments
WIP Patch (8.33 KB, patch)
2012-12-10 21:49 PST, Kunihiko Sakamoto
no flags
Patch (16.44 KB, patch)
2012-12-11 21:46 PST, Kunihiko Sakamoto
no flags
Patch 2 (19.04 KB, patch)
2012-12-12 18:12 PST, Kunihiko Sakamoto
no flags
Kunihiko Sakamoto
Comment 1 2012-12-10 21:49:49 PST
Created attachment 178709 [details] WIP Patch
Kunihiko Sakamoto
Comment 2 2012-12-10 21:50:39 PST
Kent-san, could you look at this patch to see if the approach is right?
Kent Tamura
Comment 3 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.
Kunihiko Sakamoto
Comment 4 2012-12-11 21:46:13 PST
Kunihiko Sakamoto
Comment 5 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.
Kent Tamura
Comment 6 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.
Kunihiko Sakamoto
Comment 7 2012-12-12 18:12:47 PST
Kunihiko Sakamoto
Comment 8 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.
Kent Tamura
Comment 9 2012-12-12 18:18:32 PST
Comment on attachment 179172 [details] Patch 2 ok, looks good.
WebKit Review Bot
Comment 10 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>
WebKit Review Bot
Comment 11 2012-12-12 19:03:11 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.