Title: [129867] trunk
Revision
129867
Author
yo...@chromium.org
Date
2012-09-28 02:40:39 -0700 (Fri, 28 Sep 2012)

Log Message

[Forms] Multiple fields month input UI
https://bugs.webkit.org/show_bug.cgi?id=97299

Reviewed by Kent Tamura.

Source/WebCore:

This patch introduces multiple fields "month" input UI in DRT. We'll
enable this feature once we add tests.

Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
and ENABLE_INPUT_MULTIPLE_FIELDS_UI.

No new tests. To reduce size of this patch, other patches add tests
for multiple fields month input UI.

Note: Actual outputs of two tests
    - fast/forms/month/month-input-visible-string.html
    - fast/forms/month/month-stepup-stepdown-from-renderer.html
are different.

* css/html.css:
(input::-webkit-datetime-edit-month-field): Added for field appearance.
(input::-webkit-datetime-edit-year-field): ditto.
(input::-webkit-datetime-edit-month-field:focus): Added to remove focus ring.
(input::-webkit-datetime-edit-year-field:focus): ditto.
* html/MonthInputType.cpp:
(WebCore::MonthInputType::formatDateTimeFieldsState): Added to format numeric value to string value as specified in HTML5 specification.
(WebCore::MonthInputType::setupLayoutParameters): Added to set layout of multiple fields.
* html/MonthInputType.h: Changed to include BaseMultipleFieldsDateAndTimeInputType.h and introduce BaseMonthInputType typedef.
(WebCore::MonthInputType::MonthInputType): Changed base class name to BaseMonthInputType.
(MonthInputType): Changed to add declarations for formatDateTimeFieldsState() and setupLayoutParameters().
* html/shadow/DateTimeEditElement.cpp:
(DateTimeEditBuilder): Changed to have copy of object in m_stepRange and m_dateValue member variables for being robust.
(WebCore::DateTimeEditBuilder::DateTimeEditBuilder): Changed to add initialize m_placeholderForMonth and m_placeholderForYear.
(WebCore::DateTimeEditBuilder::visitField): Changed to support month field and year field.
* html/shadow/DateTimeEditElement.h:
(LayoutParameters): Changed to add member variables, placeholderForMonth and placeholderForYear. Changed to have copy of object in stepRange member variable for being robust.

LayoutTests:

This patch adds Chromium port specific expectations for "month" input
type tests for multiple fields month input UI.

Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
and ENABLE_INPUT_MULTIPLE_FIELDS_UI.

* platform/chromium/fast/forms/month/month-input-visible-string-expected.txt: Added. Multiple fields month input UI doesn't have selection.
* platform/chromium/fast/forms/month/month-stepup-stepdown-from-renderer-expected.txt: Added. On multiple fields month input UI, step down/up decrement/increment a field rather than whole value.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129866 => 129867)


--- trunk/LayoutTests/ChangeLog	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/LayoutTests/ChangeLog	2012-09-28 09:40:39 UTC (rev 129867)
@@ -1,3 +1,19 @@
+2012-09-28  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Forms] Multiple fields month input UI
+        https://bugs.webkit.org/show_bug.cgi?id=97299
+
+        Reviewed by Kent Tamura.
+
+        This patch adds Chromium port specific expectations for "month" input
+        type tests for multiple fields month input UI.
+
+        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
+        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
+
+        * platform/chromium/fast/forms/month/month-input-visible-string-expected.txt: Added. Multiple fields month input UI doesn't have selection.
+        * platform/chromium/fast/forms/month/month-stepup-stepdown-from-renderer-expected.txt: Added. On multiple fields month input UI, step down/up decrement/increment a field rather than whole value.
+
 2012-09-28  Vsevolod Vlasov  <vse...@chromium.org>
 
         Unreviewed test fix.

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


