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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositingInputsUpdater.cpp

Issue 2692853016: Change PaintLayer::m_layoutObject to a reference. (Closed)
Patch Set: Added TODO Created 3 years, 10 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/layout/compositing/CompositingInputsUpdater.h" 5 #include "core/layout/compositing/CompositingInputsUpdater.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameHost.h" 8 #include "core/frame/FrameHost.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/layout/LayoutBlock.h" 10 #include "core/layout/LayoutBlock.h"
(...skipping 10 matching lines...) Expand all
21 21
22 CompositingInputsUpdater::~CompositingInputsUpdater() {} 22 CompositingInputsUpdater::~CompositingInputsUpdater() {}
23 23
24 void CompositingInputsUpdater::update() { 24 void CompositingInputsUpdater::update() {
25 TRACE_EVENT0("blink", "CompositingInputsUpdater::update"); 25 TRACE_EVENT0("blink", "CompositingInputsUpdater::update");
26 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo()); 26 updateRecursive(m_rootLayer, DoNotForceUpdate, AncestorInfo());
27 } 27 }
28 28
29 static const PaintLayer* findParentLayerOnClippingContainerChain( 29 static const PaintLayer* findParentLayerOnClippingContainerChain(
30 const PaintLayer* layer) { 30 const PaintLayer* layer) {
31 LayoutObject* current = layer->layoutObject(); 31 LayoutObject* current = &layer->layoutObject();
32 while (current) { 32 while (current) {
33 if (current->style()->position() == EPosition::kFixed) { 33 if (current->style()->position() == EPosition::kFixed) {
34 for (current = current->parent(); 34 for (current = current->parent();
35 current && !current->canContainFixedPositionObjects(); 35 current && !current->canContainFixedPositionObjects();
36 current = current->parent()) { 36 current = current->parent()) {
37 // CSS clip applies to fixed position elements even for ancestors that 37 // CSS clip applies to fixed position elements even for ancestors that
38 // are not what the fixed element is positioned with respect to. 38 // are not what the fixed element is positioned with respect to.
39 if (current->hasClip()) { 39 if (current->hasClip()) {
40 DCHECK(current->hasLayer()); 40 DCHECK(current->hasLayer());
41 return static_cast<const LayoutBoxModelObject*>(current)->layer(); 41 return static_cast<const LayoutBoxModelObject*>(current)->layer();
(...skipping 24 matching lines...) Expand all
66 } 66 }
67 ASSERT_NOT_REACHED(); 67 ASSERT_NOT_REACHED();
68 return nullptr; 68 return nullptr;
69 } 69 }
70 70
71 static bool hasClippedStackingAncestor(const PaintLayer* layer, 71 static bool hasClippedStackingAncestor(const PaintLayer* layer,
72 const PaintLayer* clippingLayer) { 72 const PaintLayer* clippingLayer) {
73 if (layer == clippingLayer) 73 if (layer == clippingLayer)
74 return false; 74 return false;
75 bool foundInterveningClip = false; 75 bool foundInterveningClip = false;
76 const LayoutObject* clippingLayoutObject = clippingLayer->layoutObject(); 76 const LayoutObject& clippingLayoutObject = clippingLayer->layoutObject();
77 for (const PaintLayer* current = layer->compositingContainer(); current; 77 for (const PaintLayer* current = layer->compositingContainer(); current;
78 current = current->compositingContainer()) { 78 current = current->compositingContainer()) {
79 if (current == clippingLayer) 79 if (current == clippingLayer)
80 return foundInterveningClip; 80 return foundInterveningClip;
81 81
82 if (current->layoutObject()->hasClipRelatedProperty() && 82 if (current->layoutObject().hasClipRelatedProperty() &&
83 !clippingLayoutObject->isDescendantOf(current->layoutObject())) 83 !clippingLayoutObject.isDescendantOf(&current->layoutObject()))
84 foundInterveningClip = true; 84 foundInterveningClip = true;
85 85
86 if (const LayoutObject* container = current->clippingContainer()) { 86 if (const LayoutObject* container = current->clippingContainer()) {
87 if (clippingLayoutObject != container && 87 if (&clippingLayoutObject != container &&
88 !clippingLayoutObject->isDescendantOf(container)) 88 !clippingLayoutObject.isDescendantOf(container))
89 foundInterveningClip = true; 89 foundInterveningClip = true;
90 } 90 }
91 } 91 }
92 return false; 92 return false;
93 } 93 }
94 94
95 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer, 95 void CompositingInputsUpdater::updateRecursive(PaintLayer* layer,
96 UpdateType updateType, 96 UpdateType updateType,
97 AncestorInfo info) { 97 AncestorInfo info) {
98 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate) 98 if (!layer->childNeedsCompositingInputsUpdate() && updateType != ForceUpdate)
99 return; 99 return;
100 100
101 const PaintLayer* previousOverflowLayer = layer->ancestorOverflowLayer(); 101 const PaintLayer* previousOverflowLayer = layer->ancestorOverflowLayer();
102 layer->updateAncestorOverflowLayer(info.lastOverflowClipLayer); 102 layer->updateAncestorOverflowLayer(info.lastOverflowClipLayer);
103 if (info.lastOverflowClipLayer && layer->needsCompositingInputsUpdate() && 103 if (info.lastOverflowClipLayer && layer->needsCompositingInputsUpdate() &&
104 layer->layoutObject()->style()->position() == EPosition::kSticky) { 104 layer->layoutObject().style()->position() == EPosition::kSticky) {
105 if (info.lastOverflowClipLayer != previousOverflowLayer && 105 if (info.lastOverflowClipLayer != previousOverflowLayer &&
106 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 106 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
107 // Old ancestor scroller should no longer have these constraints. 107 // Old ancestor scroller should no longer have these constraints.
108 ASSERT(!previousOverflowLayer || 108 ASSERT(!previousOverflowLayer ||
109 !previousOverflowLayer->getScrollableArea() 109 !previousOverflowLayer->getScrollableArea()
110 ->stickyConstraintsMap() 110 ->stickyConstraintsMap()
111 .contains(layer)); 111 .contains(layer));
112 112
113 if (info.lastOverflowClipLayer->isRootLayer()) 113 if (info.lastOverflowClipLayer->isRootLayer()) {
114 layer->layoutObject().view()->frameView()->addViewportConstrainedObject(
115 layer->layoutObject());
116 } else if (previousOverflowLayer &&
117 previousOverflowLayer->isRootLayer()) {
114 layer->layoutObject() 118 layer->layoutObject()
115 ->view() 119 .view()
116 ->frameView()
117 ->addViewportConstrainedObject(layer->layoutObject());
118 else if (previousOverflowLayer && previousOverflowLayer->isRootLayer())
119 layer->layoutObject()
120 ->view()
121 ->frameView() 120 ->frameView()
122 ->removeViewportConstrainedObject(layer->layoutObject()); 121 ->removeViewportConstrainedObject(layer->layoutObject());
122 }
123 } 123 }
124 layer->layoutObject()->updateStickyPositionConstraints(); 124 layer->layoutObject().updateStickyPositionConstraints();
125 125
126 // Sticky position constraints and ancestor overflow scroller affect 126 // Sticky position constraints and ancestor overflow scroller affect
127 // the sticky layer position, so we need to update it again here. 127 // the sticky layer position, so we need to update it again here.
128 // TODO(flackr): This should be refactored in the future to be clearer 128 // TODO(flackr): This should be refactored in the future to be clearer
129 // (i.e. update layer position and ancestor inputs updates in the 129 // (i.e. update layer position and ancestor inputs updates in the
130 // same walk) 130 // same walk)
131 layer->updateLayerPosition(); 131 layer->updateLayerPosition();
132 } 132 }
133 133
134 m_geometryMap.pushMappingsToAncestor(layer, layer->parent()); 134 m_geometryMap.pushMappingsToAncestor(layer, layer->parent());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 169
170 const PaintLayer* parent = layer->parent(); 170 const PaintLayer* parent = layer->parent();
171 properties.opacityAncestor = 171 properties.opacityAncestor =
172 parent->isTransparent() ? parent : parent->opacityAncestor(); 172 parent->isTransparent() ? parent : parent->opacityAncestor();
173 properties.transformAncestor = 173 properties.transformAncestor =
174 parent->transform() ? parent : parent->transformAncestor(); 174 parent->transform() ? parent : parent->transformAncestor();
175 properties.filterAncestor = parent->hasFilterInducingProperty() 175 properties.filterAncestor = parent->hasFilterInducingProperty()
176 ? parent 176 ? parent
177 : parent->filterAncestor(); 177 : parent->filterAncestor();
178 bool layerIsFixedPosition = 178 bool layerIsFixedPosition =
179 layer->layoutObject()->style()->position() == EPosition::kFixed; 179 layer->layoutObject().style()->position() == EPosition::kFixed;
180 properties.nearestFixedPositionLayer = 180 properties.nearestFixedPositionLayer =
181 layerIsFixedPosition ? layer : parent->nearestFixedPositionLayer(); 181 layerIsFixedPosition ? layer : parent->nearestFixedPositionLayer();
182 182
183 if (info.hasAncestorWithClipRelatedProperty) { 183 if (info.hasAncestorWithClipRelatedProperty) {
184 const PaintLayer* parentLayerOnClippingContainerChain = 184 const PaintLayer* parentLayerOnClippingContainerChain =
185 findParentLayerOnClippingContainerChain(layer); 185 findParentLayerOnClippingContainerChain(layer);
186 const bool parentHasClipRelatedProperty = 186 const bool parentHasClipRelatedProperty =
187 parentLayerOnClippingContainerChain->layoutObject() 187 parentLayerOnClippingContainerChain->layoutObject()
188 ->hasClipRelatedProperty(); 188 .hasClipRelatedProperty();
189 properties.clippingContainer = 189 properties.clippingContainer =
190 parentHasClipRelatedProperty 190 parentHasClipRelatedProperty
191 ? parentLayerOnClippingContainerChain->layoutObject() 191 ? &parentLayerOnClippingContainerChain->layoutObject()
192 : parentLayerOnClippingContainerChain->clippingContainer(); 192 : parentLayerOnClippingContainerChain->clippingContainer();
193 193
194 if (layer->layoutObject()->isOutOfFlowPositioned() && 194 if (layer->layoutObject().isOutOfFlowPositioned() &&
195 !layer->subtreeIsInvisible()) { 195 !layer->subtreeIsInvisible()) {
196 const PaintLayer* clippingLayer = 196 const PaintLayer* clippingLayer =
197 properties.clippingContainer 197 properties.clippingContainer
198 ? properties.clippingContainer->enclosingLayer() 198 ? properties.clippingContainer->enclosingLayer()
199 : layer->compositor()->rootLayer(); 199 : layer->compositor()->rootLayer();
200 if (hasClippedStackingAncestor(layer, clippingLayer)) 200 if (hasClippedStackingAncestor(layer, clippingLayer))
201 properties.clipParent = clippingLayer; 201 properties.clipParent = clippingLayer;
202 } 202 }
203 } 203 }
204 204
205 if (info.lastScrollingAncestor) { 205 if (info.lastScrollingAncestor) {
206 const LayoutObject* containingBlock = 206 const LayoutObject* containingBlock =
207 layer->layoutObject()->containingBlock(); 207 layer->layoutObject().containingBlock();
208 const PaintLayer* parentLayerOnContainingBlockChain = 208 const PaintLayer* parentLayerOnContainingBlockChain =
209 findParentLayerOnContainingBlockChain(containingBlock); 209 findParentLayerOnContainingBlockChain(containingBlock);
210 210
211 properties.ancestorScrollingLayer = 211 properties.ancestorScrollingLayer =
212 parentLayerOnContainingBlockChain->ancestorScrollingLayer(); 212 parentLayerOnContainingBlockChain->ancestorScrollingLayer();
213 if (parentLayerOnContainingBlockChain->scrollsOverflow()) 213 if (parentLayerOnContainingBlockChain->scrollsOverflow())
214 properties.ancestorScrollingLayer = parentLayerOnContainingBlockChain; 214 properties.ancestorScrollingLayer = parentLayerOnContainingBlockChain;
215 215
216 if (layer->stackingNode()->isStacked() && 216 if (layer->stackingNode()->isStacked() &&
217 properties.ancestorScrollingLayer && 217 properties.ancestorScrollingLayer &&
218 !info.ancestorStackingContext->layoutObject()->isDescendantOf( 218 !info.ancestorStackingContext->layoutObject().isDescendantOf(
219 properties.ancestorScrollingLayer->layoutObject())) 219 &properties.ancestorScrollingLayer->layoutObject()))
220 properties.scrollParent = properties.ancestorScrollingLayer; 220 properties.scrollParent = properties.ancestorScrollingLayer;
221 } 221 }
222 } 222 }
223 223
224 layer->updateAncestorDependentCompositingInputs( 224 layer->updateAncestorDependentCompositingInputs(
225 properties, info.hasAncestorWithClipPath); 225 properties, info.hasAncestorWithClipPath);
226 } 226 }
227 227
228 if (layer->stackingNode()->isStackingContext()) 228 if (layer->stackingNode()->isStackingContext())
229 info.ancestorStackingContext = layer; 229 info.ancestorStackingContext = layer;
230 230
231 if (layer->isRootLayer() || layer->layoutObject()->hasOverflowClip()) 231 if (layer->isRootLayer() || layer->layoutObject().hasOverflowClip())
232 info.lastOverflowClipLayer = layer; 232 info.lastOverflowClipLayer = layer;
233 233
234 if (layer->scrollsOverflow()) 234 if (layer->scrollsOverflow())
235 info.lastScrollingAncestor = layer; 235 info.lastScrollingAncestor = layer;
236 236
237 if (layer->layoutObject()->hasClipRelatedProperty()) 237 if (layer->layoutObject().hasClipRelatedProperty())
238 info.hasAncestorWithClipRelatedProperty = true; 238 info.hasAncestorWithClipRelatedProperty = true;
239 239
240 if (layer->layoutObject()->hasClipPath()) 240 if (layer->layoutObject().hasClipPath())
241 info.hasAncestorWithClipPath = true; 241 info.hasAncestorWithClipPath = true;
242 242
243 for (PaintLayer* child = layer->firstChild(); child; 243 for (PaintLayer* child = layer->firstChild(); child;
244 child = child->nextSibling()) 244 child = child->nextSibling())
245 updateRecursive(child, updateType, info); 245 updateRecursive(child, updateType, info);
246 246
247 layer->didUpdateCompositingInputs(); 247 layer->didUpdateCompositingInputs();
248 248
249 m_geometryMap.popMappingsToAncestor(layer->parent()); 249 m_geometryMap.popMappingsToAncestor(layer->parent());
250 250
251 if (layer->selfPaintingStatusChanged()) { 251 if (layer->selfPaintingStatusChanged()) {
252 layer->clearSelfPaintingStatusChanged(); 252 layer->clearSelfPaintingStatusChanged();
253 // If the floating object becomes non-self-painting, so some ancestor should 253 // If the floating object becomes non-self-painting, so some ancestor should
254 // paint it; if it becomes self-painting, it should paint itself and no 254 // paint it; if it becomes self-painting, it should paint itself and no
255 // ancestor should paint it. 255 // ancestor should paint it.
256 if (layer->layoutObject()->isFloating()) { 256 if (layer->layoutObject().isFloating()) {
257 LayoutBlockFlow::updateAncestorShouldPaintFloatingObject( 257 LayoutBlockFlow::updateAncestorShouldPaintFloatingObject(
258 *layer->layoutBox()); 258 *layer->layoutBox());
259 } 259 }
260 } 260 }
261 } 261 }
262 262
263 #if DCHECK_IS_ON() 263 #if DCHECK_IS_ON()
264 264
265 void CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared( 265 void CompositingInputsUpdater::assertNeedsCompositingInputsUpdateBitsCleared(
266 PaintLayer* layer) { 266 PaintLayer* layer) {
267 ASSERT(!layer->childNeedsCompositingInputsUpdate()); 267 ASSERT(!layer->childNeedsCompositingInputsUpdate());
268 ASSERT(!layer->needsCompositingInputsUpdate()); 268 ASSERT(!layer->needsCompositingInputsUpdate());
269 269
270 for (PaintLayer* child = layer->firstChild(); child; 270 for (PaintLayer* child = layer->firstChild(); child;
271 child = child->nextSibling()) 271 child = child->nextSibling())
272 assertNeedsCompositingInputsUpdateBitsCleared(child); 272 assertNeedsCompositingInputsUpdateBitsCleared(child);
273 } 273 }
274 274
275 #endif 275 #endif
276 276
277 } // namespace blink 277 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698