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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp

Issue 1854423002: ASSERT -> {DCHECK|DCHECK_XX}, ENABLE(ASSERT) -> DCHECK_IS_ON() in dom (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark svg/as-image/svg-nested.html crash on win Created 4 years, 8 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (shadowRoot->isV1()) 138 if (shadowRoot->isV1())
139 return false; 139 return false;
140 return !Traversal<InsertionPoint>::firstAncestor(*this); 140 return !Traversal<InsertionPoint>::firstAncestor(*this);
141 } 141 }
142 142
143 bool InsertionPoint::isActive() const 143 bool InsertionPoint::isActive() const
144 { 144 {
145 if (!canBeActive()) 145 if (!canBeActive())
146 return false; 146 return false;
147 ShadowRoot* shadowRoot = containingShadowRoot(); 147 ShadowRoot* shadowRoot = containingShadowRoot();
148 ASSERT(shadowRoot); 148 DCHECK(shadowRoot);
149 if (!isHTMLShadowElement(*this) || shadowRoot->descendantShadowElementCount( ) <= 1) 149 if (!isHTMLShadowElement(*this) || shadowRoot->descendantShadowElementCount( ) <= 1)
150 return true; 150 return true;
151 151
152 // Slow path only when there are more than one shadow elements in a shadow t ree. That should be a rare case. 152 // Slow path only when there are more than one shadow elements in a shadow t ree. That should be a rare case.
153 const HeapVector<Member<InsertionPoint>>& insertionPoints = shadowRoot->desc endantInsertionPoints(); 153 const HeapVector<Member<InsertionPoint>>& insertionPoints = shadowRoot->desc endantInsertionPoints();
154 for (size_t i = 0; i < insertionPoints.size(); ++i) { 154 for (size_t i = 0; i < insertionPoints.size(); ++i) {
155 InsertionPoint* point = insertionPoints[i].get(); 155 InsertionPoint* point = insertionPoints[i].get();
156 if (isHTMLShadowElement(*point)) 156 if (isHTMLShadowElement(*point))
157 return point == this; 157 return point == this;
158 } 158 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 rootOwner->setNeedsDistributionRecalc(); 228 rootOwner->setNeedsDistributionRecalc();
229 } 229 }
230 230
231 // host can be null when removedFrom() is called from ElementShadow destruct or. 231 // host can be null when removedFrom() is called from ElementShadow destruct or.
232 ElementShadow* rootOwner = root ? root->owner() : 0; 232 ElementShadow* rootOwner = root ? root->owner() : 0;
233 233
234 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. 234 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
235 clearDistribution(); 235 clearDistribution();
236 236
237 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { 237 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) {
238 ASSERT(root); 238 DCHECK(root);
239 m_registeredWithShadowRoot = false; 239 m_registeredWithShadowRoot = false;
240 root->didRemoveInsertionPoint(this); 240 root->didRemoveInsertionPoint(this);
241 if (rootOwner) { 241 if (rootOwner) {
242 if (canAffectSelector()) 242 if (canAffectSelector())
243 rootOwner->willAffectSelector(); 243 rootOwner->willAffectSelector();
244 } 244 }
245 } 245 }
246 246
247 HTMLElement::removedFrom(insertionPoint); 247 HTMLElement::removedFrom(insertionPoint);
248 } 248 }
249 249
250 DEFINE_TRACE(InsertionPoint) 250 DEFINE_TRACE(InsertionPoint)
251 { 251 {
252 visitor->trace(m_distributedNodes); 252 visitor->trace(m_distributedNodes);
253 HTMLElement::trace(visitor); 253 HTMLElement::trace(visitor);
254 } 254 }
255 255
256 const InsertionPoint* resolveReprojection(const Node* projectedNode) 256 const InsertionPoint* resolveReprojection(const Node* projectedNode)
257 { 257 {
258 ASSERT(projectedNode); 258 DCHECK(projectedNode);
259 const InsertionPoint* insertionPoint = 0; 259 const InsertionPoint* insertionPoint = 0;
260 const Node* current = projectedNode; 260 const Node* current = projectedNode;
261 ElementShadow* lastElementShadow = 0; 261 ElementShadow* lastElementShadow = 0;
262 while (true) { 262 while (true) {
263 ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current); 263 ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current);
264 if (!shadow || shadow == lastElementShadow) 264 if (!shadow || shadow == lastElementShadow)
265 break; 265 break;
266 lastElementShadow = shadow; 266 lastElementShadow = shadow;
267 const InsertionPoint* insertedTo = shadow->finalDestinationInsertionPoin tFor(projectedNode); 267 const InsertionPoint* insertedTo = shadow->finalDestinationInsertionPoin tFor(projectedNode);
268 if (!insertedTo) 268 if (!insertedTo)
269 break; 269 break;
270 ASSERT(current != insertedTo); 270 DCHECK_NE(current, insertedTo);
271 current = insertedTo; 271 current = insertedTo;
272 insertionPoint = insertedTo; 272 insertionPoint = insertedTo;
273 } 273 }
274 return insertionPoint; 274 return insertionPoint;
275 } 275 }
276 276
277 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results) 277 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results)
278 { 278 {
279 const Node* current = &node; 279 const Node* current = &node;
280 ElementShadow* lastElementShadow = 0; 280 ElementShadow* lastElementShadow = 0;
281 while (true) { 281 while (true) {
282 ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current); 282 ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current);
283 if (!shadow || shadow == lastElementShadow) 283 if (!shadow || shadow == lastElementShadow)
284 return; 284 return;
285 lastElementShadow = shadow; 285 lastElementShadow = shadow;
286 const DestinationInsertionPoints* insertionPoints = shadow->destinationI nsertionPointsFor(&node); 286 const DestinationInsertionPoints* insertionPoints = shadow->destinationI nsertionPointsFor(&node);
287 if (!insertionPoints) 287 if (!insertionPoints)
288 return; 288 return;
289 for (size_t i = 0; i < insertionPoints->size(); ++i) 289 for (size_t i = 0; i < insertionPoints->size(); ++i)
290 results.append(insertionPoints->at(i).get()); 290 results.append(insertionPoints->at(i).get());
291 ASSERT(current != insertionPoints->last().get()); 291 DCHECK_NE(current, insertionPoints->last().get());
292 current = insertionPoints->last().get(); 292 current = insertionPoints->last().get();
293 } 293 }
294 } 294 }
295 295
296 } // namespace blink 296 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698