Title: [141195] trunk
Revision
141195
Author
[email protected]
Date
2013-01-29 18:05:22 -0800 (Tue, 29 Jan 2013)

Log 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).

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141194 => 141195)


--- trunk/LayoutTests/ChangeLog	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/LayoutTests/ChangeLog	2013-01-30 02:05:22 UTC (rev 141195)
@@ -1,3 +1,28 @@
+2013-01-29  Kent Tamura  <[email protected]>
+
+        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.
+
+        * 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).
+
 2013-01-29  Roger Fong  <[email protected]>
 
         Unreviewed. More Windows7 gardening.

Modified: trunk/LayoutTests/fast/forms/date/date-appearance-basic-expected.txt (141194 => 141195)


--- trunk/LayoutTests/fast/forms/date/date-appearance-basic-expected.txt	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/LayoutTests/fast/forms/date/date-appearance-basic-expected.txt	2013-01-30 02:05:22 UTC (rev 141195)
@@ -7,6 +7,6 @@
 text-transform: 
 background, color: 
 font-size, font-weight: 
-font-size with fixed input width: 
-Fixed input height: 
+font-size with fixed input width:   
+Fixed input height:   
 -webkit-appearance:none: 

Modified: trunk/LayoutTests/fast/forms/date/date-appearance-basic.html (141194 => 141195)


--- trunk/LayoutTests/fast/forms/date/date-appearance-basic.html	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/LayoutTests/fast/forms/date/date-appearance-basic.html	2013-01-30 02:05:22 UTC (rev 141195)
@@ -17,8 +17,10 @@
     <li>text-transform: <input type="date" value="2012-10-05" style="text-transform: lowercase;"></li>
     <li>background, color: <input type="date" value="2012-10-05" style="border: 0px; background: green; color: yellow;"></li>
     <li>font-size, font-weight: <input type="date" value="2012-10-05" style="font-size: 20pt; font-weight: bold;"></li>
-    <li>font-size with fixed input width: <input type="date" value="2012-10-05" style="font-size: 20pt; width: 14em;"></li>
-    <li>Fixed input height: <input type="date" value="2012-10-05" style="height: 4em;"></li>
+    <li>font-size with fixed input width: <input type="date" value="2012-10-05" style="font-size: 20pt; width: 14em;">
+      <input type="date" value="99999-12-31" style="font-size: 20pt; width: 5em;"></li>
+    <li>Fixed input height: <input type="date" value="2012-10-05" style="height: 4em;">
+      <input type="date" value="2013-01-28" style="font-size: 20px; height: 10px;"></li>
     <li>-webkit-appearance:none: <input type="date" value="2012-10-05" style="-webkit-appearance: none;"></li>
 </ul>
 </body>

Modified: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html (141194 => 141195)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-focus-style.html	2013-01-30 02:05:22 UTC (rev 141195)
@@ -29,7 +29,7 @@
 
 testInput.focus();
 var shadowRoot = internals.oldestShadowRoot(testInput);
