Diff
Modified: trunk/Source/WebCore/ChangeLog (93333 => 93334)
--- trunk/Source/WebCore/ChangeLog 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/ChangeLog 2011-08-18 19:28:33 UTC (rev 93334)
@@ -1,5 +1,37 @@
2011-08-18 Levi Weintraub <le...@chromium.org>
+ Switch RenderTextControl* to new layout types
+ https://bugs.webkit.org/show_bug.cgi?id=66250
+
+ Reviewed by Eric Seidel.
+
+ Convertikng the RenderTextControl* classes to use the LayoutUnit abstraction.
+
+ No new tests as no change in behavior.
+
+ * rendering/LayoutTypes.h:
+ (WebCore::layoutMod): Added a function to perform the modulo operation on LayoutUnits.
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::hitInnerTextElement):
+ * rendering/RenderTextControl.h:
+ * rendering/RenderTextControlMultiLine.cpp:
+ (WebCore::RenderTextControlMultiLine::preferredContentWidth):
+ (WebCore::RenderTextControlMultiLine::baselinePosition):
+ * rendering/RenderTextControlMultiLine.h:
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlSingleLine::layout):
+ (WebCore::RenderTextControlSingleLine::controlClipRect):
+ (WebCore::RenderTextControlSingleLine::preferredContentWidth):
+ (WebCore::RenderTextControlSingleLine::scrollWidth):
+ (WebCore::RenderTextControlSingleLine::scrollHeight):
+ (WebCore::RenderTextControlSingleLine::scrollLeft):
+ (WebCore::RenderTextControlSingleLine::scrollTop):
+ (WebCore::RenderTextControlSingleLine::setScrollLeft):
+ (WebCore::RenderTextControlSingleLine::setScrollTop):
+ * rendering/RenderTextControlSingleLine.h:
+
+2011-08-18 Levi Weintraub <le...@chromium.org>
+
Switch Inline rendering classes to new layout types
https://bugs.webkit.org/show_bug.cgi?id=66239
Modified: trunk/Source/WebCore/rendering/LayoutTypes.h (93333 => 93334)
--- trunk/Source/WebCore/rendering/LayoutTypes.h 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/LayoutTypes.h 2011-08-18 19:28:33 UTC (rev 93334)
@@ -91,6 +91,11 @@
return LayoutPoint(p.width(), p.height());
}
+inline LayoutUnit layoutMod(const LayoutUnit& numerator, const LayoutUnit& denominator)
+{
+ return numerator % denominator;
+}
+
} // namespace WebCore
#endif // LayoutTypes_h
Modified: trunk/Source/WebCore/rendering/RenderTextControl.cpp (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControl.cpp 2011-08-18 19:28:33 UTC (rev 93334)
@@ -299,7 +299,7 @@
void RenderTextControl::hitInnerTextElement(HitTestResult& result, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset)
{
- IntPoint adjustedLocation = accumulatedOffset + location();
+ LayoutPoint adjustedLocation = accumulatedOffset + location();
HTMLElement* innerText = innerTextElement();
result.setInnerNode(innerText);
result.setInnerNonSharedNode(innerText);
Modified: trunk/Source/WebCore/rendering/RenderTextControl.h (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControl.h 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControl.h 2011-08-18 19:28:33 UTC (rev 93334)
@@ -63,7 +63,7 @@
static bool hasValidAvgCharWidth(AtomicString family);
virtual float getAvgCharWidth(AtomicString family);
- virtual int preferredContentWidth(float charWidth) const = 0;
+ virtual LayoutUnit preferredContentWidth(float charWidth) const = 0;
virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight) = 0;
virtual RenderStyle* textBaseStyle() const = 0;
Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.cpp 2011-08-18 19:28:33 UTC (rev 93334)
@@ -64,10 +64,10 @@
return RenderTextControl::getAvgCharWidth(family);
}
-int RenderTextControlMultiLine::preferredContentWidth(float charWidth) const
+LayoutUnit RenderTextControlMultiLine::preferredContentWidth(float charWidth) const
{
int factor = static_cast<HTMLTextAreaElement*>(node())->cols();
- return static_cast<int>(ceilf(charWidth * factor)) + scrollbarThickness();
+ return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
}
void RenderTextControlMultiLine::adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight)
@@ -75,7 +75,7 @@
setHeight(height() + lineHeight * static_cast<HTMLTextAreaElement*>(node())->rows());
}
-int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
+LayoutUnit RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
{
return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
}
Modified: trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControlMultiLine.h 2011-08-18 19:28:33 UTC (rev 93334)
@@ -37,9 +37,9 @@
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const LayoutPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
virtual float getAvgCharWidth(AtomicString family);
- virtual int preferredContentWidth(float charWidth) const;
- virtual void adjustControlHeightBasedOnLineHeight(int lineHeight);
- virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
+ virtual LayoutUnit preferredContentWidth(float charWidth) const;
+ virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
+ virtual LayoutUnit baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
virtual void updateFromElement();
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.cpp 2011-08-18 19:28:33 UTC (rev 93334)
@@ -265,12 +265,12 @@
currentHeight = innerTextRenderer->height();
if (!container && currentHeight != contentHeight()) {
LayoutUnit heightDiff = currentHeight - contentHeight();
- innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + heightDiff % 2));
+ innerTextRenderer->setY(innerTextRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
} else if (inputElement()->isSearchField() && containerRenderer && containerRenderer->height() > contentHeight()) {
// A quirk for find-in-page box on Safari Windows.
// http://webkit.org/b/63157
LayoutUnit heightDiff = containerRenderer->height() - contentHeight();
- containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + heightDiff % 2));
+ containerRenderer->setY(containerRenderer->y() - (heightDiff / 2 + layoutMod(heightDiff, 2)));
}
// Ignores the paddings for the inner spin button.
@@ -370,10 +370,10 @@
return !!containerElement();
}
-IntRect RenderTextControlSingleLine::controlClipRect(const IntPoint& additionalOffset) const
+LayoutRect RenderTextControlSingleLine::controlClipRect(const LayoutPoint& additionalOffset) const
{
ASSERT(hasControlClip());
- IntRect clipRect = IntRect(containerElement()->renderBox()->frameRect());
+ LayoutRect clipRect = LayoutRect(containerElement()->renderBox()->frameRect());
clipRect.moveBy(additionalOffset);
return clipRect;
}
@@ -390,14 +390,14 @@
return RenderTextControl::getAvgCharWidth(family);
}
-int RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
+LayoutUnit RenderTextControlSingleLine::preferredContentWidth(float charWidth) const
{
int factor;
bool includesDecoration = inputElement()->sizeShouldIncludeDecoration(factor);
if (factor <= 0)
factor = 20;
- int result = static_cast<int>(ceilf(charWidth * factor));
+ LayoutUnit result = static_cast<LayoutUnit>(ceiledLayoutUnit(charWidth * factor));
float maxCharWidth = 0.f;
AtomicString family = style()->font().family().family();
@@ -719,41 +719,41 @@
layer->autoscroll();
}
-int RenderTextControlSingleLine::scrollWidth() const
+LayoutUnit RenderTextControlSingleLine::scrollWidth() const
{
if (innerTextElement())
return innerTextElement()->scrollWidth();
return RenderBlock::scrollWidth();
}
-int RenderTextControlSingleLine::scrollHeight() const
+LayoutUnit RenderTextControlSingleLine::scrollHeight() const
{
if (innerTextElement())
return innerTextElement()->scrollHeight();
return RenderBlock::scrollHeight();
}
-int RenderTextControlSingleLine::scrollLeft() const
+LayoutUnit RenderTextControlSingleLine::scrollLeft() const
{
if (innerTextElement())
return innerTextElement()->scrollLeft();
return RenderBlock::scrollLeft();
}
-int RenderTextControlSingleLine::scrollTop() const
+LayoutUnit RenderTextControlSingleLine::scrollTop() const
{
if (innerTextElement())
return innerTextElement()->scrollTop();
return RenderBlock::scrollTop();
}
-void RenderTextControlSingleLine::setScrollLeft(int newLeft)
+void RenderTextControlSingleLine::setScrollLeft(LayoutUnit newLeft)
{
if (innerTextElement())
innerTextElement()->setScrollLeft(newLeft);
}
-void RenderTextControlSingleLine::setScrollTop(int newTop)
+void RenderTextControlSingleLine::setScrollTop(LayoutUnit newTop)
{
if (innerTextElement())
innerTextElement()->setScrollTop(newTop);
Modified: trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h (93333 => 93334)
--- trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2011-08-18 19:23:22 UTC (rev 93333)
+++ trunk/Source/WebCore/rendering/RenderTextControlSingleLine.h 2011-08-18 19:28:33 UTC (rev 93334)
@@ -51,7 +51,7 @@
private:
virtual bool hasControlClip() const;
- virtual IntRect controlClipRect(const IntPoint&) const;
+ virtual LayoutRect controlClipRect(const LayoutPoint&) const;
virtual bool isTextField() const { return true; }
virtual void paint(PaintInfo&, const LayoutPoint&);
@@ -62,18 +62,18 @@
virtual void autoscroll();
// Subclassed to forward to our inner div.
- virtual int scrollLeft() const;
- virtual int scrollTop() const;
- virtual int scrollWidth() const;
- virtual int scrollHeight() const;
- virtual void setScrollLeft(int);
- virtual void setScrollTop(int);
+ virtual LayoutUnit scrollLeft() const;
+ virtual LayoutUnit scrollTop() const;
+ virtual LayoutUnit scrollWidth() const;
+ virtual LayoutUnit scrollHeight() const;
+ virtual void setScrollLeft(LayoutUnit);
+ virtual void setScrollTop(LayoutUnit);
virtual bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
virtual bool logicalScroll(ScrollLogicalDirection, ScrollGranularity, float multiplier = 1, Node** stopNode = 0);
int textBlockWidth() const;
virtual float getAvgCharWidth(AtomicString family);
- virtual int preferredContentWidth(float charWidth) const;
+ virtual LayoutUnit preferredContentWidth(float charWidth) const;
virtual void adjustControlHeightBasedOnLineHeight(LayoutUnit lineHeight);
virtual void updateFromElement();