Title: [125634] trunk
Revision
125634
Author
[email protected]
Date
2012-08-14 19:08:02 -0700 (Tue, 14 Aug 2012)

Log Message

[Forms] Make input type "time" to use multiple field time input UI
https://bugs.webkit.org/show_bug.cgi?id=93929

Reviewed by Kent Tamura.

Source/WebCore:

This patch changes input type "time" UI to use multiple field time
input UI when build flag ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS
enabled.

No new tests. This patch doesn't change behavior for users, however,
this patch changes behavior on layout tests. Tests will be added
in another patch with runtime enabled feature flag is enabled.

Test expectations for following tests are updated:
 - fast/forms/time/time-input-visible-string.html
 - fast/forms/time/time-stepup-stepdown-from-renderer.html

* html/BaseDateAndTimeInputType.h:
(BaseDateAndTimeInputType): Exposed serialize() to derived classes.
* html/TimeInputType.cpp:
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::DateTimeEditControlOwnerImpl):
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::~DateTimeEditControlOwnerImpl):
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::editControlMouseFocus):
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::editControlValueChanged):
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerDisabled):
(WebCore::TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerReadOnly):
(WebCore::TimeInputType::TimeInputType):
(WebCore::TimeInputType::~TimeInputType):
(WebCore::TimeInputType::createRenderer):
(WebCore::TimeInputType::createShadowSubtree):
(WebCore::TimeInputType::destroyShadowSubtree):
(WebCore::TimeInputType::forwardEvent):
(WebCore::TimeInputType::disabledAttributeChanged):
(WebCore::TimeInputType::handleKeydownEvent):
(WebCore::TimeInputType::handleDOMActivateEvent):
(WebCore::TimeInputType::isKeyboardFocusable):
(WebCore::TimeInputType::isMouseFocusable):
(WebCore::TimeInputType::minOrMaxAttributeChanged):
(WebCore::TimeInputType::readonlyAttributeChanged):
(WebCore::TimeInputType::isTextField):
(WebCore::TimeInputType::setValue):
(WebCore::TimeInputType::shouldUseInputMethod):
(WebCore::TimeInputType::stepAttributeChanged):
(WebCore::TimeInputType::updateEditElementLayout):
(WebCore::TimeInputType::updateInnerTextValue):
(WebCore::TimeInputType):
* html/TimeInputType.h:
(TimeInputType):
(DateTimeEditControlOwnerImpl):

LayoutTests:

This patch added test expectations for multiple fields time input UI
testing which are different behavior from single field time input UI
for Chromium which enables multiple fields time input UI.

* platform/chromium/fast/forms/time/time-input-visible-string-expected.txt: Select all in a field doesn't select text.
* platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt: Fields don't change value on Up/Down keyboard events when they don't have focus and Up/Down keyboard increment/decrement value on hour field rather than minute field.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125633 => 125634)


--- trunk/LayoutTests/ChangeLog	2012-08-15 01:51:14 UTC (rev 125633)
+++ trunk/LayoutTests/ChangeLog	2012-08-15 02:08:02 UTC (rev 125634)
@@ -1,3 +1,17 @@
+2012-08-14  Yoshifumi Inoue  <[email protected]>
+
+        [Forms] Make input type "time" to use multiple field time input UI
+        https://bugs.webkit.org/show_bug.cgi?id=93929
+
+        Reviewed by Kent Tamura.
+
+        This patch added test expectations for multiple fields time input UI
+        testing which are different behavior from single field time input UI
+        for Chromium which enables multiple fields time input UI.
+
+        * platform/chromium/fast/forms/time/time-input-visible-string-expected.txt: Select all in a field doesn't select text.
+        * platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt: Fields don't change value on Up/Down keyboard events when they don't have focus and Up/Down keyboard increment/decrement value on hour field rather than minute field.
+
 2012-08-14  Dean Jackson  <[email protected]>
 
         Initial call to webkitRequestAnimationFrame returns 0, Spec indicates the handle should always be > 0