-var fields = getElementByPseudoId(shadowRoot, "-webkit-datetime-edit").childNodes;
+var fields = getElementByPseudoId(shadowRoot, "-webkit-datetime-edit-fields-wrapper").childNodes;
 for (var index = 0; index < fields.length; ++index) {
     var field = fields[index];
     if (field.nodeType != 1)

Added: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt (0 => 141195)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt	2013-01-30 02:05:22 UTC (rev 141195)
@@ -0,0 +1,10 @@
+Check if changing focus in a multiple fields input scrolls the content.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS initialScrollLeft < container.scrollLeft is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Property changes on: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html (0 => 141195)


--- trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html	2013-01-30 02:05:22 UTC (rev 141195)
@@ -0,0 +1,20 @@
+<!DOCTYPE>
+<body>
+<script src=""
+<script src=""
+
+<input id="time1" type="time" style="font-size:20px; width:40px;">
+
+<script>
+description('Check if changing focus in a multiple fields input scrolls the content.');
+if (!window.eventSender || !window.internals)
+    debug('This test rquires DRT/WRT.');
+var time1 = $('time1');
+time1.focus();
+var container = getElementByPseudoId(internals.oldestShadowRoot(time1), '-webkit-datetime-edit');
+var initialScrollLeft = container.scrollLeft;
+eventSender.keyDown('\t');
+shouldBeTrue('initialScrollLeft < container.scrollLeft');
+</script>
+<script src=""
+</body>
Property changes on: trunk/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-narrow-width-scroll.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (141194 => 141195)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2013-01-30 02:05:22 UTC (rev 141195)
@@ -4306,6 +4306,23 @@
 webkit.org/b/105574 platform/chromium/fast/forms/suggestion-picker/month-suggestion-picker-appearance-with-scroll-bar.html [ ImageOnlyFailure ]
 webkit.org/b/105574 platform/chromium/fast/forms/suggestion-picker/week-suggestion-picker-appearance-with-scroll-bar.html [ ImageOnlyFailure ]
 
+# Needs rebaseline.
+webkit.org/b/108069 fast/forms/date/date-appearance-basic.html [ ImageOnlyFailure ]
+webkit.org/b/108069 fast/forms/date/date-appearance-pseudo-elements.html [ ImageOnlyFailure ]
+webkit.org/b/108069 fast/forms/month/month-appearance-pseudo-elements.html [ ImageOnlyFailure ]
+webkit.org/b/108069 fast/forms/time/time-appearance-pseudo-elements.html [ ImageOnlyFailure ]
+webkit.org/b/108069 fast/forms/week/week-appearance-pseudo-elements.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetime-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetime-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/datetimelocal-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/month-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-locale-hebrew.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-appearance-with-scroll-bar.html [ ImageOnlyFailure ]
+webkit.org/b/108069 platform/chromium/fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl.html [ ImageOnlyFailure ]
+
 webkit.org/b/97333 fast/canvas/canvas-path-object.html [ Failure ]
 webkit.org/b/97333 platform/chromium/virtual/gpu/fast/canvas/canvas-path-object.html [ Failure ]
 

Modified: trunk/LayoutTests/platform/chromium-mac/fast/forms/date/date-appearance-basic-expected.png


(Binary files differ)

Modified: trunk/Source/WebCore/ChangeLog (141194 => 141195)


--- trunk/Source/WebCore/ChangeLog	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/ChangeLog	2013-01-30 02:05:22 UTC (rev 141195)
@@ -1,3 +1,85 @@
+2013-01-29  Kent Tamura  <[email protected]>
+
+        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.
+
+        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)
+
 2013-01-29  Tom Sepez  <[email protected]>
 
         [v8] Enable binding integrity on linux

Modified: trunk/Source/WebCore/css/html.css (141194 => 141195)


