Changeset 141195 in webkit


Ignore:
Timestamp:
Jan 29, 2013 6:05:22 PM (11 years ago)
Author:
tkent@chromium.org
Message:

INPUT_MULTIPLE_FIELDS_UI: The content should not overflow the <input> boundary
https://bugs.webkit.org/show_bug.cgi?id=108069

Reviewed by Hajime Morita.

Source/WebCore:

To avoid the overflow, we do:
A) Specify overflow:hidden to <input>.

However, we need to make sub-fields and buttons workable even if the
width is smaller than the intrinsic size. So, we do:
B) Make DateTimeEditElement shrinkable, and
C) Make the sub-fields scrollable horizontally like input[type=text].

To achieve B, we need to remove -webkit-date-and-time-container (D)
because width property for <input> can shrink only the direct child
elements.

Tests: fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html
and new test cases in fast/forms/date/date-appearance-basic.html.

  • css/html.css:

(input[type="date"]):
Change -webkit-align-items value. (D)
Specify overflow:hidden. (A)
(input[type="datetime"]): Ditto.
(input[type="datetime-local"]): Ditto.
(input[type="month"]): Ditto.
(input[type="time"]): Ditto.
(input[type="week"]): Ditto.
(input::-webkit-datetime-edit):
Add min-width:0 (B), and overflow:hidden. (C)
Remove unnecessary white-space:pre because of white-space:nowrap below.
(input::-webkit-datetime-edit-fields-wrapper):
Added. This is the child of -webkit-datetime-edit, and contains
sub-fields. (C)

  • html/BaseMultipleFieldsDateAndTimeInputType.cpp:

(WebCore::BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree):
Remove -webkit-date-and-time-container, and append DateTimeEditElement,
spin button, and picker indicator element to the ShadowRoot. (D)
(WebCore::BaseMultipleFieldsDateAndTimeInputType::shouldApplyLocaleDirection):
<input> for multiple fields UI should have the direction of the browser
locale. This is a replacement of the code for dir attribute in
updateInnerTextValue below. (D)
(WebCore::BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue):
Remove the code to set dir= to -webkit-date-and-time-container.

  • html/BaseMultipleFieldsDateAndTimeInputType.h:

(BaseMultipleFieldsDateAndTimeInputType):
Declare shouldApplyLocaleDirection. (D)

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::HTMLInputElement):
Calls setHasCustomCallbacks for customStyleForRenderer. (D)
(WebCore::HTMLInputElement::customStyleForRenderer):
Set direction to RenderStyle if shouldApplyLocaleDirection is true. This
is a replacement of the dir setting code in
BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue. (D)

  • html/HTMLInputElement.h:

(HTMLInputElement): Declare customStyleForRenderer. (D)

  • html/InputType.cpp:

(WebCore::InputType::shouldApplyLocaleDirection):
Add default implmentation of shouldApplyLocaleDirection. (D)

  • html/InputType.h:

(InputType): Declare shouldApplyLocaleDirection. (D)

  • html/shadow/DateTimeEditElement.cpp:

(WebCore::DateTimeEditBuilder::visitLiteral):
Add elements to -webkit-datetime-edit-fields-wrapper element. (C)
(WebCore::DateTimeEditElement::fieldsWrapperElement):
A helper to get -webkit-datetime-edit-fields-wrapper element. (C)
(WebCore::DateTimeEditElement::addField):
Add elements to -webkit-datetime-edit-fields-wrapper element. (C)
(WebCore::DateTimeEditElement::customStyleForRenderer):

  • Iterate over children of -webkit-datetime-edit-fields-wrapper element. (C)
  • Set width property instead of min-width. (B)

(WebCore::DateTimeEditElement::layout):

  • Prepare -webkit-datetime-edit-fields-wrapper element. (C)
  • Handle children of -webkit-datetime-edit-fields-wrapper element. (C)
  • Need to do style recalc because child structure is changed. (C)
  • html/shadow/DateTimeEditElement.h:

(DateTimeEditElement): Declare fieldsWrapperElement. (C)

