Title: [197401] trunk/Source/WebCore
Revision
197401
Author
[email protected]
Date
2016-03-01 09:33:47 -0800 (Tue, 01 Mar 2016)

Log Message

Text control shadow element style shouldn't depend on renderers
https://bugs.webkit.org/show_bug.cgi?id=154855

Reviewed by Andreas Kling.

Currently the code for computing style for text control shadow elements lives in render tree.
Style is the input for building a render tree and should be computable without having one.

Fix by moving virtual createInnerTextStyle() from RenderTextControl hierarchy to the DOM side
HTMLTextFormControlElement hierarchy.

* dom/Element.cpp:
(WebCore::Element::didDetachRenderers):
(WebCore::Element::customStyleForRenderer):

    Also pass shadow host style as it is needed for text controls.

* dom/Element.h:
* dom/PseudoElement.cpp:
(WebCore::PseudoElement::clearHostElement):
(WebCore::PseudoElement::customStyleForRenderer):
* dom/PseudoElement.h:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setRangeText):
(WebCore::HTMLInputElement::createInnerTextStyle):
(WebCore::HTMLInputElement::setupDateTimeChooserParameters):
* html/HTMLInputElement.h:
* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::willRespondToMouseClickEvents):
(WebCore::HTMLTextAreaElement::createInnerTextStyle):
* html/HTMLTextAreaElement.h:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::directionForFormData):
(WebCore::HTMLTextFormControlElement::adjustInnerTextStyle):
* html/HTMLTextFormControlElement.h:
(WebCore::HTMLTextFormControlElement::cachedSelectionDirection):
* html/shadow/TextControlInnerElements.cpp:
(WebCore::TextControlInnerElement::create):
(WebCore::TextControlInnerElement::customStyleForRenderer):
(WebCore::TextControlInnerTextElement::renderer):
(WebCore::TextControlInnerTextElement::customStyleForRenderer):
* html/shadow/TextControlInnerElements.h:
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::styleDidChange):
(WebCore::RenderTextControl::textBlockLogicalHeight):
(WebCore::RenderTextControl::adjustInnerTextStyle): Deleted.
* rendering/RenderTextControl.h:
* rendering/RenderTextControlMultiLine.cpp:
(WebCore::RenderTextControlMultiLine::baselinePosition):
(WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
(WebCore::RenderTextControlMultiLine::createInnerTextStyle): Deleted.

    createInnerTextStyle moves to HTMLTextAreaElement::createInnerTextStyle

* rendering/RenderTextControlMultiLine.h:
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):

    Remove m_desiredInnerTextLogicalHeight cache. It doesn't work, it is never valid when hit.

(WebCore::RenderTextControlSingleLine::layout):
(WebCore::RenderTextControlSingleLine::styleDidChange):
(WebCore::RenderTextControlSingleLine::computeControlLogicalHeight):
(WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
(WebCore::RenderTextControlSingleLine::createInnerTextStyle): Deleted.
(WebCore::RenderTextControlSingleLine::createInnerBlockStyle): Deleted.

    - createInnerTextStyle moves to HTMLInputElement::createInnerTextStyle
    - createInnerBlockStyle moves to TextControlInnerElement::customStyleForRenderer

* rendering/RenderTextControlSingleLine.h:
(WebCore::RenderTextControlSingleLine::centerContainerIfNeeded):
(WebCore::RenderTextControlSingleLine::containerElement):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::styleForElement):
* svg/SVGElement.cpp:
(WebCore::SVGElement::synchronizeSystemLanguage):
(WebCore::SVGElement::customStyleForRenderer):
* svg/SVGElement.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (197400 => 197401)


