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

Side by Side Diff: Source/core/dom/ContainerNodeAlgorithms.cpp

Issue 51273002: Have ChildFrameDisconnector / ChildListMutationScope deal with references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2012 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!node.isElementNode()) 112 if (!node.isElementNode())
113 return; 113 return;
114 114
115 if (ElementShadow* shadow = toElement(node).shadow()) { 115 if (ElementShadow* shadow = toElement(node).shadow()) {
116 ShadowRootVector roots(shadow); 116 ShadowRootVector roots(shadow);
117 for (size_t i = 0; i < roots.size(); ++i) 117 for (size_t i = 0; i < roots.size(); ++i)
118 notifyNodeRemovedFromTree(*roots[i]); 118 notifyNodeRemovedFromTree(*roots[i]);
119 } 119 }
120 } 120 }
121 121
122 void ChildFrameDisconnector::collectFrameOwners(ElementShadow* shadow) 122 void ChildFrameDisconnector::collectFrameOwners(ElementShadow& shadow)
123 { 123 {
124 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = root->old erShadowRoot()) 124 for (ShadowRoot* root = shadow.youngestShadowRoot(); root; root = root->olde rShadowRoot())
125 collectFrameOwners(root); 125 collectFrameOwners(*root);
126 } 126 }
127 127
128 #ifndef NDEBUG 128 #ifndef NDEBUG
129 unsigned assertConnectedSubrameCountIsConsistent(Node* node) 129 unsigned assertConnectedSubrameCountIsConsistent(Node& node)
130 { 130 {
131 unsigned count = 0; 131 unsigned count = 0;
132 132
133 if (node->isElementNode()) { 133 if (node.isElementNode()) {
134 if (node->isFrameOwnerElement() && toHTMLFrameOwnerElement(node)->conten tFrame()) 134 if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentF rame())
135 count++; 135 count++;
136 136
137 if (ElementShadow* shadow = toElement(node)->shadow()) { 137 if (ElementShadow* shadow = toElement(node).shadow()) {
138 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot()) 138 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot())
139 count += assertConnectedSubrameCountIsConsistent(root); 139 count += assertConnectedSubrameCountIsConsistent(*root);
140 } 140 }
141 } 141 }
142 142
143 for (Node* child = node->firstChild(); child; child = child->nextSibling()) 143 for (Node* child = node.firstChild(); child; child = child->nextSibling())
144 count += assertConnectedSubrameCountIsConsistent(child); 144 count += assertConnectedSubrameCountIsConsistent(*child);
145 145
146 // If we undercount there's possibly a security bug since we'd leave frames 146 // If we undercount there's possibly a security bug since we'd leave frames
147 // in subtrees outside the document. 147 // in subtrees outside the document.
148 ASSERT(node->connectedSubframeCount() >= count); 148 ASSERT(node.connectedSubframeCount() >= count);
149 149
150 // If we overcount it's safe, but not optimal because it means we'll travers e 150 // If we overcount it's safe, but not optimal because it means we'll travers e
151 // through the document in ChildFrameDisconnector looking for frames that ha ve 151 // through the document in ChildFrameDisconnector looking for frames that ha ve
152 // already been disconnected. 152 // already been disconnected.
153 ASSERT(node->connectedSubframeCount() == count); 153 ASSERT(node.connectedSubframeCount() == count);
154 154
155 return count; 155 return count;
156 } 156 }
157 #endif 157 #endif
158 158
159 } 159 }
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698