Title: [130024] trunk
Revision
130024
Author
yo...@chromium.org
Date
2012-10-01 03:23:21 -0700 (Mon, 01 Oct 2012)

Log Message

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

Reviewed by Kent Tamura.

Source/WebCore:

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

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

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

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

* css/thml.css:
(input::-webkit-datetime-edit-week-field): Added for field appearance.
(input::-webkit-datetime-edit-week-field:focus): Added to remove focus ring.
* html/WeekInputType.cpp:
(WebCore::WeekInputType::formatDateTimeFieldsState): Added to format numeric value to string value as specified in HTML5 specification.
(WebCore::WeekInputType::setupLayoutParameters):  Added to set layout of multiple fields.
* html/WeekInputType.h: Changed to include BaseMultipleFieldsDateAndTimeInputType.h and introduce BaseWeekInputType typedef.
(WebCore::WeekInputType::WeekInputType): Changed base class name to BaseWeekInputType.
(WeekInputType): Changed to add declarations for formatDateTimeFieldsState() and setupLayoutParameters().
* html/shadow/DateTimeEditElement.cpp:
(WebCore::DateTimeEditBuilder::visitField): Changed to support week field.

LayoutTests:

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

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

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

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (130023 => 130024)


--- trunk/LayoutTests/ChangeLog	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/LayoutTests/ChangeLog	2012-10-01 10:23:21 UTC (rev 130024)
@@ -1,3 +1,19 @@
+2012-10-01  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Forms] Multiple fields week input UI
+        https://bugs.webkit.org/show_bug.cgi?id=97877
+
+        Reviewed by Kent Tamura.
+
+        This patch adds Chromium port specific expectations for "week" input
+        type tests for multiple fields week input UI.
+
+        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_WEEK
+        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
+
+        * platform/chromium/fast/forms/week/week-input-visible-string-expected.txt: Added. Multiple fields week input UI doesn't have selection.
+        * platform/chromium/fast/forms/week/week-stepup-stepdown-from-renderer-expected.txt: Added. On multiple fields week input UI, step down/up decrement/increment a field rather than whole value.
+
 2012-10-01  Andrey Kosyakov  <ca...@chromium.org>
 
         Unreviewed gardening -- removed TestExpectation entries for passing tests.

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


--- trunk/LayoutTests/platform/chromium/fast/forms/week/week-input-visible-string-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/week/week-input-visible-string-expected.txt	2012-10-01 10:23:21 UTC (rev 130024)
@@ -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.
+
+week: value='2011-W17' 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/week/week-input-visible-string-expected.txt
___________________________________________________________________

Added: svn:eol-style

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


--- trunk/LayoutTests/platform/chromium/fast/forms/week/week-stepup-stepdown-from-renderer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/week/week-stepup-stepdown-from-renderer-expected.txt	2012-10-01 10:23:21 UTC (rev 130024)
@@ -0,0 +1,29 @@
+Check stepping-up and -down for  from renderer. No cases of empty initial values for type=week.
+
+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-W02", null, null) should be 2010-W03. Was 2010-W02.
+FAIL stepDown("2010-W02", null, null) should be 2010-W01. Was 2010-W02.
+FAIL stepUp("2010-W02", null, null, 10) should be 2010-W12. Was 2010-W02.
+FAIL stepDown("2010-W02", null, null, 11) should be 2009-W44. Was 2010-W02.
+FAIL stepUp("1970-W01", "4", null, 2) should be 1970-W09. Was 1970-W01.
+FAIL stepDown("1970-W01", "4", null, 3) should be 1969-W41. Was 1970-W01.
+Step=any
+FAIL stepUp("2010-W02", "any", null) should be 2010-W03. Was 2010-W02.
+FAIL stepDown("2010-W02", "any", null) should be 2010-W01. Was 2010-W02.
+Overflow/underflow
+FAIL stepUp("2010-W02", "3.40282346e+38", null) should be 275760-W37. Was 2010-W02.
+FAIL stepDown("2010-W02", "3.40282346e+38", null) should be 1970-W01. Was 2010-W02.
+PASS stepUp("2010-W02", "1", "2010-W02") is "2010-W02"
+PASS stepDown("2010-W02", "1", "2010-W02") is "2010-W02"
+stepDown()/stepUp() for stepMismatch values
+FAIL stepDown("2010-W02", "2", "2009-W52") should be 2010-W01. Was 2010-W02.
+FAIL stepUp("1970-W02", "4", "") should be 1970-W05. Was 1970-W02.
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/platform/chromium/fast/forms/week/week-stepup-stepdown-from-renderer-expected.txt
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (130023 => 130024)


--- trunk/Source/WebCore/ChangeLog	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/Source/WebCore/ChangeLog	2012-10-01 10:23:21 UTC (rev 130024)
@@ -1,3 +1,36 @@
+2012-10-01  Yoshifumi Inoue  <yo...@chromium.org>
+
+        [Forms] Multiple fields week input UI
+        https://bugs.webkit.org/show_bug.cgi?id=97877
+
+        Reviewed by Kent Tamura.
+
+        This patch introduces multiple fields "week" input UI in DRT. We'll
+        enable this feature once we add tests.
+
+        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_WEEK
+        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
+
+        No new tests. To reduce size of this patch, other patches add tests
+        for multiple fields week input UI.
+
+        Note: Actual outputs of two tests
+          - fast/forms/week/week-input-visible-string.html
+          - fast/forms/week/week-stepup-stepdown-from-renderer.html
+        are different.
+
+        * css/thml.css:
+        (input::-webkit-datetime-edit-week-field): Added for field appearance.
+        (input::-webkit-datetime-edit-week-field:focus): Added to remove focus ring.
+        * html/WeekInputType.cpp:
+        (WebCore::WeekInputType::formatDateTimeFieldsState): Added to format numeric value to string value as specified in HTML5 specification.
+        (WebCore::WeekInputType::setupLayoutParameters):  Added to set layout of multiple fields.
+        * html/WeekInputType.h: Changed to include BaseMultipleFieldsDateAndTimeInputType.h and introduce BaseWeekInputType typedef.
+        (WebCore::WeekInputType::WeekInputType): Changed base class name to BaseWeekInputType.
+        (WeekInputType): Changed to add declarations for formatDateTimeFieldsState() and setupLayoutParameters().
+        * html/shadow/DateTimeEditElement.cpp:
+        (WebCore::DateTimeEditBuilder::visitField): Changed to support week field.
+
 2012-10-01  Pavel Feldman  <pfeld...@chromium.org>
 
         Web Inspector: do not use InspectorInstrumentation::hasFrontends() check when collecting stacks