--- trunk/Source/WebCore/ChangeLog	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/ChangeLog	2016-03-01 17:33:47 UTC (rev 197401)
@@ -1,3 +1,85 @@
+2016-03-01  Antti Koivisto  <[email protected]>
+
+        Text control shadow element style shouldn't depend on renderers
+        https://bugs.webkit.org/show_bug.cgi?id=154855
+
+        Reviewed by Andreas Kling.
+
+        Currently the code for computing style for text control shadow elements lives in render tree.
+        Style is the input for building a render tree and should be computable without having one.
+
+        Fix by moving virtual createInnerTextStyle() from RenderTextControl hierarchy to the DOM side
+        HTMLTextFormControlElement hierarchy.
+
+        * dom/Element.cpp:
+        (WebCore::Element::didDetachRenderers):
+        (WebCore::Element::customStyleForRenderer):
+
+            Also pass shadow host style as it is needed for text controls.
+
+        * dom/Element.h:
+        * dom/PseudoElement.cpp:
+        (WebCore::PseudoElement::clearHostElement):
+        (WebCore::PseudoElement::customStyleForRenderer):
+        * dom/PseudoElement.h:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setRangeText):
+        (WebCore::HTMLInputElement::createInnerTextStyle):
+        (WebCore::HTMLInputElement::setupDateTimeChooserParameters):
+        * html/HTMLInputElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::willRespondToMouseClickEvents):
+        (WebCore::HTMLTextAreaElement::createInnerTextStyle):
+        * html/HTMLTextAreaElement.h:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::directionForFormData):
+        (WebCore::HTMLTextFormControlElement::adjustInnerTextStyle):
+        * html/HTMLTextFormControlElement.h:
+        (WebCore::HTMLTextFormControlElement::cachedSelectionDirection):
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::TextControlInnerElement::create):
+        (WebCore::TextControlInnerElement::customStyleForRenderer):
+        (WebCore::TextControlInnerTextElement::renderer):
+        (WebCore::TextControlInnerTextElement::customStyleForRenderer):
+        * html/shadow/TextControlInnerElements.h:
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::styleDidChange):
+        (WebCore::RenderTextControl::textBlockLogicalHeight):
+        (WebCore::RenderTextControl::adjustInnerTextStyle): Deleted.
+        * rendering/RenderTextControl.h:
+        * rendering/RenderTextControlMultiLine.cpp:
+        (WebCore::RenderTextControlMultiLine::baselinePosition):
+        (WebCore::RenderTextControlMultiLine::layoutSpecialExcludedChild):
+        (WebCore::RenderTextControlMultiLine::createInnerTextStyle): Deleted.
+
+            createInnerTextStyle moves to HTMLTextAreaElement::createInnerTextStyle
+
+        * rendering/RenderTextControlMultiLine.h:
+        * rendering/RenderTextControlSingleLine.cpp:
+        (WebCore::RenderTextControlSingleLine::RenderTextControlSingleLine):
+
+            Remove m_desiredInnerTextLogicalHeight cache. It doesn't work, it is never valid when hit.
+
+        (WebCore::RenderTextControlSingleLine::layout):
+        (WebCore::RenderTextControlSingleLine::styleDidChange):
+        (WebCore::RenderTextControlSingleLine::computeControlLogicalHeight):
+        (WebCore::RenderTextControlSingleLine::textShouldBeTruncated):
+        (WebCore::RenderTextControlSingleLine::createInnerTextStyle): Deleted.
+        (WebCore::RenderTextControlSingleLine::createInnerBlockStyle): Deleted.
+
+            - createInnerTextStyle moves to HTMLInputElement::createInnerTextStyle
+            - createInnerBlockStyle moves to TextControlInnerElement::customStyleForRenderer
+
+        * rendering/RenderTextControlSingleLine.h:
+        (WebCore::RenderTextControlSingleLine::centerContainerIfNeeded):
+        (WebCore::RenderTextControlSingleLine::containerElement):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::styleForElement):
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::synchronizeSystemLanguage):
+        (WebCore::SVGElement::customStyleForRenderer):
+        * svg/SVGElement.h:
+
 2016-03-01  Manuel Rego Casasnovas  <[email protected]>
 
         [css-grid] Get rid of GridResolvedPosition

Modified: trunk/Source/WebCore/dom/Element.cpp (197400 => 197401)


--- trunk/Source/WebCore/dom/Element.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/dom/Element.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -3265,7 +3265,7 @@
     ASSERT(hasCustomStyleResolveCallbacks());
 }
 