Added: trunk/LayoutTests/platform/chromium/fast/forms/time/time-input-visible-string-expected.txt (0 => 125634)


--- trunk/LayoutTests/platform/chromium/fast/forms/time/time-input-visible-string-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/time/time-input-visible-string-expected.txt	2012-08-15 02:08:02 UTC (rev 125634)
@@ -0,0 +1,9 @@
+The user-visible values of week input fields should be localized if the platform has a LocalizedDate implementation. Otherwise, they should be in the HTML5 formats.
+
+time: value='01:56:20.391' visible='The user-visible values of week input fields should be localized if the platform has a LocalizedDate implementation. Otherwise, they should be in the HTML5 formats.
+
+'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/platform/chromium/fast/forms/time/time-input-visible-string-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt (0 => 125634)


--- trunk/LayoutTests/platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt	2012-08-15 02:08:02 UTC (rev 125634)
@@ -0,0 +1,31 @@
+Check stepping-up and -down for time input fields from renderer. No cases of empty initial values.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Function arguments are (value, step, {min or max}, [stepCount]).
+Normal cases
+FAIL stepUp("20:13", null, null) should be 20:14. Was 20:13.
+FAIL stepDown("20:13", null, null) should be 20:12. Was 20:13.
+FAIL stepUp("20:13", null, null, 10) should be 20:23. Was 20:13.
+FAIL stepDown("20:13", null, null, 11) should be 20:02. Was 20:13.
+FAIL stepUp("20:13", "4", null, 2) should be 20:13:08. Was 20:13.
+FAIL stepDown("20:13", "4", null, 3) should be 20:12:48. Was 20:13.
+Step=any
+FAIL stepUp("20:13", "any", null) should be 20:14. Was 20:13.
+FAIL stepDown("20:13", "any", null) should be 20:12. Was 20:13.
+Overflow/underflow
+FAIL stepUp("20:13", "3.40282346e+38", null) should be 23:59:59.999. Was 20:13.
+FAIL stepDown("20:13", "3.40282346e+38", null) should be 00:00:00. Was 20:13.
+PASS stepUp("20:13", "1", "20:13") is "20:13"
+PASS stepDown("20:13", "1", "20:13") is "20:13"
+PASS stepUp("23:59", null, null) is "23:59"
+PASS stepDown("00:00", null, null) is "00:00"
+stepDown()/stepUp() for stepMismatch values
+FAIL stepDown("20:13", "3", "20:12:56") should be 20:12:59. Was 20:13.
+FAIL stepUp("00:13", "7", "") should be 00:13:04. Was 00:13.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/platform/chromium/fast/forms/time/time-stepup-stepdown-from-renderer-expected.txt
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (125633 => 125634)


