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

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
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
75 // container and the spanner. See PaintPropertyTreeBuilder for details. 114 // container and the spanner. See PaintPropertyTreeBuilder for details.
76 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true; 115 localContext.treeBuilderContext.isUnderMultiColumnSpanner = true;
77 const auto& placeholder = toLayoutMultiColumnSpannerPlaceholder(object); 116 const auto& placeholder = toLayoutMultiColumnSpannerPlaceholder(object);
78 bool descendantsFullyUpdated = 117 bool descendantsFullyUpdated =
79 walk(*placeholder.layoutObjectInFlowThread(), localContext); 118 walk(*placeholder.layoutObjectInFlowThread(), localContext);
80 if (descendantsFullyUpdated) { 119 if (descendantsFullyUpdated) {
81 // If descendants were not fully updated, do not clear flags. During the 120 // If descendants were not fully updated, do not clear flags. During the
82 // next PrePaintTreeWalk, these flags will be used again. 121 // next PrePaintTreeWalk, these flags will be used again.
83 object.getMutableForPainting().clearPaintInvalidationFlags(); 122 object.getMutableForPainting().clearPaintInvalidationFlags();
84 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); 123 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
85 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); 124 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate();
86 } 125 }
87 return descendantsFullyUpdated; 126 return descendantsFullyUpdated;
88 } 127 }
89 128
129 // This must happen before updateContextForBoxPosition, because the
130 // latter reads some of the state computed uere.
131 updateAuxiliaryObjectProperties(object, localContext);
132
90 // Ensure the current context takes into account the box position. This can 133 // 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 134 // change the current context's paint offset so it must proceed the paint
92 // offset property update check. 135 // offset property update check.
93 m_propertyTreeBuilder.updateContextForBoxPosition( 136 m_propertyTreeBuilder.updateContextForBoxPosition(
94 object, localContext.treeBuilderContext); 137 object, localContext.treeBuilderContext);
95 // Many paint properties depend on paint offset so we force an update of 138 // Many paint properties depend on paint offset so we force an update of
96 // properties if the paint offset changes. 139 // properties if the paint offset changes.
97 if (object.previousPaintOffset() != 140 if (object.previousPaintOffset() !=
98 localContext.treeBuilderContext.current.paintOffset) { 141 localContext.treeBuilderContext.current.paintOffset) {
99 object.getMutableForPainting().setNeedsPaintPropertyUpdate(); 142 object.getMutableForPainting().setNeedsPaintPropertyUpdate();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // If descendants were not updated, do not clear flags. During the next 192 // If descendants were not updated, do not clear flags. During the next
150 // PrePaintTreeWalk, these flags will be used again. 193 // PrePaintTreeWalk, these flags will be used again.
151 object.getMutableForPainting().clearPaintInvalidationFlags(); 194 object.getMutableForPainting().clearPaintInvalidationFlags();
152 object.getMutableForPainting().clearNeedsPaintPropertyUpdate(); 195 object.getMutableForPainting().clearNeedsPaintPropertyUpdate();
153 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate(); 196 object.getMutableForPainting().clearDescendantNeedsPaintPropertyUpdate();
154 } 197 }
155 return descendantsFullyUpdated; 198 return descendantsFullyUpdated;
156 } 199 }
157 200
158 } // namespace blink 201 } // 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