LayoutTests:

  • fast/forms/date/date-appearance-basic-expected.txt:
  • fast/forms/date/date-appearance-basic.html:

Add test cases for small width and small height.

  • fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html:

Update the code because of shadow tree structure change.

  • fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html:

Added.

  • fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt:

Added.

  • platform/chromium-mac/fast/forms/date/date-appearance-basic-expected.png:
  • platform/chromium/TestExpectations:
    • date-appearance-basic.html: New test cases are added.
    • *-appearance-pseudo-element.html: :before :after position is slightly changed because of the -webkit-align-items change.
    • suggestion-picker/*.html: RTL behavior is changed. The direction of suggestion pickers matches to the direction of the input content (browser locale).
Location:
trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r141194 r141195  
     12013-01-29  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: The content should not overflow the <input> boundary
     4        https://bugs.webkit.org/show_bug.cgi?id=108069
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/forms/date/date-appearance-basic-expected.txt:
     9        * fast/forms/date/date-appearance-basic.html:
     10        Add test cases for small width and small height.
     11        * fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html:
     12        Update the code because of shadow tree structure change.
     13        * fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html:
     14        Added.
     15        * fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt:
     16        Added.
     17        * platform/chromium-mac/fast/forms/date/date-appearance-basic-expected.png:
     18        * platform/chromium/TestExpectations:
     19         - date-appearance-basic.html: New test cases are added.
     20         - *-appearance-pseudo-element.html: :before :after position is slightly
     21           changed because of the -webkit-align-items change.
     22         - suggestion-picker/*.html: RTL behavior is changed. The direction of
     23           suggestion pickers matches to the direction of the input content
     24           (browser locale).
     25
    1262013-01-29  Roger Fong  <roger_fong@apple.com>
    227
  • trunk/LayoutTests/fast/forms/date/date-appearance-basic-expected.txt

    r135840 r141195  
    88background, color:
    99font-size, font-weight:
    10 font-size with fixed input width:
    11 Fixed input height:
     10font-size with fixed input width:  
     11Fixed input height:  
    1212-webkit-appearance:none:
  • trunk/LayoutTests/fast/forms/date/date-appearance-basic.html

    r135840 r141195  
    1818    <li>background, color: <input type="date" value="2012-10-05" style="border: 0px; background: green; color: yellow;"></li>
    1919    <li>font-size, font-weight: <input type="date" value="2012-10-05" style="font-size: 20pt; font-weight: bold;"></li>
    20     <li>font-size with fixed input width: <input type="date" value="2012-10-05" style="font-size: 20pt; width: 14em;"></li>
    21     <li>Fixed input height: <input type="date" value="2012-10-05" style="height: 4em;"></li>
     20    <li>font-size with fixed input width: <input type="date" value="2012-10-05" style="font-size: 20pt; width: 14em;">
     21      <input type="date" value="99999-12-31" style="font-size: 20pt; width: 5em;"></li>
     22    <li>Fixed input height: <input type="date" value="2012-10-05" style="height: 4em;">
     23      <input type="date" value="2013-01-28" style="font-size: 20px; height: 10px;"></li>
    2224    <li>-webkit-appearance:none: <input type="date" value="2012-10-05" style="-webkit-appearance: none;"></li>
    2325</ul>
  • trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html

    r130293 r141195  
    3030testInput.focus();
    3131var shadowRoot = internals.oldestShadowRoot(testInput);
    32 var fields = getElementByPseudoId(shadowRoot, "-webkit-datetime-edit").childNodes;
     32var fields = getElementByPseudoId(shadowRoot, "-webkit-datetime-edit-fields-wrapper").childNodes;
    3333for (var index = 0; index < fields.length; ++index) {
    3434    var field = fields[index];
  • trunk/LayoutTests/platform/chromium/TestExpectations

    r141188 r141195  
    43074307webkit.org/b/105574 platform/chromium/fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar.html [ ImageOnlyFailure ]
    43084308
     4309# Needs rebaseline.
     4310webkit.org/b/108069 fast/forms/date/date-appearance-basic.html [ ImageOnlyFailure ]
     4311webkit.org/b/108069 fast/forms/date/date-appearance-pseudo-elements.html [ ImageOnlyFailure ]
     4312webkit.org/b/108069 fast/forms/month/month-appearance-pseudo-elements.html [ ImageOnlyFailure ]
     4313webkit.org/b/108069 fast/forms/time/time-appearance-pseudo-elements.html [ ImageOnlyFailure ]
     4314webkit.org/b/108069 fast/forms/week/week-appearance-pseudo-elements.html [ ImageOnlyFailure ]
     4315webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4316webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetime-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
     4317webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetime-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4318webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
     4319webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4320webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/month-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4321webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
     4322webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4323webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-with-scroll-bar.html [ ImageOnlyFailure ]
     4324webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
     4325
    43094326webkit.org/b/97333 fast/canvas/canvas-path-object.html [ Failure ]
    43104327webkit.org/b/97333 platform/chromium/virtual/gpu/fast/canvas/canvas-path-object.html [ Failure ]
  • trunk/Source/WebCore/ChangeLog

    r141193 r141195  
     12013-01-29  Kent Tamura  <tkent@chromium.org>
     2
     3        INPUT_MULTIPLE_FIELDS_UI: The content should not overflow the <input> boundary
     4        https://bugs.webkit.org/show_bug.cgi?id=108069
     5
     6        Reviewed by Hajime Morita.
     7
     8        To avoid the overflow, we do:
     9        A) Specify overflow:hidden to <input>.
     10
     11        However, we need to make sub-fields and buttons workable even if the
     12        width is smaller than the intrinsic size. So, we do:
     13        B) Make DateTimeEditElement shrinkable, and
     14        C) Make the sub-fields scrollable horizontally like input[type=text].
     15
     16        To achieve B, we need to remove -webkit-date-and-time-container (D)
     17        because width property for <input> can shrink only the direct child
     18        elements.
     19
     20        Tests: fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html
     21        and new test cases in fast/forms/date/date-appearance-basic.html.
     22
     23        * css/html.css:
     24        (input[type="date"]):
     25        Change -webkit-align-items value. (D)
     26        Specify overflow:hidden. (A)
     27        (input[type="datetime"]): Ditto.
     28        (input[type="datetime-local"]): Ditto.
     29        (input[type="month"]): Ditto.
     30        (input[type="time"]): Ditto.
     31        (input[type="week"]): Ditto.
     32        (input::-webkit-datetime-edit):
     33        Add min-width:0 (B), and overflow:hidden. (C)
     34        Remove unnecessary white-space:pre because of white-space:nowrap below.
     35        (input::-webkit-datetime-edit-fields-wrapper):
     36        Added. This is the child of -webkit-datetime-edit, and contains
     37        sub-fields. (C)
     38        * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
     39        (WebCore::BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree):
     40        Remove -webkit-date-and-time-container, and append DateTimeEditElement,
     41        spin button, and picker indicator element to the ShadowRoot. (D)
     42        (WebCore::BaseMultipleFieldsDateAndTimeInputType::shouldApplyLocaleDirection):
     43        <input> for multiple fields UI should have the direction of the browser
     44        locale. This is a replacement of the code for dir attribute in
     45        updateInnerTextValue below. (D)
     46        (WebCore::BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue):
     47        Remove the code to set dir= to -webkit-date-and-time-container.
     48        * html/BaseMultipleFieldsDateAndTimeInputType.h:
     49        (BaseMultipleFieldsDateAndTimeInputType):
     50        Declare shouldApplyLocaleDirection. (D)
     51        * html/HTMLInputElement.cpp:
     52        (WebCore::HTMLInputElement::HTMLInputElement):
     53        Calls setHasCustomCallbacks for customStyleForRenderer. (D)
     54        (WebCore::HTMLInputElement::customStyleForRenderer):
     55        Set direction to RenderStyle if shouldApplyLocaleDirection is true. This
     56        is a replacement of the dir setting code in
     57        BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue. (D)
     58        * html/HTMLInputElement.h:
     59        (HTMLInputElement): Declare customStyleForRenderer. (D)
     60        * html/InputType.cpp:
     61        (WebCore::InputType::shouldApplyLocaleDirection):
     62        Add default implmentation of shouldApplyLocaleDirection. (D)
     63        * html/InputType.h:
     64        (InputType): Declare shouldApplyLocaleDirection. (D)
     65
     66        * html/shadow/DateTimeEditElement.cpp:
     67        (WebCore::DateTimeEditBuilder::visitLiteral):
     68        Add elements to -webkit-datetime-edit-fields-wrapper element. (C)
     69        (WebCore::DateTimeEditElement::fieldsWrapperElement):
     70        A helper to get -webkit-datetime-edit-fields-wrapper element. (C)
     71        (WebCore::DateTimeEditElement::addField):
     72        Add elements to -webkit-datetime-edit-fields-wrapper element. (C)
     73        (WebCore::DateTimeEditElement::customStyleForRenderer):
     74        - Iterate over children of -webkit-datetime-edit-fields-wrapper element. (C)
     75        - Set width property instead of min-width. (B)
     76        (WebCore::DateTimeEditElement::layout):
     77        - Prepare -webkit-datetime-edit-fields-wrapper element. (C)
     78        - Handle children of -webkit-datetime-edit-fields-wrapper element. (C)
     79        - Need to do style recalc because child structure is changed. (C)
     80        * html/shadow/DateTimeEditElement.h:
     81        (DateTimeEditElement): Declare fieldsWrapperElement. (C)
     82
    1832013-01-29  Tom Sepez  <tsepez@chromium.org>
    284
  • trunk/Source/WebCore/css/html.css

    r140341 r141195  
    487487#if defined(ENABLE_INPUT_TYPE_DATE) && ENABLE_INPUT_TYPE_DATE
    488488input[type="date"] {
    489     -webkit-align-items: stretch;
     489    -webkit-align-items: center;
    490490    display: -webkit-inline-flex;
    491491    font-family: monospace;
     492    overflow: hidden;
    492493    padding: 0;
    493494    -webkit-padding-start: 1px;
     
    496497#if defined(ENABLE_INPUT_TYPE_DATETIME) && ENABLE_INPUT_TYPE_DATETIME
    497498input[type="datetime"] {
    498     -webkit-align-items: stretch;
     499    -webkit-align-items: center;
    499500    display: -webkit-inline-flex;
    500501    font-family: monospace;
     502    overflow: hidden;
    501503    padding: 0;
    502504    -webkit-padding-start: 1px;
     
    505507#if defined(ENABLE_INPUT_TYPE_DATETIMELOCAL) && ENABLE_INPUT_TYPE_DATETIMELOCAL
    506508input[type="datetime-local"] {
    507     -webkit-align-items: stretch;
     509    -webkit-align-items: center;
    508510    display: -webkit-inline-flex;
    509511    font-family: monospace;
     512    overflow: hidden;
    510513    padding: 0;
    511514    -webkit-padding-start: 1px;
     
    514517#if defined(ENABLE_INPUT_TYPE_MONTH) && ENABLE_INPUT_TYPE_MONTH
    515518input[type="month"] {
    516     -webkit-align-items: stretch;
     519    -webkit-align-items: center;
    517520    display: -webkit-inline-flex;
    518521    font-family: monospace;
     522    overflow: hidden;
    519523    padding: 0;
    520524    -webkit-padding-start: 1px;
     
    523527#if defined(ENABLE_INPUT_TYPE_TIME) && ENABLE_INPUT_TYPE_TIME
    524528input[type="time"] {
    525     -webkit-align-items: stretch;
     529    -webkit-align-items: center;
    526530    display: -webkit-inline-flex;
    527531    font-family: monospace;
     532    overflow: hidden;
    528533    padding: 0;
    529534    -webkit-padding-start: 1px;
     
    532537#if defined(ENABLE_INPUT_TYPE_WEEK) && ENABLE_INPUT_TYPE_WEEK
    533538input[type="week"] {
    534     -webkit-align-items: stretch;
     539    -webkit-align-items: center;
    535540    display: -webkit-inline-flex;
    536541    font-family: monospace;
     542    overflow: hidden;
    537543    padding: 0;
    538544    -webkit-padding-start: 1px;
     
    544550    -webkit-user-modify: read-only !important;
    545551    display: inline-block;
    546     white-space: pre;
     552    min-width: 0;
     553    overflow: hidden;
     554}
     555
     556input::-webkit-datetime-edit-fields-wrapper {
     557    -webkit-user-modify: read-only !important;
     558    display: inline-block;
     559    padding: 1px 0;
     560    white-space: nowrap;
    547561}
    548562
     
    598612    display: inline;
    599613    font: inherit !important;
    600 }
    601 
    602 input::-webkit-date-and-time-container {
    603     -webkit-align-items: center;
    604     -webkit-flex: 1;
    605     display: -webkit-inline-flex;
    606614}
    607615
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp

    r140385 r141195  
    191191void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree()
    192192{
    193     DEFINE_STATIC_LOCAL(AtomicString, dateAndTimeInputContainerPseudoId, ("-webkit-date-and-time-container", AtomicString::ConstructFromLiteral));
    194 
    195193    ASSERT(element()->shadow());
    196194
    197195    Document* document = element()->document();
    198     RefPtr<HTMLDivElement> container = HTMLDivElement::create(document);
    199     element()->userAgentShadowRoot()->appendChild(container);
    200     container->setPseudo(dateAndTimeInputContainerPseudoId);
     196    ContainerNode* container = element()->userAgentShadowRoot();
    201197
    202198    RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(document, *this));
     
    341337}
    342338
     339bool BaseMultipleFieldsDateAndTimeInputType::shouldApplyLocaleDirection() const
     340{
     341    return true;
     342}
     343
    343344bool BaseMultipleFieldsDateAndTimeInputType::shouldUseInputMethod() const
    344345{
     
    355356    if (!m_dateTimeEditElement)
    356357        return;
    357 
    358     AtomicString direction = element()->locale().isRTL() ? AtomicString("rtl", AtomicString::ConstructFromLiteral) : AtomicString("ltr", AtomicString::ConstructFromLiteral);
    359     if (Element* container = ElementTraversal::firstWithin(element()->userAgentShadowRoot()))
    360         container->setAttribute(HTMLNames::dirAttr, direction);
    361358
    362359    DateTimeEditElement::LayoutParameters layoutParameters(element()->locale(), createStepRange(AnyIsDefaultStep));
  • trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h

    r139424 r141195  
    9494    virtual FormControlState saveFormControlState() const OVERRIDE FINAL;
    9595    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE FINAL;
     96    virtual bool shouldApplyLocaleDirection() const OVERRIDE;
    9697    virtual bool shouldUseInputMethod() const OVERRIDE FINAL;
    9798    virtual void stepAttributeChanged() OVERRIDE FINAL;
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r141066 r141195  
    5858#include "LocalizedStrings.h"
    5959#include "MouseEvent.h"
     60#include "PlatformLocale.h"
    6061#include "RenderTextControlSingleLine.h"
    6162#include "RenderTheme.h"
     
    6566#include "ShadowRoot.h"
    6667#include "ScriptEventListener.h"
     68#include "StyleResolver.h"
    6769#include <wtf/MathExtras.h>
    6870#include <wtf/StdLibExtras.h>
     
    134136{
    135137    ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
     138#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     139    setHasCustomCallbacks();
     140#endif
    136141}
    137142
     
    19651970}
    19661971
     1972#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     1973PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
     1974{
     1975    RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
     1976    if (!m_inputType->shouldApplyLocaleDirection())
     1977        return originalStyle.release();
     1978    TextDirection contentDirection = locale().isRTL() ? RTL : LTR;
     1979    if (originalStyle->direction() == contentDirection)
     1980        return originalStyle.release();
     1981    RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
     1982    style->setDirection(contentDirection);
     1983    return style.release();
     1984}
     1985#endif
     1986
    19671987} // namespace
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r141066 r141195  
    403403    void addToRadioButtonGroup();
    404404    void removeFromRadioButtonGroup();
     405#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
     406    virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
     407#endif
    405408
    406409    AtomicString m_name;
  • trunk/Source/WebCore/html/InputType.cpp

    r141086 r141195  
    740740}
    741741
     742bool InputType::shouldApplyLocaleDirection() const
     743{
     744    return false;
     745}
     746
    742747bool InputType::shouldResetOnDocumentActivation()
    743748{
  • trunk/Source/WebCore/html/InputType.h

    r141086 r141195  
    262262    virtual bool storesValueSeparateFromAttribute();
    263263    virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior);
     264    virtual bool shouldApplyLocaleDirection() const;
    264265    virtual bool shouldResetOnDocumentActivation();
    265266    virtual bool shouldRespectListAttribute();
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp

    r139865 r141195  
    369369    }
    370370    element->appendChild(Text::create(m_editElement.document(), text));
    371     m_editElement.appendChild(element);
     371    m_editElement.fieldsWrapperElement()->appendChild(element);
    372372}
    373373
     
    412412}
    413413
     414inline Element* DateTimeEditElement::fieldsWrapperElement() const
     415{
     416    ASSERT(firstChild());
     417    return toElement(firstChild());
     418}
     419
    414420void DateTimeEditElement::addField(PassRefPtr<DateTimeFieldElement> field)
    415421{
     
    417423        return;
    418424    m_fields.append(field.get());
    419     appendChild(field);
     425    fieldsWrapperElement()->appendChild(field);
    420426}
    421427
     
    448454    RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
    449455    float width = 0;
    450     for (Node* child = firstChild(); child; child = child->nextSibling()) {
     456    for (Node* child = fieldsWrapperElement()->firstChild(); child; child = child->nextSibling()) {
    451457        if (!child->isElementNode())
    452458            continue;
     
    462468        }
    463469    }
    464     style->setMinWidth(Length(ceilf(width), Fixed));
     470    style->setWidth(Length(ceilf(width), Fixed));
    465471    return style.release();
    466472}
     
    580586void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const DateComponents& dateValue)
    581587{
     588    DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-edit-fields-wrapper", AtomicString::ConstructFromLiteral));
     589    if (!firstChild()) {
     590        RefPtr<HTMLDivElement> element = HTMLDivElement::create(document());
     591        element->setPseudo(fieldsWrapperPseudoId);
     592        appendChild(element.get());
     593    }
     594    Element* fieldsWrapper = fieldsWrapperElement();
     595
    582596    size_t focusedFieldIndex = this->focusedFieldIndex();
    583597    DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex);
     
    585599
    586600    DateTimeEditBuilder builder(*this, layoutParameters, dateValue);
    587     Node* lastChildToBeRemoved = lastChild();
     601    Node* lastChildToBeRemoved = fieldsWrapper->lastChild();
    588602    if (!builder.build(layoutParameters.dateTimeFormat) || m_fields.isEmpty()) {
    589         lastChildToBeRemoved = lastChild();
     603        lastChildToBeRemoved = fieldsWrapper->lastChild();
    590604        builder.build(layoutParameters.fallbackDateTimeFormat);
    591605    }
     
    603617
    604618    if (lastChildToBeRemoved) {
    605         for (Node* childNode = firstChild(); childNode; childNode = firstChild()) {
    606             removeChild(childNode);
     619        for (Node* childNode = fieldsWrapper->firstChild(); childNode; childNode = fieldsWrapper->firstChild()) {
     620            fieldsWrapper->removeChild(childNode);
    607621            if (childNode == lastChildToBeRemoved)
    608622                break;
    609623        }
     624        setNeedsStyleRecalc();
    610625    }
    611626}
  • trunk/Source/WebCore/html/shadow/DateTimeEditElement.h

    r138254 r141195  
    8888    virtual void defaultEventHandler(Event*) OVERRIDE;
    8989    void disabledStateChanged();
     90    Element* fieldsWrapperElement() const;
    9091    void focusIfNoFocus();
    9192    void focusByOwner();
Note: See TracChangeset for help on using the changeset viewer.