Changeset 197637 in webkit
- Timestamp:
- Mar 6, 2016, 2:17:52 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
-
ChangeLog (modified) (1 diff)
-
html/HTMLInputElement.cpp (modified) (2 diffs)
-
html/HTMLInputElement.h (modified) (1 diff)
-
html/HTMLTextAreaElement.cpp (modified) (3 diffs)
-
html/HTMLTextAreaElement.h (modified) (1 diff)
-
html/HTMLTextFormControlElement.cpp (modified) (1 diff)
-
html/TextFieldInputType.cpp (modified) (1 diff)
-
html/shadow/TextControlInnerElements.cpp (modified) (2 diffs)
-
html/shadow/TextControlInnerElements.h (modified) (1 diff)
-
rendering/RenderTextControlSingleLine.cpp (modified) (2 diffs)
-
rendering/RenderTextControlSingleLine.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r197634 r197637 1 2016-03-06 Antti Koivisto <antti@apple.com> 2 3 RenderTextControlSingleLine shouldn't mutate placeholder element inline style 4 https://bugs.webkit.org/show_bug.cgi?id=155086 5 6 Reviewed by Andreas Kling. 7 8 Text field placeholder element is currently managed by changing its inline style 9 from the host renderer based on the host style and state. Rendering poking 10 into DOM is wrong. 11 12 * html/HTMLInputElement.cpp: 13 (WebCore::HTMLInputElement::setRangeText): 14 (WebCore::HTMLInputElement::shouldTruncateText): 15 16 Add a helper. 17 18 (WebCore::HTMLInputElement::createInnerTextStyle): 19 * html/HTMLInputElement.h: 20 * html/HTMLTextAreaElement.cpp: 21 (WebCore::HTMLTextAreaElement::HTMLTextAreaElement): 22 (WebCore::HTMLTextAreaElement::placeholderElement): 23 (WebCore::HTMLTextAreaElement::matchesReadWritePseudoClass): 24 (WebCore::HTMLTextAreaElement::updatePlaceholderText): 25 26 Use the new shadow element. 27 28 * html/HTMLTextAreaElement.h: 29 * html/HTMLTextFormControlElement.cpp: 30 (WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility): 31 32 No more poking to inline style. 33 34 (WebCore::HTMLTextFormControlElement::setSelectionStart): 35 * html/TextFieldInputType.cpp: 36 (WebCore::TextFieldInputType::updatePlaceholderText): 37 38 Use the new shadow element. 39 40 * html/shadow/TextControlInnerElements.cpp: 41 (WebCore::TextControlPlaceholderElement::TextControlPlaceholderElement): 42 43 Add a subclass for the placeholder element instead of just using div. 44 45 (WebCore::TextControlPlaceholderElement::customStyleForRenderer): 46 47 Compute style base on the host state and style. 48 49 (WebCore::SearchFieldResultsButtonElement::SearchFieldResultsButtonElement): 50 * html/shadow/TextControlInnerElements.h: 51 * rendering/RenderTextControlSingleLine.cpp: 52 (WebCore::RenderTextControlSingleLine::styleDidChange): 53 54 No more setInlineStyleProperty. 55 This now needs to trigger layout like it does with other inner elements. 56 57 (WebCore::RenderTextControlSingleLine::computeControlLogicalHeight): 58 (WebCore::RenderTextControlSingleLine::autoscroll): 59 (WebCore::RenderTextControlSingleLine::textShouldBeTruncated): Deleted. 60 * rendering/RenderTextControlSingleLine.h: 61 1 62 2016-03-05 Ryosuke Niwa <rniwa@webkit.org> 2 63 -
trunk/Source/WebCore/html/HTMLInputElement.cpp
r197563 r197637 1860 1860 } 1861 1861 1862 bool HTMLInputElement::shouldTruncateText(const RenderStyle& style) const 1863 { 1864 if (!isTextField()) 1865 return false; 1866 return document().focusedElement() != this && style.textOverflow() == TextOverflowEllipsis; 1867 } 1868 1862 1869 Ref<RenderStyle> HTMLInputElement::createInnerTextStyle(const RenderStyle& style) const 1863 1870 { … … 1870 1877 textBlockStyle.get().setOverflowX(OHIDDEN); 1871 1878 textBlockStyle.get().setOverflowY(OHIDDEN); 1872 1873 bool textShouldBeTruncated = document().focusedElement() != this && style.textOverflow() == TextOverflowEllipsis; 1874 textBlockStyle.get().setTextOverflow(textShouldBeTruncated ? TextOverflowEllipsis : TextOverflowClip); 1879 textBlockStyle.get().setTextOverflow(shouldTruncateText(style) ? TextOverflowEllipsis : TextOverflowClip); 1875 1880 1876 1881 // Do not allow line-height to be smaller than our default. -
trunk/Source/WebCore/html/HTMLInputElement.h
r197566 r197637 322 322 void capsLockStateMayHaveChanged(); 323 323 324 bool shouldTruncateText(const RenderStyle&) const; 325 324 326 protected: 325 327 HTMLInputElement(const QualifiedName&, Document&, HTMLFormElement*, bool createdByParser); -
trunk/Source/WebCore/html/HTMLTextAreaElement.cpp
r197458 r197637 93 93 , m_rows(defaultRows) 94 94 , m_cols(defaultCols) 95 , m_wrap(SoftWrap)96 , m_placeholder(0)97 , m_isDirty(false)98 , m_wasModifiedByUser(false)99 95 { 100 96 ASSERT(hasTagName(textareaTag)); … … 498 494 HTMLElement* HTMLTextAreaElement::placeholderElement() const 499 495 { 500 return m_placeholder ;496 return m_placeholder.get(); 501 497 } 502 498 … … 517 513 } 518 514 if (!m_placeholder) { 519 RefPtr<HTMLDivElement> placeholder = HTMLDivElement::create(document()); 520 m_placeholder = placeholder.get(); 521 m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); 522 m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); 515 m_placeholder = TextControlPlaceholderElement::create(document()); 523 516 userAgentShadowRoot()->insertBefore(*m_placeholder, innerTextElement()->nextSibling()); 524 517 } -
trunk/Source/WebCore/html/HTMLTextAreaElement.h
r197566 r197637 125 125 unsigned m_cols; 126 126 int m_maxLength { -1 }; 127 WrapMethod m_wrap ;128 HTMLElement*m_placeholder;127 WrapMethod m_wrap { SoftWrap }; 128 RefPtr<HTMLElement> m_placeholder; 129 129 mutable String m_value; 130 mutable bool m_isDirty ;131 mutable bool m_wasModifiedByUser ;130 mutable bool m_isDirty { false }; 131 mutable bool m_wasModifiedByUser { false }; 132 132 }; 133 133 -
trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp
r197458 r197637 165 165 166 166 setNeedsStyleRecalc(); 167 168 if (HTMLElement* placeholder = placeholderElement())169 placeholder->setInlineStyleProperty(CSSPropertyDisplay, m_isPlaceholderVisible ? CSSValueBlock : CSSValueNone, true);170 167 } 171 168 -
trunk/Source/WebCore/html/TextFieldInputType.cpp
r197458 r197637 495 495 } 496 496 if (!m_placeholder) { 497 m_placeholder = HTMLDivElement::create(element().document()); 498 m_placeholder->setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); 499 m_placeholder->setInlineStyleProperty(CSSPropertyDisplay, element().isPlaceholderVisible() ? CSSValueBlock : CSSValueNone, true); 500 element().userAgentShadowRoot()->insertBefore(*m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION); 501 497 m_placeholder = TextControlPlaceholderElement::create(element().document()); 498 element().userAgentShadowRoot()->insertBefore(*m_placeholder, m_container ? m_container.get() : innerTextElement(), ASSERT_NO_EXCEPTION); 502 499 } 503 500 m_placeholder->setInnerText(placeholderText, ASSERT_NO_EXCEPTION); -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp
r197401 r197637 40 40 #include "RenderView.h" 41 41 #include "ScriptController.h" 42 #include "ShadowRoot.h" 42 43 #include "TextEvent.h" 43 44 #include "TextEventInputType.h" … … 140 141 // ---------------------------- 141 142 143 TextControlPlaceholderElement::TextControlPlaceholderElement(Document& document) 144 : HTMLDivElement(divTag, document) 145 { 146 setPseudo(AtomicString("-webkit-input-placeholder", AtomicString::ConstructFromLiteral)); 147 setHasCustomStyleResolveCallbacks(); 148 } 149 150 RefPtr<RenderStyle> TextControlPlaceholderElement::customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) 151 { 152 auto style = resolveStyle(&parentStyle); 153 154 auto& controlElement = downcast<HTMLTextFormControlElement>(*containingShadowRoot()->host()); 155 style->setDisplay(controlElement.isPlaceholderVisible() ? BLOCK : NONE); 156 157 if (is<HTMLInputElement>(controlElement)) { 158 auto& inputElement = downcast<HTMLInputElement>(controlElement); 159 style->setTextOverflow(inputElement.shouldTruncateText(*shadowHostStyle) ? TextOverflowEllipsis : TextOverflowClip); 160 } 161 162 return WTFMove(style); 163 } 164 165 // ---------------------------- 166 142 167 inline SearchFieldResultsButtonElement::SearchFieldResultsButtonElement(Document& document) 143 168 : HTMLDivElement(divTag, document) -
trunk/Source/WebCore/html/shadow/TextControlInnerElements.h
r197563 r197637 71 71 }; 72 72 73 class TextControlPlaceholderElement final : public HTMLDivElement { 74 public: 75 static Ref<TextControlPlaceholderElement> create(Document& document) { return adoptRef(*new TextControlPlaceholderElement(document)); } 76 77 private: 78 TextControlPlaceholderElement(Document&); 79 80 RefPtr<RenderStyle> customStyleForRenderer(RenderStyle& parentStyle, RenderStyle* shadowHostStyle) override; 81 }; 82 73 83 class SearchFieldResultsButtonElement final : public HTMLDivElement { 74 84 public: -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp
r197401 r197637 246 246 containerRenderer->style().setWidth(Length()); 247 247 } 248 RenderTextControlInnerBlock* innerTextRenderer = innerTextElement()->renderer(); 249 if (innerTextRenderer && diff == StyleDifferenceLayout) 250 innerTextRenderer->setNeedsLayout(MarkContainingBlockChain); 251 if (HTMLElement* placeholder = inputElement().placeholderElement()) 252 placeholder->setInlineStyleProperty(CSSPropertyTextOverflow, textShouldBeTruncated() ? CSSValueEllipsis : CSSValueClip); 248 if (diff == StyleDifferenceLayout) { 249 if (auto* innerTextRenderer = innerTextElement()->renderer()) 250 innerTextRenderer->setNeedsLayout(MarkContainingBlockChain); 251 if (auto* placeholder = inputElement().placeholderElement()) { 252 if (placeholder->renderer()) 253 placeholder->renderer()->setNeedsLayout(MarkContainingBlockChain); 254 } 255 } 253 256 setHasOverflowClip(false); 254 257 } … … 322 325 } 323 326 324 bool RenderTextControlSingleLine::textShouldBeTruncated() const325 {326 return document().focusedElement() != &inputElement() && style().textOverflow() == TextOverflowEllipsis;327 }328 329 327 void RenderTextControlSingleLine::autoscroll(const IntPoint& position) 330 328 { -
trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h
r197566 r197637 74 74 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override; 75 75 76 bool textShouldBeTruncated() const;77 78 76 HTMLElement* innerSpinButtonElement() const; 79 77 };
Note:
See TracChangeset
for help on using the changeset viewer.