Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalk.cpp

Issue 2529293012: Invalidate paint properties on paint offset changes (Closed)
Patch Set: Fix transform underinvalidation, skip several spinvalidation skips Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/PrePaintTreeWalk.h" 5 #include "core/paint/PrePaintTreeWalk.h"
6 6
7 #include "core/dom/DocumentLifecycle.h" 7 #include "core/dom/DocumentLifecycle.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" 10 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #endif 57 #endif
58 // If descendants were not fully updated, do not clear flags. During the 58 // If descendants were not fully updated, do not clear flags. During the
59 // next PrePaintTreeWalk, these flags will be used again. 59 // next PrePaintTreeWalk, these flags will be used again.
60 frameView.clearNeedsPaintPropertyUpdate(); 60 frameView.clearNeedsPaintPropertyUpdate();
61 } 61 }
62 return descendantsFullyUpdated; 62 return descendantsFullyUpdated;
63 } 63 }
64 64
65 bool PrePaintTreeWalk::walk(const LayoutObject& object, 65 bool PrePaintTreeWalk::walk(const LayoutObject& object,
66 const PrePaintTreeWalkContext& context) { 66 const PrePaintTreeWalkContext& context) {
67 // Early out from the treewalk if possible.
68 if (!object.needsPaintPropertyUpdate() &&
69 !object.descendantNeedsPaintPropertyUpdate() &&
70 !context.treeBuilderContext.forceSubtreeUpdate &&
71 !context.paintInvalidatorContext.forcedSubtreeInvalidationFlags &&
72 !object
73 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) {
74 // Even though the subtree was not walked, we know that a walk will not
75 // change anything and can return true as if the subtree was fully updated.
76 return true;
77 }
78
79 PrePaintTreeWalkContext localContext(context); 67 PrePaintTreeWalkContext localContext(context);
80 68
81 // TODO(pdr): These should be removable once paint offset changes mark an
82 // object as needing a paint property update. Below, we temporarily re-use
83 // paint invalidation flags to detect paint offset changes.
84 if (localContext.paintInvalidatorContext.forcedSubtreeInvalidationFlags) {
85 // forcedSubtreeInvalidationFlags will be true if locations have changed
86 // which will affect paint properties (e.g., PaintOffset).
87 localContext.treeBuilderContext.forceSubtreeUpdate = true;
88 } else if (object.shouldDoFullPaintInvalidation()) {
89 // shouldDoFullPaintInvalidation will be true when locations or overflow
90 // changes which will affect paint properties (e.g., PaintOffset, scroll).
91 object.getMutableForPainting().setNeedsPaintPropertyUpdate();
92 } else if (object.mayNeedPaintInvalidation()) {
93 // mayNeedpaintInvalidation will be true when locations change which will
94 // affect paint properties (e.g., PaintOffset).
95 object.getMutableForPainting().setNeedsPaintPropertyUpdate();
96 }
97
98 // TODO(pdr): Ensure multi column works with incremental property tree 69 // TODO(pdr): Ensure multi column works with incremental property tree
99 // construction. 70 // construction.
100 if (object.isLayoutMultiColumnSpannerPlaceholder()) { 71 if (object.isLayoutMultiColumnSpannerPlaceholder()) {
101 // Walk multi-column spanner as if it replaces the placeholder. 72 // Walk multi-column spanner as if it replaces the placeholder.
102 // Set the flag so that the tree builder can specially handle out-of-flow 73 // Set the flag so that the tree builder can specially handle out-of-flow
103 // positioned descendants if their containers are between the multi-column 74 // positioned descendants if their containers are between the multi-column
104 // container and the spanner. See PaintPropertyTreeBuilder for details. 75 // container and the spanner. See PaintPropertyTreeBuilder for details.
105 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true; 76 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true;
77 const auto& placeholder = toLayoutMultiColumnSpannerPlaceholder(object);
106 bool descendantsFullyUpdated = 78 bool descendantsFullyUpdated =
107 walk(*toLayoutMultiColumnSpannerPlaceholder(object) 79 walk(*placeholder.layoutObjectInFlowThread(), localContext);
108 .layoutObjectInFlowThread(),
109 localContext);
110 if (descendantsFullyUpdated) { 80 if (descendantsFullyUpdated) {
111 // If descendants were not fully updated, do not clear flags. During the 81 // If descendants were not fully updated, do not clear flags. During the
112 // next PrePaintTreeWalk, these flags will be used again. 82 // next PrePaintTreeWalk, these flags will be used again.
113 object.getMutableForPainting().clearPaintInvalidationFlags(); 83 object.getMutableForPainting().clearPaintInvalidationFlags();
114 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); 84 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
115 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); 85 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate();
116 } 86 }
117 return descendantsFullyUpdated; 87 return descendantsFullyUpdated;
118 } 88 }
119 89
90 // Ensure the current context takes into account the box position. This can
91 // change the current context's paint offset so it must proceed the paint
92 // offset property update check.
93 m_propertyTreeBuilder.updateContextForBoxPosition(
94 object, localContext.treeBuilderContext);
95 // Many paint properties depend on paint offset so we force an update of
96 // properties if the paint offset changes.
97 if (object.previousPaintOffset() !=
98 localContext.treeBuilderContext.current.paintOffset) {
99 object.getMutableForPainting().setNeedsPaintPropertyUpdate();
100 }
101
102 // Early out from the treewalk if possible.
103 if (!object.needsPaintPropertyUpdate() &&
104 !object.descendantNeedsPaintPropertyUpdate() &&
105 !localContext.treeBuilderContext.forceSubtreeUpdate &&
106 !localContext.paintInvalidatorContext.forcedSubtreeInvalidationFlags &&
107 !object
108 .shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState()) {
109 // Even though the subtree was not walked, we know that a walk will not
110 // change anything and can return true as if the subtree was fully updated.
111 return true;
112 }
113
120 m_propertyTreeBuilder.updatePropertiesForSelf( 114 m_propertyTreeBuilder.updatePropertiesForSelf(
121 object, localContext.treeBuilderContext); 115 object, localContext.treeBuilderContext);
122 m_paintInvalidator.invalidatePaintIfNeeded( 116 m_paintInvalidator.invalidatePaintIfNeeded(
123 object, localContext.paintInvalidatorContext); 117 object, localContext.paintInvalidatorContext);
124 m_propertyTreeBuilder.updatePropertiesForChildren( 118 m_propertyTreeBuilder.updatePropertiesForChildren(
125 object, localContext.treeBuilderContext); 119 object, localContext.treeBuilderContext);
126 120
127 bool descendantsFullyUpdated = true; 121 bool descendantsFullyUpdated = true;
128 for (const LayoutObject* child = object.slowFirstChild(); child; 122 for (const LayoutObject* child = object.slowFirstChild(); child;
129 child = child->nextSibling()) { 123 child = child->nextSibling()) {
(...skipping 25 matching lines...) Expand all
155 // If descendants were not updated, do not clear flags. During the next 149 // If descendants were not updated, do not clear flags. During the next
156 // PrePaintTreeWalk, these flags will be used again. 150 // PrePaintTreeWalk, these flags will be used again.
157 object.getMutableForPainting().clearPaintInvalidationFlags(); 151 object.getMutableForPainting().clearPaintInvalidationFlags();
158 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); 152 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
159 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); 153 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate();
160 } 154 }
161 return descendantsFullyUpdated; 155 return descendantsFullyUpdated;
162 } 156 }
163 157
164 } // namespace blink 158 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698