| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 class ShadowRootVector : public Vector<RefPtr<ShadowRoot> > { | 36 class ShadowRootVector : public Vector<RefPtr<ShadowRoot> > { |
| 37 public: | 37 public: |
| 38 explicit ShadowRootVector(ElementShadow* tree) | 38 explicit ShadowRootVector(ElementShadow* tree) |
| 39 { | 39 { |
| 40 for (ShadowRoot* root = tree->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) | 40 for (ShadowRoot* root = tree->youngestShadowRoot(); root; root = root->o
lderShadowRoot()) |
| 41 append(root); | 41 append(root); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN
ode* node) | 45 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoDocument(ContainerN
ode& node) |
| 46 { | 46 { |
| 47 ChildNodesLazySnapshot snapshot(node); | 47 ChildNodesLazySnapshot snapshot(node); |
| 48 while (RefPtr<Node> child = snapshot.nextNode()) { | 48 while (RefPtr<Node> child = snapshot.nextNode()) { |
| 49 // If we have been removed from the document during this loop, then | 49 // If we have been removed from the document during this loop, then |
| 50 // we don't want to tell the rest of our children that they've been | 50 // we don't want to tell the rest of our children that they've been |
| 51 // inserted into the document because they haven't. | 51 // inserted into the document because they haven't. |
| 52 if (node->inDocument() && child->parentNode() == node) | 52 if (node.inDocument() && child->parentNode() == node) |
| 53 notifyNodeInsertedIntoDocument(child.get()); | 53 notifyNodeInsertedIntoDocument(*child); |
| 54 } | 54 } |
| 55 | 55 |
| 56 if (!node->isElementNode()) | 56 if (!node.isElementNode()) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 if (ElementShadow* shadow = toElement(node)->shadow()) { | 59 if (ElementShadow* shadow = toElement(node).shadow()) { |
| 60 ShadowRootVector roots(shadow); | 60 ShadowRootVector roots(shadow); |
| 61 for (size_t i = 0; i < roots.size(); ++i) { | 61 for (size_t i = 0; i < roots.size(); ++i) { |
| 62 if (node->inDocument() && roots[i]->host() == node) | 62 if (node.inDocument() && roots[i]->host() == node) |
| 63 notifyNodeInsertedIntoDocument(roots[i].get()); | 63 notifyNodeInsertedIntoDocument(*roots[i]); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoTree(ContainerNode*
node) | 68 void ChildNodeInsertionNotifier::notifyDescendantInsertedIntoTree(ContainerNode&
node) |
| 69 { | 69 { |
| 70 for (Node* child = node->firstChild(); child; child = child->nextSibling())
{ | 70 for (Node* child = node.firstChild(); child; child = child->nextSibling()) { |
| 71 if (child->isContainerNode()) | 71 if (child->isContainerNode()) |
| 72 notifyNodeInsertedIntoTree(toContainerNode(child)); | 72 notifyNodeInsertedIntoTree(toContainerNode(*child)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 for (ShadowRoot* root = node->youngestShadowRoot(); root; root = root->older
ShadowRoot()) | 75 for (ShadowRoot* root = node.youngestShadowRoot(); root; root = root->olderS
hadowRoot()) |
| 76 notifyNodeInsertedIntoTree(root); | 76 notifyNodeInsertedIntoTree(*root); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode
* node) | 79 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromDocument(ContainerNode
& node) |
| 80 { | 80 { |
| 81 ChildNodesLazySnapshot snapshot(node); | 81 ChildNodesLazySnapshot snapshot(node); |
| 82 while (RefPtr<Node> child = snapshot.nextNode()) { | 82 while (RefPtr<Node> child = snapshot.nextNode()) { |
| 83 // If we have been added to the document during this loop, then we | 83 // If we have been added to the document during this loop, then we |
| 84 // don't want to tell the rest of our children that they've been | 84 // don't want to tell the rest of our children that they've been |
| 85 // removed from the document because they haven't. | 85 // removed from the document because they haven't. |
| 86 if (!node->inDocument() && child->parentNode() == node) | 86 if (!node.inDocument() && child->parentNode() == node) |
| 87 notifyNodeRemovedFromDocument(child.get()); | 87 notifyNodeRemovedFromDocument(*child); |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (!node->isElementNode()) | 90 if (!node.isElementNode()) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 if (node->document().cssTarget() == node) | 93 if (node.document().cssTarget() == node) |
| 94 node->document().setCSSTarget(0); | 94 node.document().setCSSTarget(0); |
| 95 | 95 |
| 96 if (ElementShadow* shadow = toElement(node)->shadow()) { | 96 if (ElementShadow* shadow = toElement(node).shadow()) { |
| 97 ShadowRootVector roots(shadow); | 97 ShadowRootVector roots(shadow); |
| 98 for (size_t i = 0; i < roots.size(); ++i) { | 98 for (size_t i = 0; i < roots.size(); ++i) { |
| 99 if (!node->inDocument() && roots[i]->host() == node) | 99 if (!node.inDocument() && roots[i]->host() == node) |
| 100 notifyNodeRemovedFromDocument(roots[i].get()); | 100 notifyNodeRemovedFromDocument(*roots[i]); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromTree(ContainerNode* no
de) | 105 void ChildNodeRemovalNotifier::notifyDescendantRemovedFromTree(ContainerNode& no
de) |
| 106 { | 106 { |
| 107 for (Node* child = node->firstChild(); child; child = child->nextSibling())
{ | 107 for (Node* child = node.firstChild(); child; child = child->nextSibling()) { |
| 108 if (child->isContainerNode()) | 108 if (child->isContainerNode()) |
| 109 notifyNodeRemovedFromTree(toContainerNode(child)); | 109 notifyNodeRemovedFromTree(toContainerNode(*child)); |
| 110 } | 110 } |
| 111 | 111 |
| 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].get()); | 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->old
erShadowRoot()) |
| 125 collectFrameOwners(root); | 125 collectFrameOwners(root); |
| 126 } | 126 } |
| 127 | 127 |
| 128 #ifndef NDEBUG | 128 #ifndef NDEBUG |
| (...skipping 21 matching lines...) Expand all Loading... |
| 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 } |
| OLD | NEW |