diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/RenderTextControlMultiLine.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/rendering/RenderTextControlMultiLine.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderTextControlMultiLine.cpp | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp index fa8d8a801..daf8c8173 100644 --- a/Source/WebCore/rendering/RenderTextControlMultiLine.cpp +++ b/Source/WebCore/rendering/RenderTextControlMultiLine.cpp @@ -32,20 +32,27 @@ namespace WebCore { -RenderTextControlMultiLine::RenderTextControlMultiLine(HTMLTextAreaElement& element, PassRef<RenderStyle> style) - : RenderTextControl(element, std::move(style)) +RenderTextControlMultiLine::RenderTextControlMultiLine(HTMLTextAreaElement& element, RenderStyle&& style) + : RenderTextControl(element, WTFMove(style)) { } RenderTextControlMultiLine::~RenderTextControlMultiLine() { - if (textAreaElement().inDocument()) + // Do not add any code here. Add it to willBeDestroyed() instead. +} + +void RenderTextControlMultiLine::willBeDestroyed() +{ + if (textAreaElement().isConnected()) textAreaElement().rendererWillBeDestroyed(); + + RenderTextControl::willBeDestroyed(); } HTMLTextAreaElement& RenderTextControlMultiLine::textAreaElement() const { - return toHTMLTextAreaElement(RenderTextControl::textFormControlElement()); + return downcast<HTMLTextAreaElement>(RenderTextControl::textFormControlElement()); } bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) @@ -59,22 +66,22 @@ bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitT return true; } -float RenderTextControlMultiLine::getAvgCharWidth(AtomicString family) +float RenderTextControlMultiLine::getAverageCharWidth() { #if !PLATFORM(IOS) // Since Lucida Grande is the default font, we want this to match the width // of Courier New, the default font for textareas in IE, Firefox and Safari Win. // 1229 is the avgCharWidth value in the OS/2 table for Courier New. - if (family == "Lucida Grande") + if (style().fontCascade().firstFamily() == "Lucida Grande") return scaleEmToUnits(1229); #endif - return RenderTextControl::getAvgCharWidth(family); + return RenderTextControl::getAverageCharWidth(); } LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWidth) const { - return static_cast<LayoutUnit>(ceilf(charWidth * textAreaElement().cols())) + scrollbarThickness(); + return ceilf(charWidth * textAreaElement().cols()) + scrollbarThickness(); } LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const @@ -87,34 +94,16 @@ int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode); } -PassRef<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); - if (!placeholderRenderer) - return 0; - if (!placeholderRenderer->isBox()) - return placeholderRenderer; - RenderBox* placeholderBox = toRenderBox(placeholderRenderer); - placeholderBox->style().setLogicalWidth(Length(contentLogicalWidth() - placeholderBox->borderAndPaddingLogicalWidth(), Fixed)); - placeholderBox->layoutIfNeeded(); - placeholderBox->setX(borderLeft() + paddingLeft()); - placeholderBox->setY(borderTop() + paddingTop()); + if (is<RenderBox>(placeholderRenderer)) { + auto& placeholderBox = downcast<RenderBox>(*placeholderRenderer); + placeholderBox.mutableStyle().setLogicalWidth(Length(contentLogicalWidth() - placeholderBox.borderAndPaddingLogicalWidth(), Fixed)); + placeholderBox.layoutIfNeeded(); + placeholderBox.setX(borderLeft() + paddingLeft()); + placeholderBox.setY(borderTop() + paddingTop()); + } return placeholderRenderer; } |