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

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

Issue 1413583002: Make ElementShadow::youngestShadowRoot() return a reference (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more tail -> head Created 5 years, 2 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 "config.h" 5 #include "config.h"
6 #include "core/dom/ChildFrameDisconnector.h" 6 #include "core/dom/ChildFrameDisconnector.h"
7 7
8 #include "core/dom/shadow/ElementShadow.h" 8 #include "core/dom/shadow/ElementShadow.h"
9 #include "core/dom/shadow/ShadowRoot.h" 9 #include "core/dom/shadow/ShadowRoot.h"
10 #include "core/html/HTMLFrameOwnerElement.h" 10 #include "core/html/HTMLFrameOwnerElement.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 HTMLFrameOwnerElement* owner = m_frameOwners[i].get(); 61 HTMLFrameOwnerElement* owner = m_frameOwners[i].get();
62 // Don't need to traverse up the tree for the first owner since no 62 // Don't need to traverse up the tree for the first owner since no
63 // script could have moved it. 63 // script could have moved it.
64 if (!i || root().containsIncludingShadowDOM(owner)) 64 if (!i || root().containsIncludingShadowDOM(owner))
65 owner->disconnectContentFrame(); 65 owner->disconnectContentFrame();
66 } 66 }
67 } 67 }
68 68
69 void ChildFrameDisconnector::collectFrameOwners(ElementShadow& shadow) 69 void ChildFrameDisconnector::collectFrameOwners(ElementShadow& shadow)
70 { 70 {
71 for (ShadowRoot* root = shadow.youngestShadowRoot(); root; root = root->olde rShadowRoot()) 71 for (ShadowRoot* root = &shadow.youngestShadowRoot(); root; root = root->old erShadowRoot())
72 collectFrameOwners(*root); 72 collectFrameOwners(*root);
73 } 73 }
74 74
75 #if ENABLE(ASSERT) 75 #if ENABLE(ASSERT)
76 static unsigned checkConnectedSubframeCountIsConsistent(Node& node) 76 static unsigned checkConnectedSubframeCountIsConsistent(Node& node)
77 { 77 {
78 unsigned count = 0; 78 unsigned count = 0;
79 79
80 if (node.isElementNode()) { 80 if (node.isElementNode()) {
81 if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentF rame()) 81 if (node.isFrameOwnerElement() && toHTMLFrameOwnerElement(node).contentF rame())
82 count++; 82 count++;
83 83
84 if (ElementShadow* shadow = toElement(node).shadow()) { 84 if (ElementShadow* shadow = toElement(node).shadow()) {
85 for (ShadowRoot* root = shadow->youngestShadowRoot(); root; root = r oot->olderShadowRoot()) 85 for (ShadowRoot* root = &shadow->youngestShadowRoot(); root; root = root->olderShadowRoot())
86 count += checkConnectedSubframeCountIsConsistent(*root); 86 count += checkConnectedSubframeCountIsConsistent(*root);
87 } 87 }
88 } 88 }
89 89
90 for (Node* child = node.firstChild(); child; child = child->nextSibling()) 90 for (Node* child = node.firstChild(); child; child = child->nextSibling())
91 count += checkConnectedSubframeCountIsConsistent(*child); 91 count += checkConnectedSubframeCountIsConsistent(*child);
92 92
93 // If we undercount there's possibly a security bug since we'd leave frames 93 // If we undercount there's possibly a security bug since we'd leave frames
94 // in subtrees outside the document. 94 // in subtrees outside the document.
95 ASSERT(node.connectedSubframeCount() >= count); 95 ASSERT(node.connectedSubframeCount() >= count);
96 96
97 // If we overcount it's safe, but not optimal because it means we'll travers e 97 // If we overcount it's safe, but not optimal because it means we'll travers e
98 // through the document in ChildFrameDisconnector looking for frames that ha ve 98 // through the document in ChildFrameDisconnector looking for frames that ha ve
99 // already been disconnected. 99 // already been disconnected.
100 ASSERT(node.connectedSubframeCount() == count); 100 ASSERT(node.connectedSubframeCount() == count);
101 101
102 return count; 102 return count;
103 } 103 }
104 #endif 104 #endif
105 105
106 } 106 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698