Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/FrameView.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/FrameView.cpp b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| index 8b43865107c3c03ed3f4aef590f6580215115b9a..4427bc73478c59214f8d622b4447dd750919aed0 100644 |
| --- a/third_party/WebKit/Source/core/frame/FrameView.cpp |
| +++ b/third_party/WebKit/Source/core/frame/FrameView.cpp |
| @@ -224,13 +224,18 @@ void FrameView::reset() |
| } |
| template <typename Function> |
| -void FrameView::forAllFrameViews(Function function) |
| +void FrameView::forAllNonThrottlingFrameViews(Function function) |
| { |
| - for (Frame* frame = m_frame.get(); frame; frame = frame->tree().traverseNext(m_frame.get())) { |
| - if (!frame->isLocalFrame()) |
| + if (shouldThrottleRendering()) |
| + return; |
|
Xianzhu
2015/10/28 18:10:23
We need to check frame throttling in frame parent-
|
| + |
| + function(*this); |
| + |
| + for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { |
| + if (!child->isLocalFrame()) |
| continue; |
| - if (FrameView* view = toLocalFrame(frame)->view()) |
| - function(*view); |
| + if (FrameView* childView = toLocalFrame(child)->view()) |
| + childView->forAllNonThrottlingFrameViews(function); |
| } |
| } |
| @@ -1291,9 +1296,7 @@ bool FrameView::shouldSetCursor() const |
| void FrameView::scrollContentsIfNeededRecursive() |
| { |
| - forAllFrameViews([](FrameView& frameView) { |
| - if (frameView.shouldThrottleRendering()) |
| - return; |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { |
| frameView.scrollContentsIfNeeded(); |
| }); |
| } |
| @@ -1823,7 +1826,7 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor) |
| void FrameView::updateBackgroundRecursively(const Color& backgroundColor, bool transparent) |
| { |
| - forAllFrameViews([backgroundColor, transparent](FrameView& frameView) { |
| + forAllNonThrottlingFrameViews([backgroundColor, transparent](FrameView& frameView) { |
| frameView.setTransparent(transparent); |
| frameView.setBaseBackgroundColor(backgroundColor); |
| }); |
| @@ -2456,7 +2459,7 @@ void FrameView::updateLifecyclePhasesInternal(LifeCycleUpdateOption phases, cons |
| if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| updatePaintProperties(); |
| - if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled()) { |
| + if (RuntimeEnabledFeatures::slimmingPaintSynchronizedPaintingEnabled() && !m_frame->document()->printing()) { |
|
Xianzhu
2015/10/28 18:10:23
Without this check, we'll mistakenly paint onto th
|
| synchronizedPaint(interestRect); |
| if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) |
| compositeForSlimmingPaintV2(); |
| @@ -2479,9 +2482,9 @@ void FrameView::updatePaintProperties() |
| { |
| ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| - forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InUpdatePaintProperties); }); |
| PaintPropertyTreeBuilder().buildPropertyTrees(*this); |
| - forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::UpdatePaintPropertiesClean); }); |
| } |
| void FrameView::synchronizedPaint(const LayoutRect* interestRect) |
| @@ -2491,16 +2494,16 @@ void FrameView::synchronizedPaint(const LayoutRect* interestRect) |
| LayoutView* view = layoutView(); |
| ASSERT(view); |
| - // TODO(chrishtr): figure out if there can be any GraphicsLayer above this one that draws content. |
| - GraphicsLayer* rootGraphicsLayer = view->layer()->graphicsLayerBacking(); |
| - forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); }); |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InPaint); }); |
| // A null graphics layer can occur for painting of SVG images that are not parented into the main frame tree. |
| - if (rootGraphicsLayer) { |
| + if (GraphicsLayer* rootGraphicsLayer = view->compositor()->rootGraphicsLayer()) { |
| + while (GraphicsLayer* parent = rootGraphicsLayer->parent()) |
| + rootGraphicsLayer = parent; |
|
Xianzhu
2015/10/28 18:10:23
We need to start from the top-most graphics layer
|
| synchronizedPaintRecursively(rootGraphicsLayer, interestRect); |
| } |
| - forAllFrameViews([](FrameView& frameView) { |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { |
| frameView.lifecycle().advanceTo(DocumentLifecycle::PaintClean); |
| frameView.layoutView()->layer()->clearNeedsRepaintRecursively(); |
| }); |
| @@ -2511,6 +2514,13 @@ void FrameView::synchronizedPaintRecursively(GraphicsLayer* graphicsLayer, const |
| ASSERT(graphicsLayer->paintController()); |
| GraphicsContext context(*graphicsLayer->paintController()); |
| + if (GraphicsLayer* maskLayer = graphicsLayer->maskLayer()) |
| + synchronizedPaintRecursively(maskLayer, interestRect); |
| + if (GraphicsLayer* contentsClippingMaskLayer = graphicsLayer->contentsClippingMaskLayer()) |
| + synchronizedPaintRecursively(contentsClippingMaskLayer, interestRect); |
| + if (GraphicsLayer* replicaLayer = graphicsLayer->replicaLayer()) |
| + synchronizedPaintRecursively(replicaLayer, interestRect); |
|
Xianzhu
2015/10/28 18:10:22
These GraphicsLayers are not in the normal parent-
|
| + |
| // TODO(chrishtr): fix unit tests to not inject one-off interest rects. |
| if (interestRect) |
| graphicsLayer->paint(context, roundedIntRect(*interestRect)); |
| @@ -2529,13 +2539,13 @@ void FrameView::compositeForSlimmingPaintV2() |
| ASSERT(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
| ASSERT(frame() == page()->mainFrame() || (!frame().tree().parent()->isLocalFrame())); |
| - forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InCompositingForSlimmingPaintV2); }); |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::InCompositingForSlimmingPaintV2); }); |
| // Detached frames can have no root graphics layer. |
| if (GraphicsLayer* rootGraphicsLayer = layoutView()->layer()->graphicsLayerBacking()) |
| rootGraphicsLayer->paintController()->commitNewDisplayItems(); |
| - forAllFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::CompositingForSlimmingPaintV2Clean); }); |
| + forAllNonThrottlingFrameViews([](FrameView& frameView) { frameView.lifecycle().advanceTo(DocumentLifecycle::CompositingForSlimmingPaintV2Clean); }); |
| } |
| void FrameView::updateFrameTimingRequestsIfNeeded() |
| @@ -2619,7 +2629,8 @@ void FrameView::invalidateTreeIfNeededRecursive() |
| Vector<LayoutObject*> pendingDelayedPaintInvalidations; |
| PaintInvalidationState rootPaintInvalidationState(*layoutView(), pendingDelayedPaintInvalidations); |
| - invalidateTreeIfNeeded(rootPaintInvalidationState); |
| + if (lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) |
|
Xianzhu
2015/10/28 18:10:23
This check is moved out of the loop below, so that
|
| + invalidateTreeIfNeeded(rootPaintInvalidationState); |
| // Some frames may be not reached during the above invalidateTreeIfNeeded because |
| // - the frame is a detached frame; or |
| @@ -2627,11 +2638,8 @@ void FrameView::invalidateTreeIfNeededRecursive() |
| // We need to call invalidateTreeIfNeededRecursive() for such frames to finish required |
| // paint invalidation and advance their life cycle state. |
| for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { |
| - if (!child->isLocalFrame()) |
| - continue; |
| - FrameView* childFrameView = toLocalFrame(child)->view(); |
| - if (childFrameView->lifecycle().state() < DocumentLifecycle::PaintInvalidationClean) |
| - childFrameView->invalidateTreeIfNeededRecursive(); |
| + if (child->isLocalFrame()) |
| + toLocalFrame(child)->view()->invalidateTreeIfNeededRecursive(); |
| } |
| // Process objects needing paint invalidation on the next frame. See the definition of PaintInvalidationDelayedFull for more details. |