-RefPtr<RenderStyle> Element::customStyleForRenderer(RenderStyle&)
+RefPtr<RenderStyle> Element::customStyleForRenderer(RenderStyle&, RenderStyle*)
 {
     ASSERT(hasCustomStyleResolveCallbacks());
     return nullptr;

Modified: trunk/Source/WebCore/dom/Element.h (197400 => 197401)


--- trunk/Source/WebCore/dom/Element.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/dom/Element.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -476,7 +476,7 @@
     virtual void didAttachRenderers();
     virtual void willDetachRenderers();
     virtual void didDetachRenderers();
-    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle);
+    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle);
 
     LayoutRect absoluteEventHandlerBounds(bool& includesFixedPositionElements) override;
 

Modified: trunk/Source/WebCore/dom/PseudoElement.cpp (197400 => 197401)


--- trunk/Source/WebCore/dom/PseudoElement.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/dom/PseudoElement.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -76,7 +76,7 @@
     m_hostElement = nullptr;
 }
 
-RefPtr<RenderStyle> PseudoElement::customStyleForRenderer(RenderStyle& parentStyle)
+RefPtr<RenderStyle> PseudoElement::customStyleForRenderer(RenderStyle& parentStyle, RenderStyle*)
 {
     return m_hostElement->renderer()->getCachedPseudoStyle(m_pseudoId, &parentStyle);
 }

Modified: trunk/Source/WebCore/dom/PseudoElement.h (197400 => 197401)


--- trunk/Source/WebCore/dom/PseudoElement.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/dom/PseudoElement.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -45,7 +45,7 @@
     Element* hostElement() const { return m_hostElement; }
     void clearHostElement();
 
-    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle) override;
+    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) override;
     virtual void didAttachRenderers() override;
     virtual void didRecalcStyle(Style::Change) override;
     virtual bool rendererIsNeeded(const RenderStyle&) override;

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -1867,6 +1867,29 @@
     HTMLTextFormControlElement::setRangeText(replacement, start, end, selectionMode, ec);
 }
 
+Ref<RenderStyle> HTMLInputElement::createInnerTextStyle(const RenderStyle& style) const
+{
+    auto textBlockStyle = RenderStyle::create();
+    textBlockStyle.get().inheritFrom(&style);
+    adjustInnerTextStyle(style, textBlockStyle.get());
+
+    textBlockStyle.get().setWhiteSpace(PRE);
+    textBlockStyle.get().setOverflowWrap(NormalOverflowWrap);
+    textBlockStyle.get().setOverflowX(OHIDDEN);
+    textBlockStyle.get().setOverflowY(OHIDDEN);
+
+    bool textShouldBeTruncated = document().focusedElement() != this && style.textOverflow() == TextOverflowEllipsis;
+    textBlockStyle.get().setTextOverflow(textShouldBeTruncated ? TextOverflowEllipsis : TextOverflowClip);
+
+    // Do not allow line-height to be smaller than our default.
+    if (textBlockStyle.get().fontMetrics().lineSpacing() > style.computedLineHeight())
+        textBlockStyle.get().setLineHeight(RenderStyle::initialLineHeight());
+
+    textBlockStyle.get().setDisplay(BLOCK);
+
+    return textBlockStyle;
+}
+
 #if ENABLE(DATE_AND_TIME_INPUT_TYPES)
 bool HTMLInputElement::setupDateTimeChooserParameters(DateTimeChooserParameters& parameters)
 {

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -140,7 +140,10 @@
 #endif
 
     HTMLElement* containerElement() const;
+    
     virtual TextControlInnerTextElement* innerTextElement() const override final;
+    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle&) const override;
+
     HTMLElement* innerBlockElement() const;
     HTMLElement* innerSpinButtonElement() const;
     HTMLElement* capsLockIndicatorElement() const;

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -540,4 +540,20 @@
     return !isDisabledFormControl();
 }
 
