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

Unified Diff: Source/core/frame/FrameView.cpp

Issue 543203004: Revert "Move some scroll invalidations to the paint invalidation phase" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months 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
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderLayerRepainter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/FrameView.cpp
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp
index 0aead4777869975461aa32155082b51948005ade..068f3d14dc6d5f6e2926d31a6a3a56af7af2cb86 100644
--- a/Source/core/frame/FrameView.cpp
+++ b/Source/core/frame/FrameView.cpp
@@ -1244,18 +1244,12 @@ void FrameView::scrollContentsIfNeededRecursive()
}
}
-// FIXME: If we had a flag to force invalidations in a whole subtree, we could get rid of this function (crbug.com/410097).
-static void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(const RenderLayer* layer)
+void FrameView::scrollContentsIfNeeded()
{
- layer->renderer()->setShouldDoFullPaintInvalidation(true);
-
- for (RenderLayer* child = layer->firstChild(); child; child = child->nextSibling()) {
- // Don't include paint invalidation rects for composited child layers; they will paint themselves and have a different origin.
- if (child->isPaintInvalidationContainer())
- continue;
-
- setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(child);
- }
+ bool didScroll = !pendingScrollDelta().isZero();
+ ScrollView::scrollContentsIfNeeded();
+ if (didScroll)
+ updateFixedElementPaintInvalidationRectsAfterScroll();
}
bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
@@ -1268,6 +1262,7 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
return true;
}
+ Region regionToUpdate;
ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
RenderObject* renderer = *it;
@@ -1275,7 +1270,8 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
ASSERT(renderer->hasLayer());
RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
- if (layer->isPaintInvalidationContainer())
+ CompositingState state = layer->compositingState();
+ if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking)
continue;
if (layer->subtreeIsInvisible())
@@ -1286,10 +1282,39 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta)
if (layer->hasAncestorWithFilterOutsets())
return false;
- setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(layer);
+ IntRect updateRect = pixelSnappedIntRect(layer->paintInvalidator().paintInvalidationRectIncludingNonCompositingDescendants());
+
+ const RenderLayerModelObject* repaintContainer = layer->renderer()->containerForPaintInvalidation();
+ if (repaintContainer && !repaintContainer->isRenderView()) {
+ // Invalidate the old and new locations of fixed position elements that are not drawn into the RenderView.
+ updateRect.moveBy(scrollPosition());
+ IntRect previousRect = updateRect;
+ previousRect.move(scrollDelta);
+ // FIXME: Rather than uniting the rects, we should just issue both invalidations.
+ updateRect.unite(previousRect);
+ layer->renderer()->invalidatePaintUsingContainer(repaintContainer, updateRect, InvalidationScroll);
+ } else {
+ // Coalesce the paint invalidations that will be issued to the renderView.
+ updateRect = contentsToRootView(updateRect);
+ if (!updateRect.isEmpty())
+ regionToUpdate.unite(updateRect);
+ }
}
InspectorInstrumentation::didScroll(page());
+
+ // Invalidate the old and new locations of fixed position elements that are drawn into the RenderView.
+ Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
+ size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
+ for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
+ IntRect updateRect = subRectsToUpdate[i];
+ IntRect scrolledRect = updateRect;
+ scrolledRect.move(-scrollDelta);
+ updateRect.unite(scrolledRect);
+ // FIXME: We should be able to issue these invalidations separately and before we actually scroll.
+ renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidationInRect(rootViewToContents(updateRect));
+ }
+
return true;
}
@@ -1519,6 +1544,32 @@ void FrameView::updateLayersAndCompositingAfterScrollIfNeeded()
}
}
+void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll()
+{
+ if (!hasViewportConstrainedObjects())
+ return;
+
+ // Update the paint invalidation rects for fixed elements after scrolling and invalidation to reflect
+ // the new scroll position.
+ ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObjects->end();
+ for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrainedObjects->begin(); it != end; ++it) {
+ RenderObject* renderer = *it;
+ // m_viewportConstrainedObjects should not contain non-viewport constrained objects.
+ ASSERT(renderer->style()->hasViewportConstrainedPosition());
+
+ // Fixed items should always have layers.
+ ASSERT(renderer->hasLayer());
+
+ RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
+
+ // Don't need to do this for composited fixed items.
+ if (layer->compositingState() == PaintsIntoOwnBacking)
+ continue;
+
+ layer->paintInvalidator().computePaintInvalidationRectsIncludingNonCompositingDescendants();
+ }
+}
+
void FrameView::updateCompositedSelectionBoundsIfNeeded()
{
if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled())
@@ -2516,8 +2567,7 @@ void FrameView::updateLayoutAndStyleForPainting()
updateWidgetPositionsIfNeeded();
- RenderView* view = renderView();
- if (view) {
+ if (RenderView* view = renderView()) {
TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "UpdateLayerTree", "frame", m_frame.get());
// FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing.
InspectorInstrumentation::willUpdateLayerTree(m_frame.get());
@@ -2530,13 +2580,11 @@ void FrameView::updateLayoutAndStyleForPainting()
updateCompositedSelectionBoundsIfNeeded();
InspectorInstrumentation::didUpdateLayerTree(m_frame.get());
- }
- scrollContentsIfNeededRecursive();
-
- if (view)
invalidateTreeIfNeededRecursive();
+ }
+ scrollContentsIfNeededRecursive();
ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean);
}
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderLayerRepainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698