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

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

Issue 2561693002: Move sticky position constraints update to the pre-paint tree walk. (Closed)
Patch Set: none 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/PaintLayer.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"
11 #include "core/layout/LayoutPart.h" 11 #include "core/layout/LayoutPart.h"
12 #include "core/layout/LayoutView.h" 12 #include "core/layout/LayoutView.h"
13 #include "core/paint/PaintLayer.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 struct PrePaintTreeWalkContext { 17 struct PrePaintTreeWalkContext {
17 PrePaintTreeWalkContext() : paintInvalidatorContext(treeBuilderContext) {} 18 PrePaintTreeWalkContext()
19 : paintInvalidatorContext(treeBuilderContext),
20 ancestorOverflowPaintLayer(nullptr) {}
18 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext) 21 PrePaintTreeWalkContext(const PrePaintTreeWalkContext& parentContext)
19 : treeBuilderContext(parentContext.treeBuilderContext), 22 : treeBuilderContext(parentContext.treeBuilderContext),
20 paintInvalidatorContext(treeBuilderContext, 23 paintInvalidatorContext(treeBuilderContext,
21 parentContext.paintInvalidatorContext) {} 24 parentContext.paintInvalidatorContext),
25 ancestorOverflowPaintLayer(parentContext.ancestorOverflowPaintLayer) {}
22 26
23 PaintPropertyTreeBuilderContext treeBuilderContext; 27 PaintPropertyTreeBuilderContext treeBuilderContext;
24 PaintInvalidatorContext paintInvalidatorContext; 28 PaintInvalidatorContext paintInvalidatorContext;
29
30 // The ancestor in the PaintLayer tree which has overflow clip, or
pdr. 2016/12/09 00:04:10 The PrePaintTreeWalk is shared by paint invalidati
chrishtr 2016/12/09 01:22:54 Are you suggesting making an AuxiliaryObjectProper
31 // is the root layer. Note that it is tree ancestor, not containing
32 // block or stacking ancestor.
33 PaintLayer* ancestorOverflowPaintLayer;
25 }; 34 };
26 35
27 void PrePaintTreeWalk::walk(FrameView& rootFrame) { 36 void PrePaintTreeWalk::walk(FrameView& rootFrame) {
28 DCHECK(rootFrame.frame().document()->lifecycle().state() == 37 DCHECK(rootFrame.frame().document()->lifecycle().state() ==
29 DocumentLifecycle::InPrePaint); 38 DocumentLifecycle::InPrePaint);
30 39
31 PrePaintTreeWalkContext initialContext; 40 PrePaintTreeWalkContext initialContext;
32 initialContext.treeBuilderContext = 41 initialContext.treeBuilderContext =
33 m_propertyTreeBuilder.setupInitialContext(); 42 m_propertyTreeBuilder.setupInitialContext();
34 walk(rootFrame, initialContext); 43 walk(rootFrame, initialContext);
(...skipping 20 matching lines...) Expand all
55 #if DCHECK_IS_ON() 64 #if DCHECK_IS_ON()
56 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags(); 65 frameView.layoutView()->assertSubtreeClearedPaintInvalidationFlags();
57 #endif 66 #endif
58 // If descendants were not fully updated, do not clear flags. During the 67 // If descendants were not fully updated, do not clear flags. During the
59 // next PrePaintTreeWalk, these flags will be used again. 68 // next PrePaintTreeWalk, these flags will be used again.
60 frameView.clearNeedsPaintPropertyUpdate(); 69 frameView.clearNeedsPaintPropertyUpdate();
61 } 70 }
62 return descendantsFullyUpdated; 71 return descendantsFullyUpdated;
63 } 72 }
64 73
74 static void updateAuxiliaryObjectProperties(
75 const LayoutObject& object,
76 PrePaintTreeWalkContext& localContext) {
77 PaintLayer* paintLayer = nullptr;
78
79 if (object.isBoxModelObject() && object.hasLayer())
80 paintLayer = object.enclosingLayer();
81
82 if (paintLayer) {
83 paintLayer->updateAncestorOverflowLayer(
84 localContext.ancestorOverflowPaintLayer);
85 }
86
87 if (object.styleRef().position() == StickyPosition && paintLayer) {
88 paintLayer->layoutObject()->updateStickyPositionConstraints();
89
90 // Sticky position constraints and ancestor overflow scroller affect
91 // the sticky layer position, so we need to update it again here.
92 // TODO(flackr): This should be refactored in the future to be clearer
93 // (i.e. update layer position and ancestor inputs updates in the
94 // same walk)
95 paintLayer->updateLayerPosition();
96 }
97
98 if (object.hasOverflowClip() || (paintLayer && paintLayer->isRootLayer())) {
99 DCHECK(paintLayer);
100 localContext.ancestorOverflowPaintLayer = paintLayer;
101 }
102 }
103
65 bool PrePaintTreeWalk::walk(const LayoutObject& object, 104 bool PrePaintTreeWalk::walk(const LayoutObject& object,
66 const PrePaintTreeWalkContext& context) { 105 const PrePaintTreeWalkContext& context) {
67 PrePaintTreeWalkContext localContext(context); 106 PrePaintTreeWalkContext localContext(context);
68 107
69 // TODO(pdr): Ensure multi column works with incremental property tree 108 // TODO(pdr): Ensure multi column works with incremental property tree
70 // construction. 109 // construction.
71 if (object.isLayoutMultiColumnSpannerPlaceholder()) { 110 if (object.isLayoutMultiColumnSpannerPlaceholder()) {
72 // Walk multi-column spanner as if it replaces the placeholder. 111 // Walk multi-column spanner as if it replaces the placeholder.
73 // Set the flag so that the tree builder can specially handle out-of-flow 112 // Set the flag so that the tree builder can specially handle out-of-flow
74 // positioned descendants if their containers are between the multi-column 113 // positioned descendants if their containers are between the multi-column
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return true; 150 return true;
112 } 151 }
113 152
114 m_propertyTreeBuilder.updatePropertiesForSelf( 153 m_propertyTreeBuilder.updatePropertiesForSelf(
115 object, localContext.treeBuilderContext); 154 object, localContext.treeBuilderContext);
116 m_paintInvalidator.invalidatePaintIfNeeded( 155 m_paintInvalidator.invalidatePaintIfNeeded(
117 object, localContext.paintInvalidatorContext); 156 object, localContext.paintInvalidatorContext);
118 m_propertyTreeBuilder.updatePropertiesForChildren( 157 m_propertyTreeBuilder.updatePropertiesForChildren(
119 object, localContext.treeBuilderContext); 158 object, localContext.treeBuilderContext);
120 159
160 updateAuxiliaryObjectProperties(object, localContext);
161
121 bool descendantsFullyUpdated = true; 162 bool descendantsFullyUpdated = true;
122 for (const LayoutObject* child = object.slowFirstChild(); child; 163 for (const LayoutObject* child = object.slowFirstChild(); child;
123 child = child->nextSibling()) { 164 child = child->nextSibling()) {
124 // Column spanners are walked through their placeholders. See above. 165 // Column spanners are walked through their placeholders. See above.
125 if (child->isColumnSpanAll()) 166 if (child->isColumnSpanAll())
126 continue; 167 continue;
127 bool childFullyUpdated = walk(*child, localContext); 168 bool childFullyUpdated = walk(*child, localContext);
128 if (!childFullyUpdated) 169 if (!childFullyUpdated)
129 descendantsFullyUpdated = false; 170 descendantsFullyUpdated = false;
130 } 171 }
(...skipping 18 matching lines...) Expand all
149 // If descendants were not updated, do not clear flags. During the next 190 // If descendants were not updated, do not clear flags. During the next
150 // PrePaintTreeWalk, these flags will be used again. 191 // PrePaintTreeWalk, these flags will be used again.
151 object.getMutableForPainting().clearPaintInvalidationFlags(); 192 object.getMutableForPainting().clearPaintInvalidationFlags();
152 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); 193 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
153 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); 194 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate();
154 } 195 }
155 return descendantsFullyUpdated; 196 return descendantsFullyUpdated;
156 } 197 }
157 198
158 } // namespace blink 199 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698