Changeset 127398 in webkit


Ignore:
Timestamp:
Sep 2, 2012 9:03:19 PM (12 years ago)
Author:
yosin@chromium.org
Message:

[Forms] AM/PM field of multiple fields time input UI should be fixed width
https://bugs.webkit.org/show_bug.cgi?id=95542

Reviewed by Kent Tamura.

This patch changes width of AM/PM field of multiple field time input
UI fixed as maximum width of labels or "--".

This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.

No new tests. Once multiple field time input UI uses "lang" HTML
attribute to take time format, we can write a test for this patch.

  • css/html.css:

(input::-webkit-datetime-edit-ampm-field): Added "display" property to "inline-block" for setting width.
Added "text-align" property to "center".

  • html/shadow/DateTimeSymbolicFieldElement.cpp:

(WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement): Changed to call setHasCustomCallback().
(WebCore::DateTimeSymbolicFieldElement::customStyleForRenderer): Added for setting field with from maximum width of labels.

  • html/shadow/DateTimeSymbolicFieldElement.h:

(WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue): Added for using visible empty value in customStyleForRenderer() and visibleValue().
(WebCore::DateTimeSymbolicFieldElement::visibleValue): Changed to call visibleEmptyValue() instead of using literal "--".
(DateTimeSymbolicFieldElement): Added a declaration of customStyleForRenderer().

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r127392 r127398  
     12012-09-02  Yoshifumi Inoue  <yosin@chromium.org>
     2
     3        [Forms] AM/PM field of multiple fields time input UI should be fixed width
     4        https://bugs.webkit.org/show_bug.cgi?id=95542
     5
     6        Reviewed by Kent Tamura.
     7
     8        This patch changes width of AM/PM field of multiple field time input
     9        UI fixed as maximum width of labels or "--".
     10
     11        This patch affects ports which enable both ENABLE_INPUT_TYPE_TIME and
     12        ENABLE_INPUT_TYPE_TIME_MULTIPLE_FIELDS.
     13
     14        No new tests. Once multiple field time input UI uses "lang" HTML
     15        attribute to take time format, we can write a test for this patch.
     16
     17        * css/html.css:
     18        (input::-webkit-datetime-edit-ampm-field): Added "display" property to "inline-block" for setting width.
     19        Added "text-align" property to "center".
     20        * html/shadow/DateTimeSymbolicFieldElement.cpp:
     21        (WebCore::DateTimeSymbolicFieldElement::DateTimeSymbolicFieldElement): Changed to call setHasCustomCallback().
     22        (WebCore::DateTimeSymbolicFieldElement::customStyleForRenderer): Added for setting field with from maximum width of labels.
     23        * html/shadow/DateTimeSymbolicFieldElement.h:
     24        (WebCore::DateTimeSymbolicFieldElement::visibleEmptyValue): Added for using visible empty value in customStyleForRenderer() and visibleValue().
     25        (WebCore::DateTimeSymbolicFieldElement::visibleValue): Changed to call visibleEmptyValue() instead of using literal "--".
     26        (DateTimeSymbolicFieldElement): Added a declaration of customStyleForRenderer().
     27
    1282012-09-02  Benjamin Poulain  <bpoulain@apple.com>
    229
  • trunk/Source/WebCore/css/html.css

    r126728 r127398  
    492492    border: none;
    493493    padding: 0.15em;
     494    display: inline-block;
     495    text-align: center;
    494496}
    495497
  • trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.cpp

    r127085 r127398  
    2828#include "DateTimeSymbolicFieldElement.h"
    2929
     30#include "FontCache.h"
    3031#include "KeyboardEvent.h"
     32#include "RenderStyle.h"
     33#include "StyleResolver.h"
     34#include "TextRun.h"
    3135#include <wtf/unicode/Unicode.h>
    3236
     
    3943{
    4044    ASSERT(!symbols.isEmpty());
     45    setHasCustomCallbacks();
     46}
     47
     48PassRefPtr<RenderStyle> DateTimeSymbolicFieldElement::customStyleForRenderer()
     49{
     50    FontCachePurgePreventer fontCachePurgePreventer;
     51    RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
     52    RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
     53    float maxiumWidth = style->font().width(visibleEmptyValue());
     54    for (unsigned index = 0; index < m_symbols.size(); ++index)
     55        maxiumWidth = std::max(maxiumWidth, style->font().width(m_symbols[index]));
     56    style->setWidth(Length(maxiumWidth, Fixed));
     57    return style.release();
    4158}
    4259
     
    99116}
    100117
     118String DateTimeSymbolicFieldElement::visibleEmptyValue() const
     119{
     120    // FIXME: Number of dashs should be maximum length of labels.
     121    return "--";
     122}
     123
    101124String DateTimeSymbolicFieldElement::visibleValue() const
    102125{
    103     return hasValue() ? m_symbols[m_selectedIndex] : "--";
     126    return hasValue() ? m_symbols[m_selectedIndex] : visibleEmptyValue();
    104127}
    105128
  • trunk/Source/WebCore/html/shadow/DateTimeSymbolicFieldElement.h

    r127085 r127398  
    4444    static const int invalidIndex = -1;
    4545
     46    virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE FINAL;
     47    String visibleEmptyValue() const;
     48
    4649    // DateTimeFieldElement functions.
    4750    virtual void handleKeyboardEvent(KeyboardEvent*) OVERRIDE FINAL;
Note: See TracChangeset for help on using the changeset viewer.