--- trunk/LayoutTests/platform/chromium/fast/forms/month/month-input-visible-string-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/month/month-input-visible-string-expected.txt	2012-09-28 09:40:39 UTC (rev 129867)
@@ -0,0 +1,9 @@
+The user-visible values of month input fields should be localized if the platform has a LocalizedDate implementation. Otherwise, they should be in the HTML5 formats.
+
+month: value='2011-04' visible='The user-visible values of month 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
+

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


--- trunk/LayoutTests/platform/chromium/fast/forms/month/month-stepup-stepdown-from-renderer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/month/month-stepup-stepdown-from-renderer-expected.txt	2012-09-28 09:40:39 UTC (rev 129867)
@@ -0,0 +1,29 @@
+Check stepping-up and -down for month 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("2010-02", null, null) should be 2010-03. Was 2010-02.
+FAIL stepDown("2010-02", null, null) should be 2010-01. Was 2010-02.
+FAIL stepUp("2010-02", null, null, 10) should be 2010-12. Was 2010-02.
+FAIL stepDown("2010-02", null, null, 11) should be 2009-03. Was 2010-02.
+FAIL stepUp("1970-01", "4", null, 2) should be 1970-09. Was 1970-01.
+FAIL stepDown("1970-01", "4", null, 3) should be 1969-01. Was 1970-01.
+Step=any
+FAIL stepUp("2010-02", "any", null) should be 2010-03. Was 2010-02.
+FAIL stepDown("2010-02", "any", null) should be 2010-01. Was 2010-02.
+Overflow/underflow
+FAIL stepUp("2010-02", "3.40282346e+38", null) should be 275760-09. Was 2010-02.
+FAIL stepDown("2010-02", "3.40282346e+38", null) should be 1970-01. Was 2010-02.
+PASS stepUp("2010-02", "1", "2010-02") is "2010-02"
+PASS stepDown("2010-02", "1", "2010-02") is "2010-02"
+stepDown()/stepUp() for stepMismatch values
+FAIL stepDown("2010-02", "3", "2009-10") should be 2010-01. Was 2010-02.
+FAIL stepUp("1970-02", "4", "") should be 1970-05. Was 1970-02.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/Source/WebCore/ChangeLog (129866 => 129867)


--- trunk/Source/WebCore/ChangeLog	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/ChangeLog	2012-09-28 09:40:39 UTC (rev 129867)
@@ -1,3 +1,42 @@
+2012-09-28  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Forms] Multiple fields month input UI
+        https://bugs.webkit.org/show_bug.cgi?id=97299
+
+        Reviewed by Kent Tamura.
+
+        This patch introduces multiple fields "month" input UI in DRT. We'll
+        enable this feature once we add tests.
+
+        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
+        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
+
+        No new tests. To reduce size of this patch, other patches add tests
+        for multiple fields month input UI.
+
+        Note: Actual outputs of two tests
+            - fast/forms/month/month-input-visible-string.html
+            - fast/forms/month/month-stepup-stepdown-from-renderer.html
+        are different.
+
+        * css/html.css:
+        (input::-webkit-datetime-edit-month-field): Added for field appearance.
+        (input::-webkit-datetime-edit-year-field): ditto.
+        (input::-webkit-datetime-edit-month-field:focus): Added to remove focus ring.
+        (input::-webkit-datetime-edit-year-field:focus): ditto.
+        * html/MonthInputType.cpp:
+        (WebCore::MonthInputType::formatDateTimeFieldsState): Added to format numeric value to string value as specified in HTML5 specification.
+        (WebCore::MonthInputType::setupLayoutParameters): Added to set layout of multiple fields.
+        * html/MonthInputType.h: Changed to include BaseMultipleFieldsDateAndTimeInputType.h and introduce BaseMonthInputType typedef.
+        (WebCore::MonthInputType::MonthInputType): Changed base class name to BaseMonthInputType.
+        (MonthInputType): Changed to add declarations for formatDateTimeFieldsState() and setupLayoutParameters().
+        * html/shadow/DateTimeEditElement.cpp:
+        (DateTimeEditBuilder): Changed to have copy of object in m_stepRange and m_dateValue member variables for being robust.
+        (WebCore::DateTimeEditBuilder::DateTimeEditBuilder): Changed to add initialize m_placeholderForMonth and m_placeholderForYear.
+        (WebCore::DateTimeEditBuilder::visitField): Changed to support month field and year field.
+        * html/shadow/DateTimeEditElement.h:
+        (LayoutParameters): Changed to add member variables, placeholderForMonth and placeholderForYear. Changed to have copy of object in stepRange member variable for being robust.
+
 2012-09-28  Eunmi Lee  <eunmi15....@samsung.com>
 
         [EFL][WK2] Refactoring initialization and shutdown codes of EFL libraries.

