Index: Source/core/frame/FrameView.cpp |
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp |
index 8f2d646c804d0db3a04aac9a6f07a81752979b1a..1d42955718a66044a56fc81304a31640761a017e 100644 |
--- a/Source/core/frame/FrameView.cpp |
+++ b/Source/core/frame/FrameView.cpp |
@@ -1241,18 +1241,12 @@ |
} |
} |
-// 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) |
-{ |
- 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); |
- } |
+void FrameView::scrollContentsIfNeeded() |
+{ |
+ bool didScroll = !pendingScrollDelta().isZero(); |
+ ScrollView::scrollContentsIfNeeded(); |
+ if (didScroll) |
+ updateFixedElementPaintInvalidationRectsAfterScroll(); |
} |
bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
@@ -1265,6 +1259,7 @@ |
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; |
@@ -1272,7 +1267,8 @@ |
ASSERT(renderer->hasLayer()); |
RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
- if (layer->isPaintInvalidationContainer()) |
+ CompositingState state = layer->compositingState(); |
+ if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking) |
continue; |
if (layer->subtreeIsInvisible()) |
@@ -1283,10 +1279,39 @@ |
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; |
} |
@@ -1513,6 +1538,32 @@ |
updateWidgetPositions(); |
if (RenderView* renderView = this->renderView()) |
renderView->layer()->setNeedsCompositingInputsUpdate(); |
+ } |
+} |
+ |
+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(); |
} |
} |
@@ -2509,8 +2560,7 @@ |
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()); |
@@ -2523,13 +2573,11 @@ |
updateCompositedSelectionBoundsIfNeeded(); |
InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); |
+ |
+ invalidateTreeIfNeededRecursive(); |
} |
scrollContentsIfNeededRecursive(); |
- |
- if (view) |
- invalidateTreeIfNeededRecursive(); |
- |
ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); |
} |