- Revision
- 128478
- Author
- [email protected]
- Date
- 2012-09-13 10:22:21 -0700 (Thu, 13 Sep 2012)
Log Message
Refactor paint overflow clipping
https://bugs.webkit.org/show_bug.cgi?id=96625
Patch by Sami Kyostila <[email protected]> on 2012-09-13
Reviewed by Simon Fraser.
The same logic for applying overflow clipping based on the cached size of a
RenderBox has been duplicated to four different places. Consolidate them to a
single RenderBox utility function.
This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=96087.
No new functionality; covered by existing tests.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::applyCachedClipAndScrollOffsetForRepaint):
(WebCore):
(WebCore::RenderBox::computeRectForRepaint):
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::clippedOverflowRectForRepaint):
(WebCore::RenderInline::computeRectForRepaint):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::computeRectForRepaint):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128477 => 128478)
--- trunk/Source/WebCore/ChangeLog 2012-09-13 17:03:05 UTC (rev 128477)
+++ trunk/Source/WebCore/ChangeLog 2012-09-13 17:22:21 UTC (rev 128478)
@@ -1,3 +1,30 @@
+2012-09-13 Sami Kyostila <[email protected]>
+
+ Refactor paint overflow clipping
+ https://bugs.webkit.org/show_bug.cgi?id=96625
+
+ Reviewed by Simon Fraser.
+
+ The same logic for applying overflow clipping based on the cached size of a
+ RenderBox has been duplicated to four different places. Consolidate them to a
+ single RenderBox utility function.
+
+ This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=96087.
+
+ No new functionality; covered by existing tests.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::applyCachedClipAndScrollOffsetForRepaint):
+ (WebCore):
+ (WebCore::RenderBox::computeRectForRepaint):
+ * rendering/RenderBox.h:
+ (RenderBox):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::clippedOverflowRectForRepaint):
+ (WebCore::RenderInline::computeRectForRepaint):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::computeRectForRepaint):
+
2012-09-13 Simon Hausmann <[email protected]>
Another prospective Qt/Windows build fix: Add missing CString.h include.
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (128477 => 128478)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-13 17:03:05 UTC (rev 128477)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-13 17:22:21 UTC (rev 128478)
@@ -647,6 +647,17 @@
return layer()->size();
}
+void RenderBox::applyCachedClipAndScrollOffsetForRepaint(LayoutRect& paintRect) const
+{
+ paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden.
+
+ // height() is inaccurate if we're in the middle of a layout of this RenderBox, so use the
+ // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
+ // anyway if its size does change.
+ LayoutRect clipRect(LayoutPoint(), cachedSizeForOverflowClip());
+ paintRect = intersection(paintRect, clipRect);
+}
+
LayoutUnit RenderBox::minPreferredLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
@@ -1574,21 +1585,13 @@
// FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout,
// its controlClipRect will be wrong. For overflow clip we use the values cached by the layer.
+ rect.setLocation(topLeft);
if (o->hasOverflowClip()) {
RenderBox* containerBox = toRenderBox(o);
-
- // o->height() is inaccurate if we're in the middle of a layout of |o|, so use the
- // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
- // anyway if its size does change.
- topLeft -= containerBox->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
-
- LayoutRect repaintRect(topLeft, rect.size());
- LayoutRect boxRect(LayoutPoint(), containerBox->cachedSizeForOverflowClip());
- rect = intersection(repaintRect, boxRect);
+ containerBox->applyCachedClipAndScrollOffsetForRepaint(rect);
if (rect.isEmpty())
return;
- } else
- rect.setLocation(topLeft);
+ }
if (containerSkipped) {
// If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates.
Modified: trunk/Source/WebCore/rendering/RenderBox.h (128477 => 128478)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-09-13 17:03:05 UTC (rev 128477)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-09-13 17:22:21 UTC (rev 128478)
@@ -509,6 +509,7 @@
IntSize scrolledContentOffset() const;
LayoutSize cachedSizeForOverflowClip() const;
+ void applyCachedClipAndScrollOffsetForRepaint(LayoutRect& paintRect) const;
virtual bool hasRelativeDimensions() const;
virtual bool hasRelativeLogicalHeight() const;
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (128477 => 128478)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2012-09-13 17:03:05 UTC (rev 128477)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2012-09-13 17:22:21 UTC (rev 128478)
@@ -993,16 +993,9 @@
if (cb->hasColumns())
cb->adjustRectForColumns(repaintRect);
- if (cb->hasOverflowClip()) {
- // cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
- // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
- // anyway if its size does change.
- repaintRect.move(-cb->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
+ if (cb->hasOverflowClip())
+ cb->applyCachedClipAndScrollOffsetForRepaint(repaintRect);
- LayoutRect boxRect(LayoutPoint(), cb->cachedSizeForOverflowClip());
- repaintRect.intersect(boxRect);
- }
-
cb->computeRectForRepaint(repaintContainer, repaintRect);
if (outlineSize) {
@@ -1073,21 +1066,13 @@
// FIXME: We ignore the lightweight clipping rect that controls use, since if |o| is in mid-layout,
// its controlClipRect will be wrong. For overflow clip we use the values cached by the layer.
+ rect.setLocation(topLeft);
if (o->hasOverflowClip()) {
RenderBox* containerBox = toRenderBox(o);
-
- // o->height() is inaccurate if we're in the middle of a layout of |o|, so use the
- // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
- // anyway if its size does change.
- topLeft -= containerBox->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
-
- LayoutRect repaintRect(topLeft, rect.size());
- LayoutRect boxRect(LayoutPoint(), containerBox->cachedSizeForOverflowClip());
- rect = intersection(repaintRect, boxRect);
+ containerBox->applyCachedClipAndScrollOffsetForRepaint(rect);
if (rect.isEmpty())
return;
- } else
- rect.setLocation(topLeft);
+ }
if (containerSkipped) {
// If the repaintContainer is below o, then we need to map the rect into repaintContainer's coordinates.
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (128477 => 128478)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2012-09-13 17:03:05 UTC (rev 128477)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2012-09-13 17:22:21 UTC (rev 128478)
@@ -1507,16 +1507,8 @@
}
if (o->hasOverflowClip()) {
- // o->height() is inaccurate if we're in the middle of a layout of |o|, so use the
- // layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
- // anyway if its size does change.
RenderBox* boxParent = toRenderBox(o);
-
- LayoutRect repaintRect(rect);
- repaintRect.move(-boxParent->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
-
- LayoutRect boxRect(LayoutPoint(), boxParent->cachedSizeForOverflowClip());
- rect = intersection(repaintRect, boxRect);
+ boxParent->applyCachedClipAndScrollOffsetForRepaint(rect);
if (rect.isEmpty())
return;
}