Modified: trunk/Source/WebCore/css/html.css (129866 => 129867)


--- trunk/Source/WebCore/css/html.css	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/css/html.css	2012-09-28 09:40:39 UTC (rev 129867)
@@ -477,6 +477,7 @@
 #endif
 
 #if defined(ENABLE_INPUT_MULTIPLE_FIELDS_UI) && ENABLE_INPUT_MULTIPLE_FIELDS_UI
+input[type="month"],
 input[type="time"] {
     font-family: monospace;
 }
@@ -519,6 +520,14 @@
     padding: 0.15em;
 }
 
+input::-webkit-datetime-edit-month-field {
+    -webkit-user-modify: read-only !important;
+    display: inline-block;
+    border: none;
+    text-align: center;
+    padding: 0.15em;
+}
+
 /* This selector is used when step >= 3600 second but format contains minute field. */
 input::-webkit-datetime-edit-minute-field[readonly] {
     color: GrayText;
@@ -532,12 +541,22 @@
     padding: 0.15em;
 }
 
+input::-webkit-datetime-edit-year-field {
+    -webkit-user-modify: read-only !important;
+    display: inline-block;
+    border: none;
+    text-align: center;
+    padding: 0.15em;
+}
+
 /* Remove focus ring from fields and use highlight color */
 input::-webkit-datetime-edit-ampm-field:focus,
 input::-webkit-datetime-edit-hour-field:focus,
 input::-webkit-datetime-edit-millisecond-field:focus,
 input::-webkit-datetime-edit-minute-field:focus,
-input::-webkit-datetime-edit-second-field:focus {
+input::-webkit-datetime-edit-month-field:focus,
+input::-webkit-datetime-edit-second-field:focus,
+input::-webkit-datetime-edit-year-field:focus {
   background-color: highlight;
   color: highlighttext;
   outline: none;
@@ -548,6 +567,7 @@
     color: GrayText;
 }
 
+input[type="month"]::-webkit-inner-spin-button,
 input[type="time"]::-webkit-inner-spin-button {
     margin-left: 0.2em;
 }

Modified: trunk/Source/WebCore/html/MonthInputType.cpp (129866 => 129867)


--- trunk/Source/WebCore/html/MonthInputType.cpp	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/html/MonthInputType.cpp	2012-09-28 09:40:39 UTC (rev 129867)
@@ -42,6 +42,13 @@
 
 #if ENABLE(INPUT_TYPE_MONTH)
 
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "DateTimeFieldsState.h"
+#include "LocalizedStrings.h"
+#include "Localizer.h"
+#include <wtf/text/WTFString.h>
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -137,6 +144,22 @@
     return true;
 }
 
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+String MonthInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
+{
+    if (!dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear())
+        return emptyString();
+    return String::format("%04u-%02u", dateTimeFieldsState.year(), dateTimeFieldsState.month());
+}
+
+void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const
+{
+    layoutParameters.dateTimeFormat = monthFormatInLDML();
+    layoutParameters.fallbackDateTimeFormat = "MM/yyyy";
+    layoutParameters.placeholderForMonth = "--";
+    layoutParameters.placeholderForYear = "----";
+}
+#endif
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/html/MonthInputType.h (129866 => 129867)