+Ref<RenderStyle> HTMLTextAreaElement::createInnerTextStyle(const RenderStyle& style) const
+{
+    auto textBlockStyle = RenderStyle::create();
+    textBlockStyle.get().inheritFrom(&style);
+    adjustInnerTextStyle(style, textBlockStyle.get());
+    textBlockStyle.get().setDisplay(BLOCK);
+
+#if PLATFORM(IOS)
+    // We're adding three extra pixels of padding to line textareas up with text fields.  
+    textBlockStyle.get().setPaddingLeft(Length(3, Fixed));
+    textBlockStyle.get().setPaddingRight(Length(3, Fixed));
+#endif
+
+    return textBlockStyle;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -54,6 +54,7 @@
     bool isValidValue(const String&) const;
     
     virtual TextControlInnerTextElement* innerTextElement() const override;
+    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle&) const override;
 
     void rendererWillBeDestroyed();
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -26,6 +26,7 @@
 #include "HTMLTextFormControlElement.h"
 
 #include "AXObjectCache.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "ChromeClient.h"
 #include "Document.h"
 #include "Event.h"
@@ -758,4 +759,48 @@
     return "ltr";
 }
 
+void HTMLTextFormControlElement::adjustInnerTextStyle(const RenderStyle& parentStyle, RenderStyle& textBlockStyle) const
+{
+    // The inner block, if present, always has its direction set to LTR,
+    // so we need to inherit the direction and unicode-bidi style from the element.
+    textBlockStyle.setDirection(parentStyle.direction());
+    textBlockStyle.setUnicodeBidi(parentStyle.unicodeBidi());
+
+    if (HTMLElement* innerText = innerTextElement()) {
+        if (const StyleProperties* properties = innerText->presentationAttributeStyle()) {
+            RefPtr<CSSValue> value = properties->getPropertyCSSValue(CSSPropertyWebkitUserModify);
+            if (is<CSSPrimitiveValue>(value.get()))
+                textBlockStyle.setUserModify(downcast<CSSPrimitiveValue>(*value));
+        }
+    }
+
+    if (isDisabledFormControl())
+        textBlockStyle.setColor(document().page()->theme().disabledTextColor(textBlockStyle.visitedDependentColor(CSSPropertyColor), parentStyle.visitedDependentColor(CSSPropertyBackgroundColor)));
+#if PLATFORM(IOS)
+    if (textBlockStyle.textSecurity() != TSNONE && !textBlockStyle.isLeftToRightDirection()) {
+        // Preserve the alignment but force the direction to LTR so that the last-typed, unmasked character
+        // (which cannot have RTL directionality) will appear to the right of the masked characters. See <rdar://problem/7024375>.
+        
+        switch (textBlockStyle.textAlign()) {
+        case TASTART:
+        case JUSTIFY:
+            textBlockStyle.setTextAlign(RIGHT);
+            break;
+        case TAEND:
+            textBlockStyle.setTextAlign(LEFT);
+            break;
+        case LEFT:
+        case RIGHT:
+        case CENTER:
+        case WEBKIT_LEFT:
+        case WEBKIT_RIGHT:
+        case WEBKIT_CENTER:
+            break;
+        }
+
+        textBlockStyle.setDirection(LTR);
+    }
+#endif
+}
+
 } // namespace Webcore

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (197400 => 197401)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -79,6 +79,7 @@
     virtual String value() const = 0;
 
     virtual TextControlInnerTextElement* innerTextElement() const = 0;
+    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle&) const = 0;
 
     void selectionChanged(bool shouldFireSelectEvent);
     WEBCORE_EXPORT bool lastChangeWasUserEdit() const;
@@ -120,6 +121,8 @@
 
     String valueWithHardLineBreaks() const;
 
+    void adjustInnerTextStyle(const RenderStyle& parentStyle, RenderStyle& textBlockStyle) const;
+
 private:
     TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); }
 

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (197400 => 197401)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -73,10 +73,21 @@
     return adoptRef(*new TextControlInnerElement(document));
 }
 
-RefPtr<RenderStyle> TextControlInnerElement::customStyleForRenderer(RenderStyle&)
+RefPtr<RenderStyle> TextControlInnerElement::customStyleForRenderer(RenderStyle&, RenderStyle* shadowHostStyle)
 {
-    RenderTextControlSingleLine& parentRenderer = downcast<RenderTextControlSingleLine>(*shadowHost()->renderer());
-    return parentRenderer.createInnerBlockStyle(&parentRenderer.style());
+    auto innerContainerStyle = RenderStyle::create();
+    innerContainerStyle.get().inheritFrom(shadowHostStyle);
+
+    innerContainerStyle.get().setFlexGrow(1);
+    // min-width: 0; is needed for correct shrinking.
+    innerContainerStyle.get().setMinWidth(Length(0, Fixed));
+    innerContainerStyle.get().setDisplay(BLOCK);
+    innerContainerStyle.get().setDirection(LTR);
+
+    // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable.
+    innerContainerStyle.get().setUserModify(READ_ONLY);
+
+    return WTFMove(innerContainerStyle);
 }
 
 // ---------------------------
