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

Side by Side Diff: third_party/WebKit/Source/core/dom/TreeScope.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) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 TreeScope::TreeScope(ContainerNode& rootNode, Document& document) 59 TreeScope::TreeScope(ContainerNode& rootNode, Document& document)
60 : m_rootNode(&rootNode) 60 : m_rootNode(&rootNode)
61 , m_document(&document) 61 , m_document(&document)
62 , m_parentTreeScope(&document) 62 , m_parentTreeScope(&document)
63 #if !ENABLE(OILPAN) 63 #if !ENABLE(OILPAN)
64 , m_guardRefCount(0) 64 , m_guardRefCount(0)
65 #endif 65 #endif
66 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 66 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
67 { 67 {
68 ASSERT(rootNode != document); 68 DCHECK_NE(rootNode, document);
69 #if !ENABLE(OILPAN) 69 #if !ENABLE(OILPAN)
70 m_parentTreeScope->guardRef(); 70 m_parentTreeScope->guardRef();
71 #endif 71 #endif
72 m_rootNode->setTreeScope(this); 72 m_rootNode->setTreeScope(this);
73 } 73 }
74 74
75 TreeScope::TreeScope(Document& document) 75 TreeScope::TreeScope(Document& document)
76 : m_rootNode(document) 76 : m_rootNode(document)
77 , m_document(&document) 77 , m_document(&document)
78 , m_parentTreeScope(nullptr) 78 , m_parentTreeScope(nullptr)
79 #if !ENABLE(OILPAN) 79 #if !ENABLE(OILPAN)
80 , m_guardRefCount(0) 80 , m_guardRefCount(0)
81 #endif 81 #endif
82 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create()) 82 , m_idTargetObserverRegistry(IdTargetObserverRegistry::create())
83 { 83 {
84 m_rootNode->setTreeScope(this); 84 m_rootNode->setTreeScope(this);
85 } 85 }
86 86
87 TreeScope::~TreeScope() 87 TreeScope::~TreeScope()
88 { 88 {
89 #if !ENABLE(OILPAN) 89 #if !ENABLE(OILPAN)
90 ASSERT(!m_guardRefCount); 90 DCHECK(!m_guardRefCount);
91 m_rootNode->setTreeScope(nullptr); 91 m_rootNode->setTreeScope(nullptr);
92 92
93 if (m_selection) { 93 if (m_selection) {
94 m_selection->clearTreeScope(); 94 m_selection->clearTreeScope();
95 m_selection = nullptr; 95 m_selection = nullptr;
96 } 96 }
97 97
98 if (m_parentTreeScope) 98 if (m_parentTreeScope)
99 m_parentTreeScope->guardDeref(); 99 m_parentTreeScope->guardDeref();
100 #endif 100 #endif
(...skipping 27 matching lines...) Expand all
128 { 128 {
129 m_elementsById.clear(); 129 m_elementsById.clear();
130 m_imageMapsByName.clear(); 130 m_imageMapsByName.clear();
131 m_labelsByForAttribute.clear(); 131 m_labelsByForAttribute.clear();
132 } 132 }
133 #endif 133 #endif
134 134
135 void TreeScope::setParentTreeScope(TreeScope& newParentScope) 135 void TreeScope::setParentTreeScope(TreeScope& newParentScope)
136 { 136 {
137 // A document node cannot be re-parented. 137 // A document node cannot be re-parented.
138 ASSERT(!rootNode().isDocumentNode()); 138 DCHECK(!rootNode().isDocumentNode());
139 139
140 #if !ENABLE(OILPAN) 140 #if !ENABLE(OILPAN)
141 newParentScope.guardRef(); 141 newParentScope.guardRef();
142 if (m_parentTreeScope) 142 if (m_parentTreeScope)
143 m_parentTreeScope->guardDeref(); 143 m_parentTreeScope->guardDeref();
144 #endif 144 #endif
145 m_parentTreeScope = &newParentScope; 145 m_parentTreeScope = &newParentScope;
146 setDocument(newParentScope.document()); 146 setDocument(newParentScope.document());
147 } 147 }
148 148
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 Element* TreeScope::hitTestPoint(int x, int y, const HitTestRequest& request) co nst 282 Element* TreeScope::hitTestPoint(int x, int y, const HitTestRequest& request) co nst
283 { 283 {
284 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y, reque st); 284 HitTestResult result = hitTestInDocument(&rootNode().document(), x, y, reque st);
285 Node* node = result.innerNode(); 285 Node* node = result.innerNode();
286 if (!node || node->isDocumentNode()) 286 if (!node || node->isDocumentNode())
287 return nullptr; 287 return nullptr;
288 if (node->isPseudoElement() || node->isTextNode()) 288 if (node->isPseudoElement() || node->isTextNode())
289 node = node->parentOrShadowHostNode(); 289 node = node->parentOrShadowHostNode();
290 ASSERT(!node || node->isElementNode() || node->isShadowRoot()); 290 DCHECK(!node || node->isElementNode() || node->isShadowRoot());
291 node = ancestorInThisScope(node); 291 node = ancestorInThisScope(node);
292 if (!node || !node->isElementNode()) 292 if (!node || !node->isElementNode())
293 return nullptr; 293 return nullptr;
294 return toElement(node); 294 return toElement(node);
295 } 295 }
296 296
297 HeapVector<Member<Element>> TreeScope::elementsFromHitTestResult(HitTestResult& result) const 297 HeapVector<Member<Element>> TreeScope::elementsFromHitTestResult(HitTestResult& result) const
298 { 298 {
299 HeapVector<Member<Element>> elements; 299 HeapVector<Member<Element>> elements;
300 300
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::ListBased | HitTestRequest::PenetratingList); 339 HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | H itTestRequest::ListBased | HitTestRequest::PenetratingList);
340 HitTestResult result(request, hitPoint); 340 HitTestResult result(request, hitPoint);
341 document.layoutView()->hitTest(result); 341 document.layoutView()->hitTest(result);
342 342
343 return elementsFromHitTestResult(result); 343 return elementsFromHitTestResult(result);
344 } 344 }
345 345
346 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement * element) 346 void TreeScope::addLabel(const AtomicString& forAttributeValue, HTMLLabelElement * element)
347 { 347 {
348 ASSERT(m_labelsByForAttribute); 348 DCHECK(m_labelsByForAttribute);
349 m_labelsByForAttribute->add(forAttributeValue, element); 349 m_labelsByForAttribute->add(forAttributeValue, element);
350 } 350 }
351 351
352 void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElem ent* element) 352 void TreeScope::removeLabel(const AtomicString& forAttributeValue, HTMLLabelElem ent* element)
353 { 353 {
354 ASSERT(m_labelsByForAttribute); 354 DCHECK(m_labelsByForAttribute);
355 m_labelsByForAttribute->remove(forAttributeValue, element); 355 m_labelsByForAttribute->remove(forAttributeValue, element);
356 } 356 }
357 357
358 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV alue) 358 HTMLLabelElement* TreeScope::labelElementForId(const AtomicString& forAttributeV alue)
359 { 359 {
360 if (forAttributeValue.isEmpty()) 360 if (forAttributeValue.isEmpty())
361 return nullptr; 361 return nullptr;
362 362
363 if (!m_labelsByForAttribute) { 363 if (!m_labelsByForAttribute) {
364 // Populate the map on first access. 364 // Populate the map on first access.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // Strict mode, names need to match exactly. 403 // Strict mode, names need to match exactly.
404 if (anchor.name() == name) 404 if (anchor.name() == name)
405 return &anchor; 405 return &anchor;
406 } 406 }
407 } 407 }
408 return nullptr; 408 return nullptr;
409 } 409 }
410 410
411 void TreeScope::adoptIfNeeded(Node& node) 411 void TreeScope::adoptIfNeeded(Node& node)
412 { 412 {
413 ASSERT(this); 413 DCHECK(this);
414 ASSERT(!node.isDocumentNode()); 414 DCHECK(!node.isDocumentNode());
415 #if !ENABLE(OILPAN) 415 #if !ENABLE(OILPAN)
416 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); 416 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun);
417 #endif 417 #endif
418 TreeScopeAdopter adopter(node, *this); 418 TreeScopeAdopter adopter(node, *this);
419 if (adopter.needsScopeChange()) 419 if (adopter.needsScopeChange())
420 adopter.execute(); 420 adopter.execute();
421 } 421 }
422 422
423 Element* TreeScope::adjustedFocusedElement() const 423 Element* TreeScope::adjustedFocusedElement() const
424 { 424 {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 visitor->trace(m_idTargetObserverRegistry); 576 visitor->trace(m_idTargetObserverRegistry);
577 visitor->trace(m_selection); 577 visitor->trace(m_selection);
578 visitor->trace(m_elementsById); 578 visitor->trace(m_elementsById);
579 visitor->trace(m_imageMapsByName); 579 visitor->trace(m_imageMapsByName);
580 visitor->trace(m_labelsByForAttribute); 580 visitor->trace(m_labelsByForAttribute);
581 visitor->trace(m_scopedStyleResolver); 581 visitor->trace(m_scopedStyleResolver);
582 visitor->trace(m_radioButtonGroupScope); 582 visitor->trace(m_radioButtonGroupScope);
583 } 583 }
584 584
585 } // namespace blink 585 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/TreeScope.h ('k') | third_party/WebKit/Source/core/dom/TreeScopeAdopter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698