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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerStackingNode.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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // in order to determine if we isStacked() we have to ask the paint 59 // in order to determine if we isStacked() we have to ask the paint
60 // layer about some of its state. 60 // layer about some of its state.
61 PaintLayerStackingNode::PaintLayerStackingNode(PaintLayer* layer) 61 PaintLayerStackingNode::PaintLayerStackingNode(PaintLayer* layer)
62 : m_layer(layer) 62 : m_layer(layer)
63 #if DCHECK_IS_ON() 63 #if DCHECK_IS_ON()
64 , 64 ,
65 m_layerListMutationAllowed(true), 65 m_layerListMutationAllowed(true),
66 m_stackingParent(0) 66 m_stackingParent(0)
67 #endif 67 #endif
68 { 68 {
69 m_isStacked = layoutObject()->styleRef().isStacked(); 69 m_isStacked = layoutObject().styleRef().isStacked();
70 70
71 // Non-stacking contexts should have empty z-order lists. As this is already 71 // Non-stacking contexts should have empty z-order lists. As this is already
72 // the case, there is no need to dirty / recompute these lists. 72 // the case, there is no need to dirty / recompute these lists.
73 m_zOrderListsDirty = isStackingContext(); 73 m_zOrderListsDirty = isStackingContext();
74 } 74 }
75 75
76 PaintLayerStackingNode::~PaintLayerStackingNode() { 76 PaintLayerStackingNode::~PaintLayerStackingNode() {
77 #if DCHECK_IS_ON() 77 #if DCHECK_IS_ON()
78 if (!layoutObject()->documentBeingDestroyed()) { 78 if (!layoutObject().documentBeingDestroyed()) {
79 DCHECK(!isInStackingParentZOrderLists()); 79 DCHECK(!isInStackingParentZOrderLists());
80 80
81 updateStackingParentForZOrderLists(0); 81 updateStackingParentForZOrderLists(0);
82 } 82 }
83 #endif 83 #endif
84 } 84 }
85 85
86 // Helper for the sorting of layers by z-index. 86 // Helper for the sorting of layers by z-index.
87 static inline bool compareZIndex(PaintLayerStackingNode* first, 87 static inline bool compareZIndex(PaintLayerStackingNode* first,
88 PaintLayerStackingNode* second) { 88 PaintLayerStackingNode* second) {
89 return first->zIndex() < second->zIndex(); 89 return first->zIndex() < second->zIndex();
90 } 90 }
91 91
92 PaintLayerCompositor* PaintLayerStackingNode::compositor() const { 92 PaintLayerCompositor* PaintLayerStackingNode::compositor() const {
93 DCHECK(layoutObject()->view()); 93 DCHECK(layoutObject().view());
94 return layoutObject()->view()->compositor(); 94 return layoutObject().view()->compositor();
95 } 95 }
96 96
97 void PaintLayerStackingNode::dirtyZOrderLists() { 97 void PaintLayerStackingNode::dirtyZOrderLists() {
98 #if DCHECK_IS_ON() 98 #if DCHECK_IS_ON()
99 DCHECK(m_layerListMutationAllowed); 99 DCHECK(m_layerListMutationAllowed);
100 #endif 100 #endif
101 DCHECK(isStackingContext()); 101 DCHECK(isStackingContext());
102 102
103 #if DCHECK_IS_ON() 103 #if DCHECK_IS_ON()
104 updateStackingParentForZOrderLists(0); 104 updateStackingParentForZOrderLists(0);
105 #endif 105 #endif
106 106
107 if (m_posZOrderList) 107 if (m_posZOrderList)
108 m_posZOrderList->clear(); 108 m_posZOrderList->clear();
109 if (m_negZOrderList) 109 if (m_negZOrderList)
110 m_negZOrderList->clear(); 110 m_negZOrderList->clear();
111 m_zOrderListsDirty = true; 111 m_zOrderListsDirty = true;
112 112
113 if (!layoutObject()->documentBeingDestroyed()) 113 if (!layoutObject().documentBeingDestroyed())
114 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 114 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
115 } 115 }
116 116
117 void PaintLayerStackingNode::dirtyStackingContextZOrderLists() { 117 void PaintLayerStackingNode::dirtyStackingContextZOrderLists() {
118 if (PaintLayerStackingNode* stackingNode = ancestorStackingContextNode()) 118 if (PaintLayerStackingNode* stackingNode = ancestorStackingContextNode())
119 stackingNode->dirtyZOrderLists(); 119 stackingNode->dirtyZOrderLists();
120 } 120 }
121 121
122 void PaintLayerStackingNode::rebuildZOrderLists() { 122 void PaintLayerStackingNode::rebuildZOrderLists() {
123 #if DCHECK_IS_ON() 123 #if DCHECK_IS_ON()
(...skipping 12 matching lines...) Expand all
136 136
137 if (m_negZOrderList) 137 if (m_negZOrderList)
138 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(), 138 std::stable_sort(m_negZOrderList->begin(), m_negZOrderList->end(),
139 compareZIndex); 139 compareZIndex);
140 140
141 // Append layers for top layer elements after normal layer collection, to 141 // Append layers for top layer elements after normal layer collection, to
142 // ensure they are on top regardless of z-indexes. The layoutObjects of top 142 // ensure they are on top regardless of z-indexes. The layoutObjects of top
143 // layer elements are children of the view, sorted in top layer stacking 143 // layer elements are children of the view, sorted in top layer stacking
144 // order. 144 // order.
145 if (layer()->isRootLayer()) { 145 if (layer()->isRootLayer()) {
146 LayoutBlockFlow* rootBlock = layoutObject()->view(); 146 LayoutBlockFlow* rootBlock = layoutObject().view();
147 // If the viewport is paginated, everything (including "top-layer" elements) 147 // If the viewport is paginated, everything (including "top-layer" elements)
148 // gets redirected to the flow thread. So that's where we have to look, in 148 // gets redirected to the flow thread. So that's where we have to look, in
149 // that case. 149 // that case.
150 if (LayoutBlockFlow* multiColumnFlowThread = 150 if (LayoutBlockFlow* multiColumnFlowThread =
151 rootBlock->multiColumnFlowThread()) 151 rootBlock->multiColumnFlowThread())
152 rootBlock = multiColumnFlowThread; 152 rootBlock = multiColumnFlowThread;
153 for (LayoutObject* child = rootBlock->firstChild(); child; 153 for (LayoutObject* child = rootBlock->firstChild(); child;
154 child = child->nextSibling()) { 154 child = child->nextSibling()) {
155 Element* childElement = (child->node() && child->node()->isElementNode()) 155 Element* childElement = (child->node() && child->node()->isElementNode())
156 ? toElement(child->node()) 156 ? toElement(child->node())
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 228
229 void PaintLayerStackingNode::updateLayerListsIfNeeded() { 229 void PaintLayerStackingNode::updateLayerListsIfNeeded() {
230 updateZOrderLists(); 230 updateZOrderLists();
231 } 231 }
232 232
233 void PaintLayerStackingNode::styleDidChange(const ComputedStyle* oldStyle) { 233 void PaintLayerStackingNode::styleDidChange(const ComputedStyle* oldStyle) {
234 bool wasStackingContext = oldStyle ? oldStyle->isStackingContext() : false; 234 bool wasStackingContext = oldStyle ? oldStyle->isStackingContext() : false;
235 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0; 235 int oldZIndex = oldStyle ? oldStyle->zIndex() : 0;
236 236
237 bool isStackingContext = this->isStackingContext(); 237 bool isStackingContext = this->isStackingContext();
238 bool shouldBeStacked = layoutObject()->styleRef().isStacked(); 238 bool shouldBeStacked = layoutObject().styleRef().isStacked();
239 if (isStackingContext == wasStackingContext && 239 if (isStackingContext == wasStackingContext &&
240 m_isStacked == shouldBeStacked && oldZIndex == zIndex()) 240 m_isStacked == shouldBeStacked && oldZIndex == zIndex())
241 return; 241 return;
242 242
243 dirtyStackingContextZOrderLists(); 243 dirtyStackingContextZOrderLists();
244 244
245 if (isStackingContext) 245 if (isStackingContext)
246 dirtyZOrderLists(); 246 dirtyZOrderLists();
247 else 247 else
248 clearZOrderLists(); 248 clearZOrderLists();
249 249
250 if (m_isStacked != shouldBeStacked) { 250 if (m_isStacked != shouldBeStacked) {
251 m_isStacked = shouldBeStacked; 251 m_isStacked = shouldBeStacked;
252 if (!layoutObject()->documentBeingDestroyed() && !layer()->isRootLayer()) 252 if (!layoutObject().documentBeingDestroyed() && !layer()->isRootLayer())
253 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); 253 compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
254 } 254 }
255 } 255 }
256 256
257 PaintLayerStackingNode* PaintLayerStackingNode::ancestorStackingContextNode() 257 PaintLayerStackingNode* PaintLayerStackingNode::ancestorStackingContextNode()
258 const { 258 const {
259 for (PaintLayer* ancestor = layer()->parent(); ancestor; 259 for (PaintLayer* ancestor = layer()->parent(); ancestor;
260 ancestor = ancestor->parent()) { 260 ancestor = ancestor->parent()) {
261 PaintLayerStackingNode* stackingNode = ancestor->stackingNode(); 261 PaintLayerStackingNode* stackingNode = ancestor->stackingNode();
262 if (stackingNode->isStackingContext()) 262 if (stackingNode->isStackingContext())
263 return stackingNode; 263 return stackingNode;
264 } 264 }
265 return 0; 265 return 0;
266 } 266 }
267 267
268 LayoutBoxModelObject* PaintLayerStackingNode::layoutObject() const { 268 LayoutBoxModelObject& PaintLayerStackingNode::layoutObject() const {
269 return m_layer->layoutObject(); 269 return m_layer->layoutObject();
270 } 270 }
271 271
272 } // namespace blink 272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698