Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1516683002: Introducing LayoutObject::mapToVisibleRectInContainerSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fix flipping logic Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutBox.cpp b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
index 3b671d8d42b3358bd8d550c09b3042365177e79c..d673e7fcaa3e2c9d03513f105841d0e1f73988d7 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBox.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutBox.cpp
@@ -939,20 +939,28 @@ IntSize LayoutBox::scrolledContentOffset() const
return flooredIntSize(layer()->scrollableArea()->scrollOffset());
}
+void LayoutBox::applyCachedScrollOffsetForPaintInvalidation(LayoutRect& paintRect) const
+{
+ ASSERT(hasLayer());
+ ASSERT(hasOverflowClip());
+
+ LayoutSize offset = LayoutSize(-scrolledContentOffset());
+ if (UNLIKELY(hasFlippedBlocksWritingMode())) {
+ if (isHorizontalWritingMode())
+ offset.setHeight(-offset.height());
+ else
+ offset.setWidth(-offset.width());
+ }
+ paintRect.move(offset);
+}
+
void LayoutBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& paintRect) const
{
ASSERT(hasLayer());
ASSERT(hasOverflowClip());
+ applyCachedScrollOffsetForPaintInvalidation(paintRect);
flipForWritingMode(paintRect);
- paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden.
-
- // Do not clip scroll layer contents because the compositor expects the whole layer
- // to be always invalidated in-time.
- if (usesCompositedScrolling()) {
- flipForWritingMode(paintRect);
- return;
- }
// size() is inaccurate if we're in the middle of a layout of this LayoutBox, so use the
// layer's size instead. Even if the layer's size is wrong, the layer itself will issue paint invalidations
@@ -1426,7 +1434,7 @@ bool LayoutBox::intersectsVisibleViewport()
LayoutView* layoutView = view();
while (layoutView->frame()->ownerLayoutObject())
layoutView = layoutView->frame()->ownerLayoutObject()->view();
- mapRectToPaintInvalidationBacking(layoutView, rect, 0);
+ mapToVisibleRectInContainerSpace(layoutView, rect, 0);
return rect.intersects(LayoutRect(layoutView->frameView()->scrollableArea()->visibleContentRectDouble()));
}
@@ -1856,11 +1864,11 @@ LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
}
LayoutRect r = visualOverflowRect();
- mapRectToPaintInvalidationBacking(paintInvalidationContainer, r, paintInvalidationState);
+ mapToVisibleRectInContainerSpace(paintInvalidationContainer, r, paintInvalidationState);
return r;
}
-void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) const
+void LayoutBox::mapToVisibleRectInContainerSpace(const LayoutBoxModelObject* paintInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintInvalidationState) const
{
// The rect we compute at each step is shifted by our x/y offset in the parent container's coordinate space.
// Only when we cross a writing mode boundary will we have to possibly flipForWritingMode (to convert into a more appropriate
@@ -1934,7 +1942,10 @@ void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
rect.setLocation(topLeft);
if (o->hasOverflowClip()) {
LayoutBox* containerBox = toLayoutBox(o);
- containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect);
+ if (o == paintInvalidationContainer)
+ containerBox->applyCachedScrollOffsetForPaintInvalidation(rect);
+ else
+ containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect);
if (rect.isEmpty())
return;
}
@@ -1950,9 +1961,9 @@ void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
}
if (o->isLayoutView())
- toLayoutView(o)->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, LayoutView::viewportConstrainedPosition(position), paintInvalidationState);
+ toLayoutView(o)->mapToVisibleRectInContainerSpace(paintInvalidationContainer, rect, LayoutView::viewportConstrainedPosition(position), paintInvalidationState);
else
- o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, paintInvalidationState);
+ o->mapToVisibleRectInContainerSpace(paintInvalidationContainer, rect, paintInvalidationState);
}
void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& paintInvalidationRect) const
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.h ('k') | third_party/WebKit/Source/core/layout/LayoutFlowThread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698