--- trunk/Source/WebCore/html/MonthInputType.h	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/html/MonthInputType.h	2012-09-28 09:40:39 UTC (rev 129867)
@@ -31,18 +31,27 @@
 #ifndef MonthInputType_h
 #define MonthInputType_h
 
+#if ENABLE(INPUT_TYPE_MONTH)
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "BaseMultipleFieldsDateAndTimeInputType.h"
+#else
 #include "BaseDateAndTimeInputType.h"
+#endif
 
-#if ENABLE(INPUT_TYPE_MONTH)
-
 namespace WebCore {
 
-class MonthInputType : public BaseDateAndTimeInputType {
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+typedef BaseMultipleFieldsDateAndTimeInputType BaseMonthInputType;
+#else
+typedef BaseDateAndTimeInputType BaseMonthInputType;
+#endif
+
+class MonthInputType : public BaseMonthInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    MonthInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
+    MonthInputType(HTMLInputElement* element) : BaseMonthInputType(element) { }
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual double valueAsDate() const OVERRIDE;
@@ -53,6 +62,12 @@
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const OVERRIDE;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const OVERRIDE;
     virtual bool isMonthField() const OVERRIDE;
+
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    // BaseMultipleFieldsDateAndTimeInputType functions
+    virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE FINAL;
+    virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE FINAL;
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (129866 => 129867)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-09-28 09:40:39 UTC (rev 129867)
@@ -64,9 +64,11 @@
     virtual void visitLiteral(const String&) OVERRIDE FINAL;
 
     DateTimeEditElement& m_editElement;
-    const DateComponents& m_dateValue;
-    const StepRange& m_stepRange;
+    const DateComponents m_dateValue;
+    const StepRange m_stepRange;
     Localizer& m_localizer;
+    const String m_placeholderForMonth;
+    const String m_placeholderForYear;
 };
 
 DateTimeEditBuilder::DateTimeEditBuilder(DateTimeEditElement& elemnt, const DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& dateValue)
@@ -74,6 +76,8 @@
     , m_dateValue(dateValue)
     , m_stepRange(layoutParameters.stepRange)
     , m_localizer(layoutParameters.localizer)
+    , m_placeholderForMonth(layoutParameters.placeholderForMonth)
+    , m_placeholderForYear(layoutParameters.placeholderForYear)
 {
 }
 
@@ -119,6 +123,11 @@
         return;
     }
 
+    case DateTimeFormat::FieldTypeMonth:
+        // We always use "MM", two digits month, even if "M", "MMM", "MMMM", or "MMMMM".
+        m_editElement.addField(DateTimeMonthFieldElement::create(document, m_editElement, m_placeholderForMonth));
+        return;
+
     case DateTimeFormat::FieldTypePeriod:
         m_editElement.addField(DateTimeAMPMFieldElement::create(document, m_editElement, m_localizer.timeAMPMLabels()));
         return;
@@ -144,6 +153,10 @@
         return;
     }
 
+    case DateTimeFormat::FieldTypeYear:
+        m_editElement.addField(DateTimeYearFieldElement::create(document, m_editElement, m_placeholderForYear));
+        return;
+
     default:
         return;
     }

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.h (129866 => 129867)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2012-09-28 09:40:24 UTC (rev 129866)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2012-09-28 09:40:39 UTC (rev 129867)
@@ -65,7 +65,9 @@
         String dateTimeFormat;
         String fallbackDateTimeFormat;
         Localizer& localizer;
-        const StepRange& stepRange;
+        const StepRange stepRange;
+        String placeholderForMonth;
+        String placeholderForYear;
 
         LayoutParameters(Localizer& localizer, const StepRange& stepRange)
             : localizer(localizer)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to