- Revision
- 110034
- Author
- tk...@chromium.org
- Date
- 2012-03-07 01:04:58 -0800 (Wed, 07 Mar 2012)
Log Message
Cleanup of RenderTextControl::adjustControlHeightBasedOnLineHeight()
https://bugs.webkit.org/show_bug.cgi?id=80480
Reviewed by Hajime Morita.
The callsite of adjustControlHeightBasedOnLineHeight() stored
padding+border+margin height of the inner text in height(), and
adjustControlHeightBasedOnLineHeight() implementations refered it. It
was unreasonable and hard to understand.
The purpose of adjustControlHeightBasedOnLineHeight() is to compute
- the maximum height of line-heights of the inner text and decorations
- the maximum height of padding+border+margin heights of the inner text and decorations,
and to sum them up. This patch rewrites the code to make it understood easily.
adjustControlHeightBasedOnLineHeight() is renamed to
computeControlheight(), it takes additional parameter of
padding+boder+margin height, and returns the sum of them.
No behavior change.
* rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::computeLogicalHeight):
* rendering/RenderTextControl.h:
(RenderTextControl):
* rendering/RenderTextControlMultiLine.cpp:
(WebCore::RenderTextControlMultiLine::computeControlHeight):
* rendering/RenderTextControlMultiLine.h:
(RenderTextControlMultiLine):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlSingleLine::computeControlHeight):
* rendering/RenderTextControlSingleLine.h:
(RenderTextControlSingleLine):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (110033 => 110034)
--- trunk/Source/WebCore/ChangeLog 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/ChangeLog 2012-03-07 09:04:58 UTC (rev 110034)
@@ -1,3 +1,39 @@
+2012-03-07 Kent Tamura <tk...@chromium.org>
+
+ Cleanup of RenderTextControl::adjustControlHeightBasedOnLineHeight()
+ https://bugs.webkit.org/show_bug.cgi?id=80480
+
+ Reviewed by Hajime Morita.
+
+ The callsite of adjustControlHeightBasedOnLineHeight() stored
+ padding+border+margin height of the inner text in height(), and
+ adjustControlHeightBasedOnLineHeight() implementations refered it. It
+ was unreasonable and hard to understand.
+
+ The purpose of adjustControlHeightBasedOnLineHeight() is to compute
+ - the maximum height of line-heights of the inner text and decorations
+ - the maximum height of padding+border+margin heights of the inner text and decorations,
+ and to sum them up. This patch rewrites the code to make it understood easily.
+
+ adjustControlHeightBasedOnLineHeight() is renamed to
+ computeControlheight(), it takes additional parameter of
+ padding+boder+margin height, and returns the sum of them.
+
+ No behavior change.
+
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::computeLogicalHeight):
+ * rendering/RenderTextControl.h:
+ (RenderTextControl):
+ * rendering/RenderTextControlMultiLine.cpp:
+ (WebCore::RenderTextControlMultiLine::computeControlHeight):
+ * rendering/RenderTextControlMultiLine.h:
+ (RenderTextControlMultiLine):
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::computeControlHeight):
+ * rendering/RenderTextControlSingleLine.h:
+ (RenderTextControlSingleLine):
+
2012-03-06 Eric Seidel <e...@webkit.org>
Make WTF public headers use fully-qualified include paths and remove ForwardingHeaders/wtf
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2012-03-07 09:04:58 UTC (rev 110034)
@@ -142,15 +142,10 @@
{
HTMLElement* innerText = innerTextElement();
ASSERT(innerText);
- RenderBox* innerTextRenderBox = innerText->renderBox();
+ RenderBox* innerTextBox = innerText->renderBox();
+ LayoutUnit nonContentHeight = innerTextBox->borderAndPaddingHeight() + innerTextBox->marginTop() + innerTextBox->marginBottom();
+ setHeight(computeControlHeight(innerTextBox->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes), nonContentHeight) + borderAndPaddingHeight());
- setHeight(innerTextRenderBox->borderTop() + innerTextRenderBox->borderBottom() +
- innerTextRenderBox->paddingTop() + innerTextRenderBox->paddingBottom() +
- innerTextRenderBox->marginTop() + innerTextRenderBox->marginBottom());
-
- adjustControlHeightBasedOnLineHeight(innerText->renderBox()->lineHeight(true, HorizontalLine, PositionOfInteriorLineBoxes));
- setHeight(height() + 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());
Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControl.h 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h 2012-03-07 09:04:58 UTC (rev 110034)
@@ -58,7 +58,7 @@
static bool hasValidAvgCharWidth(AtomicString family);
virtual float getAvgCharWidth(AtomicString family);
virtual LayoutUnit preferredContentWidth(float charWidth) const = 0;
- virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight) = 0;
+ virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const = 0;
virtual RenderStyle* textBaseStyle() const = 0;
virtual void updateFromElement();
Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp 2012-03-07 09:04:58 UTC (rev 110034)
@@ -70,9 +70,9 @@
return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
}
-void RenderTextControlMultiLine::adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight)
+LayoutUnit RenderTextControlMultiLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
{
- setHeight(height() + lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows());
+ return lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows() + nonContentHeight;
}
LayoutUnit RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h 2012-03-07 09:04:58 UTC (rev 110034)
@@ -38,7 +38,7 @@
virtual float getAvgCharWidth(AtomicString family);
virtual LayoutUnit preferredContentWidth(float charWidth) const;
- virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
+ virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
virtual RenderStyle* textBaseStyle() const;
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2012-03-07 09:04:58 UTC (rev 110034)
@@ -449,28 +449,22 @@
return result;
}
-void RenderTextControlSingleLine::adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight)
+LayoutUnit RenderTextControlSingleLine::computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
{
HTMLElement* resultsButton = resultsButtonElement();
if (RenderBox* resultsRenderer = resultsButton ? resultsButton->renderBox() : 0) {
resultsRenderer->computeLogicalHeight();
- setHeight(max(height(),
- resultsRenderer->borderTop() + resultsRenderer->borderBottom() +
- resultsRenderer->paddingTop() + resultsRenderer->paddingBottom() +
- resultsRenderer->marginTop() + resultsRenderer->marginBottom()));
+ nonContentHeight = max(nonContentHeight, resultsRenderer->borderAndPaddingHeight() + resultsRenderer->marginTop() + resultsRenderer->marginBottom());
lineHeight = max(lineHeight, resultsRenderer->height());
}
HTMLElement* cancelButton = cancelButtonElement();
if (RenderBox* cancelRenderer = cancelButton ? cancelButton->renderBox() : 0) {
cancelRenderer->computeLogicalHeight();
- setHeight(max(height(),
- cancelRenderer->borderTop() + cancelRenderer->borderBottom() +
- cancelRenderer->paddingTop() + cancelRenderer->paddingBottom() +
- cancelRenderer->marginTop() + cancelRenderer->marginBottom()));
+ nonContentHeight = max(nonContentHeight, cancelRenderer->borderAndPaddingHeight() + cancelRenderer->marginTop() + cancelRenderer->marginBottom());
lineHeight = max(lineHeight, cancelRenderer->height());
}
- setHeight(height() + lineHeight);
+ return lineHeight + nonContentHeight;
}
void RenderTextControlSingleLine::updateFromElement()
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (110033 => 110034)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2012-03-07 08:50:54 UTC (rev 110033)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2012-03-07 09:04:58 UTC (rev 110034)
@@ -78,8 +78,8 @@
int textBlockWidth() const;
virtual float getAvgCharWidth(AtomicString family);
virtual LayoutUnit preferredContentWidth(float charWidth) const;
- virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
-
+ virtual LayoutUnit computeControlHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const OVERRIDE;
+
virtual void updateFromElement();
virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);