--- trunk/Source/WebCore/ChangeLog	2012-08-15 01:51:14 UTC (rev 125633)
+++ trunk/Source/WebCore/ChangeLog	2012-08-15 02:08:02 UTC (rev 125634)
@@ -1,3 +1,55 @@
+2012-08-14  Yoshifumi Inoue  <[email protected]>
+
+        [Forms] Make input type "time" to use multiple field time input UI
+        https://bugs.webkit.org/show_bug.cgi?id=93929
+
+        Reviewed by Kent Tamura.
+
+        This patch changes input type "time" UI to use multiple field time
+        input UI when build flag ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS
+        enabled.
+
+        No new tests. This patch doesn't change behavior for users, however,
+        this patch changes behavior on layout tests. Tests will be added
+        in another patch with runtime enabled feature flag is enabled.
+
+        Test expectations for following tests are updated:
+         - fast/forms/time/time-input-visible-string.html
+         - fast/forms/time/time-stepup-stepdown-from-renderer.html
+
+        * html/BaseDateAndTimeInputType.h:
+        (BaseDateAndTimeInputType): Exposed serialize() to derived classes.
+        * html/TimeInputType.cpp:
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::DateTimeEditControlOwnerImpl):
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::~DateTimeEditControlOwnerImpl):
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::editControlMouseFocus):
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::editControlValueChanged):
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerDisabled):
+        (WebCore::TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerReadOnly):
+        (WebCore::TimeInputType::TimeInputType):
+        (WebCore::TimeInputType::~TimeInputType):
+        (WebCore::TimeInputType::createRenderer):
+        (WebCore::TimeInputType::createShadowSubtree):
+        (WebCore::TimeInputType::destroyShadowSubtree):
+        (WebCore::TimeInputType::forwardEvent):
+        (WebCore::TimeInputType::disabledAttributeChanged):
+        (WebCore::TimeInputType::handleKeydownEvent):
+        (WebCore::TimeInputType::handleDOMActivateEvent):
+        (WebCore::TimeInputType::isKeyboardFocusable):
+        (WebCore::TimeInputType::isMouseFocusable):
+        (WebCore::TimeInputType::minOrMaxAttributeChanged):
+        (WebCore::TimeInputType::readonlyAttributeChanged):
+        (WebCore::TimeInputType::isTextField):
+        (WebCore::TimeInputType::setValue):
+        (WebCore::TimeInputType::shouldUseInputMethod):
+        (WebCore::TimeInputType::stepAttributeChanged):
+        (WebCore::TimeInputType::updateEditElementLayout):
+        (WebCore::TimeInputType::updateInnerTextValue):
+        (WebCore::TimeInputType):
+        * html/TimeInputType.h:
+        (TimeInputType):
+        (DateTimeEditControlOwnerImpl):
+
 2012-08-14  Dean Jackson  <[email protected]>
 
         Initial call to webkitRequestAnimationFrame returns 0, Spec indicates the handle should always be > 0

Modified: trunk/Source/WebCore/html/BaseDateAndTimeInputType.h (125633 => 125634)


--- trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2012-08-15 01:51:14 UTC (rev 125633)
+++ trunk/Source/WebCore/html/BaseDateAndTimeInputType.h	2012-08-15 02:08:02 UTC (rev 125634)
@@ -44,6 +44,7 @@
     virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE;
     virtual Decimal parseToNumber(const String&, const Decimal&) const OVERRIDE;
     virtual bool parseToDateComponents(const String&, DateComponents*) const OVERRIDE;
+    virtual String serialize(const Decimal&) const OVERRIDE;
     String serializeWithComponents(const DateComponents&) const;
 
 private:
@@ -58,7 +59,6 @@
     virtual bool typeMismatch() const OVERRIDE;
     virtual Decimal defaultValueForStepUp() const OVERRIDE;
     virtual bool isSteppable() const OVERRIDE;
-    virtual String serialize(const Decimal&) const OVERRIDE;
     virtual String serializeWithMilliseconds(double) const;
     virtual String localizeValue(const String&) const OVERRIDE;
     virtual String visibleValue() const OVERRIDE;

Modified: trunk/Source/WebCore/html/TimeInputType.cpp (125633 => 125634)


