Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| index 5d639a1d6945e3b112569310f6e9319609b3aaf0..a2c8addbdb6ca334bdde9212a6230e87a1edeeaa 100644 |
| --- a/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| +++ b/third_party/WebKit/Source/core/layout/compositing/PaintLayerCompositor.cpp |
| @@ -184,12 +184,16 @@ static LayoutVideo* FindFullscreenVideoLayoutObject(Document& document) { |
| return ToLayoutVideo(layout_object); |
| } |
| -void PaintLayerCompositor::UpdateIfNeededRecursive() { |
| +void PaintLayerCompositor::UpdateIfNeededRecursive( |
| + DocumentLifecycle::LifecycleState target_state) { |
| SCOPED_BLINK_UMA_HISTOGRAM_TIMER("Blink.Compositing.UpdateTime"); |
| - UpdateIfNeededRecursiveInternal(); |
| + UpdateIfNeededRecursiveInternal(target_state); |
| } |
| -void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() { |
| +void PaintLayerCompositor::UpdateIfNeededRecursiveInternal( |
| + DocumentLifecycle::LifecycleState target_state) { |
| + DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean); |
| + |
| FrameView* view = layout_view_.GetFrameView(); |
| if (view->ShouldThrottleRendering()) |
| return; |
| @@ -205,10 +209,11 @@ void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() { |
| // the middle of frame detach. |
| // TODO(bbudge) Remove this check when trusted Pepper plugins are gone. |
| if (local_frame->GetDocument()->IsActive() && |
| - !local_frame->ContentLayoutItem().IsNull()) |
| + !local_frame->ContentLayoutItem().IsNull()) { |
| local_frame->ContentLayoutItem() |
| .Compositor() |
| - ->UpdateIfNeededRecursiveInternal(); |
| + ->UpdateIfNeededRecursiveInternal(target_state); |
| + } |
| } |
| TRACE_EVENT0("blink", "PaintLayerCompositor::updateIfNeededRecursive"); |
| @@ -226,9 +231,11 @@ void PaintLayerCompositor::UpdateIfNeededRecursiveInternal() { |
| layout_view_.CommitPendingSelection(); |
| - Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate); |
| - UpdateIfNeeded(); |
| - Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean); |
| + UpdateIfNeeded(target_state); |
| + DCHECK(Lifecycle().GetState() == DocumentLifecycle::kCompositingInputsClean || |
| + Lifecycle().GetState() == DocumentLifecycle::kCompositingClean); |
| + if (target_state == DocumentLifecycle::kCompositingInputsClean) |
| + return; |
| Optional<CompositorElementIdSet> composited_element_ids; |
| DocumentAnimations::UpdateAnimations(layout_view_.GetDocument(), |
| @@ -371,17 +378,27 @@ GraphicsLayer* PaintLayerCompositor::ParentForContentLayers() const { |
| return IsMainFrame() ? GetVisualViewport().ScrollLayer() : nullptr; |
| } |
| -void PaintLayerCompositor::UpdateIfNeeded() { |
| +void PaintLayerCompositor::UpdateIfNeeded( |
| + DocumentLifecycle::LifecycleState target_state) { |
| + DCHECK(target_state >= DocumentLifecycle::kCompositingInputsClean); |
| + |
| + Lifecycle().AdvanceTo(DocumentLifecycle::kInCompositingUpdate); |
| + |
| CompositingUpdateType update_type = pending_update_type_; |
| pending_update_type_ = kCompositingUpdateNone; |
| if (!HasAcceleratedCompositing()) { |
| UpdateWithoutAcceleratedCompositing(update_type); |
| + Lifecycle().AdvanceTo( |
| + std::min(DocumentLifecycle::kCompositingClean, target_state)); |
| return; |
| } |
| - if (update_type == kCompositingUpdateNone) |
| + if (update_type == kCompositingUpdateNone) { |
| + Lifecycle().AdvanceTo( |
| + std::min(DocumentLifecycle::kCompositingClean, target_state)); |
| return; |
| + } |
| PaintLayer* update_root = RootLayer(); |
| @@ -396,6 +413,16 @@ void PaintLayerCompositor::UpdateIfNeeded() { |
| update_root); |
| #endif |
| + // In the case where we only want to make compositing inputs clean, we |
| + // early-exit here. Because we have not handled the other implications of |
| + // |pending_update_type_| > kCompositingUpdateNone, we must restore the |
| + // pending update type for a future call. |
| + if (target_state == DocumentLifecycle::kCompositingInputsClean) { |
| + pending_update_type_ = update_type; |
| + Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); |
| + return; |
| + } |
| + |
| CompositingRequirementsUpdater(layout_view_, compositing_reason_finder_) |
| .Update(update_root); |
| @@ -422,6 +449,15 @@ void PaintLayerCompositor::UpdateIfNeeded() { |
| } |
| } |
| + // If we hit this check then we were asked to only make compositing inputs |
| + // clean but they were already clean. Therefore the correct behavior is to |
| + // just restore the pending state and exit. |
| + if (target_state == DocumentLifecycle::kCompositingInputsClean) { |
|
flackr
2017/04/12 15:50:15
I think this early exit would be cleaner at the to
smcgruer
2017/04/12 17:18:44
Done.
|
| + pending_update_type_ = update_type; |
| + Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingInputsClean); |
| + return; |
| + } |
| + |
| if (RuntimeEnabledFeatures::compositorWorkerEnabled() && scroll_layer_) { |
| // If rootLayerScrolls is enabled, these properties are applied in |
| // CompositedLayerMapping::updateElementIdAndCompositorMutableProperties. |
| @@ -488,6 +524,8 @@ void PaintLayerCompositor::UpdateIfNeeded() { |
| // Inform the inspector that the layer tree has changed. |
| if (IsMainFrame()) |
| probe::layerTreeDidChange(layout_view_.GetFrame()); |
| + |
| + Lifecycle().AdvanceTo(DocumentLifecycle::kCompositingClean); |
| } |
| static void RestartAnimationOnCompositor(const LayoutObject& layout_object) { |