--- trunk/Source/WebCore/css/html.css	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/css/html.css	2013-01-30 02:05:22 UTC (rev 141195)
@@ -486,54 +486,60 @@
 #if defined(ENABLE_INPUT_MULTIPLE_FIELDS_UI) && ENABLE_INPUT_MULTIPLE_FIELDS_UI
 #if defined(ENABLE_INPUT_TYPE_DATE) && ENABLE_INPUT_TYPE_DATE
 input[type="date"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
 #endif
 #if defined(ENABLE_INPUT_TYPE_DATETIME) && ENABLE_INPUT_TYPE_DATETIME
 input[type="datetime"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
 #endif
 #if defined(ENABLE_INPUT_TYPE_DATETIMELOCAL) && ENABLE_INPUT_TYPE_DATETIMELOCAL
 input[type="datetime-local"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
 #endif
 #if defined(ENABLE_INPUT_TYPE_MONTH) && ENABLE_INPUT_TYPE_MONTH
 input[type="month"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
 #endif
 #if defined(ENABLE_INPUT_TYPE_TIME) && ENABLE_INPUT_TYPE_TIME
 input[type="time"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
 #endif
 #if defined(ENABLE_INPUT_TYPE_WEEK) && ENABLE_INPUT_TYPE_WEEK
 input[type="week"] {
-    -webkit-align-items: stretch;
+    -webkit-align-items: center;
     display: -webkit-inline-flex;
     font-family: monospace;
+    overflow: hidden;
     padding: 0;
     -webkit-padding-start: 1px;
 }
@@ -543,9 +549,17 @@
     -webkit-flex: 1;
     -webkit-user-modify: read-only !important;
     display: inline-block;
-    white-space: pre;
+    min-width: 0;
+    overflow: hidden;
 }
 
+input::-webkit-datetime-edit-fields-wrapper {
+    -webkit-user-modify: read-only !important;
+    display: inline-block;
+    padding: 1px 0;
+    white-space: nowrap;
+}
+
 /* If you update padding, border, or margin in the following ruleset, update
    DateTimeFieldElement::maximumWidth too. */
 input::-webkit-datetime-edit-ampm-field,
@@ -599,12 +613,6 @@
     font: inherit !important;
 }
 
-input::-webkit-date-and-time-container {
-    -webkit-align-items: center;
-    -webkit-flex: 1;
-    display: -webkit-inline-flex;
-}
-
 input[type="date"]::-webkit-inner-spin-button,
 input[type="datetime"]::-webkit-inner-spin-button,
 input[type="datetime-local"]::-webkit-inner-spin-button,

Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp (141194 => 141195)


--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.cpp	2013-01-30 02:05:22 UTC (rev 141195)
@@ -190,14 +190,10 @@
 
 void BaseMultipleFieldsDateAndTimeInputType::createShadowSubtree()
 {
-    DEFINE_STATIC_LOCAL(AtomicString, dateAndTimeInputContainerPseudoId, ("-webkit-date-and-time-container", AtomicString::ConstructFromLiteral));
-
     ASSERT(element()->shadow());
 
     Document* document = element()->document();
-    RefPtr<HTMLDivElement> container = HTMLDivElement::create(document);
-    element()->userAgentShadowRoot()->appendChild(container);
-    container->setPseudo(dateAndTimeInputContainerPseudoId);
+    ContainerNode* container = element()->userAgentShadowRoot();
 
     RefPtr<DateTimeEditElement> dateTimeEditElement(DateTimeEditElement::create(document, *this));
     m_dateTimeEditElement = dateTimeEditElement.get();
@@ -340,6 +336,11 @@
     }
 }
 
+bool BaseMultipleFieldsDateAndTimeInputType::shouldApplyLocaleDirection() const
+{
+    return true;
+}
+
 bool BaseMultipleFieldsDateAndTimeInputType::shouldUseInputMethod() const
 {
     return false;
@@ -355,10 +356,6 @@
     if (!m_dateTimeEditElement)
         return;
 
-    AtomicString direction = element()->locale().isRTL() ? AtomicString("rtl", AtomicString::ConstructFromLiteral) : AtomicString("ltr", AtomicString::ConstructFromLiteral);
-    if (Element* container = ElementTraversal::firstWithin(element()->userAgentShadowRoot()))
-        container->setAttribute(HTMLNames::dirAttr, direction);
-
     DateTimeEditElement::LayoutParameters layoutParameters(element()->locale(), createStepRange(AnyIsDefaultStep));
 
     DateComponents date;

Modified: trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h (141194 => 141195)


--- trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/BaseMultipleFieldsDateAndTimeInputType.h	2013-01-30 02:05:22 UTC (rev 141195)
@@ -93,6 +93,7 @@
     virtual void restoreFormControlState(const FormControlState&) OVERRIDE FINAL;
     virtual FormControlState saveFormControlState() const OVERRIDE FINAL;
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE FINAL;
+    virtual bool shouldApplyLocaleDirection() const OVERRIDE;
     virtual bool shouldUseInputMethod() const OVERRIDE FINAL;
     virtual void stepAttributeChanged() OVERRIDE FINAL;
     virtual void updateInnerTextValue() OVERRIDE FINAL;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (141194 => 141195)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2013-01-30 02:05:22 UTC (rev 141195)
@@ -57,6 +57,7 @@
 #include "Language.h"
 #include "LocalizedStrings.h"
 #include "MouseEvent.h"
+#include "PlatformLocale.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
@@ -64,6 +65,7 @@
 #include "SearchInputType.h"
 #include "ShadowRoot.h"
 #include "ScriptEventListener.h"
+#include "StyleResolver.h"
 #include <wtf/MathExtras.h>
 #include <wtf/StdLibExtras.h>
 
@@ -133,6 +135,9 @@
     , m_inputType(InputType::createText(this))
 {
     ASSERT(hasTagName(inputTag) || hasTagName(isindexTag));
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    setHasCustomCallbacks();
+#endif
 }
 
 PassRefPtr<HTMLInputElement> HTMLInputElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form, bool createdByParser)
@@ -1964,4 +1969,19 @@
 #endif
 }
 
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+PassRefPtr<RenderStyle> HTMLInputElement::customStyleForRenderer()
+{
+    RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
+    if (!m_inputType->shouldApplyLocaleDirection())
+        return originalStyle.release();
+    TextDirection contentDirection = locale().isRTL() ? RTL : LTR;
+    if (originalStyle->direction() == contentDirection)
+        return originalStyle.release();
+    RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
+    style->setDirection(contentDirection);
+    return style.release();
+}
+#endif
+
 } // namespace

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (141194 => 141195)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2013-01-30 02:05:22 UTC (rev 141195)
@@ -402,6 +402,9 @@
     CheckedRadioButtons* checkedRadioButtons() const;
     void addToRadioButtonGroup();
     void removeFromRadioButtonGroup();
