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

Side by Side Diff: third_party/WebKit/Source/core/dom/ChildFrameDisconnector.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 // 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/dom/ChildFrameDisconnector.h" 5 #include "core/dom/ChildFrameDisconnector.h"
6 6
7 #include "core/dom/shadow/ElementShadow.h" 7 #include "core/dom/shadow/ElementShadow.h"
8 #include "core/dom/shadow/ShadowRoot.h" 8 #include "core/dom/shadow/ShadowRoot.h"
9 #include "core/html/HTMLFrameOwnerElement.h" 9 #include "core/html/HTMLFrameOwnerElement.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 #if ENABLE(ASSERT) 14 #if DCHECK_IS_ON()
15 static unsigned checkConnectedSubframeCountIsConsistent(Node&); 15 static unsigned checkConnectedSubframeCountIsConsistent(Node&);
16 #endif 16 #endif
17 17
18 void ChildFrameDisconnector::disconnect(DisconnectPolicy policy) 18 void ChildFrameDisconnector::disconnect(DisconnectPolicy policy)
19 { 19 {
20 #if ENABLE(ASSERT) 20 #if DCHECK_IS_ON()
21 checkConnectedSubframeCountIsConsistent(root()); 21 checkConnectedSubframeCountIsConsistent(root());
22 #endif 22 #endif
23 23
24 if (!root().connectedSubframeCount()) 24 if (!root().connectedSubframeCount())
25 return; 25 return;
26 26
27 if (policy == RootAndDescendants) { 27 if (policy == RootAndDescendants) {
28 collectFrameOwners(root()); 28 collectFrameOwners(root());
29 } else { 29 } else {
30 for (Node* child = root().firstChild(); child; child = child->nextSiblin g()) 30 for (Node* child = root().firstChild(); child; child = child->nextSiblin g())
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 owner->disconnectContentFrame(); 64 owner->disconnectContentFrame();
65 } 65 }
66 } 66 }
67 67
68 void ChildFrameDisconnector::collectFrameOwners(ElementShadow& shadow) 68 void ChildFrameDisconnector::collectFrameOwners(ElementShadow& shadow)
69 { 69 {
70 for (ShadowRoot* root = &shadow.youngestShadowRoot(); root; root = root->old erShadowRoot()) 70 for (ShadowRoot* root = &shadow.youngestShadowRoot(); root; root = root->old erShadowRoot())
71 collectFrameOwners(*root); 71 collectFrameOwners(*root);
72 } 72 }
73 73
74 #if ENABLE(ASSERT) 74 #if DCHECK_IS_ON()
75 static unsigned checkConnectedSubframeCountIsConsistent(Node& node) 75 static unsigned checkConnectedSubframeCountIsConsistent(Node& node)
76 { 76 {
77 unsigned count = 0; 77 unsigned count = 0;
78 78
79 if (node.isElementNode()) { 79 if (node.isElementNode()) {
80 if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentF rame()) 80 if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentF rame())
81 count++; 81 count++;
82 82
83 if (ElementShadow* shadow = toElement(node).shadow()) { 83 if (ElementShadow* shadow = toElement(node).shadow()) {
84 for (ShadowRoot* root = &shadow->youngestShadowRoot(); root; root = root->olderShadowRoot()) 84 for (ShadowRoot* root = &shadow->youngestShadowRoot(); root; root = root->olderShadowRoot())
85 count += checkConnectedSubframeCountIsConsistent(*root); 85 count += checkConnectedSubframeCountIsConsistent(*root);
86 } 86 }
87 } 87 }
88 88
89 for (Node* child = node.firstChild(); child; child = child->nextSibling()) 89 for (Node* child = node.firstChild(); child; child = child->nextSibling())
90 count += checkConnectedSubframeCountIsConsistent(*child); 90 count += checkConnectedSubframeCountIsConsistent(*child);
91 91
92 // If we undercount there's possibly a security bug since we'd leave frames 92 // If we undercount there's possibly a security bug since we'd leave frames
93 // in subtrees outside the document. 93 // in subtrees outside the document.
94 ASSERT(node.connectedSubframeCount() >= count); 94 DCHECK_GE(node.connectedSubframeCount(), count);
95 95
96 // If we overcount it's safe, but not optimal because it means we'll travers e 96 // If we overcount it's safe, but not optimal because it means we'll travers e
97 // through the document in ChildFrameDisconnector looking for frames that ha ve 97 // through the document in ChildFrameDisconnector looking for frames that ha ve
98 // already been disconnected. 98 // already been disconnected.
99 ASSERT(node.connectedSubframeCount() == count); 99 DCHECK_EQ(node.connectedSubframeCount(), count);
100 100
101 return count; 101 return count;
102 } 102 }
103 #endif 103 #endif
104 104
105 } // namespace blink 105 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/CharacterData.cpp ('k') | third_party/WebKit/Source/core/dom/ChildListMutationScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698