From 284837daa07b29d6a63a748544a90b1f5842ac5c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 10 Sep 2012 19:10:20 +0200 Subject: Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073) New snapshot --- Source/WebCore/rendering/RenderTextControl.cpp | 30 +++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'Source/WebCore/rendering/RenderTextControl.cpp') diff --git a/Source/WebCore/rendering/RenderTextControl.cpp b/Source/WebCore/rendering/RenderTextControl.cpp index 3bc25b897..cb7637db3 100644 --- a/Source/WebCore/rendering/RenderTextControl.cpp +++ b/Source/WebCore/rendering/RenderTextControl.cpp @@ -110,13 +110,18 @@ int RenderTextControl::textBlockWidth() const { Element* innerText = innerTextElement(); ASSERT(innerText); - return width() - borderAndPaddingWidth() - innerText->renderBox()->paddingLeft() - innerText->renderBox()->paddingRight(); + + LayoutUnit unitWidth = width() - borderAndPaddingWidth(); + if (innerText->renderer()) + unitWidth -= innerText->renderBox()->paddingLeft() + innerText->renderBox()->paddingRight(); + + return unitWidth; } void RenderTextControl::updateFromElement() { Element* innerText = innerTextElement(); - if (innerText) + if (innerText && innerText->renderer()) updateUserModifyProperty(node(), innerText->renderer()->style()); } @@ -143,13 +148,14 @@ void RenderTextControl::computeLogicalHeight() { HTMLElement* innerText = innerTextElement(); ASSERT(innerText); - RenderBox* innerTextBox = innerText->renderBox(); - LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight(); - setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight()); + if (RenderBox* innerTextBox = innerText->renderBox()) { + LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginHeight(); + setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight()); - // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap. - if (style()->overflowX() == OSCROLL || (style()->overflowX() == OAUTO && innerText->renderer()->style()->wordWrap() == NormalWordWrap)) - setHeight(height() + scrollbarThickness()); + // We are able to have a horizontal scrollbar if the overflow style is scroll, or if its auto and there's no word wrap. + if (style()->overflowX() == OSCROLL || (style()->overflowX() == OAUTO && innerText->renderer()->style()->overflowWrap() == NormalOverflowWrap)) + setHeight(height() + scrollbarThickness()); + } RenderBlock::computeLogicalHeight(); } @@ -157,6 +163,9 @@ void RenderTextControl::computeLogicalHeight() void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset) { HTMLElement* innerText = innerTextElement(); + if (!innerText->renderer()) + return; + LayoutPoint adjustedLocation = accumulatedOffset + location(); LayoutPoint localPoint = pointInContainer - toLayoutSize(adjustedLocation + innerText->renderBox()->location()); if (hasOverflowClip()) @@ -257,8 +266,9 @@ void RenderTextControl::computePreferredLogicalWidths() else { // Use average character width. Matches IE. AtomicString family = style()->font().family().family(); - RenderBox* innerTextRenderBox = innerTextElement()->renderBox(); - m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family)) + innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight(); + m_maxPreferredLogicalWidth = preferredContentWidth(getAvgCharWidth(family)); + if (RenderBox* innerTextRenderBox = innerTextElement()->renderBox()) + m_maxPreferredLogicalWidth += innerTextRenderBox->paddingLeft() + innerTextRenderBox->paddingRight(); } if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) { -- cgit v1.2.1