Changeset 129854 in webkit


Ignore:
Timestamp:
Sep 27, 2012 11:18:15 PM (12 years ago)
Author:
yosin@chromium.org
Message:

[Forms] Adding placeholder feature to DateTimeNumericElement, and update its existing subclasses.
https://bugs.webkit.org/show_bug.cgi?id=97863

Reviewed by Kent Tamura.

This patch is a part of preparation of implementing multiple fields
date/time input UI.

This patch introduces placeholder feature to DateTimeNumericElement
to display date format guide in field, e.g. displaying "dd/mm/yyyy".

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

No new tests. This patch doesn't change behavior.

  • html/shadow/DateTimeFieldElements.cpp:

(WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement): Changed to pass placeholder class to base class.
(WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement): ditto
(WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement): ditto
(WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement): ditto

  • html/shadow/DateTimeNumericFieldElement.cpp: Removed no more needed static function displaySizeOfNumbre().

(WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement): Changed to add new parameter to take placeholder.
(WebCore::DateTimeNumericFieldElement::visibleValue): Changed to use m_placholder.

  • html/shadow/DateTimeNumericFieldElement.h:

(DateTimeNumericFieldElement): Changed to add a member variable m_placholder to hold placholder to DateTimeNumbericElement class.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r129852 r129854  
     12012-09-27  Yoshifumi Inoue  <yosin@chromium.org>
     2
     3        [Forms] Adding placeholder feature to DateTimeNumericElement, and update its existing subclasses.
     4        https://bugs.webkit.org/show_bug.cgi?id=97863
     5
     6        Reviewed by Kent Tamura.
     7
     8        This patch is a part of preparation of implementing multiple fields
     9        date/time input UI.
     10
     11        This patch introduces placeholder feature to DateTimeNumericElement
     12        to display date format guide in field, e.g. displaying "dd/mm/yyyy".
     13
     14        Note: This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
     15        ENABLE_INPUT_MULTIPLE_FIELDS_UI.
     16
     17        No new tests. This patch doesn't change behavior.
     18
     19        * html/shadow/DateTimeFieldElements.cpp:
     20        (WebCore::DateTimeHourFieldElement::DateTimeHourFieldElement): Changed to pass placeholder class to base class.
     21        (WebCore::DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement): ditto
     22        (WebCore::DateTimeMinuteFieldElement::DateTimeMinuteFieldElement): ditto
     23        (WebCore::DateTimeSecondFieldElement::DateTimeSecondFieldElement): ditto
     24        * html/shadow/DateTimeNumericFieldElement.cpp: Removed no more needed static function displaySizeOfNumbre().
     25        (WebCore::DateTimeNumericFieldElement::DateTimeNumericFieldElement): Changed to add new parameter to take placeholder.
     26        (WebCore::DateTimeNumericFieldElement::visibleValue): Changed to use m_placholder.
     27        * html/shadow/DateTimeNumericFieldElement.h:
     28        (DateTimeNumericFieldElement): Changed to add a member variable m_placholder to hold placholder to DateTimeNumbericElement class.
     29
    1302012-09-27  Kent Tamura  <tkent@chromium.org>
    231
  • trunk/Source/WebCore/html/shadow/DateTimeFieldElements.cpp

    r129612 r129854  
    7171
    7272DateTimeHourFieldElement::DateTimeHourFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum)
    73     : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum)
     73    : DateTimeNumericFieldElement(document, fieldOwner, minimum, maximum, "--")
    7474    , m_alignment(maximum + maximum % 2)
    7575{
     
    176176
    177177DateTimeMillisecondFieldElement::DateTimeMillisecondFieldElement(Document* document, FieldOwner& fieldOwner)
    178     : DateTimeNumericFieldElement(document, fieldOwner, 0, 999)
     178    : DateTimeNumericFieldElement(document, fieldOwner, 0, 999, "---")
    179179{
    180180}
     
    217217
    218218DateTimeMinuteFieldElement::DateTimeMinuteFieldElement(Document* document, FieldOwner& fieldOwner)
    219     : DateTimeNumericFieldElement(document, fieldOwner, 0, 59)
     219    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--")
    220220{
    221221}
     
    258258
    259259DateTimeSecondFieldElement::DateTimeSecondFieldElement(Document* document, FieldOwner& fieldOwner)
    260     : DateTimeNumericFieldElement(document, fieldOwner, 0, 59)
     260    : DateTimeNumericFieldElement(document, fieldOwner, 0, 59, "--")
    261261{
    262262}
  • trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.cpp

    r129832 r129854  
    3636static const DOMTimeStamp typeAheadTimeout = 1000;
    3737
    38 static size_t displaySizeOfNumber(int value)
    39 {
    40     ASSERT(value >= 0);
    41 
    42     if (!value)
    43         return 1;
    44 
    45     int numberOfDigits = 0;
    46     while (value) {
    47         value /= 10;
    48         ++numberOfDigits;
    49     }
    50 
    51     return numberOfDigits;
    52 }
    53 
    5438DateTimeNumericFieldElement::Range::Range(int minimum, int maximum)
    5539    : maximum(maximum)
     
    6448}
    6549
    66 DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum)
     50DateTimeNumericFieldElement::DateTimeNumericFieldElement(Document* document, FieldOwner& fieldOwner, int minimum, int maximum, const String& placeholder)
    6751    : DateTimeFieldElement(document, fieldOwner)
    6852    , m_lastDigitCharTime(0)
     53    , m_placeholder(placeholder)
    6954    , m_range(minimum, maximum)
    7055    , m_value(0)
     
    187172String DateTimeNumericFieldElement::visibleValue() const
    188173{
    189     if (m_hasValue)
    190         return value();
    191 
    192     StringBuilder builder;
    193     for (int numberOfDashs = std::max(displaySizeOfNumber(m_range.maximum), displaySizeOfNumber(m_range.minimum)); numberOfDashs; --numberOfDashs)
    194         builder.append('-');
    195     return builder.toString();
     174    return m_hasValue ? value() : m_placeholder;
    196175}
    197176
  • trunk/Source/WebCore/html/shadow/DateTimeNumericFieldElement.h

    r129832 r129854  
    5151    };
    5252
    53     DateTimeNumericFieldElement(Document*, FieldOwner&, int minimum, int maximum);
     53    DateTimeNumericFieldElement(Document*, FieldOwner&, int minimum, int maximum, const String& placeholder);
    5454
    5555    int clampValue(int value) const { return m_range.clampValue(value); }
     
    7676
    7777    DOMTimeStamp m_lastDigitCharTime;
     78    const String m_placeholder;
    7879    const Range m_range;
    7980    int m_value;
Note: See TracChangeset for help on using the changeset viewer.