@@ -121,10 +132,9 @@
     return downcast<RenderTextControlInnerBlock>(HTMLDivElement::renderer());
 }
 
-RefPtr<RenderStyle> TextControlInnerTextElement::customStyleForRenderer(RenderStyle&)
+RefPtr<RenderStyle> TextControlInnerTextElement::customStyleForRenderer(RenderStyle&, RenderStyle* shadowHostStyle)
 {
-    RenderTextControl& parentRenderer = downcast<RenderTextControl>(*shadowHost()->renderer());
-    return parentRenderer.createInnerTextStyle(&parentRenderer.style());
+    return downcast<HTMLTextFormControlElement>(*shadowHost()).createInnerTextStyle(*shadowHostStyle);
 }
 
 // ----------------------------

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (197400 => 197401)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -48,7 +48,7 @@
 
 protected:
     TextControlInnerElement(Document&);
-    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle) override;
+    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) override;
 
 private:
     virtual bool isMouseFocusable() const override { return false; }
@@ -65,7 +65,7 @@
 private:
     TextControlInnerTextElement(Document&);
     virtual RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override;
-    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle) override;
+    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) override;
     virtual bool isMouseFocusable() const override { return false; }
     virtual bool isTextControlInnerTextElement() const override { return true; }
 };

Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControl.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -22,7 +22,6 @@
 #include "config.h"
 #include "RenderTextControl.h"
 
-#include "CSSPrimitiveValueMappings.h"
 #include "HTMLTextFormControlElement.h"
 #include "HitTestResult.h"
 #include "RenderText.h"
@@ -68,56 +67,11 @@
         // Reset them now to avoid getting a spurious layout hint.
         innerTextRenderer->style().setHeight(Length());
         innerTextRenderer->style().setWidth(Length());
-        innerTextRenderer->setStyle(createInnerTextStyle(&style()));
+        innerTextRenderer->setStyle(textFormControlElement().createInnerTextStyle(style()));
     }
     textFormControlElement().updatePlaceholderVisibility();
 }
 
-void RenderTextControl::adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle& textBlockStyle) const
-{
-    // The inner block, if present, always has its direction set to LTR,
-    // so we need to inherit the direction and unicode-bidi style from the element.
-    textBlockStyle.setDirection(style().direction());
-    textBlockStyle.setUnicodeBidi(style().unicodeBidi());
-
-    HTMLTextFormControlElement& control = textFormControlElement();
-    if (HTMLElement* innerText = control.innerTextElement()) {
-        if (const StyleProperties* properties = innerText->presentationAttributeStyle()) {
-            RefPtr<CSSValue> value = properties->getPropertyCSSValue(CSSPropertyWebkitUserModify);
-            if (is<CSSPrimitiveValue>(value.get()))
-                textBlockStyle.setUserModify(downcast<CSSPrimitiveValue>(*value));
-        }
-    }
-
-    if (control.isDisabledFormControl())
-        textBlockStyle.setColor(theme().disabledTextColor(textBlockStyle.visitedDependentColor(CSSPropertyColor), startStyle->visitedDependentColor(CSSPropertyBackgroundColor)));
-#if PLATFORM(IOS)
-    if (textBlockStyle.textSecurity() != TSNONE && !textBlockStyle.isLeftToRightDirection()) {
-        // Preserve the alignment but force the direction to LTR so that the last-typed, unmasked character
-        // (which cannot have RTL directionality) will appear to the right of the masked characters. See <rdar://problem/7024375>.
-        
-        switch (textBlockStyle.textAlign()) {
-        case TASTART:
-        case JUSTIFY:
-            textBlockStyle.setTextAlign(RIGHT);
-            break;
-        case TAEND:
-            textBlockStyle.setTextAlign(LEFT);
-            break;
-        case LEFT:
-        case RIGHT:
-        case CENTER:
-        case WEBKIT_LEFT:
-        case WEBKIT_RIGHT:
-        case WEBKIT_CENTER:
-            break;
-        }
-
-        textBlockStyle.setDirection(LTR);
-    }
-#endif
-}
-
 int RenderTextControl::textBlockLogicalHeight() const
 {
     return logicalHeight() - borderAndPaddingLogicalHeight();

Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControl.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -35,7 +35,6 @@
     virtual ~RenderTextControl();
 
     WEBCORE_EXPORT HTMLTextFormControlElement& textFormControlElement() const;
-    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const = 0;
 
 #if PLATFORM(IOS)
     bool canScroll() const;
@@ -51,7 +50,6 @@
     TextControlInnerTextElement* innerTextElement() const;
 
     int scrollbarThickness() const;
-    void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle& textBlockStyle) const;
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
 

Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -87,22 +87,6 @@
     return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
 }
 
