Chromium Code Reviews| Index: Source/core/frame/FrameView.cpp |
| diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp |
| index 8a77e1c54aaa736455d5ab871b9195bd530617c6..026c28f45f5b9a55d6832f3452df1687ba90927f 100644 |
| --- a/Source/core/frame/FrameView.cpp |
| +++ b/Source/core/frame/FrameView.cpp |
| @@ -1344,6 +1344,19 @@ static void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(c |
| } |
| } |
| +LayoutRect paintInvalidationRectIncludingNonCompositingDescendants(RenderLayer* layer) |
| +{ |
| + LayoutRect paintInvalidationRect = layer->renderer()->previousPaintInvalidationRect(); |
| + 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->compositingState() == PaintsIntoOwnBacking || child->compositingState() == PaintsIntoGroupedBacking) |
|
dsinclair
2014/11/11 19:51:23
Should this be isPaintInvalidationContainer()?
|
| + continue; |
| + |
| + paintInvalidationRect.unite(paintInvalidationRectIncludingNonCompositingDescendants(child)); |
| + } |
| + return paintInvalidationRect; |
| +} |
| + |
| bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
| { |
| if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) |
| @@ -1354,13 +1367,15 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
| return true; |
| } |
| + Region regionToUpdate; |
| for (const auto& viewportConstrainedObject : *m_viewportConstrainedObjects) { |
| RenderObject* renderer = viewportConstrainedObject; |
| ASSERT(renderer->style()->hasViewportConstrainedPosition()); |
| ASSERT(renderer->hasLayer()); |
| RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
| - if (layer->isPaintInvalidationContainer()) |
| + CompositingState state = layer->compositingState(); |
| + if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking) |
|
dsinclair
2014/11/11 19:51:23
Should this stay as layer->isPaintInvalidationCont
Julien - ping for review
2014/11/12 18:46:01
Changed as it made more sense.
|
| continue; |
| if (layer->subtreeIsInvisible()) |
| @@ -1371,10 +1386,39 @@ bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
| if (layer->hasAncestorWithFilterOutsets()) |
| return false; |
| - setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(layer); |
| + IntRect updateRect = pixelSnappedIntRect(paintInvalidationRectIncludingNonCompositingDescendants(layer)); |
| + |
| + 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, PaintInvalidationScroll); |
| + } 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()->setBackingNeedsPaintInvalidationInRect(rootViewToContents(updateRect), PaintInvalidationScroll); |
| + } |
| + |
| return true; |
| } |
| @@ -2554,12 +2598,12 @@ void FrameView::updateLayoutAndStyleForPainting() |
| updateCompositedSelectionBoundsIfNeeded(); |
| InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); |
| - } |
| - scrollContentsIfNeededRecursive(); |
| + scrollContentsIfNeededRecursive(); |
|
dsinclair
2014/11/11 19:51:23
Did you mean to move these up into the if (view) {
Julien - ping for review
2014/11/12 18:46:01
It was a bad merge, fixed.
|
| - if (view) |
| - invalidateTreeIfNeededRecursive(); |
| + if (view) |
| + invalidateTreeIfNeededRecursive(); |
| + } |
| ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); |
| } |
| @@ -3513,6 +3557,28 @@ void FrameView::scrollContentsIfNeeded() |
| m_pendingScrollDelta = DoubleSize(); |
| // FIXME: Change scrollContents() to take DoubleSize. crbug.com/414283. |
| scrollContents(flooredIntSize(scrollDelta)); |
| + updateFixedElementPaintInvalidationRectsAfterScroll(); |
| +} |
| + |
| +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; |
| + forceRecomputePaintInvalidationRectsIncludingNonCompositingDescendants(layer->renderer()); |
| + } |
| } |
| void FrameView::scrollContents(const IntSize& scrollDelta) |