--- trunk/Source/WebCore/html/TimeInputType.cpp	2012-08-15 01:51:14 UTC (rev 125633)
+++ trunk/Source/WebCore/html/TimeInputType.cpp	2012-08-15 02:08:02 UTC (rev 125634)
@@ -40,6 +40,11 @@
 #include <wtf/PassOwnPtr.h>
 
 #if ENABLE(INPUT_TYPE_TIME)
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#include "ElementShadow.h"
+#include "KeyboardEvent.h"
+#include "ShadowRoot.h"
+#endif
 
 namespace WebCore {
 
@@ -108,6 +113,177 @@
     return true;
 }
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+
+TimeInputType::DateTimeEditControlOwnerImpl::DateTimeEditControlOwnerImpl(TimeInputType& timeInputType)
+    : m_timeInputType(timeInputType)
+{
+}
+
+TimeInputType::DateTimeEditControlOwnerImpl::~DateTimeEditControlOwnerImpl()
+{
+}
+
+void TimeInputType::DateTimeEditControlOwnerImpl::editControlMouseFocus()
+{
+    m_timeInputType.element()->focus();
+}
+
+void TimeInputType::DateTimeEditControlOwnerImpl::editControlValueChanged()
+{
+    RefPtr<HTMLInputElement> input(m_timeInputType.element());
+    input->setValueInternal(m_timeInputType.serialize(Decimal::fromDouble(m_timeInputType.m_dateTimeEditElement->valueAsDouble())), DispatchNoEvent);
+    input->setNeedsStyleRecalc();
+    input->dispatchFormControlInputEvent();
+    input->dispatchFormControlChangeEvent();
+}
+
+bool TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerDisabled() const
+{
+    return m_timeInputType.element()->readOnly();
+}
+
+bool TimeInputType::DateTimeEditControlOwnerImpl::isEditControlOwnerReadOnly() const
+{
+    return m_timeInputType.element()->disabled();
+}
+
+TimeInputType::TimeInputType(HTMLInputElement* element)
+    : BaseDateAndTimeInputType(element)
+    , m_dateTimeEditElement(0)
+    , m_dateTimeEditControlOwnerImpl(*this)
+{
+}
+
+TimeInputType::~TimeInputType()
+{
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->removeEditControlOwner();
+}
+
+RenderObject* TimeInputType::createRenderer(RenderArena* arena, RenderStyle* style) const
+{
+    return InputType::createRenderer(arena, style);
+}
+
+void TimeInputType::createShadowSubtree()
+{
+    ASSERT(element()->shadow());
+
+    const StepRange stepRange(createStepRange(AnyIsDefaultStep));
+    RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(element()->document(), m_dateTimeEditControlOwnerImpl, stepRange));
+    m_dateTimeEditElement = dateTimeEditElement.get();
+    element()->userAgentShadowRoot()->appendChild(m_dateTimeEditElement);
+    updateInnerTextValue();
+}
+
+void TimeInputType::destroyShadowSubtree()
+{
+    if (m_dateTimeEditElement) {
+        m_dateTimeEditElement->removeEditControlOwner();
+        m_dateTimeEditElement = 0;
+    }
+    BaseDateAndTimeInputType::destroyShadowSubtree();
+}
+
+void TimeInputType::forwardEvent(Event* event)
+{
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->defaultEventHandler(event);
+}
+
+void TimeInputType::disabledAttributeChanged()
+{
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->disabledStateChanged();
+}
+
+void TimeInputType::handleKeydownEvent(KeyboardEvent* event)
+{
+    forwardEvent(event);
+}
+
+void TimeInputType::handleDOMActivateEvent(Event* event)
+{
+    if (element()->disabled() || element()->readOnly() || !element()->renderer())
+        return;
+
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->focus();
+
+    event->setDefaultHandled();
+}
+
+bool TimeInputType::isKeyboardFocusable(KeyboardEvent*) const
+{
+    return element()->isTextFormControlFocusable();
+}
+
+bool TimeInputType::isMouseFocusable() const
+{
+    return element()->isTextFormControlFocusable();
+}
+
+void TimeInputType::minOrMaxAttributeChanged()
+{
+    updateEditElementLayout();
+}
+
+void TimeInputType::readonlyAttributeChanged()
+{
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->readOnlyStateChanged();
+}
+
+bool TimeInputType::isTextField() const
+{
+    return false;
+}
+
+void TimeInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior)
+{
+    InputType::setValue(sanitizedValue, valueChanged, eventBehavior);
+    if (valueChanged)
+        updateInnerTextValue();
+}
+
+bool TimeInputType::shouldUseInputMethod() const
+{
+    return false;
+}
+
+void TimeInputType::stepAttributeChanged()
+{
+    updateEditElementLayout();
+}
+
+void TimeInputType::updateEditElementLayout()
+{
+    if (m_dateTimeEditElement)
+        m_dateTimeEditElement->layout(createStepRange(AnyIsDefaultStep));
+}
+
+void TimeInputType::updateInnerTextValue()
+{
+    if (!m_dateTimeEditElement)
+        return;
+
+    DateComponents date;
+    if (parseToDateComponents(element()->value(), &date))
+        m_dateTimeEditElement->setValueAsDate(date);
+    else {
+        const StepRange stepRange(createStepRange(AnyIsDefaultStep));
+        setMillisecondToDateComponents(stepRange.minimum().toDouble(), &date);
+        m_dateTimeEditElement->setEmptyValue(date);
+    }
+}
+#else
+TimeInputType(HTMLInputElement* element)
+    : BaseDateAndTimeInputType(element)
+{
+}
+#endif
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/html/TimeInputType.h (125633 => 125634)