+#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
+    virtual PassRefPtr<RenderStyle> customStyleForRenderer() OVERRIDE;
+#endif
 
     AtomicString m_name;
     String m_valueIfDirty;

Modified: trunk/Source/WebCore/html/InputType.cpp (141194 => 141195)


--- trunk/Source/WebCore/html/InputType.cpp	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/InputType.cpp	2013-01-30 02:05:22 UTC (rev 141195)
@@ -739,6 +739,11 @@
     return 0;
 }
 
+bool InputType::shouldApplyLocaleDirection() const
+{
+    return false;
+}
+
 bool InputType::shouldResetOnDocumentActivation()
 {
     return false;

Modified: trunk/Source/WebCore/html/InputType.h (141194 => 141195)


--- trunk/Source/WebCore/html/InputType.h	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/InputType.h	2013-01-30 02:05:22 UTC (rev 141195)
@@ -261,6 +261,7 @@
     virtual bool canSetValue(const String&);
     virtual bool storesValueSeparateFromAttribute();
     virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior);
+    virtual bool shouldApplyLocaleDirection() const;
     virtual bool shouldResetOnDocumentActivation();
     virtual bool shouldRespectListAttribute();
     virtual bool shouldRespectSpeechAttribute();

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp (141194 => 141195)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.cpp	2013-01-30 02:05:22 UTC (rev 141195)
@@ -368,7 +368,7 @@
             element->appendChild(Text::create(m_editElement.document(), String(&rightToLeftMark, 1)));
     }
     element->appendChild(Text::create(m_editElement.document(), text));
-    m_editElement.appendChild(element);
+    m_editElement.fieldsWrapperElement()->appendChild(element);
 }
 
 DateTimeNumericFieldElement::Parameters DateTimeEditBuilder::createNumericFieldParameters(const Decimal& msPerFieldUnit, const Decimal& msPerFieldSize) const
@@ -411,12 +411,18 @@
         m_fields[fieldIndex]->removeEventHandler();
 }
 