-Ref<RenderStyle> RenderTextControlMultiLine::createInnerTextStyle(const RenderStyle* startStyle) const
-{
-    auto textBlockStyle = RenderStyle::create();
-    textBlockStyle.get().inheritFrom(startStyle);
-    adjustInnerTextStyle(startStyle, textBlockStyle.get());
-    textBlockStyle.get().setDisplay(BLOCK);
-
-#if PLATFORM(IOS)
-    // We're adding three extra pixels of padding to line textareas up with text fields.  
-    textBlockStyle.get().setPaddingLeft(Length(3, Fixed));
-    textBlockStyle.get().setPaddingRight(Length(3, Fixed));
-#endif
-
-    return textBlockStyle;
-}
-
 RenderObject* RenderTextControlMultiLine::layoutSpecialExcludedChild(bool relayoutChildren)
 {
     RenderObject* placeholderRenderer = RenderTextControl::layoutSpecialExcludedChild(relayoutChildren);

Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -47,7 +47,6 @@
     virtual LayoutUnit computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const override;
     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
 
-    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const override;
     virtual RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
 };
 

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -55,7 +55,6 @@
 
 RenderTextControlSingleLine::RenderTextControlSingleLine(HTMLInputElement& element, Ref<RenderStyle>&& style)
     : RenderTextControl(element, WTFMove(style))
-    , m_desiredInnerTextLogicalHeight(-1)
 {
 }
 
@@ -129,8 +128,6 @@
         if (desiredLogicalHeight != innerTextRenderer->logicalHeight())
             setNeedsLayout(MarkOnlyThis);
 
-        m_desiredInnerTextLogicalHeight = desiredLogicalHeight;
-
         innerTextRenderer->style().setLogicalHeight(Length(desiredLogicalHeight, Fixed));
         innerTextRenderer->setNeedsLayout(MarkOnlyThis);
         if (innerBlockRenderer) {
@@ -234,7 +231,6 @@
 
 void RenderTextControlSingleLine::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
-    m_desiredInnerTextLogicalHeight = -1;
     RenderTextControl::styleDidChange(diff, oldStyle);
 
     // We may have set the width and the height in the old style in layout().
@@ -325,46 +321,6 @@
     return lineHeight + nonContentHeight;
 }
 
