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 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 if (!node.isDocumentFragment()) { | 65 if (!node.isDocumentFragment()) { |
66 nodes.append(&node); | 66 nodes.append(&node); |
67 if (ContainerNode* oldParent = node.parentNode()) | 67 if (ContainerNode* oldParent = node.parentNode()) |
68 oldParent->removeChild(&node, exceptionState); | 68 oldParent->removeChild(&node, exceptionState); |
69 return; | 69 return; |
70 } | 70 } |
71 getChildNodes(node, nodes); | 71 getChildNodes(node, nodes); |
72 toContainerNode(node).removeChildren(); | 72 toContainerNode(node).removeChildren(); |
73 } | 73 } |
74 | 74 |
75 #if !ENABLE(OILPAN) | |
75 void ContainerNode::removeDetachedChildren() | 76 void ContainerNode::removeDetachedChildren() |
76 { | 77 { |
77 if (connectedSubframeCount()) { | 78 if (connectedSubframeCount()) { |
78 for (Node* child = firstChild(); child; child = child->nextSibling()) | 79 for (Node* child = firstChild(); child; child = child->nextSibling()) |
79 child->updateAncestorConnectedSubframeCountForRemoval(); | 80 child->updateAncestorConnectedSubframeCountForRemoval(); |
80 } | 81 } |
81 ASSERT(needsAttach()); | 82 ASSERT(needsAttach()); |
82 removeDetachedChildrenInContainer<Node, ContainerNode>(*this); | 83 removeDetachedChildrenInContainer<Node, ContainerNode>(*this); |
83 } | 84 } |
85 #endif | |
84 | 86 |
85 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) | 87 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode& oldParent) |
86 { | 88 { |
87 while (RefPtr<Node> child = oldParent.firstChild()) { | 89 while (RefPtr<Node> child = oldParent.firstChild()) { |
88 oldParent.parserRemoveChild(*child); | 90 oldParent.parserRemoveChild(*child); |
89 treeScope().adoptIfNeeded(*child); | 91 treeScope().adoptIfNeeded(*child); |
90 parserAppendChild(child.get()); | 92 parserAppendChild(child.get()); |
91 } | 93 } |
92 } | 94 } |
93 | 95 |
94 ContainerNode::~ContainerNode() | 96 ContainerNode::~ContainerNode() |
95 { | 97 { |
96 #if !ENABLE(OILPAN) | 98 #if ENABLE(OILPAN) |
99 ASSERT(needsAttach()); | |
100 #else | |
97 willBeDeletedFromDocument(); | 101 willBeDeletedFromDocument(); |
102 removeDetachedChildren(); | |
98 #endif | 103 #endif |
99 removeDetachedChildren(); | |
100 } | 104 } |
101 | 105 |
102 bool ContainerNode::isChildTypeAllowed(const Node& child) const | 106 bool ContainerNode::isChildTypeAllowed(const Node& child) const |
103 { | 107 { |
104 if (!child.isDocumentFragment()) | 108 if (!child.isDocumentFragment()) |
105 return childTypeAllowed(child.nodeType()); | 109 return childTypeAllowed(child.nodeType()); |
106 | 110 |
107 for (Node* node = child.firstChild(); node; node = node->nextSibling()) { | 111 for (Node* node = child.firstChild(); node; node = node->nextSibling()) { |
108 if (!childTypeAllowed(node->nodeType())) | 112 if (!childTypeAllowed(node->nodeType())) |
109 return false; | 113 return false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 | 251 |
248 ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle re parenting (and want DOM mutation events). | 252 ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle re parenting (and want DOM mutation events). |
249 ASSERT(!newChild.nextSibling()); | 253 ASSERT(!newChild.nextSibling()); |
250 ASSERT(!newChild.previousSibling()); | 254 ASSERT(!newChild.previousSibling()); |
251 ASSERT(!newChild.isShadowRoot()); | 255 ASSERT(!newChild.isShadowRoot()); |
252 | 256 |
253 Node* prev = nextChild.previousSibling(); | 257 Node* prev = nextChild.previousSibling(); |
254 ASSERT(m_lastChild != prev); | 258 ASSERT(m_lastChild != prev); |
255 nextChild.setPreviousSibling(&newChild); | 259 nextChild.setPreviousSibling(&newChild); |
256 if (prev) { | 260 if (prev) { |
257 ASSERT(m_firstChild != nextChild); | 261 ASSERT(firstChild() != nextChild); |
258 ASSERT(prev->nextSibling() == nextChild); | 262 ASSERT(prev->nextSibling() == nextChild); |
259 prev->setNextSibling(&newChild); | 263 prev->setNextSibling(&newChild); |
260 } else { | 264 } else { |
261 ASSERT(m_firstChild == nextChild); | 265 ASSERT(firstChild() == nextChild); |
262 m_firstChild = &newChild; | 266 m_firstChild = &newChild; |
263 } | 267 } |
264 newChild.setParentOrShadowHostNode(this); | 268 newChild.setParentOrShadowHostNode(this); |
265 newChild.setPreviousSibling(prev); | 269 newChild.setPreviousSibling(prev); |
266 newChild.setNextSibling(&nextChild); | 270 newChild.setNextSibling(&nextChild); |
267 } | 271 } |
268 | 272 |
269 void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node& nextChil d) | 273 void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node& nextChil d) |
270 { | 274 { |
271 ASSERT(newChild); | 275 ASSERT(newChild); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 } | 406 } |
403 | 407 |
404 ChildFrameDisconnector(*this).disconnect(ChildFrameDisconnector::Descendants Only); | 408 ChildFrameDisconnector(*this).disconnect(ChildFrameDisconnector::Descendants Only); |
405 } | 409 } |
406 | 410 |
407 void ContainerNode::disconnectDescendantFrames() | 411 void ContainerNode::disconnectDescendantFrames() |
408 { | 412 { |
409 ChildFrameDisconnector(*this).disconnect(); | 413 ChildFrameDisconnector(*this).disconnect(); |
410 } | 414 } |
411 | 415 |
416 void ContainerNode::trace(Visitor* visitor) | |
417 { | |
418 visitor->trace(m_firstChild); | |
419 visitor->trace(m_lastChild); | |
420 Node::trace(visitor); | |
421 } | |
422 | |
412 void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState) | 423 void ContainerNode::removeChild(Node* oldChild, ExceptionState& exceptionState) |
413 { | 424 { |
414 #if !ENABLE(OILPAN) | 425 #if !ENABLE(OILPAN) |
415 // Check that this node is not "floating". | 426 // Check that this node is not "floating". |
416 // If it is, it can be deleted as a side effect of sending mutation events. | 427 // If it is, it can be deleted as a side effect of sending mutation events. |
417 ASSERT(refCount() || parentOrShadowHostNode()); | 428 ASSERT(refCount() || parentOrShadowHostNode()); |
418 #endif | 429 #endif |
419 | 430 |
420 RefPtr<Node> protect(this); | 431 RefPtr<Node> protect(this); |
421 | 432 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 | 479 |
469 ASSERT(oldChild.parentNode() == this); | 480 ASSERT(oldChild.parentNode() == this); |
470 | 481 |
471 if (!oldChild.needsAttach()) | 482 if (!oldChild.needsAttach()) |
472 oldChild.detach(); | 483 oldChild.detach(); |
473 | 484 |
474 if (nextChild) | 485 if (nextChild) |
475 nextChild->setPreviousSibling(previousChild); | 486 nextChild->setPreviousSibling(previousChild); |
476 if (previousChild) | 487 if (previousChild) |
477 previousChild->setNextSibling(nextChild); | 488 previousChild->setNextSibling(nextChild); |
478 if (m_firstChild == oldChild) | 489 if (m_firstChild == &oldChild) |
tkent
2014/05/07 00:41:19
We should add operator==(const Member<Node>, const
Mads Ager (chromium)
2014/05/07 12:13:16
Yes, we should, thanks!
| |
479 m_firstChild = nextChild; | 490 m_firstChild = nextChild; |
480 if (m_lastChild == oldChild) | 491 if (m_lastChild == &oldChild) |
481 m_lastChild = previousChild; | 492 m_lastChild = previousChild; |
482 | 493 |
483 oldChild.setPreviousSibling(0); | 494 oldChild.setPreviousSibling(0); |
484 oldChild.setNextSibling(0); | 495 oldChild.setNextSibling(0); |
485 oldChild.setParentOrShadowHostNode(0); | 496 oldChild.setParentOrShadowHostNode(0); |
486 | 497 |
487 document().adoptIfNeeded(oldChild); | 498 document().adoptIfNeeded(oldChild); |
488 } | 499 } |
489 | 500 |
490 void ContainerNode::parserRemoveChild(Node& oldChild) | 501 void ContainerNode::parserRemoveChild(Node& oldChild) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
557 ChildNodeRemovalNotifier(*this).notify(*removedChildren[i]); | 568 ChildNodeRemovalNotifier(*this).notify(*removedChildren[i]); |
558 } | 569 } |
559 | 570 |
560 dispatchSubtreeModifiedEvent(); | 571 dispatchSubtreeModifiedEvent(); |
561 } | 572 } |
562 | 573 |
563 void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& excep tionState) | 574 void ContainerNode::appendChild(PassRefPtr<Node> newChild, ExceptionState& excep tionState) |
564 { | 575 { |
565 RefPtr<ContainerNode> protect(this); | 576 RefPtr<ContainerNode> protect(this); |
566 | 577 |
578 #if !ENABLE(OILPAN) | |
567 // Check that this node is not "floating". | 579 // Check that this node is not "floating". |
568 // If it is, it can be deleted as a side effect of sending mutation events. | 580 // If it is, it can be deleted as a side effect of sending mutation events. |
569 ASSERT(refCount() || parentOrShadowHostNode()); | 581 ASSERT(refCount() || parentOrShadowHostNode()); |
582 #endif | |
570 | 583 |
571 // Make sure adding the new child is ok | 584 // Make sure adding the new child is ok |
572 if (!checkAcceptChild(newChild.get(), 0, exceptionState)) | 585 if (!checkAcceptChild(newChild.get(), 0, exceptionState)) |
573 return; | 586 return; |
574 ASSERT(newChild); | 587 ASSERT(newChild); |
575 | 588 |
576 if (newChild == m_lastChild) // nothing to do | 589 if (newChild == m_lastChild) // nothing to do |
577 return; | 590 return; |
578 | 591 |
579 NodeVector targets; | 592 NodeVector targets; |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 // dispatch the DOMNodeRemovedFromDocument event to all descendants | 1001 // dispatch the DOMNodeRemovedFromDocument event to all descendants |
989 if (c->inDocument() && document->hasListenerType(Document::DOMNODEREMOVEDFRO MDOCUMENT_LISTENER)) { | 1002 if (c->inDocument() && document->hasListenerType(Document::DOMNODEREMOVEDFRO MDOCUMENT_LISTENER)) { |
990 NodeChildRemovalTracker scope(child); | 1003 NodeChildRemovalTracker scope(child); |
991 for (; c; c = NodeTraversal::next(*c, &child)) | 1004 for (; c; c = NodeTraversal::next(*c, &child)) |
992 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false)); | 1005 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false)); |
993 } | 1006 } |
994 } | 1007 } |
995 | 1008 |
996 void ContainerNode::updateTreeAfterInsertion(Node& child) | 1009 void ContainerNode::updateTreeAfterInsertion(Node& child) |
997 { | 1010 { |
1011 #if !ENABLE(OILPAN) | |
998 ASSERT(refCount()); | 1012 ASSERT(refCount()); |
999 ASSERT(child.refCount()); | 1013 ASSERT(child.refCount()); |
1014 #endif | |
1000 | 1015 |
1001 ChildListMutationScope(*this).childAdded(child); | 1016 ChildListMutationScope(*this).childAdded(child); |
1002 | 1017 |
1003 childrenChanged(false, child.previousSibling(), child.nextSibling(), 1); | 1018 childrenChanged(false, child.previousSibling(), child.nextSibling(), 1); |
1004 | 1019 |
1005 ChildNodeInsertionNotifier(*this).notify(child); | 1020 ChildNodeInsertionNotifier(*this).notify(child); |
1006 | 1021 |
1007 dispatchChildInsertionEvents(child); | 1022 dispatchChildInsertionEvents(child); |
1008 } | 1023 } |
1009 | 1024 |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 return true; | 1212 return true; |
1198 | 1213 |
1199 if (node->isElementNode() && toElement(node)->shadow()) | 1214 if (node->isElementNode() && toElement(node)->shadow()) |
1200 return true; | 1215 return true; |
1201 | 1216 |
1202 return false; | 1217 return false; |
1203 } | 1218 } |
1204 #endif | 1219 #endif |
1205 | 1220 |
1206 } // namespace WebCore | 1221 } // namespace WebCore |
OLD | NEW |