Changeset 129867 in webkit


Ignore:
Timestamp:
Sep 28, 2012 2:40:39 AM (12 years ago)
Author:
yosin@chromium.org
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.
Location:
trunk
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r129865 r129867  
     12012-09-28  Yoshifumi Inoue  <yosin@chromium.org>
     2
     3        [Forms] Multiple fields month input UI
     4        https://bugs.webkit.org/show_bug.cgi?id=97299
     5
     6        Reviewed by Kent Tamura.
     7
     8        This patch adds Chromium port specific expectations for "month" input
     9        type tests for multiple fields month input UI.
     10
     11        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
     12        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
     13
     14        * platform/chromium/fast/forms/month/month-input-visible-string-expected.txt: Added. Multiple fields month input UI doesn't have selection.
     15        * 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.
     16
    1172012-09-28  Vsevolod Vlasov  <vsevik@chromium.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r129863 r129867  
     12012-09-28  Yoshifumi Inoue  <yosin@chromium.org>
     2
     3        [Forms] Multiple fields month input UI
     4        https://bugs.webkit.org/show_bug.cgi?id=97299
     5
     6        Reviewed by Kent Tamura.
     7
     8        This patch introduces multiple fields "month" input UI in DRT. We'll
     9        enable this feature once we add tests.
     10
     11        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_MONTH
     12        and ENABLE_INPUT_MULTIPLE_FIELDS_UI.
     13
     14        No new tests. To reduce size of this patch, other patches add tests
     15        for multiple fields month input UI.
     16
     17        Note: Actual outputs of two tests
     18            - fast/forms/month/month-input-visible-string.html
     19            - fast/forms/month/month-stepup-stepdown-from-renderer.html
     20        are different.
     21
     22        * css/html.css:
     23        (input::-webkit-datetime-edit-month-field): Added for field appearance.
     24        (input::-webkit-datetime-edit-year-field): ditto.
     25        (input::-webkit-datetime-edit-month-field:focus): Added to remove focus ring.
     26        (input::-webkit-datetime-edit-year-field:focus): ditto.
     27        * html/MonthInputType.cpp:
     28        (WebCore::MonthInputType::formatDateTimeFieldsState): Added to format numeric value to string value as specified in HTML5 specification.
     29        (WebCore::MonthInputType::setupLayoutParameters): Added to set layout of multiple fields.
     30        * html/MonthInputType.h: Changed to include BaseMultipleFieldsDateAndTimeInputType.h and introduce BaseMonthInputType typedef.
     31        (WebCore::MonthInputType::MonthInputType): Changed base class name to BaseMonthInputType.
     32        (MonthInputType): Changed to add declarations for formatDateTimeFieldsState() and setupLayoutParameters().
     33        * html/shadow/DateTimeEditElement.cpp:
     34        (DateTimeEditBuilder): Changed to have copy of object in m_stepRange and m_dateValue member variables for being robust.
     35        (WebCore::DateTimeEditBuilder::DateTimeEditBuilder): Changed to add initialize m_placeholderForMonth and m_placeholderForYear.
     36        (WebCore::DateTimeEditBuilder::visitField): Changed to support month field and year field.
     37        * html/shadow/DateTimeEditElement.h:
     38        (LayoutParameters): Changed to add member variables, placeholderForMonth and placeholderForYear. Changed to have copy of object in stepRange member variable for being robust.
     39
    1402012-09-28  Eunmi Lee  <eunmi15.lee@samsung.com>
    241
  • trunk/Source/WebCore/css/html.css

    r129612 r129867  
    478478
    479479#if defined(ENABLE_INPUT_MULTIPLE_FIELDS_UI) && ENABLE_INPUT_MULTIPLE_FIELDS_UI
     480input[type="month"],
    480481input[type="time"] {
    481482    font-family: monospace;
     
    520521}
    521522
     523input::-webkit-datetime-edit-month-field {
     524    -webkit-user-modify: read-only !important;
     525    display: inline-block;
     526    border: none;
     527    text-align: center;
     528    padding: 0.15em;
     529}
     530
    522531/* This selector is used when step >= 3600 second but format contains minute field. */
    523532input::-webkit-datetime-edit-minute-field[readonly] {
     
    526535
    527536input::-webkit-datetime-edit-second-field {
     537    -webkit-user-modify: read-only !important;
     538    display: inline-block;
     539    border: none;
     540    text-align: center;
     541    padding: 0.15em;
     542}
     543
     544input::-webkit-datetime-edit-year-field {
    528545    -webkit-user-modify: read-only !important;
    529546    display: inline-block;
     
    538555input::-webkit-datetime-edit-millisecond-field:focus,
    539556input::-webkit-datetime-edit-minute-field:focus,
    540 input::-webkit-datetime-edit-second-field:focus {
     557input::-webkit-datetime-edit-month-field:focus,
     558input::-webkit-datetime-edit-second-field:focus,
     559input::-webkit-datetime-edit-year-field:focus {
    541560  background-color: highlight;
    542561  color: highlighttext;
     
    549568}
    550569
     570input[type="month"]::-webkit-inner-spin-button,
    551571input[type="time"]::-webkit-inner-spin-button {
    552572    margin-left: 0.2em;
  • trunk/Source/WebCore/html/MonthInputType.cpp

    r128149 r129867  
    4242
    4343#if ENABLE(INPUT_TYPE_MONTH)
     44
     45#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     46#include "DateTimeFieldsState.h"
     47#include "LocalizedStrings.h"
     48#include "Localizer.h"
     49#include <wtf/text/WTFString.h>
     50#endif
    4451
    4552namespace WebCore {
     
    138145}
    139146
     147#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     148String MonthInputType::formatDateTimeFieldsState(const DateTimeFieldsState& dateTimeFieldsState) const
     149{
     150    if (!dateTimeFieldsState.hasMonth() || !dateTimeFieldsState.hasYear())
     151        return emptyString();
     152    return String::format("%04u-%02u", dateTimeFieldsState.year(), dateTimeFieldsState.month());
     153}
     154
     155void MonthInputType::setupLayoutParameters(DateTimeEditElement::LayoutParameters& layoutParameters, const DateComponents& date) const
     156{
     157    layoutParameters.dateTimeFormat = monthFormatInLDML();
     158    layoutParameters.fallbackDateTimeFormat = "MM/yyyy";
     159    layoutParameters.placeholderForMonth = "--";
     160    layoutParameters.placeholderForYear = "----";
     161}
     162#endif
    140163} // namespace WebCore
    141164
  • trunk/Source/WebCore/html/MonthInputType.h

    r120313 r129867  
    3232#define MonthInputType_h
    3333
     34#if ENABLE(INPUT_TYPE_MONTH)
     35#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     36#include "BaseMultipleFieldsDateAndTimeInputType.h"
     37#else
    3438#include "BaseDateAndTimeInputType.h"
    35 
    36 #if ENABLE(INPUT_TYPE_MONTH)
     39#endif
    3740
    3841namespace WebCore {
    3942
    40 class MonthInputType : public BaseDateAndTimeInputType {
     43#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     44typedef BaseMultipleFieldsDateAndTimeInputType BaseMonthInputType;
     45#else
     46typedef BaseDateAndTimeInputType BaseMonthInputType;
     47#endif
     48
     49class MonthInputType : public BaseMonthInputType {
    4150public:
    4251    static PassOwnPtr<InputType> create(HTMLInputElement*);
    4352
    4453private:
    45     MonthInputType(HTMLInputElement* element) : BaseDateAndTimeInputType(element) { }
     54    MonthInputType(HTMLInputElement* element) : BaseMonthInputType(element) { }
    4655    virtual const AtomicString& formControlType() const OVERRIDE;
    4756    virtual DateComponents::Type dateType() const OVERRIDE;
     
    5463    virtual bool setMillisecondToDateComponents(double, DateComponents*) const OVERRIDE;
    5564    virtual bool isMonthField() const OVERRIDE;
     65
     66#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     67    // BaseMultipleFieldsDateAndTimeInputType functions
     68    virtual String formatDateTimeFieldsState(const DateTimeFieldsState&) const OVERRIDE FINAL;
     69    virtual void setupLayoutParameters(DateTimeEditElement::LayoutParameters&, const DateComponents&) const OVERRIDE FINAL;
     70#endif
    5671};
    5772
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp

    r129832 r129867  
    6565
    6666    DateTimeEditElement& m_editElement;
    67     const DateComponents& m_dateValue;
    68     const StepRange& m_stepRange;
     67    const DateComponents m_dateValue;
     68    const StepRange m_stepRange;
    6969    Localizer& m_localizer;
     70    const String m_placeholderForMonth;
     71    const String m_placeholderForYear;
    7072};
    7173
     
    7577    , m_stepRange(layoutParameters.stepRange)
    7678    , m_localizer(layoutParameters.localizer)
     79    , m_placeholderForMonth(layoutParameters.placeholderForMonth)
     80    , m_placeholderForYear(layoutParameters.placeholderForYear)
    7781{
    7882}
     
    120124    }
    121125
     126    case DateTimeFormat::FieldTypeMonth:
     127        // We always use "MM", two digits month, even if "M", "MMM", "MMMM", or "MMMMM".
     128        m_editElement.addField(DateTimeMonthFieldElement::create(document, m_editElement, m_placeholderForMonth));
     129        return;
     130
    122131    case DateTimeFormat::FieldTypePeriod:
    123132        m_editElement.addField(DateTimeAMPMFieldElement::create(document, m_editElement, m_localizer.timeAMPMLabels()));
     
    144153        return;
    145154    }
     155
     156    case DateTimeFormat::FieldTypeYear:
     157        m_editElement.addField(DateTimeYearFieldElement::create(document, m_editElement, m_placeholderForYear));
     158        return;
    146159
    147160    default:
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.h

    r129832 r129867  
    6666        String fallbackDateTimeFormat;
    6767        Localizer& localizer;
    68         const StepRange& stepRange;
     68        const StepRange stepRange;
     69        String placeholderForMonth;
     70        String placeholderForYear;
    6971
    7072        LayoutParameters(Localizer& localizer, const StepRange& stepRange)
Note: See TracChangeset for help on using the changeset viewer.