-Ref<RenderStyle> RenderTextControlSingleLine::createInnerTextStyle(const RenderStyle* startStyle) const
-{
-    auto textBlockStyle = RenderStyle::create();
-    textBlockStyle.get().inheritFrom(startStyle);
-    adjustInnerTextStyle(startStyle, textBlockStyle.get());
-
-    textBlockStyle.get().setWhiteSpace(PRE);
-    textBlockStyle.get().setOverflowWrap(NormalOverflowWrap);
-    textBlockStyle.get().setOverflowX(OHIDDEN);
-    textBlockStyle.get().setOverflowY(OHIDDEN);
-    textBlockStyle.get().setTextOverflow(textShouldBeTruncated() ? TextOverflowEllipsis : TextOverflowClip);
-
-    if (m_desiredInnerTextLogicalHeight >= 0)
-        textBlockStyle.get().setLogicalHeight(Length(m_desiredInnerTextLogicalHeight, Fixed));
-    // Do not allow line-height to be smaller than our default.
-    if (textBlockStyle.get().fontMetrics().lineSpacing() > lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes))
-        textBlockStyle.get().setLineHeight(RenderStyle::initialLineHeight());
-
-    textBlockStyle.get().setDisplay(BLOCK);
-
-    return textBlockStyle;
-}
-
-Ref<RenderStyle> RenderTextControlSingleLine::createInnerBlockStyle(const RenderStyle* startStyle) const
-{
-    auto innerBlockStyle = RenderStyle::create();
-    innerBlockStyle.get().inheritFrom(startStyle);
-
-    innerBlockStyle.get().setFlexGrow(1);
-    // min-width: 0; is needed for correct shrinking.
-    innerBlockStyle.get().setMinWidth(Length(0, Fixed));
-    innerBlockStyle.get().setDisplay(BLOCK);
-    innerBlockStyle.get().setDirection(LTR);
-
-    // We don't want the shadow dom to be editable, so we set this block to read-only in case the input itself is editable.
-    innerBlockStyle.get().setUserModify(READ_ONLY);
-
-    return innerBlockStyle;
-}
-
 bool RenderTextControlSingleLine::textShouldBeTruncated() const
 {
     return document().focusedElement() != &inputElement() && style().textOverflow() == TextOverflowEllipsis;

Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (197400 => 197401)


--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -34,9 +34,6 @@
 public:
     RenderTextControlSingleLine(HTMLInputElement&, Ref<RenderStyle>&&);
     virtual ~RenderTextControlSingleLine();
-    // FIXME: Move create*Style() to their classes.
-    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle* startStyle) const override;
-    Ref<RenderStyle> createInnerBlockStyle(const RenderStyle* startStyle) const;
 
 protected:
     virtual void centerContainerIfNeeded(RenderBox*) const { }
@@ -79,8 +76,6 @@
     bool textShouldBeTruncated() const;
 
     HTMLElement* innerSpinButtonElement() const;
-
-    LayoutUnit m_desiredInnerTextLogicalHeight;
 };
 
 inline HTMLElement* RenderTextControlSingleLine::containerElement() const

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (197400 => 197401)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -179,7 +179,10 @@
     }
 
     if (element.hasCustomStyleResolveCallbacks()) {
-        if (RefPtr<RenderStyle> style = element.customStyleForRenderer(inheritedStyle))
+        RenderStyle* shadowHostStyle = nullptr;
+        if (auto* shadowRoot = scope().shadowRoot)
+            shadowHostStyle = shadowRoot->host()->renderStyle();
+        if (RefPtr<RenderStyle> style = element.customStyleForRenderer(inheritedStyle, shadowHostStyle))
             return style.releaseNonNull();
     }
 

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (197400 => 197401)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2016-03-01 17:33:47 UTC (rev 197401)
@@ -788,7 +788,7 @@
     contextElement->synchronizeSystemLanguage();
 }
 
-RefPtr<RenderStyle> SVGElement::customStyleForRenderer(RenderStyle& parentStyle)
+RefPtr<RenderStyle> SVGElement::customStyleForRenderer(RenderStyle& parentStyle, RenderStyle*)
 {
     // If the element is in a <use> tree we get the style from the definition tree.
     if (auto* styleElement = this->correspondingElement())

Modified: trunk/Source/WebCore/svg/SVGElement.h (197400 => 197401)


--- trunk/Source/WebCore/svg/SVGElement.h	2016-03-01 16:54:19 UTC (rev 197400)
+++ trunk/Source/WebCore/svg/SVGElement.h	2016-03-01 17:33:47 UTC (rev 197401)
@@ -119,7 +119,7 @@
     void synchronizeAnimatedSVGAttribute(const QualifiedName&) const;
     static void synchronizeAllAnimatedSVGAttribute(SVGElement*);
  
-    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle) override;
+    virtual RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) override;
 
     static void synchronizeRequiredFeatures(SVGElement* contextElement);
     static void synchronizeRequiredExtensions(SVGElement* contextElement);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to