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 83ebd785bdce76b3621a14e01a18a264c8db71fe..886b2cee6bf5aaab041221d6ea94493146afcbd3 100644 |
| --- a/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| +++ b/third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp |
| @@ -20,6 +20,7 @@ struct PrePaintTreeWalkContext { |
| paintInvalidatorContext(treeBuilderContext, |
| parentContext.paintInvalidatorContext) {} |
| + bool needToUpdatePaintPropertySubtree = false; |
| PaintPropertyTreeBuilderContext treeBuilderContext; |
| PaintInvalidatorContext paintInvalidatorContext; |
| }; |
| @@ -41,8 +42,26 @@ void PrePaintTreeWalk::walk(FrameView& frameView, |
| return; |
| PrePaintTreeWalkContext localContext(context); |
| - m_propertyTreeBuilder.buildTreeNodes(frameView, |
| - localContext.treeBuilderContext); |
| + |
| + // Check whether we need to update the paint property trees. |
| + if (!localContext.needToUpdatePaintPropertySubtree) { |
| + if (context.paintInvalidatorContext.forcedSubtreeInvalidationFlags) { |
| + // forcedSubtreeInvalidationFlags will be true if locations have changed |
| + // which will affect paint properties (e.g., PaintOffset). |
| + localContext.needToUpdatePaintPropertySubtree = true; |
| + } else if (frameView.needsPaintPropertyUpdate()) { |
| + // Paint properties can depend on their ancestor properties so ensure |
| + // the entire subtree is rebuilt on any changes. |
| + // TODO(pdr): Add additional granularity to the needs update approach |
| + // such as the ability to do local updates that don't change the subtree. |
| + localContext.needToUpdatePaintPropertySubtree = true; |
| + } |
| + } |
| + if (localContext.needToUpdatePaintPropertySubtree) |
| + frameView.setNeedsPaintPropertyUpdate(); |
| + |
| + m_propertyTreeBuilder.updateProperties(frameView, |
| + localContext.treeBuilderContext); |
| if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { |
| m_paintInvalidator.invalidatePaintIfNeeded( |
| @@ -56,12 +75,39 @@ void PrePaintTreeWalk::walk(FrameView& frameView, |
| if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags(); |
| #endif |
| + |
| + frameView.clearNeedsPaintPropertyUpdate(); |
| } |
| void PrePaintTreeWalk::walk(const LayoutObject& object, |
| const PrePaintTreeWalkContext& context) { |
| PrePaintTreeWalkContext localContext(context); |
| + // Check whether we need to update the paint property trees. |
| + if (!localContext.needToUpdatePaintPropertySubtree) { |
| + if (context.paintInvalidatorContext.forcedSubtreeInvalidationFlags) { |
| + // forcedSubtreeInvalidationFlags will be true if locations have changed |
| + // which will affect paint properties (e.g., PaintOffset). |
| + localContext.needToUpdatePaintPropertySubtree = true; |
| + } else if (object.needsPaintPropertyUpdate()) { |
| + // Paint properties can depend on their ancestor properties so ensure |
| + // the entire subtree is rebuilt on any changes. |
| + // TODO(pdr): Add additional granularity to the needs update approach |
| + // such as the ability to do local updates that don't change the subtree. |
| + localContext.needToUpdatePaintPropertySubtree = true; |
| + } else if ( |
| + object |
| + .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) { |
| + // TODO(pdr): Better document the exact reason we need to check this |
| + // paint invalidation state. |
| + localContext.needToUpdatePaintPropertySubtree = true; |
|
Xianzhu
2016/10/26 19:21:51
I think we don't need to set needToUpdatePaintProp
pdr.
2016/10/26 23:10:19
Initially I'd like to rebuild entire subtrees anyt
Xianzhu
2016/10/26 23:19:40
SGTM.
(I overlooked the previous needToUpdatePain
|
| + } |
| + } |
| + if (localContext.needToUpdatePaintPropertySubtree) |
| + object.getMutableForPainting().setNeedsPaintPropertyUpdate(); |
| + |
| + // TODO(pdr): Ensure multi column works with incremental property tree |
| + // construction. |
| if (object.isLayoutMultiColumnSpannerPlaceholder()) { |
| // Walk multi-column spanner as if it replaces the placeholder. |
| // Set the flag so that the tree builder can specially handle out-of-flow |
| @@ -75,12 +121,14 @@ void PrePaintTreeWalk::walk(const LayoutObject& object, |
| return; |
| } |
| - m_propertyTreeBuilder.buildTreeNodesForSelf(object, |
| - localContext.treeBuilderContext); |
| + m_propertyTreeBuilder.updatePropertiesForSelf( |
| + object, localContext.treeBuilderContext); |
| + |
| if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) |
| m_paintInvalidator.invalidatePaintIfNeeded( |
| object, localContext.paintInvalidatorContext); |
| - m_propertyTreeBuilder.buildTreeNodesForChildren( |
| + |
| + m_propertyTreeBuilder.updatePropertiesForChildren( |
| object, localContext.treeBuilderContext); |
| for (const LayoutObject* child = object.slowFirstChild(); child; |
| @@ -104,6 +152,8 @@ void PrePaintTreeWalk::walk(const LayoutObject& object, |
| } |
| // TODO(pdr): Investigate RemoteFrameView (crbug.com/579281). |
| } |
| + |
| + object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); |
| } |
| } // namespace blink |