--- trunk/Source/WebCore/html/TimeInputType.h	2012-08-15 01:51:14 UTC (rev 125633)
+++ trunk/Source/WebCore/html/TimeInputType.h	2012-08-15 02:08:02 UTC (rev 125634)
@@ -35,14 +35,22 @@
 
 #if ENABLE(INPUT_TYPE_TIME)
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+#include "DateTimeEditElement.h"
+#endif
+
 namespace WebCore {
 
 class TimeInputType : public BaseDateAndTimeInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+    virtual ~TimeInputType();
+#endif
+
 private:
-    TimeInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
+    TimeInputType(HTMLInputElement*);
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual Decimal defaultValueForStepUp() const OVERRIDE;
@@ -50,6 +58,49 @@
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const OVERRIDE;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const OVERRIDE;
     virtual bool isTimeField() const OVERRIDE;
+
+#if ENABLE(INPUT_TYPE_TIME_MULTIPLE_FIELDS)
+    class DateTimeEditControlOwnerImpl : public DateTimeEditElement::EditControlOwner {
+        WTF_MAKE_NONCOPYABLE(DateTimeEditControlOwnerImpl);
+
+    public:
+        DateTimeEditControlOwnerImpl(TimeInputType&);
+        virtual ~DateTimeEditControlOwnerImpl();
+
+    private:
+        virtual void editControlMouseFocus() OVERRIDE FINAL;
+        virtual void editControlValueChanged() OVERRIDE FINAL;
+        virtual bool isEditControlOwnerDisabled() const OVERRIDE FINAL;
+        virtual bool isEditControlOwnerReadOnly() const OVERRIDE FINAL;
+
+        TimeInputType& m_timeInputType;
+    };
+
+    friend class DateTimeEditControlOwnerImpl;
+
+    void updateEditElementLayout();
+
+    // InputType functions
+    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) const OVERRIDE FINAL;
+    virtual void createShadowSubtree() OVERRIDE FINAL;
+    virtual void destroyShadowSubtree() OVERRIDE FINAL;
+    virtual void disabledAttributeChanged() OVERRIDE FINAL;
+    virtual void forwardEvent(Event*) OVERRIDE FINAL;
+    virtual void handleDOMActivateEvent(Event*) OVERRIDE FINAL;
+    virtual void handleKeydownEvent(KeyboardEvent*) OVERRIDE FINAL;
+    virtual bool isKeyboardFocusable(KeyboardEvent*) const OVERRIDE FINAL;
+    virtual bool isMouseFocusable() const OVERRIDE FINAL;
+    virtual bool isTextField() const OVERRIDE FINAL;
+    virtual void minOrMaxAttributeChanged() OVERRIDE FINAL;
+    virtual void readonlyAttributeChanged() OVERRIDE FINAL;
+    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE FINAL;
+    virtual bool shouldUseInputMethod() const OVERRIDE FINAL;
+    virtual void stepAttributeChanged() OVERRIDE FINAL;
+    virtual void updateInnerTextValue() OVERRIDE FINAL;
+
+    DateTimeEditElement* m_dateTimeEditElement;
+    DateTimeEditControlOwnerImpl m_dateTimeEditControlOwnerImpl;
+#endif
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to