Text control shadow element style shouldn't depend on renderers
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2016 17:33:47 +0000 (17:33 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2016 17:33:47 +0000 (17:33 +0000)
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197401 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/Element.h
Source/WebCore/dom/PseudoElement.cpp
Source/WebCore/dom/PseudoElement.h
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/html/HTMLInputElement.h
Source/WebCore/html/HTMLTextAreaElement.cpp
Source/WebCore/html/HTMLTextAreaElement.h
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/html/shadow/TextControlInnerElements.h
Source/WebCore/rendering/RenderTextControl.cpp
Source/WebCore/rendering/RenderTextControl.h
Source/WebCore/rendering/RenderTextControlMultiLine.cpp
Source/WebCore/rendering/RenderTextControlMultiLine.h
Source/WebCore/rendering/RenderTextControlSingleLine.cpp
Source/WebCore/rendering/RenderTextControlSingleLine.h
Source/WebCore/style/StyleTreeResolver.cpp
Source/WebCore/svg/SVGElement.cpp
Source/WebCore/svg/SVGElement.h

index f973bf1..b2a776b 100644 (file)
@@ -1,3 +1,85 @@
+2016-03-01  Antti Koivisto  <antti@apple.com>
+
+        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  <rego@igalia.com>
 
         [css-grid] Get rid of GridResolvedPosition
index 62fab18..b6b5680 100644 (file)
@@ -3265,7 +3265,7 @@ void Element::didDetachRenderers()
     ASSERT(hasCustomStyleResolveCallbacks());
 }
 
-RefPtr<RenderStyle> Element::customStyleForRenderer(RenderStyle&)
+RefPtr<RenderStyle> Element::customStyleForRenderer(RenderStyle&, RenderStyle*)
 {
     ASSERT(hasCustomStyleResolveCallbacks());
     return nullptr;
index c6f6d4f..23d1269 100644 (file)
@@ -476,7 +476,7 @@ public:
     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;
 
index cf9eac0..b7c7053 100644 (file)
@@ -76,7 +76,7 @@ void PseudoElement::clearHostElement()
     m_hostElement = nullptr;
 }
 
-RefPtr<RenderStyle> PseudoElement::customStyleForRenderer(RenderStyle& parentStyle)
+RefPtr<RenderStyle> PseudoElement::customStyleForRenderer(RenderStyle& parentStyle, RenderStyle*)
 {
     return m_hostElement->renderer()->getCachedPseudoStyle(m_pseudoId, &parentStyle);
 }
index 0e23464..879c4aa 100644 (file)
@@ -45,7 +45,7 @@ public:
     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;
index ba0b873..08dd9c7 100644 (file)
@@ -1867,6 +1867,29 @@ void HTMLInputElement::setRangeText(const String& replacement, unsigned start, u
     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)
 {
index 83e8915..7768c7f 100644 (file)
@@ -140,7 +140,10 @@ public:
 #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;
index 86cd708..00ca35d 100644 (file)
@@ -540,4 +540,20 @@ bool HTMLTextAreaElement::willRespondToMouseClickEvents()
     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
index c4ba06d..bba47e2 100644 (file)
@@ -54,6 +54,7 @@ public:
     bool isValidValue(const String&) const;
     
     virtual TextControlInnerTextElement* innerTextElement() const override;
+    virtual Ref<RenderStyle> createInnerTextStyle(const RenderStyle&) const override;
 
     void rendererWillBeDestroyed();
 
index 149f9db..ef90d48 100644 (file)
@@ -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 @@ String HTMLTextFormControlElement::directionForFormData() const
     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
index 7245bd2..4f7f73e 100644 (file)
@@ -79,6 +79,7 @@ public:
     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 @@ protected:
 
     String valueWithHardLineBreaks() const;
 
+    void adjustInnerTextStyle(const RenderStyle& parentStyle, RenderStyle& textBlockStyle) const;
+
 private:
     TextFieldSelectionDirection cachedSelectionDirection() const { return static_cast<TextFieldSelectionDirection>(m_cachedSelectionDirection); }
 
index 9cc2ee1..b332c7f 100644 (file)
@@ -73,10 +73,21 @@ Ref<TextControlInnerElement> TextControlInnerElement::create(Document& document)
     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 @@ RenderTextControlInnerBlock* TextControlInnerTextElement::renderer() const
     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);
 }
 
 // ----------------------------
index 6cfa550..e5c809e 100644 (file)
@@ -48,7 +48,7 @@ public:
 
 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 @@ public:
 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; }
 };
index 77712b1..88fd7b9 100644 (file)
@@ -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 @@ void RenderTextControl::styleDidChange(StyleDifference diff, const RenderStyle*
         // 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();
index d0f7e09..74fdc3f 100644 (file)
@@ -35,7 +35,6 @@ public:
     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 @@ protected:
     TextControlInnerTextElement* innerTextElement() const;
 
     int scrollbarThickness() const;
-    void adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle& textBlockStyle) const;
 
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
 
index 8cefbf8..90eb75a 100644 (file)
@@ -87,22 +87,6 @@ int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool
     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);
index 192b782..fe114de 100644 (file)
@@ -47,7 +47,6 @@ private:
     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;
 };
 
index e6f5b6b..7b440e7 100644 (file)
@@ -55,7 +55,6 @@ using namespace HTMLNames;
 
 RenderTextControlSingleLine::RenderTextControlSingleLine(HTMLInputElement& element, Ref<RenderStyle>&& style)
     : RenderTextControl(element, WTFMove(style))
-    , m_desiredInnerTextLogicalHeight(-1)
 {
 }
 
@@ -129,8 +128,6 @@ void RenderTextControlSingleLine::layout()
         if (desiredLogicalHeight != innerTextRenderer->logicalHeight())
             setNeedsLayout(MarkOnlyThis);
 
-        m_desiredInnerTextLogicalHeight = desiredLogicalHeight;
-
         innerTextRenderer->style().setLogicalHeight(Length(desiredLogicalHeight, Fixed));
         innerTextRenderer->setNeedsLayout(MarkOnlyThis);
         if (innerBlockRenderer) {
@@ -234,7 +231,6 @@ bool RenderTextControlSingleLine::nodeAtPoint(const HitTestRequest& request, Hit
 
 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 @@ LayoutUnit RenderTextControlSingleLine::computeControlLogicalHeight(LayoutUnit l
     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;
index a5f80f4..e30753c 100644 (file)
@@ -34,9 +34,6 @@ class RenderTextControlSingleLine : public RenderTextControl {
 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 @@ private:
     bool textShouldBeTruncated() const;
 
     HTMLElement* innerSpinButtonElement() const;
-
-    LayoutUnit m_desiredInnerTextLogicalHeight;
 };
 
 inline HTMLElement* RenderTextControlSingleLine::containerElement() const
index 2743dee..08da937 100644 (file)
@@ -179,7 +179,10 @@ Ref<RenderStyle> TreeResolver::styleForElement(Element& element, RenderStyle& in
     }
 
     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();
     }
 
index 8cf85c5..38d4e55 100644 (file)
@@ -788,7 +788,7 @@ void SVGElement::synchronizeSystemLanguage(SVGElement* contextElement)
     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())
index 3c6b5e2..de96a50 100644 (file)
@@ -119,7 +119,7 @@ public:
     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);