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, 2013 Apple Inc. All rights
reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights
reserved. |
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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 if (tail) | 525 if (tail) |
526 tail->setNextSibling(n); | 526 tail->setNextSibling(n); |
527 else | 527 else |
528 head = n; | 528 head = n; |
529 | 529 |
530 tail = n; | 530 tail = n; |
531 } else { | 531 } else { |
532 RefPtrWillBeRawPtr<Node> protect(n); // removedFromDocument may remo
ve all references to this node. | 532 RefPtrWillBeRawPtr<Node> protect(n); // removedFromDocument may remo
ve all references to this node. |
533 container.document().adoptIfNeeded(*n); | 533 container.document().adoptIfNeeded(*n); |
534 if (n->inDocument()) | 534 if (n->inDocument()) |
535 container.notifyNodeRemoved(*n, next); | 535 container.notifyNodeRemoved(*n); |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 container.setLastChild(nullptr); | 539 container.setLastChild(nullptr); |
540 } | 540 } |
541 #endif | 541 #endif |
542 | 542 |
543 DEFINE_TRACE(ContainerNode) | 543 DEFINE_TRACE(ContainerNode) |
544 { | 544 { |
545 visitor->trace(m_firstChild); | 545 visitor->trace(m_firstChild); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 exceptionState.throwDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in response to a mutatio
n?"); | 584 exceptionState.throwDOMException(NotFoundError, "The node to be removed
is no longer a child of this node. Perhaps it was moved in response to a mutatio
n?"); |
585 return nullptr; | 585 return nullptr; |
586 } | 586 } |
587 | 587 |
588 { | 588 { |
589 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 589 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
590 | 590 |
591 Node* prev = child->previousSibling(); | 591 Node* prev = child->previousSibling(); |
592 Node* next = child->nextSibling(); | 592 Node* next = child->nextSibling(); |
593 removeBetween(prev, next, *child); | 593 removeBetween(prev, next, *child); |
594 notifyNodeRemoved(*child, next); | 594 notifyNodeRemoved(*child); |
595 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC
hangeSourceAPI)); | 595 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC
hangeSourceAPI)); |
596 } | 596 } |
597 dispatchSubtreeModifiedEvent(); | 597 dispatchSubtreeModifiedEvent(); |
598 return child; | 598 return child; |
599 } | 599 } |
600 | 600 |
601 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol
dChild) | 601 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol
dChild) |
602 { | 602 { |
603 EventDispatchForbiddenScope assertNoEventDispatch; | 603 EventDispatchForbiddenScope assertNoEventDispatch; |
604 | 604 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 return; | 636 return; |
637 | 637 |
638 ChildListMutationScope(*this).willRemoveChild(oldChild); | 638 ChildListMutationScope(*this).willRemoveChild(oldChild); |
639 oldChild.notifyMutationObserversNodeWillDetach(); | 639 oldChild.notifyMutationObserversNodeWillDetach(); |
640 | 640 |
641 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 641 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
642 Node* prev = oldChild.previousSibling(); | 642 Node* prev = oldChild.previousSibling(); |
643 Node* next = oldChild.nextSibling(); | 643 Node* next = oldChild.nextSibling(); |
644 removeBetween(prev, next, oldChild); | 644 removeBetween(prev, next, oldChild); |
645 | 645 |
646 notifyNodeRemoved(oldChild, next); | 646 notifyNodeRemoved(oldChild); |
647 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha
ngeSourceParser)); | 647 childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenCha
ngeSourceParser)); |
648 } | 648 } |
649 | 649 |
650 // This differs from other remove functions because it forcibly removes all the
children, | 650 // This differs from other remove functions because it forcibly removes all the
children, |
651 // regardless of read-only status or event exceptions, e.g. | 651 // regardless of read-only status or event exceptions, e.g. |
652 void ContainerNode::removeChildren(SubtreeModificationAction action) | 652 void ContainerNode::removeChildren(SubtreeModificationAction action) |
653 { | 653 { |
654 if (!m_firstChild) | 654 if (!m_firstChild) |
655 return; | 655 return; |
656 | 656 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 688 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
689 | 689 |
690 { | 690 { |
691 EventDispatchForbiddenScope assertNoEventDispatch; | 691 EventDispatchForbiddenScope assertNoEventDispatch; |
692 ScriptForbiddenScope forbidScript; | 692 ScriptForbiddenScope forbidScript; |
693 | 693 |
694 #if !ENABLE(OILPAN) | 694 #if !ENABLE(OILPAN) |
695 removedChildren.reserveInitialCapacity(countChildren()); | 695 removedChildren.reserveInitialCapacity(countChildren()); |
696 #endif | 696 #endif |
697 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) { | 697 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) { |
698 Node* next = child->nextSibling(); | 698 removeBetween(0, child->nextSibling(), *child); |
699 removeBetween(nullptr, next, *child); | |
700 #if !ENABLE(OILPAN) | 699 #if !ENABLE(OILPAN) |
701 removedChildren.append(child.get()); | 700 removedChildren.append(child.get()); |
702 #endif | 701 #endif |
703 notifyNodeRemoved(*child, next); | 702 notifyNodeRemoved(*child); |
704 } | 703 } |
705 } | 704 } |
706 | 705 |
707 ChildrenChange change = {AllChildrenRemoved, nullptr, nullptr, ChildrenC
hangeSourceAPI}; | 706 ChildrenChange change = {AllChildrenRemoved, nullptr, nullptr, ChildrenC
hangeSourceAPI}; |
708 childrenChanged(change); | 707 childrenChanged(change); |
709 } | 708 } |
710 | 709 |
711 if (action == DispatchSubtreeModifiedEvent) | 710 if (action == DispatchSubtreeModifiedEvent) |
712 dispatchSubtreeModifiedEvent(); | 711 dispatchSubtreeModifiedEvent(); |
713 } | 712 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 // into detached subtrees that are not in a shadow tree. | 840 // into detached subtrees that are not in a shadow tree. |
842 if (!inDocument() && !isInShadowTree() && !node.isContainerNode()) | 841 if (!inDocument() && !isInShadowTree() && !node.isContainerNode()) |
843 continue; | 842 continue; |
844 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted
Into(this)) | 843 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted
Into(this)) |
845 postInsertionNotificationTargets.append(&node); | 844 postInsertionNotificationTargets.append(&node); |
846 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) | 845 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) |
847 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); | 846 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); |
848 } | 847 } |
849 } | 848 } |
850 | 849 |
851 void ContainerNode::notifyNodeRemoved(Node& root, Node* next) | 850 void ContainerNode::notifyNodeRemoved(Node& root) |
852 { | 851 { |
853 ScriptForbiddenScope forbidScript; | 852 ScriptForbiddenScope forbidScript; |
854 EventDispatchForbiddenScope assertNoEventDispatch; | 853 EventDispatchForbiddenScope assertNoEventDispatch; |
855 | 854 |
856 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { | 855 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { |
857 // As an optimization we skip notifying Text nodes and other leaf nodes | 856 // As an optimization we skip notifying Text nodes and other leaf nodes |
858 // of removal when they're not in the Document tree and not in a shadow
root since the virtual | 857 // of removal when they're not in the Document tree and not in a shadow
root since the virtual |
859 // call to removedFrom is not needed. | 858 // call to removedFrom is not needed. |
860 if (!node.isContainerNode() && !node.isInTreeScope()) | 859 if (!node.isContainerNode() && !node.isInTreeScope()) |
861 continue; | 860 continue; |
862 node.removedFrom(this, node == root ? next : node.nextSibling()); | 861 node.removedFrom(this); |
863 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) | 862 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) |
864 notifyNodeRemoved(*shadowRoot, next); | 863 notifyNodeRemoved(*shadowRoot); |
865 } | 864 } |
866 } | 865 } |
867 | 866 |
868 void ContainerNode::attach(const AttachContext& context) | 867 void ContainerNode::attach(const AttachContext& context) |
869 { | 868 { |
870 attachChildren(context); | 869 attachChildren(context); |
871 clearChildNeedsStyleRecalc(); | 870 clearChildNeedsStyleRecalc(); |
872 Node::attach(context); | 871 Node::attach(context); |
873 } | 872 } |
874 | 873 |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 return true; | 1528 return true; |
1530 | 1529 |
1531 if (node->isElementNode() && toElement(node)->shadow()) | 1530 if (node->isElementNode() && toElement(node)->shadow()) |
1532 return true; | 1531 return true; |
1533 | 1532 |
1534 return false; | 1533 return false; |
1535 } | 1534 } |
1536 #endif | 1535 #endif |
1537 | 1536 |
1538 } // namespace blink | 1537 } // namespace blink |
OLD | NEW |