| OLD | NEW |
| 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" |
| 11 #include "wtf/Assertions.h" | 11 #include "wtf/Assertions.h" |
| 12 | 12 |
| 13 namespace WebCore { | 13 namespace WebCore { |
| 14 | 14 |
| 15 #ifndef NDEBUG | 15 #if ENABLE(ASSERT) |
| 16 static unsigned checkConnectedSubframeCountIsConsistent(Node&); | 16 static unsigned checkConnectedSubframeCountIsConsistent(Node&); |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 void ChildFrameDisconnector::disconnect(DisconnectPolicy policy) | 19 void ChildFrameDisconnector::disconnect(DisconnectPolicy policy) |
| 20 { | 20 { |
| 21 #ifndef NDEBUG | 21 #if ENABLE(ASSERT) |
| 22 checkConnectedSubframeCountIsConsistent(m_root); | 22 checkConnectedSubframeCountIsConsistent(m_root); |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 if (!m_root.connectedSubframeCount()) | 25 if (!m_root.connectedSubframeCount()) |
| 26 return; | 26 return; |
| 27 | 27 |
| 28 if (policy == RootAndDescendants) { | 28 if (policy == RootAndDescendants) { |
| 29 collectFrameOwners(m_root); | 29 collectFrameOwners(m_root); |
| 30 } else { | 30 } else { |
| 31 for (Node* child = m_root.firstChild(); child; child = child->nextSiblin
g()) | 31 for (Node* child = m_root.firstChild(); child; child = child->nextSiblin
g()) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->olde
rShadowRoot()) |
| 72 collectFrameOwners(*root); | 72 collectFrameOwners(*root); |
| 73 } | 73 } |
| 74 | 74 |
| 75 #ifndef NDEBUG | 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 = r
oot->olderShadowRoot()) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 } |
| OLD | NEW |