| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 child->updateAncestorConnectedSubframeCountForRemoval(); | 82 child->updateAncestorConnectedSubframeCountForRemoval(); |
| 83 } | 83 } |
| 84 // FIXME: We should be able to ASSERT(!confusingAndOftenMisusedAttached()) h
ere: https://bugs.webkit.org/show_bug.cgi?id=107801 | 84 // FIXME: We should be able to ASSERT(!confusingAndOftenMisusedAttached()) h
ere: https://bugs.webkit.org/show_bug.cgi?id=107801 |
| 85 removeDetachedChildrenInContainer<Node, ContainerNode>(*this); | 85 removeDetachedChildrenInContainer<Node, ContainerNode>(*this); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode* oldParent) | 88 void ContainerNode::parserTakeAllChildrenFrom(ContainerNode* oldParent) |
| 89 { | 89 { |
| 90 while (RefPtr<Node> child = oldParent->firstChild()) { | 90 while (RefPtr<Node> child = oldParent->firstChild()) { |
| 91 oldParent->parserRemoveChild(*child); | 91 oldParent->parserRemoveChild(*child); |
| 92 treeScope().adoptIfNeeded(child.get()); | 92 treeScope().adoptIfNeeded(*child); |
| 93 parserAppendChild(child.get()); | 93 parserAppendChild(child.get()); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 ContainerNode::~ContainerNode() | 97 ContainerNode::~ContainerNode() |
| 98 { | 98 { |
| 99 willBeDeletedFromDocument(); | 99 willBeDeletedFromDocument(); |
| 100 removeDetachedChildren(); | 100 removeDetachedChildren(); |
| 101 } | 101 } |
| 102 | 102 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 // Due to arbitrary code running in response to a DOM mutation event it'
s | 242 // Due to arbitrary code running in response to a DOM mutation event it'
s |
| 243 // possible that "next" is no longer a child of "this". | 243 // possible that "next" is no longer a child of "this". |
| 244 // It's also possible that "child" has been inserted elsewhere. | 244 // It's also possible that "child" has been inserted elsewhere. |
| 245 // In either of those cases, we'll just stop. | 245 // In either of those cases, we'll just stop. |
| 246 if (next->parentNode() != this) | 246 if (next->parentNode() != this) |
| 247 break; | 247 break; |
| 248 if (child.parentNode()) | 248 if (child.parentNode()) |
| 249 break; | 249 break; |
| 250 | 250 |
| 251 treeScope().adoptIfNeeded(&child); | 251 treeScope().adoptIfNeeded(child); |
| 252 | 252 |
| 253 insertBeforeCommon(*next, child); | 253 insertBeforeCommon(*next, child); |
| 254 | 254 |
| 255 updateTreeAfterInsertion(*this, child); | 255 updateTreeAfterInsertion(*this, child); |
| 256 } | 256 } |
| 257 | 257 |
| 258 dispatchSubtreeModifiedEvent(); | 258 dispatchSubtreeModifiedEvent(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) | 261 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 // Due to arbitrary code running in response to a DOM mutation event it'
s | 370 // Due to arbitrary code running in response to a DOM mutation event it'
s |
| 371 // possible that "next" is no longer a child of "this". | 371 // possible that "next" is no longer a child of "this". |
| 372 // It's also possible that "child" has been inserted elsewhere. | 372 // It's also possible that "child" has been inserted elsewhere. |
| 373 // In either of those cases, we'll just stop. | 373 // In either of those cases, we'll just stop. |
| 374 if (next && next->parentNode() != this) | 374 if (next && next->parentNode() != this) |
| 375 break; | 375 break; |
| 376 if (child.parentNode()) | 376 if (child.parentNode()) |
| 377 break; | 377 break; |
| 378 | 378 |
| 379 treeScope().adoptIfNeeded(&child); | 379 treeScope().adoptIfNeeded(child); |
| 380 | 380 |
| 381 // Add child before "next". | 381 // Add child before "next". |
| 382 { | 382 { |
| 383 NoEventDispatchAssertion assertNoEventDispatch; | 383 NoEventDispatchAssertion assertNoEventDispatch; |
| 384 if (next) | 384 if (next) |
| 385 insertBeforeCommon(*next, child); | 385 insertBeforeCommon(*next, child); |
| 386 else | 386 else |
| 387 appendChildToContainer(child, *this); | 387 appendChildToContainer(child, *this); |
| 388 } | 388 } |
| 389 | 389 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 previousChild->setNextSibling(nextChild); | 490 previousChild->setNextSibling(nextChild); |
| 491 if (m_firstChild == oldChild) | 491 if (m_firstChild == oldChild) |
| 492 m_firstChild = nextChild; | 492 m_firstChild = nextChild; |
| 493 if (m_lastChild == oldChild) | 493 if (m_lastChild == oldChild) |
| 494 m_lastChild = previousChild; | 494 m_lastChild = previousChild; |
| 495 | 495 |
| 496 oldChild.setPreviousSibling(0); | 496 oldChild.setPreviousSibling(0); |
| 497 oldChild.setNextSibling(0); | 497 oldChild.setNextSibling(0); |
| 498 oldChild.setParentOrShadowHostNode(0); | 498 oldChild.setParentOrShadowHostNode(0); |
| 499 | 499 |
| 500 document().adoptIfNeeded(&oldChild); | 500 document().adoptIfNeeded(oldChild); |
| 501 } | 501 } |
| 502 | 502 |
| 503 void ContainerNode::parserRemoveChild(Node& oldChild) | 503 void ContainerNode::parserRemoveChild(Node& oldChild) |
| 504 { | 504 { |
| 505 ASSERT(oldChild.parentNode() == this); | 505 ASSERT(oldChild.parentNode() == this); |
| 506 ASSERT(!oldChild.isDocumentFragment()); | 506 ASSERT(!oldChild.isDocumentFragment()); |
| 507 | 507 |
| 508 Node* prev = oldChild.previousSibling(); | 508 Node* prev = oldChild.previousSibling(); |
| 509 Node* next = oldChild.nextSibling(); | 509 Node* next = oldChild.nextSibling(); |
| 510 | 510 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { | 605 for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); +
+it) { |
| 606 ASSERT(*it); | 606 ASSERT(*it); |
| 607 Node& child = **it; | 607 Node& child = **it; |
| 608 | 608 |
| 609 // If the child has a parent again, just stop what we're doing, because | 609 // If the child has a parent again, just stop what we're doing, because |
| 610 // that means someone is doing something with DOM mutation -- can't re-p
arent | 610 // that means someone is doing something with DOM mutation -- can't re-p
arent |
| 611 // a child that already has a parent. | 611 // a child that already has a parent. |
| 612 if (child.parentNode()) | 612 if (child.parentNode()) |
| 613 break; | 613 break; |
| 614 | 614 |
| 615 treeScope().adoptIfNeeded(&child); | 615 treeScope().adoptIfNeeded(child); |
| 616 | 616 |
| 617 // Append child to the end of the list | 617 // Append child to the end of the list |
| 618 { | 618 { |
| 619 NoEventDispatchAssertion assertNoEventDispatch; | 619 NoEventDispatchAssertion assertNoEventDispatch; |
| 620 appendChildToContainer(child, *this); | 620 appendChildToContainer(child, *this); |
| 621 } | 621 } |
| 622 | 622 |
| 623 updateTreeAfterInsertion(*this, child); | 623 updateTreeAfterInsertion(*this, child); |
| 624 } | 624 } |
| 625 | 625 |
| 626 dispatchSubtreeModifiedEvent(); | 626 dispatchSubtreeModifiedEvent(); |
| 627 } | 627 } |
| 628 | 628 |
| 629 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) | 629 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) |
| 630 { | 630 { |
| 631 ASSERT(newChild); | 631 ASSERT(newChild); |
| 632 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). | 632 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). |
| 633 ASSERT(!newChild->isDocumentFragment()); | 633 ASSERT(!newChild->isDocumentFragment()); |
| 634 ASSERT(!hasTagName(HTMLNames::templateTag)); | 634 ASSERT(!hasTagName(HTMLNames::templateTag)); |
| 635 | 635 |
| 636 if (document() != newChild->document()) | 636 if (document() != newChild->document()) |
| 637 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 637 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
| 638 | 638 |
| 639 Node* last = m_lastChild; | 639 Node* last = m_lastChild; |
| 640 { | 640 { |
| 641 NoEventDispatchAssertion assertNoEventDispatch; | 641 NoEventDispatchAssertion assertNoEventDispatch; |
| 642 // FIXME: This method should take a PassRefPtr. | 642 // FIXME: This method should take a PassRefPtr. |
| 643 appendChildToContainer(*newChild, *this); | 643 appendChildToContainer(*newChild, *this); |
| 644 treeScope().adoptIfNeeded(newChild.get()); | 644 treeScope().adoptIfNeeded(*newChild); |
| 645 } | 645 } |
| 646 | 646 |
| 647 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 647 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
| 648 | 648 |
| 649 ChildListMutationScope(this).childAdded(newChild.get()); | 649 ChildListMutationScope(this).childAdded(newChild.get()); |
| 650 | 650 |
| 651 childrenChanged(true, last, 0, 1); | 651 childrenChanged(true, last, 0, 1); |
| 652 ChildNodeInsertionNotifier(*this).notify(*newChild); | 652 ChildNodeInsertionNotifier(*this).notify(*newChild); |
| 653 } | 653 } |
| 654 | 654 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 return true; | 988 return true; |
| 989 | 989 |
| 990 if (node->isElementNode() && toElement(node)->shadow()) | 990 if (node->isElementNode() && toElement(node)->shadow()) |
| 991 return true; | 991 return true; |
| 992 | 992 |
| 993 return false; | 993 return false; |
| 994 } | 994 } |
| 995 #endif | 995 #endif |
| 996 | 996 |
| 997 } // namespace WebCore | 997 } // namespace WebCore |
| OLD | NEW |