Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| index 53ebcc64224eea42f9f30b9f3b5b941acca85d57..c841a1b9d97e9d99b9ad75a20c86073f0f77c3b2 100644 |
| --- a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| @@ -21,7 +21,8 @@ struct PrePaintTreeWalkContext { |
| WTF::WrapUnique(new PaintPropertyTreeBuilderContext)), |
| paint_invalidator_context(tree_builder_context.get()), |
| ancestor_overflow_paint_layer(nullptr), |
| - ancestor_transformed_or_root_paint_layer(nullptr) {} |
| + ancestor_transformed_or_root_paint_layer(nullptr), |
| + enclosing_paint_layer(nullptr) {} |
| PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parent_context, |
| bool needs_tree_builder_context) |
| @@ -35,7 +36,8 @@ struct PrePaintTreeWalkContext { |
| ancestor_overflow_paint_layer( |
| parent_context.ancestor_overflow_paint_layer), |
| ancestor_transformed_or_root_paint_layer( |
| - parent_context.ancestor_transformed_or_root_paint_layer) { |
| + parent_context.ancestor_transformed_or_root_paint_layer), |
| + enclosing_paint_layer(parent_context.enclosing_paint_layer) { |
| #if DCHECK_IS_ON() |
| if (needs_tree_builder_context) |
| DCHECK(parent_context.tree_builder_context->is_actually_needed); |
| @@ -55,6 +57,7 @@ struct PrePaintTreeWalkContext { |
| // block or stacking ancestor. |
| PaintLayer* ancestor_overflow_paint_layer; |
| PaintLayer* ancestor_transformed_or_root_paint_layer; |
| + PaintLayer* enclosing_paint_layer; |
| }; |
| void PrePaintTreeWalk::Walk(FrameView& root_frame) { |
| @@ -66,8 +69,9 @@ void PrePaintTreeWalk::Walk(FrameView& root_frame) { |
| root_frame.GetLayoutView()->Layer(); |
| // GeometryMapper depends on paint properties. |
| - if (NeedsTreeBuilderContextUpdate(root_frame, initial_context)) |
| + if (NeedsTreeBuilderContextUpdate(root_frame, initial_context)) { |
| GeometryMapper::ClearCache(); |
| + } |
| Walk(root_frame, initial_context); |
| paint_invalidator_.ProcessPendingDelayedPaintInvalidations(); |
| @@ -79,7 +83,6 @@ void PrePaintTreeWalk::Walk(FrameView& frame_view, |
| // Skip the throttled frame. Will update it when it becomes unthrottled. |
| return; |
| } |
| - |
| bool needs_tree_builder_context_update = |
| this->NeedsTreeBuilderContextUpdate(frame_view, parent_context); |
| PrePaintTreeWalkContext context(parent_context, |
| @@ -94,7 +97,19 @@ void PrePaintTreeWalk::Walk(FrameView& frame_view, |
| context.paint_invalidator_context); |
| if (LayoutView* view = frame_view.GetLayoutView()) { |
| - Walk(*view, context); |
| + bool ignored; |
| + if (!ShouldEarlyOut(*view, context, ignored)) { |
| + context.enclosing_paint_layer = view->Layer(); |
| + if (!context.tree_builder_context) { |
| + context.tree_builder_context = |
| + WTF::WrapUnique(new PaintPropertyTreeBuilderContext); |
|
chrishtr
2017/04/12 17:31:41
This is a little weird and awkward, let's discuss
|
| + } |
| +#if DCHECK_IS_ON() |
| + if (context.tree_builder_context) |
| + context.tree_builder_context->is_actually_needed = true; |
| +#endif |
| + Walk(*view, context); |
| + } |
| #if DCHECK_IS_ON() |
| view->AssertSubtreeClearedPaintInvalidationFlags(); |
| #endif |
| @@ -126,6 +141,8 @@ static void UpdateAuxiliaryObjectProperties(const LayoutObject& object, |
| if (paint_layer->IsRootLayer() || object.HasOverflowClip()) |
| context.ancestor_overflow_paint_layer = paint_layer; |
| + |
| + context.enclosing_paint_layer = paint_layer; |
| } |
| void PrePaintTreeWalk::ComputeClipRectForContext( |
| @@ -148,6 +165,9 @@ void PrePaintTreeWalk::InvalidatePaintLayerOptimizationsIfNeeded( |
| return; |
| PaintLayer& paint_layer = *ToLayoutBoxModelObject(object).Layer(); |
| + if (!paint_layer.SupportsSubsequenceCaching()) |
| + return; |
| + |
| if (object.StyleRef().HasTransform() || |
| &object == |
| context.paint_invalidator_context.paint_invalidation_container) { |
| @@ -246,16 +266,28 @@ bool PrePaintTreeWalk::NeedsTreeBuilderContextUpdate( |
| parent_context.tree_builder_context->force_subtree_update) || |
| // If the object needs visual rect update, we should update tree |
| // builder context which is needed by visual rect update. |
| - parent_context.paint_invalidator_context.NeedsVisualRectUpdate(object); |
| + parent_context.paint_invalidator_context.NeedsVisualRectUpdate( |
| + object) || |
| + (parent_context.enclosing_paint_layer && |
|
pdr.
2017/04/12 18:40:06
Can enclosing_paint_layer ever be null here?
Do w
|
| + parent_context.enclosing_paint_layer |
| + ->HasDescendantThatSupportsSubsequenceCaching()); |
| } |
| -void PrePaintTreeWalk::Walk(const LayoutObject& object, |
| - const PrePaintTreeWalkContext& parent_context) { |
| +bool PrePaintTreeWalk::ShouldEarlyOut( |
| + const LayoutObject& object, |
| + const PrePaintTreeWalkContext& parent_context, |
| + bool& needs_tree_builder_context_update) { |
| // Early out from the tree walk if possible. |
| - bool needs_tree_builder_context_update = |
| + needs_tree_builder_context_update = |
| this->NeedsTreeBuilderContextUpdate(object, parent_context); |
| - if (!needs_tree_builder_context_update && |
| - !object.ShouldCheckForPaintInvalidation()) |
| + return !needs_tree_builder_context_update && |
| + !object.ShouldCheckForPaintInvalidation(); |
| +} |
| + |
| +void PrePaintTreeWalk::Walk(const LayoutObject& object, |
| + const PrePaintTreeWalkContext& parent_context) { |
| + bool needs_tree_builder_context_update = false; |
| + if (ShouldEarlyOut(object, parent_context, needs_tree_builder_context_update)) |
| return; |
| PrePaintTreeWalkContext context(parent_context, |