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

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/ElementShadow.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 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get()); 181 InspectorInstrumentation::didPushShadowRoot(&shadowHost, shadowRoot.get());
182 182
183 return *shadowRoot; 183 return *shadowRoot;
184 } 184 }
185 185
186 #if !ENABLE(OILPAN) 186 #if !ENABLE(OILPAN)
187 void ElementShadow::removeDetachedShadowRoots() 187 void ElementShadow::removeDetachedShadowRoots()
188 { 188 {
189 // Dont protect this ref count. 189 // Dont protect this ref count.
190 Element* shadowHost = host(); 190 Element* shadowHost = host();
191 ASSERT(shadowHost); 191 DCHECK(shadowHost);
192 192
193 while (RawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) { 193 while (RawPtr<ShadowRoot> oldRoot = m_shadowRoots.head()) {
194 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get()); 194 InspectorInstrumentation::willPopShadowRoot(shadowHost, oldRoot.get());
195 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get()); 195 shadowHost->document().removeFocusedElementOfSubtree(oldRoot.get());
196 m_shadowRoots.removeHead(); 196 m_shadowRoots.removeHead();
197 oldRoot->setParentOrShadowHostNode(0); 197 oldRoot->setParentOrShadowHostNode(0);
198 oldRoot->setParentTreeScope(shadowHost->document()); 198 oldRoot->setParentTreeScope(shadowHost->document());
199 oldRoot->setPrev(0); 199 oldRoot->setPrev(0);
200 oldRoot->setNext(0); 200 oldRoot->setNext(0);
201 } 201 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 root = root->olderShadowRoot(); 252 root = root->olderShadowRoot();
253 otherRoot = otherRoot->olderShadowRoot(); 253 otherRoot = otherRoot->olderShadowRoot();
254 } 254 }
255 255
256 return true; 256 return true;
257 } 257 }
258 258
259 const InsertionPoint* ElementShadow::finalDestinationInsertionPointFor(const Nod e* key) const 259 const InsertionPoint* ElementShadow::finalDestinationInsertionPointFor(const Nod e* key) const
260 { 260 {
261 ASSERT(key && !key->needsDistributionRecalc()); 261 DCHECK(key);
262 #if DCHECK_IS_ON()
263 DCHECK(!key->needsDistributionRecalc());
264 #endif
262 NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoint s.find(key); 265 NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoint s.find(key);
263 #if ENABLE(OILPAN) 266 #if ENABLE(OILPAN)
264 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value->last().get (); 267 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value->last().get ();
265 #else 268 #else
266 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value.last().get( ); 269 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value.last().get( );
267 #endif 270 #endif
268 } 271 }
269 272
270 const DestinationInsertionPoints* ElementShadow::destinationInsertionPointsFor(c onst Node* key) const 273 const DestinationInsertionPoints* ElementShadow::destinationInsertionPointsFor(c onst Node* key) const
271 { 274 {
272 ASSERT(key && !key->needsDistributionRecalc()); 275 DCHECK(key);
276 #if DCHECK_IS_ON()
277 DCHECK(!key->needsDistributionRecalc());
278 #endif
273 NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoint s.find(key); 279 NodeToDestinationInsertionPoints::const_iterator it = m_nodeToInsertionPoint s.find(key);
274 #if ENABLE(OILPAN) 280 #if ENABLE(OILPAN)
275 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value.get(); 281 return it == m_nodeToInsertionPoints.end() ? nullptr : it->value.get();
276 #else 282 #else
277 return it == m_nodeToInsertionPoints.end() ? nullptr : &it->value; 283 return it == m_nodeToInsertionPoints.end() ? nullptr : &it->value;
278 #endif 284 #endif
279 } 285 }
280 286
281 void ElementShadow::distribute() 287 void ElementShadow::distribute()
282 { 288 {
283 if (isV1()) 289 if (isV1())
284 distributeV1(); 290 distributeV1();
285 else 291 else
286 distributeV0(); 292 distributeV0();
287 } 293 }
288 294
289 void ElementShadow::distributeV0() 295 void ElementShadow::distributeV0()
290 { 296 {
291 HeapVector<Member<HTMLShadowElement>, 32> shadowInsertionPoints; 297 HeapVector<Member<HTMLShadowElement>, 32> shadowInsertionPoints;
292 DistributionPool pool(*host()); 298 DistributionPool pool(*host());
293 299
294 for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShado wRoot()) { 300 for (ShadowRoot* root = &youngestShadowRoot(); root; root = root->olderShado wRoot()) {
295 HTMLShadowElement* shadowInsertionPoint = 0; 301 HTMLShadowElement* shadowInsertionPoint = 0;
296 const HeapVector<Member<InsertionPoint>>& insertionPoints = root->descen dantInsertionPoints(); 302 const HeapVector<Member<InsertionPoint>>& insertionPoints = root->descen dantInsertionPoints();
297 for (size_t i = 0; i < insertionPoints.size(); ++i) { 303 for (size_t i = 0; i < insertionPoints.size(); ++i) {
298 InsertionPoint* point = insertionPoints[i].get(); 304 InsertionPoint* point = insertionPoints[i].get();
299 if (!point->isActive()) 305 if (!point->isActive())
300 continue; 306 continue;
301 if (isHTMLShadowElement(*point)) { 307 if (isHTMLShadowElement(*point)) {
302 ASSERT(!shadowInsertionPoint); 308 DCHECK(!shadowInsertionPoint);
303 shadowInsertionPoint = toHTMLShadowElement(point); 309 shadowInsertionPoint = toHTMLShadowElement(point);
304 shadowInsertionPoints.append(shadowInsertionPoint); 310 shadowInsertionPoints.append(shadowInsertionPoint);
305 } else { 311 } else {
306 pool.distributeTo(point, this); 312 pool.distributeTo(point, this);
307 if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*poi nt)) 313 if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*poi nt))
308 shadow->setNeedsDistributionRecalc(); 314 shadow->setNeedsDistributionRecalc();
309 } 315 }
310 } 316 }
311 } 317 }
312 318
313 for (size_t i = shadowInsertionPoints.size(); i > 0; --i) { 319 for (size_t i = shadowInsertionPoints.size(); i > 0; --i) {
314 HTMLShadowElement* shadowInsertionPoint = shadowInsertionPoints[i - 1]; 320 HTMLShadowElement* shadowInsertionPoint = shadowInsertionPoints[i - 1];
315 ShadowRoot* root = shadowInsertionPoint->containingShadowRoot(); 321 ShadowRoot* root = shadowInsertionPoint->containingShadowRoot();
316 ASSERT(root); 322 DCHECK(root);
317 if (root->isOldest()) { 323 if (root->isOldest()) {
318 pool.distributeTo(shadowInsertionPoint, this); 324 pool.distributeTo(shadowInsertionPoint, this);
319 } else if (root->olderShadowRoot()->type() == root->type()) { 325 } else if (root->olderShadowRoot()->type() == root->type()) {
320 // Only allow reprojecting older shadow roots between the same type to 326 // Only allow reprojecting older shadow roots between the same type to
321 // disallow reprojecting UA elements into author shadows. 327 // disallow reprojecting UA elements into author shadows.
322 DistributionPool olderShadowRootPool(*root->olderShadowRoot()); 328 DistributionPool olderShadowRootPool(*root->olderShadowRoot());
323 olderShadowRootPool.distributeTo(shadowInsertionPoint, this); 329 olderShadowRootPool.distributeTo(shadowInsertionPoint, this);
324 root->olderShadowRoot()->setShadowInsertionPointOfYoungerShadowRoot( shadowInsertionPoint); 330 root->olderShadowRoot()->setShadowInsertionPointOfYoungerShadowRoot( shadowInsertionPoint);
325 } 331 }
326 if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*shadowInser tionPoint)) 332 if (ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*shadowInser tionPoint))
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 visitor->trace(m_nodeToInsertionPoints); 405 visitor->trace(m_nodeToInsertionPoints);
400 visitor->trace(m_selectFeatures); 406 visitor->trace(m_selectFeatures);
401 // Shadow roots are linked with previous and next pointers which are traced. 407 // Shadow roots are linked with previous and next pointers which are traced.
402 // It is therefore enough to trace one of the shadow roots here and the 408 // It is therefore enough to trace one of the shadow roots here and the
403 // rest will be traced from there. 409 // rest will be traced from there.
404 visitor->trace(m_shadowRoots.head()); 410 visitor->trace(m_shadowRoots.head());
405 visitor->trace(m_slotAssignment); 411 visitor->trace(m_slotAssignment);
406 } 412 }
407 413
408 } // namespace blink 414 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698