Modified: trunk/Source/WebCore/css/html.css (130023 => 130024)


--- trunk/Source/WebCore/css/html.css	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/Source/WebCore/css/html.css	2012-10-01 10:23:21 UTC (rev 130024)
@@ -478,7 +478,8 @@
 
 #if defined(ENABLE_INPUT_MULTIPLE_FIELDS_UI) && ENABLE_INPUT_MULTIPLE_FIELDS_UI
 input[type="month"],
-input[type="time"] {
+input[type="time"],
+input[type="week"] {
     font-family: monospace;
 }
 
@@ -541,6 +542,14 @@
     padding: 0.15em;
 }
 
+input::-webkit-datetime-edit-week-field {
+    -webkit-user-modify: read-only !important;
+    display: inline-block;
+    border: none;
+    text-align: center;
+    padding: 0.15em;
+}
+
 input::-webkit-datetime-edit-year-field {
     -webkit-user-modify: read-only !important;
     display: inline-block;
@@ -556,6 +565,7 @@
 input::-webkit-datetime-edit-minute-field:focus,
 input::-webkit-datetime-edit-month-field:focus,
 input::-webkit-datetime-edit-second-field:focus,
+input::-webkit-datetime-edit-week-field:focus,
 input::-webkit-datetime-edit-year-field:focus {
   background-color: highlight;
   color: highlighttext;

Modified: trunk/Source/WebCore/html/WeekInputType.cpp (130023 => 130024)


--- trunk/Source/WebCore/html/WeekInputType.cpp	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/Source/WebCore/html/WeekInputType.cpp	2012-10-01 10:23:21 UTC (rev 130024)
@@ -39,6 +39,12 @@
 
 #if ENABLE(INPUT_TYPE_WEEK)
 
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+#include "DateTimeFieldsState.h"
+#include "LocalizedStrings.h"
+#include <wtf/text/WTFString.h>
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -91,6 +97,23 @@
     return true;
 }
 
+
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+String WeekInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
+{
+    if (!dateTimeFieldsState.hasYear() || !dateTimeFieldsState.hasWeekOfYear())
+        return emptyString();
+    return String::format("%04u-W%02u", dateTimeFieldsState.year(), dateTimeFieldsState.weekOfYear());
+}
+
+void WeekInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents&) const
+{
+    layoutParameters.dateTimeFormat = weekFormatInLDML();
+    layoutParameters.fallbackDateTimeFormat = "'Week' WW-yyyy";
+    layoutParameters.placeholderForYear = "----";
+}
+#endif
+
 } // namespace WebCore
 
 #endif

Modified: trunk/Source/WebCore/html/WeekInputType.h (130023 => 130024)


--- trunk/Source/WebCore/html/WeekInputType.h	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/Source/WebCore/html/WeekInputType.h	2012-10-01 10:23:21 UTC (rev 130024)
@@ -31,24 +31,36 @@
 #ifndef WeekInputType_h
 #define WeekInputType_h
 
-#include "BaseDateAndTimeInputType.h"
+#include "BaseMultipleFieldsDateAndTimeInputType.h"
 
 #if ENABLE(INPUT_TYPE_WEEK)
 
 namespace WebCore {
 
-class WeekInputType : public BaseDateAndTimeInputType {
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+typedef BaseMultipleFieldsDateAndTimeInputType BaseWeekInputType;
+#else
+typedef BaseDateAndTimeInputType BaseWeekInputType;
+#endif
+
+class WeekInputType : public BaseWeekInputType {
 public:
     static PassOwnPtr<InputType> create(HTMLInputElement*);
 
 private:
-    WeekInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
+    WeekInputType(HTMLInputElement* element) : BaseWeekInputType(element) { }
     virtual const AtomicString& formControlType() const OVERRIDE;
     virtual DateComponents::Type dateType() const OVERRIDE;
     virtual StepRange createStepRange(AnyStepHandling) const OVERRIDE;
     virtual bool parseToDateComponentsInternal(const UChar*, unsigned length, DateComponents*) const OVERRIDE;
     virtual bool setMillisecondToDateComponents(double, DateComponents*) const OVERRIDE;
     virtual bool isWeekField() 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 (130023 => 130024)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-10-01 09:52:42 UTC (rev 130023)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2012-10-01 10:23:21 UTC (rev 130024)
@@ -153,6 +153,10 @@
         return;
     }
 
+    case DateTimeFormat::FieldTypeWeekOfYear:
+        m_editElement.addField(DateTimeWeekFieldElement::create(document, m_editElement));
+        return;
+
     case DateTimeFormat::FieldTypeYear:
         m_editElement.addField(DateTimeYearFieldElement::create(document, m_editElement, m_placeholderForYear));
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to