https://bugs.webkit.org/show_bug.cgi?id=76971
Reviewed by David Hyatt.
Refactoring without any change in behavior.
This change adds a RenderBox::scrolledContentOffset function to handle all
the calls that goes through the layer(). This indirection will enable us to
add layer() checks without patching a lot of call sites as part of bug 75568.
We also moved down the concept of scroll offset down to RenderBox where it belongs!
* rendering/RenderLayer.h:
(RenderLayer):
(WebCore::RenderLayer::scrolledContentOffset):
Moved scrolledContent to the private section of the class to prevent misuse.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::scrolledContentOffset):
New function to add an indirection with RenderLayer.
* editing/visible_units.cpp:
(WebCore::absoluteLineDirectionPointToLocalPointInBlock):
* rendering/LayoutState.cpp:
(WebCore::LayoutState::LayoutState):
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::layoutBlock):
(WebCore::RenderBlock::paintObject):
(WebCore::RenderBlock::selectionGapRectsForRepaint):
(WebCore::RenderBlock::paintSelection):
(WebCore::RenderBlock::nodeAtPoint):
(WebCore::RenderBlock::offsetForContents):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::offsetFromContainer):
(WebCore::RenderBox::computeRectForRepaint):
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::clippedOverflowRectForRepaint):
(WebCore::RenderInline::computeRectForRepaint):
(WebCore::RenderInline::offsetFromContainer):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::computeRectForRepaint):
(WebCore::RenderObject::mapLocalToContainer):
(WebCore::RenderObject::mapAbsoluteToLocalPoint):
(WebCore::RenderObject::offsetFromContainer):
* rendering/RenderTextControlSingleLine.cpp:
(WebCore::RenderTextControlInnerBlock::positionForPoint):
Patched all those call sites to use the new function.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@108382
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-02-21 Julien Chaffraix <jchaffraix@webkit.org>
+
+ Move RenderLayer::scrolledContentOffset calls to a common function
+ https://bugs.webkit.org/show_bug.cgi?id=76971
+
+ Reviewed by David Hyatt.
+
+ Refactoring without any change in behavior.
+
+ This change adds a RenderBox::scrolledContentOffset function to handle all
+ the calls that goes through the layer(). This indirection will enable us to
+ add layer() checks without patching a lot of call sites as part of bug 75568.
+
+ We also moved down the concept of scroll offset down to RenderBox where it belongs!
+
+ * rendering/RenderLayer.h:
+ (RenderLayer):
+ (WebCore::RenderLayer::scrolledContentOffset):
+ Moved scrolledContent to the private section of the class to prevent misuse.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::scrolledContentOffset):
+ New function to add an indirection with RenderLayer.
+
+ * editing/visible_units.cpp:
+ (WebCore::absoluteLineDirectionPointToLocalPointInBlock):
+ * rendering/LayoutState.cpp:
+ (WebCore::LayoutState::LayoutState):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::layoutBlock):
+ (WebCore::RenderBlock::paintObject):
+ (WebCore::RenderBlock::selectionGapRectsForRepaint):
+ (WebCore::RenderBlock::paintSelection):
+ (WebCore::RenderBlock::nodeAtPoint):
+ (WebCore::RenderBlock::offsetForContents):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::offsetFromContainer):
+ (WebCore::RenderBox::computeRectForRepaint):
+ * rendering/RenderBox.h:
+ (RenderBox):
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::clippedOverflowRectForRepaint):
+ (WebCore::RenderInline::computeRectForRepaint):
+ (WebCore::RenderInline::offsetFromContainer):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::computeRectForRepaint):
+ (WebCore::RenderObject::mapLocalToContainer):
+ (WebCore::RenderObject::mapAbsoluteToLocalPoint):
+ (WebCore::RenderObject::offsetFromContainer):
+ * rendering/RenderTextControlSingleLine.cpp:
+ (WebCore::RenderTextControlInnerBlock::positionForPoint):
+ Patched all those call sites to use the new function.
+
2012-02-21 Emil A Eklund <eae@chromium.org>
Remove obsolete float comparison FIXMEs
RenderBlock* containingBlock = root->block();
FloatPoint absoluteBlockPoint = containingBlock->localToAbsolute(FloatPoint());
if (containingBlock->hasOverflowClip())
- absoluteBlockPoint -= containingBlock->layer()->scrolledContentOffset();
+ absoluteBlockPoint -= containingBlock->scrolledContentOffset();
if (root->block()->isHorizontalWritingMode())
return IntPoint(lineDirectionPoint - absoluteBlockPoint.x(), root->blockDirectionPointInLine());
m_clipped = true;
}
- m_paintOffset -= layer->scrolledContentOffset();
+ m_paintOffset -= renderer->scrolledContentOffset();
}
// If we establish a new page height, then cache the offset to the top of the first page.
m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y());
if (container->hasOverflowClip()) {
- RenderLayer* layer = toRenderBoxModelObject(container)->layer();
+ RenderBox* containerBox = toRenderBox(container);
+ RenderLayer* layer = containerBox->layer();
m_clipped = true;
m_clipRect = LayoutRect(toPoint(m_paintOffset), layer->size());
- m_paintOffset -= layer->scrolledContentOffset();
+ m_paintOffset -= containerBox->scrolledContentOffset();
}
}
if (hasOverflowClip()) {
// Adjust repaint rect for scroll offset
- repaintRect.move(-layer()->scrolledContentOffset());
+ repaintRect.move(-scrolledContentOffset());
// Don't allow this rect to spill out of our overflow box.
repaintRect.intersect(LayoutRect(LayoutPoint(), size()));
// Adjust our painting position if we're inside a scrolled layer (e.g., an overflow:auto div).
LayoutPoint scrolledOffset = paintOffset;
if (hasOverflowClip())
- scrolledOffset.move(-layer()->scrolledContentOffset());
+ scrolledOffset.move(-scrolledContentOffset());
// 2. paint contents
if (paintPhase != PaintPhaseSelfOutline) {
LayoutPoint offsetFromRepaintContainer = roundedLayoutPoint(transformState.mappedPoint());
if (hasOverflowClip())
- offsetFromRepaintContainer -= layer()->scrolledContentOffset();
+ offsetFromRepaintContainer -= scrolledContentOffset();
LayoutUnit lastTop = 0;
LayoutUnit lastLeft = logicalLeftSelectionOffset(this, lastTop);
LayoutRect localBounds(gapRectsBounds);
flipForWritingMode(localBounds);
gapRectsBounds = localToContainerQuad(FloatRect(localBounds), layer->renderer()).enclosingBoundingBox();
- gapRectsBounds.move(layer->scrolledContentOffset());
+ if (layer->renderer()->hasOverflowClip())
+ gapRectsBounds.move(layer->renderBox()->scrolledContentOffset());
}
layer->addBlockSelectionGapsBounds(gapRectsBounds);
}
if (checkChildren) {
// Hit test descendants first.
LayoutSize scrolledOffset(localOffset);
- if (hasOverflowClip()) {
- scrolledOffset -= layer()->scrolledContentOffset();
- }
+ if (hasOverflowClip())
+ scrolledOffset -= scrolledContentOffset();
// Hit test contents if we don't have columns.
if (!hasColumns()) {
void RenderBlock::offsetForContents(LayoutPoint& offset) const
{
if (hasOverflowClip())
- offset += layer()->scrolledContentOffset();
+ offset += scrolledContentOffset();
if (hasColumns())
adjustPointToColumnContents(offset);
return style()->paddingStart().isPercent() || style()->paddingEnd().isPercent();
}
+IntSize RenderBox::scrolledContentOffset() const
+{
+ ASSERT(hasOverflowClip());
+ ASSERT(hasLayer());
+ return layer()->scrolledContentOffset();
+}
+
LayoutUnit RenderBox::minPreferredLogicalWidth() const
{
if (preferredLogicalWidthsDirty())
}
if (o->hasOverflowClip())
- offset -= toRenderBox(o)->layer()->scrolledContentOffset();
+ offset -= toRenderBox(o)->scrolledContentOffset();
if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->isRenderInline())
offset += toRenderInline(o)->relativePositionedInlineOffset(this);
// 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->layer()->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
+ topLeft -= containerBox->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
LayoutRect repaintRect(topLeft, rect.size());
LayoutRect boxRect(LayoutPoint(), containerBox->layer()->size());
virtual bool needsPreferredWidthsRecalculation() const;
virtual void computeIntrinsicRatioInformation(FloatSize& /* intrinsicSize */, double& /* intrinsicRatio */, bool& /* isPercentageIntrinsicSize */) const { }
+ IntSize scrolledContentOffset() const;
+
protected:
virtual void willBeDestroyed();
LayoutRect scrolledPaintRect = rect;
if (clippedWithLocalScrolling) {
// Clip to the overflow area.
- context->clip(toRenderBox(this)->overflowClipRect(rect.location(), paintInfo.renderRegion));
+ RenderBox* thisBox = toRenderBox(this);
+ context->clip(thisBox->overflowClipRect(rect.location(), paintInfo.renderRegion));
// Adjust the paint rect to reflect a scrolled content box with borders at the ends.
- LayoutSize offset = layer()->scrolledContentOffset();
+ IntSize offset = thisBox->scrolledContentOffset();
scrolledPaintRect.move(-offset);
scrolledPaintRect.setWidth(bLeft + layer()->scrollWidth() + bRight);
scrolledPaintRect.setHeight(borderTop() + layer()->scrollHeight() + borderBottom());
// layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
// anyway if its size does change.
LayoutRect repaintRect(r);
- repaintRect.move(-cb->layer()->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
+ repaintRect.move(-cb->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
LayoutRect boxRect(LayoutPoint(), cb->layer()->size());
r = intersection(repaintRect, boxRect);
// 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->layer()->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
+ topLeft -= containerBox->scrolledContentOffset(); // For overflow:auto/scroll/hidden.
LayoutRect repaintRect(topLeft, rect.size());
LayoutRect boxRect(LayoutPoint(), containerBox->layer()->size());
container->adjustForColumns(offset, point);
if (container->hasOverflowClip())
- offset -= toRenderBox(container)->layer()->scrolledContentOffset();
+ offset -= toRenderBox(container)->scrolledContentOffset();
return offset;
}
// Scrolling methods for layers that can scroll their overflow.
void scrollByRecursively(LayoutUnit xDelta, LayoutUnit yDelta, ScrollOffsetClamping = ScrollOffsetUnclamped);
- IntSize scrolledContentOffset() const { return scrollOffset() + roundedIntSize(m_scrollOverflow); }
-
int scrollXOffset() const { return m_scrollOffset.width() + scrollOrigin().x(); }
int scrollYOffset() const { return m_scrollOffset.height() + scrollOrigin().y(); }
IntSize scrollOffset() const { return IntSize(scrollXOffset(), scrollYOffset()); }
bool shouldRepaintAfterLayout() const;
+ friend IntSize RenderBox::scrolledContentOffset() const;
+ IntSize scrolledContentOffset() const { return scrollOffset() + m_scrollOverflow; }
+
// The normal operator new is disallowed on all render objects.
void* operator new(size_t) throw();
RenderBox* boxParent = toRenderBox(o);
LayoutRect repaintRect(rect);
- repaintRect.move(-boxParent->layer()->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
+ repaintRect.move(-boxParent->scrolledContentOffset()); // For overflow:auto/scroll/hidden.
LayoutRect boxRect(LayoutPoint(), boxParent->layer()->size());
rect = intersection(repaintRect, boxRect);
transformState.move(columnOffset);
if (o->hasOverflowClip())
- transformState.move(-toRenderBox(o)->layer()->scrolledContentOffset());
+ transformState.move(-toRenderBox(o)->scrolledContentOffset());
o->mapLocalToContainer(repaintContainer, fixed, useTransforms, transformState, wasFixed);
}
if (o) {
o->mapAbsoluteToLocalPoint(fixed, useTransforms, transformState);
if (o->hasOverflowClip())
- transformState.move(toRenderBox(o)->layer()->scrolledContentOffset());
+ transformState.move(toRenderBox(o)->scrolledContentOffset());
}
}
o->adjustForColumns(offset, point);
if (o->hasOverflowClip())
- offset -= toRenderBox(o)->layer()->scrolledContentOffset();
+ offset -= toRenderBox(o)->scrolledContentOffset();
return offset;
}
if (m_multiLine) {
RenderTextControl* renderer = toRenderTextControl(node()->shadowAncestorNode()->renderer());
if (renderer->hasOverflowClip())
- contentsPoint += renderer->layer()->scrolledContentOffset();
+ contentsPoint += renderer->scrolledContentOffset();
}
return RenderBlock::positionForPoint(contentsPoint);