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 13 matching lines...) Expand all Loading... |
24 #include "core/dom/ContainerNode.h" | 24 #include "core/dom/ContainerNode.h" |
25 | 25 |
26 #include "bindings/core/v8/ExceptionState.h" | 26 #include "bindings/core/v8/ExceptionState.h" |
27 #include "core/dom/ChildFrameDisconnector.h" | 27 #include "core/dom/ChildFrameDisconnector.h" |
28 #include "core/dom/ChildListMutationScope.h" | 28 #include "core/dom/ChildListMutationScope.h" |
29 #include "core/dom/ClassCollection.h" | 29 #include "core/dom/ClassCollection.h" |
30 #include "core/dom/ElementTraversal.h" | 30 #include "core/dom/ElementTraversal.h" |
31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
32 #include "core/dom/FullscreenElementStack.h" | 32 #include "core/dom/FullscreenElementStack.h" |
33 #include "core/dom/NameNodeList.h" | 33 #include "core/dom/NameNodeList.h" |
34 #include "core/dom/NoEventDispatchAssertion.h" | |
35 #include "core/dom/NodeChildRemovalTracker.h" | 34 #include "core/dom/NodeChildRemovalTracker.h" |
36 #include "core/dom/NodeRareData.h" | 35 #include "core/dom/NodeRareData.h" |
37 #include "core/dom/NodeRenderStyle.h" | 36 #include "core/dom/NodeRenderStyle.h" |
38 #include "core/dom/NodeTraversal.h" | 37 #include "core/dom/NodeTraversal.h" |
39 #include "core/dom/SelectorQuery.h" | 38 #include "core/dom/SelectorQuery.h" |
40 #include "core/dom/StaticNodeList.h" | 39 #include "core/dom/StaticNodeList.h" |
41 #include "core/dom/StyleEngine.h" | 40 #include "core/dom/StyleEngine.h" |
42 #include "core/dom/shadow/ElementShadow.h" | 41 #include "core/dom/shadow/ElementShadow.h" |
43 #include "core/dom/shadow/ShadowRoot.h" | 42 #include "core/dom/shadow/ShadowRoot.h" |
44 #include "core/events/MutationEvent.h" | 43 #include "core/events/MutationEvent.h" |
45 #include "core/html/HTMLCollection.h" | 44 #include "core/html/HTMLCollection.h" |
46 #include "core/html/HTMLFrameOwnerElement.h" | 45 #include "core/html/HTMLFrameOwnerElement.h" |
47 #include "core/html/HTMLTagCollection.h" | 46 #include "core/html/HTMLTagCollection.h" |
48 #include "core/html/RadioNodeList.h" | 47 #include "core/html/RadioNodeList.h" |
49 #include "core/inspector/InspectorInstrumentation.h" | 48 #include "core/inspector/InspectorInstrumentation.h" |
50 #include "core/rendering/InlineTextBox.h" | 49 #include "core/rendering/InlineTextBox.h" |
51 #include "core/rendering/RenderText.h" | 50 #include "core/rendering/RenderText.h" |
52 #include "core/rendering/RenderTheme.h" | 51 #include "core/rendering/RenderTheme.h" |
53 #include "core/rendering/RenderView.h" | 52 #include "core/rendering/RenderView.h" |
| 53 #include "platform/EventDispatchForbiddenScope.h" |
54 #include "platform/ScriptForbiddenScope.h" | 54 #include "platform/ScriptForbiddenScope.h" |
55 | 55 |
56 namespace blink { | 56 namespace blink { |
57 | 57 |
58 using namespace HTMLNames; | 58 using namespace HTMLNames; |
59 | 59 |
60 static void dispatchChildInsertionEvents(Node&); | 60 static void dispatchChildInsertionEvents(Node&); |
61 static void dispatchChildRemovalEvents(Node&); | 61 static void dispatchChildRemovalEvents(Node&); |
62 | 62 |
63 #if ENABLE(ASSERT) | 63 #if ENABLE(ASSERT) |
64 unsigned NoEventDispatchAssertion::s_count = 0; | 64 unsigned EventDispatchForbiddenScope::s_count = 0; |
65 #endif | 65 #endif |
66 | 66 |
67 static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes,
ExceptionState& exceptionState) | 67 static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes,
ExceptionState& exceptionState) |
68 { | 68 { |
69 if (node.isDocumentFragment()) { | 69 if (node.isDocumentFragment()) { |
70 DocumentFragment& fragment = toDocumentFragment(node); | 70 DocumentFragment& fragment = toDocumentFragment(node); |
71 getChildNodes(fragment, nodes); | 71 getChildNodes(fragment, nodes); |
72 fragment.removeChildren(); | 72 fragment.removeChildren(); |
73 return; | 73 return; |
74 } | 74 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 updateTreeAfterInsertion(child); | 249 updateTreeAfterInsertion(child); |
250 } | 250 } |
251 | 251 |
252 dispatchSubtreeModifiedEvent(); | 252 dispatchSubtreeModifiedEvent(); |
253 | 253 |
254 return newChild; | 254 return newChild; |
255 } | 255 } |
256 | 256 |
257 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) | 257 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild) |
258 { | 258 { |
259 NoEventDispatchAssertion assertNoEventDispatch; | 259 EventDispatchForbiddenScope assertNoEventDispatch; |
260 ScriptForbiddenScope forbidScript; | 260 ScriptForbiddenScope forbidScript; |
261 | 261 |
262 ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle re
parenting (and want DOM mutation events). | 262 ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle re
parenting (and want DOM mutation events). |
263 ASSERT(!newChild.nextSibling()); | 263 ASSERT(!newChild.nextSibling()); |
264 ASSERT(!newChild.previousSibling()); | 264 ASSERT(!newChild.previousSibling()); |
265 ASSERT(!newChild.isShadowRoot()); | 265 ASSERT(!newChild.isShadowRoot()); |
266 | 266 |
267 Node* prev = nextChild.previousSibling(); | 267 Node* prev = nextChild.previousSibling(); |
268 ASSERT(m_lastChild != prev); | 268 ASSERT(m_lastChild != prev); |
269 nextChild.setPreviousSibling(&newChild); | 269 nextChild.setPreviousSibling(&newChild); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // In either of those cases, we'll just stop. | 395 // In either of those cases, we'll just stop. |
396 if (next && next->parentNode() != this) | 396 if (next && next->parentNode() != this) |
397 break; | 397 break; |
398 if (child.parentNode()) | 398 if (child.parentNode()) |
399 break; | 399 break; |
400 | 400 |
401 treeScope().adoptIfNeeded(child); | 401 treeScope().adoptIfNeeded(child); |
402 | 402 |
403 // Add child before "next". | 403 // Add child before "next". |
404 { | 404 { |
405 NoEventDispatchAssertion assertNoEventDispatch; | 405 EventDispatchForbiddenScope assertNoEventDispatch; |
406 if (next) | 406 if (next) |
407 insertBeforeCommon(*next, child); | 407 insertBeforeCommon(*next, child); |
408 else | 408 else |
409 appendChildCommon(child); | 409 appendChildCommon(child); |
410 } | 410 } |
411 | 411 |
412 updateTreeAfterInsertion(child); | 412 updateTreeAfterInsertion(child); |
413 } | 413 } |
414 | 414 |
415 dispatchSubtreeModifiedEvent(); | 415 dispatchSubtreeModifiedEvent(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 removeBetween(prev, next, *child); | 570 removeBetween(prev, next, *child); |
571 notifyNodeRemoved(*child); | 571 notifyNodeRemoved(*child); |
572 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC
hangeSourceAPI)); | 572 childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenC
hangeSourceAPI)); |
573 } | 573 } |
574 dispatchSubtreeModifiedEvent(); | 574 dispatchSubtreeModifiedEvent(); |
575 return child; | 575 return child; |
576 } | 576 } |
577 | 577 |
578 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol
dChild) | 578 void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol
dChild) |
579 { | 579 { |
580 NoEventDispatchAssertion assertNoEventDispatch; | 580 EventDispatchForbiddenScope assertNoEventDispatch; |
581 | 581 |
582 ASSERT(oldChild.parentNode() == this); | 582 ASSERT(oldChild.parentNode() == this); |
583 | 583 |
584 if (!oldChild.needsAttach()) | 584 if (!oldChild.needsAttach()) |
585 oldChild.detach(); | 585 oldChild.detach(); |
586 | 586 |
587 if (nextChild) | 587 if (nextChild) |
588 nextChild->setPreviousSibling(previousChild); | 588 nextChild->setPreviousSibling(previousChild); |
589 if (previousChild) | 589 if (previousChild) |
590 previousChild->setNextSibling(nextChild); | 590 previousChild->setNextSibling(nextChild); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 // FIXME: Remove this NodeVector. Right now WebPluginContainerImpl::m_elemen
t is a | 654 // FIXME: Remove this NodeVector. Right now WebPluginContainerImpl::m_elemen
t is a |
655 // raw ptr which means the code below can drop the last ref to a plugin elem
ent and | 655 // raw ptr which means the code below can drop the last ref to a plugin elem
ent and |
656 // then the code in UpdateSuspendScope::performDeferredWidgetTreeOperations
will | 656 // then the code in UpdateSuspendScope::performDeferredWidgetTreeOperations
will |
657 // try to destroy the plugin which will be a use-after-free. We should use a
RefPtr | 657 // try to destroy the plugin which will be a use-after-free. We should use a
RefPtr |
658 // in the WebPluginContainerImpl instead. | 658 // in the WebPluginContainerImpl instead. |
659 NodeVector removedChildren; | 659 NodeVector removedChildren; |
660 { | 660 { |
661 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; | 661 HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates; |
662 | 662 |
663 { | 663 { |
664 NoEventDispatchAssertion assertNoEventDispatch; | 664 EventDispatchForbiddenScope assertNoEventDispatch; |
665 ScriptForbiddenScope forbidScript; | 665 ScriptForbiddenScope forbidScript; |
666 | 666 |
667 removedChildren.reserveInitialCapacity(countChildren()); | 667 removedChildren.reserveInitialCapacity(countChildren()); |
668 | 668 |
669 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) { | 669 while (RefPtrWillBeRawPtr<Node> child = m_firstChild) { |
670 removeBetween(0, child->nextSibling(), *child); | 670 removeBetween(0, child->nextSibling(), *child); |
671 removedChildren.append(child.get()); | 671 removedChildren.append(child.get()); |
672 notifyNodeRemoved(*child); | 672 notifyNodeRemoved(*child); |
673 } | 673 } |
674 } | 674 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 ASSERT(*it); | 724 ASSERT(*it); |
725 Node& child = **it; | 725 Node& child = **it; |
726 | 726 |
727 // If the child has a parent again, just stop what we're doing, because | 727 // If the child has a parent again, just stop what we're doing, because |
728 // that means someone is doing something with DOM mutation -- can't re-p
arent | 728 // that means someone is doing something with DOM mutation -- can't re-p
arent |
729 // a child that already has a parent. | 729 // a child that already has a parent. |
730 if (child.parentNode()) | 730 if (child.parentNode()) |
731 break; | 731 break; |
732 | 732 |
733 { | 733 { |
734 NoEventDispatchAssertion assertNoEventDispatch; | 734 EventDispatchForbiddenScope assertNoEventDispatch; |
735 ScriptForbiddenScope forbidScript; | 735 ScriptForbiddenScope forbidScript; |
736 | 736 |
737 treeScope().adoptIfNeeded(child); | 737 treeScope().adoptIfNeeded(child); |
738 appendChildCommon(child); | 738 appendChildCommon(child); |
739 } | 739 } |
740 | 740 |
741 updateTreeAfterInsertion(child); | 741 updateTreeAfterInsertion(child); |
742 } | 742 } |
743 | 743 |
744 dispatchSubtreeModifiedEvent(); | 744 dispatchSubtreeModifiedEvent(); |
745 return newChild; | 745 return newChild; |
746 } | 746 } |
747 | 747 |
748 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) | 748 void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild) |
749 { | 749 { |
750 ASSERT(newChild); | 750 ASSERT(newChild); |
751 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). | 751 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re
parenting (and want DOM mutation events). |
752 ASSERT(!newChild->isDocumentFragment()); | 752 ASSERT(!newChild->isDocumentFragment()); |
753 ASSERT(!isHTMLTemplateElement(this)); | 753 ASSERT(!isHTMLTemplateElement(this)); |
754 | 754 |
755 RefPtrWillBeRawPtr<Node> protect(this); | 755 RefPtrWillBeRawPtr<Node> protect(this); |
756 | 756 |
757 if (document() != newChild->document()) | 757 if (document() != newChild->document()) |
758 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); | 758 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); |
759 | 759 |
760 { | 760 { |
761 NoEventDispatchAssertion assertNoEventDispatch; | 761 EventDispatchForbiddenScope assertNoEventDispatch; |
762 ScriptForbiddenScope forbidScript; | 762 ScriptForbiddenScope forbidScript; |
763 | 763 |
764 treeScope().adoptIfNeeded(*newChild); | 764 treeScope().adoptIfNeeded(*newChild); |
765 appendChildCommon(*newChild); | 765 appendChildCommon(*newChild); |
766 newChild->updateAncestorConnectedSubframeCountForInsertion(); | 766 newChild->updateAncestorConnectedSubframeCountForInsertion(); |
767 ChildListMutationScope(*this).childAdded(*newChild); | 767 ChildListMutationScope(*this).childAdded(*newChild); |
768 } | 768 } |
769 | 769 |
770 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); | 770 notifyNodeInserted(*newChild, ChildrenChangeSourceParser); |
771 } | 771 } |
772 | 772 |
773 void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source) | 773 void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source) |
774 { | 774 { |
775 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 775 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
776 ASSERT(!root.isShadowRoot()); | 776 ASSERT(!root.isShadowRoot()); |
777 | 777 |
778 InspectorInstrumentation::didInsertDOMNode(&root); | 778 InspectorInstrumentation::didInsertDOMNode(&root); |
779 | 779 |
780 RefPtrWillBeRawPtr<Node> protect(this); | 780 RefPtrWillBeRawPtr<Node> protect(this); |
781 RefPtrWillBeRawPtr<Node> protectNode(root); | 781 RefPtrWillBeRawPtr<Node> protectNode(root); |
782 | 782 |
783 NodeVector postInsertionNotificationTargets; | 783 NodeVector postInsertionNotificationTargets; |
784 notifyNodeInsertedInternal(root, postInsertionNotificationTargets); | 784 notifyNodeInsertedInternal(root, postInsertionNotificationTargets); |
785 | 785 |
786 childrenChanged(ChildrenChange::forInsertion(root, source)); | 786 childrenChanged(ChildrenChange::forInsertion(root, source)); |
787 | 787 |
788 for (size_t i = 0; i < postInsertionNotificationTargets.size(); ++i) { | 788 for (size_t i = 0; i < postInsertionNotificationTargets.size(); ++i) { |
789 Node* targetNode = postInsertionNotificationTargets[i].get(); | 789 Node* targetNode = postInsertionNotificationTargets[i].get(); |
790 if (targetNode->inDocument()) | 790 if (targetNode->inDocument()) |
791 targetNode->didNotifySubtreeInsertionsToDocument(); | 791 targetNode->didNotifySubtreeInsertionsToDocument(); |
792 } | 792 } |
793 } | 793 } |
794 | 794 |
795 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
tionNotificationTargets) | 795 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
tionNotificationTargets) |
796 { | 796 { |
797 NoEventDispatchAssertion assertNoEventDispatch; | 797 EventDispatchForbiddenScope assertNoEventDispatch; |
798 ScriptForbiddenScope forbidScript; | 798 ScriptForbiddenScope forbidScript; |
799 | 799 |
800 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { | 800 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { |
801 // As an optimization we don't notify leaf nodes when when inserting | 801 // As an optimization we don't notify leaf nodes when when inserting |
802 // into detached subtrees. | 802 // into detached subtrees. |
803 if (!inDocument() && !node->isContainerNode()) | 803 if (!inDocument() && !node->isContainerNode()) |
804 continue; | 804 continue; |
805 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node->inserte
dInto(this)) | 805 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node->inserte
dInto(this)) |
806 postInsertionNotificationTargets.append(node); | 806 postInsertionNotificationTargets.append(node); |
807 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; sh
adowRoot = shadowRoot->olderShadowRoot()) | 807 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; sh
adowRoot = shadowRoot->olderShadowRoot()) |
808 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); | 808 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 void ContainerNode::notifyNodeRemoved(Node& root) | 812 void ContainerNode::notifyNodeRemoved(Node& root) |
813 { | 813 { |
814 ScriptForbiddenScope forbidScript; | 814 ScriptForbiddenScope forbidScript; |
815 NoEventDispatchAssertion assertNoEventDispatch; | 815 EventDispatchForbiddenScope assertNoEventDispatch; |
816 | 816 |
817 Document& document = root.document(); | 817 Document& document = root.document(); |
818 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { | 818 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) { |
819 // As an optimization we skip notifying Text nodes and other leaf nodes | 819 // As an optimization we skip notifying Text nodes and other leaf nodes |
820 // of removal when they're not in the Document tree since the virtual | 820 // of removal when they're not in the Document tree since the virtual |
821 // call to removedFrom is not needed. | 821 // call to removedFrom is not needed. |
822 if (!node->inDocument() && !node->isContainerNode()) | 822 if (!node->inDocument() && !node->isContainerNode()) |
823 continue; | 823 continue; |
824 if (document.cssTarget() == node) | 824 if (document.cssTarget() == node) |
825 document.setCSSTarget(nullptr); | 825 document.setCSSTarget(nullptr); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 return nullptr; | 1128 return nullptr; |
1129 | 1129 |
1130 return selectorQuery->queryAll(*this); | 1130 return selectorQuery->queryAll(*this); |
1131 } | 1131 } |
1132 | 1132 |
1133 static void dispatchChildInsertionEvents(Node& child) | 1133 static void dispatchChildInsertionEvents(Node& child) |
1134 { | 1134 { |
1135 if (child.isInShadowTree()) | 1135 if (child.isInShadowTree()) |
1136 return; | 1136 return; |
1137 | 1137 |
1138 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 1138 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
1139 | 1139 |
1140 RefPtrWillBeRawPtr<Node> c(child); | 1140 RefPtrWillBeRawPtr<Node> c(child); |
1141 RefPtrWillBeRawPtr<Document> document(child.document()); | 1141 RefPtrWillBeRawPtr<Document> document(child.document()); |
1142 | 1142 |
1143 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L
ISTENER)) | 1143 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L
ISTENER)) |
1144 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse
rted, true, c->parentNode())); | 1144 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse
rted, true, c->parentNode())); |
1145 | 1145 |
1146 // dispatch the DOMNodeInsertedIntoDocument event to all descendants | 1146 // dispatch the DOMNodeInsertedIntoDocument event to all descendants |
1147 if (c->inDocument() && document->hasListenerType(Document::DOMNODEINSERTEDIN
TODOCUMENT_LISTENER)) { | 1147 if (c->inDocument() && document->hasListenerType(Document::DOMNODEINSERTEDIN
TODOCUMENT_LISTENER)) { |
1148 for (; c; c = NodeTraversal::next(*c, &child)) | 1148 for (; c; c = NodeTraversal::next(*c, &child)) |
1149 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
InsertedIntoDocument, false)); | 1149 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
InsertedIntoDocument, false)); |
1150 } | 1150 } |
1151 } | 1151 } |
1152 | 1152 |
1153 static void dispatchChildRemovalEvents(Node& child) | 1153 static void dispatchChildRemovalEvents(Node& child) |
1154 { | 1154 { |
1155 if (child.isInShadowTree()) { | 1155 if (child.isInShadowTree()) { |
1156 InspectorInstrumentation::willRemoveDOMNode(&child); | 1156 InspectorInstrumentation::willRemoveDOMNode(&child); |
1157 return; | 1157 return; |
1158 } | 1158 } |
1159 | 1159 |
1160 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); | 1160 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
1161 | 1161 |
1162 InspectorInstrumentation::willRemoveDOMNode(&child); | 1162 InspectorInstrumentation::willRemoveDOMNode(&child); |
1163 | 1163 |
1164 RefPtrWillBeRawPtr<Node> c(child); | 1164 RefPtrWillBeRawPtr<Node> c(child); |
1165 RefPtrWillBeRawPtr<Document> document(child.document()); | 1165 RefPtrWillBeRawPtr<Document> document(child.document()); |
1166 | 1166 |
1167 // dispatch pre-removal mutation events | 1167 // dispatch pre-removal mutation events |
1168 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI
STENER)) { | 1168 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI
STENER)) { |
1169 NodeChildRemovalTracker scope(child); | 1169 NodeChildRemovalTracker scope(child); |
1170 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo
ved, true, c->parentNode())); | 1170 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo
ved, true, c->parentNode())); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 return true; | 1413 return true; |
1414 | 1414 |
1415 if (node->isElementNode() && toElement(node)->shadow()) | 1415 if (node->isElementNode() && toElement(node)->shadow()) |
1416 return true; | 1416 return true; |
1417 | 1417 |
1418 return false; | 1418 return false; |
1419 } | 1419 } |
1420 #endif | 1420 #endif |
1421 | 1421 |
1422 } // namespace blink | 1422 } // namespace blink |
OLD | NEW |