+inline Element* DateTimeEditElement::fieldsWrapperElement() const
+{
+    ASSERT(firstChild());
+    return toElement(firstChild());
+}
+
 void DateTimeEditElement::addField(PassRefPtr<DateTimeFieldElement> field)
 {
     if (m_fields.size() == m_fields.capacity())
         return;
     m_fields.append(field.get());
-    appendChild(field);
+    fieldsWrapperElement()->appendChild(field);
 }
 
 bool DateTimeEditElement::anyEditableFieldsHaveValues() const
@@ -447,7 +453,7 @@
     RefPtr<RenderStyle> originalStyle = document()->styleResolver()->styleForElement(this);
     RefPtr<RenderStyle> style = RenderStyle::clone(originalStyle.get());
     float width = 0;
-    for (Node* child = firstChild(); child; child = child->nextSibling()) {
+    for (Node* child = fieldsWrapperElement()->firstChild(); child; child = child->nextSibling()) {
         if (!child->isElementNode())
             continue;
         Element* childElement = toElement(child);
@@ -461,7 +467,7 @@
             width += style->font().width(childElement->textContent());
         }
     }
-    style->setMinWidth(Length(ceilf(width), Fixed));
+    style->setWidth(Length(ceilf(width), Fixed));
     return style.release();
 }
 
@@ -579,14 +585,22 @@
 
 void DateTimeEditElement::layout(const LayoutParameters& layoutParameters, const DateComponents& dateValue)
 {
+    DEFINE_STATIC_LOCAL(AtomicString, fieldsWrapperPseudoId, ("-webkit-datetime-edit-fields-wrapper", AtomicString::ConstructFromLiteral));
+    if (!firstChild()) {
+        RefPtr<HTMLDivElement> element = HTMLDivElement::create(document());
+        element->setPseudo(fieldsWrapperPseudoId);
+        appendChild(element.get());
+    }
+    Element* fieldsWrapper = fieldsWrapperElement();
+
     size_t focusedFieldIndex = this->focusedFieldIndex();
     DateTimeFieldElement* const focusedField = fieldAt(focusedFieldIndex);
     const AtomicString focusedFieldId = focusedField ? focusedField->shadowPseudoId() : nullAtom;
 
     DateTimeEditBuilder builder(*this, layoutParameters, dateValue);
-    Node* lastChildToBeRemoved = lastChild();
+    Node* lastChildToBeRemoved = fieldsWrapper->lastChild();
     if (!builder.build(layoutParameters.dateTimeFormat) || m_fields.isEmpty()) {
-        lastChildToBeRemoved = lastChild();
+        lastChildToBeRemoved = fieldsWrapper->lastChild();
         builder.build(layoutParameters.fallbackDateTimeFormat);
     }
 
@@ -602,11 +616,12 @@
     }
 
     if (lastChildToBeRemoved) {
-        for (Node* childNode = firstChild(); childNode; childNode = firstChild()) {
-            removeChild(childNode);
+        for (Node* childNode = fieldsWrapper->firstChild(); childNode; childNode = fieldsWrapper->firstChild()) {
+            fieldsWrapper->removeChild(childNode);
             if (childNode == lastChildToBeRemoved)
                 break;
         }
+        setNeedsStyleRecalc();
     }
 }
 

Modified: trunk/Source/WebCore/html/shadow/DateTimeEditElement.h (141194 => 141195)


--- trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2013-01-30 01:51:10 UTC (rev 141194)
+++ trunk/Source/WebCore/html/shadow/DateTimeEditElement.h	2013-01-30 02:05:22 UTC (rev 141195)
@@ -87,6 +87,7 @@
     void blurByOwner();
     virtual void defaultEventHandler(Event*) OVERRIDE;
     void disabledStateChanged();
+    Element* fieldsWrapperElement() const;
     void focusIfNoFocus();
     void focusByOwner();
     bool hasFocusedField();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to