| 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 root.checkSlotChangeAfterInserted(); | 696 root.checkSlotChangeAfterInserted(); |
| 697 | 697 |
| 698 InspectorInstrumentation::didInsertDOMNode(&root); | 698 InspectorInstrumentation::didInsertDOMNode(&root); |
| 699 | 699 |
| 700 NodeVector postInsertionNotificationTargets; | 700 NodeVector postInsertionNotificationTargets; |
| 701 notifyNodeInsertedInternal(root, postInsertionNotificationTargets); | 701 notifyNodeInsertedInternal(root, postInsertionNotificationTargets); |
| 702 | 702 |
| 703 childrenChanged(ChildrenChange::forInsertion(root, source)); | 703 childrenChanged(ChildrenChange::forInsertion(root, source)); |
| 704 | 704 |
| 705 for (const auto& targetNode : postInsertionNotificationTargets) { | 705 for (const auto& targetNode : postInsertionNotificationTargets) { |
| 706 if (targetNode->inShadowIncludingDocument()) | 706 if (targetNode->isConnected()) |
| 707 targetNode->didNotifySubtreeInsertionsToDocument(); | 707 targetNode->didNotifySubtreeInsertionsToDocument(); |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 | 710 |
| 711 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
tionNotificationTargets) | 711 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
tionNotificationTargets) |
| 712 { | 712 { |
| 713 EventDispatchForbiddenScope assertNoEventDispatch; | 713 EventDispatchForbiddenScope assertNoEventDispatch; |
| 714 ScriptForbiddenScope forbidScript; | 714 ScriptForbiddenScope forbidScript; |
| 715 | 715 |
| 716 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { | 716 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { |
| 717 // As an optimization we don't notify leaf nodes when when inserting | 717 // As an optimization we don't notify leaf nodes when when inserting |
| 718 // into detached subtrees that are not in a shadow tree. | 718 // into detached subtrees that are not in a shadow tree. |
| 719 if (!inShadowIncludingDocument() && !isInShadowTree() && !node.isContain
erNode()) | 719 if (!isConnected() && !isInShadowTree() && !node.isContainerNode()) |
| 720 continue; | 720 continue; |
| 721 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted
Into(this)) | 721 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted
Into(this)) |
| 722 postInsertionNotificationTargets.append(&node); | 722 postInsertionNotificationTargets.append(&node); |
| 723 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) | 723 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha
dowRoot = shadowRoot->olderShadowRoot()) |
| 724 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); | 724 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar
gets); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 | 727 |
| 728 void ContainerNode::notifyNodeRemoved(Node& root) | 728 void ContainerNode::notifyNodeRemoved(Node& root) |
| 729 { | 729 { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 1125 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 1126 #endif | 1126 #endif |
| 1127 | 1127 |
| 1128 Node* c = &child; | 1128 Node* c = &child; |
| 1129 Document* document = &child.document(); | 1129 Document* document = &child.document(); |
| 1130 | 1130 |
| 1131 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L
ISTENER)) | 1131 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L
ISTENER)) |
| 1132 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse
rted, true, c->parentNode())); | 1132 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse
rted, true, c->parentNode())); |
| 1133 | 1133 |
| 1134 // dispatch the DOMNodeInsertedIntoDocument event to all descendants | 1134 // dispatch the DOMNodeInsertedIntoDocument event to all descendants |
| 1135 if (c->inShadowIncludingDocument() && document->hasListenerType(Document::DO
MNODEINSERTEDINTODOCUMENT_LISTENER)) { | 1135 if (c->isConnected() && document->hasListenerType(Document::DOMNODEINSERTEDI
NTODOCUMENT_LISTENER)) { |
| 1136 for (; c; c = NodeTraversal::next(*c, &child)) | 1136 for (; c; c = NodeTraversal::next(*c, &child)) |
| 1137 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
InsertedIntoDocument, false)); | 1137 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
InsertedIntoDocument, false)); |
| 1138 } | 1138 } |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 static void dispatchChildRemovalEvents(Node& child) | 1141 static void dispatchChildRemovalEvents(Node& child) |
| 1142 { | 1142 { |
| 1143 if (child.isInShadowTree()) { | 1143 if (child.isInShadowTree()) { |
| 1144 InspectorInstrumentation::willRemoveDOMNode(&child); | 1144 InspectorInstrumentation::willRemoveDOMNode(&child); |
| 1145 return; | 1145 return; |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 #if DCHECK_IS_ON() | 1148 #if DCHECK_IS_ON() |
| 1149 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); | 1149 DCHECK(!EventDispatchForbiddenScope::isEventDispatchForbidden()); |
| 1150 #endif | 1150 #endif |
| 1151 | 1151 |
| 1152 InspectorInstrumentation::willRemoveDOMNode(&child); | 1152 InspectorInstrumentation::willRemoveDOMNode(&child); |
| 1153 | 1153 |
| 1154 Node* c = &child; | 1154 Node* c = &child; |
| 1155 Document* document = &child.document(); | 1155 Document* document = &child.document(); |
| 1156 | 1156 |
| 1157 // Dispatch pre-removal mutation events. | 1157 // Dispatch pre-removal mutation events. |
| 1158 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI
STENER)) { | 1158 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI
STENER)) { |
| 1159 NodeChildRemovalTracker scope(child); | 1159 NodeChildRemovalTracker scope(child); |
| 1160 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo
ved, true, c->parentNode())); | 1160 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo
ved, true, c->parentNode())); |
| 1161 } | 1161 } |
| 1162 | 1162 |
| 1163 // Dispatch the DOMNodeRemovedFromDocument event to all descendants. | 1163 // Dispatch the DOMNodeRemovedFromDocument event to all descendants. |
| 1164 if (c->inShadowIncludingDocument() && document->hasListenerType(Document::DO
MNODEREMOVEDFROMDOCUMENT_LISTENER)) { | 1164 if (c->isConnected() && document->hasListenerType(Document::DOMNODEREMOVEDFR
OMDOCUMENT_LISTENER)) { |
| 1165 NodeChildRemovalTracker scope(child); | 1165 NodeChildRemovalTracker scope(child); |
| 1166 for (; c; c = NodeTraversal::next(*c, &child)) | 1166 for (; c; c = NodeTraversal::next(*c, &child)) |
| 1167 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
RemovedFromDocument, false)); | 1167 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode
RemovedFromDocument, false)); |
| 1168 } | 1168 } |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 void ContainerNode::updateTreeAfterInsertion(Node& child) | 1171 void ContainerNode::updateTreeAfterInsertion(Node& child) |
| 1172 { | 1172 { |
| 1173 ChildListMutationScope(*this).childAdded(child); | 1173 ChildListMutationScope(*this).childAdded(child); |
| 1174 | 1174 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1404 return true; | 1404 return true; |
| 1405 | 1405 |
| 1406 if (node->isElementNode() && toElement(node)->shadow()) | 1406 if (node->isElementNode() && toElement(node)->shadow()) |
| 1407 return true; | 1407 return true; |
| 1408 | 1408 |
| 1409 return false; | 1409 return false; |
| 1410 } | 1410 } |
| 1411 #endif | 1411 #endif |
| 1412 | 1412 |
| 1413 } // namespace blink | 1413 } // namespace blink |
| OLD | NEW |