Chromium Code Reviews| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type ' " + newChild.nodeName() + "' may not be inserted inside nodes of type '" + nodeN ame() + "'."); | 147 exceptionState.throwDOMException(HierarchyRequestError, "Nodes of type ' " + newChild.nodeName() + "' may not be inserted inside nodes of type '" + nodeN ame() + "'."); |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 return true; | 150 return true; |
| 151 } | 151 } |
| 152 | 152 |
| 153 template <typename Functor> | 153 template <typename Functor> |
| 154 void ContainerNode::insertNodeVector(const NodeVector& targets, Node* next, cons t Functor& mutator) | 154 void ContainerNode::insertNodeVector(const NodeVector& targets, Node* next, cons t Functor& mutator) |
| 155 { | 155 { |
| 156 InspectorInstrumentation::willInsertDOMNode(this); | 156 InspectorInstrumentation::willInsertDOMNode(this); |
| 157 NodeVector postInsertionNotificationTargets; | |
| 158 { | |
| 159 EventDispatchForbiddenScope assertNoEventDispatch; | |
| 160 ScriptForbiddenScope forbidScript; | |
| 161 for (const auto& targetNode : targets) { | |
| 162 DCHECK(targetNode); | |
| 163 Node& child = *targetNode; | |
| 164 // TODO(tkent): mutator never returns false because scripts don't ru n in the loop. | |
|
tkent
2016/09/08 04:52:44
Will remove unnecessary code in a follow-up CL.
| |
| 165 if (!mutator(*this, child, next)) | |
| 166 break; | |
| 167 ChildListMutationScope(*this).childAdded(child); | |
| 168 if (document().containsV1ShadowTree()) | |
| 169 child.checkSlotChangeAfterInserted(); | |
| 170 InspectorInstrumentation::didInsertDOMNode(&child); | |
| 171 notifyNodeInsertedInternal(child, postInsertionNotificationTargets); | |
| 172 } | |
| 173 } | |
| 174 for (const auto& targetNode : targets) | |
| 175 childrenChanged(ChildrenChange::forInsertion(*targetNode, ChildrenChange SourceAPI)); | |
| 176 for (const auto& descendant : postInsertionNotificationTargets) { | |
| 177 if (descendant->isConnected()) | |
| 178 descendant->didNotifySubtreeInsertionsToDocument(); | |
| 179 } | |
| 157 for (const auto& targetNode : targets) { | 180 for (const auto& targetNode : targets) { |
| 158 DCHECK(targetNode); | 181 if (targetNode->parentNode() == this) |
|
hayato
2016/09/08 06:18:55
Should we check this condition?
It looks the origi
tkent
2016/09/08 06:31:08
The DOM specification is unclear for this and we m
hayato
2016/09/08 06:48:11
We chatted offline.
We have decided to make this
| |
| 159 { | 182 dispatchChildInsertionEvents(*targetNode); |
| 160 EventDispatchForbiddenScope assertNoEventDispatch; | |
| 161 ScriptForbiddenScope forbidScript; | |
| 162 | |
| 163 if (!mutator(*this, *targetNode, next)) | |
| 164 break; | |
| 165 } | |
| 166 updateTreeAfterInsertion(*targetNode); | |
| 167 } | 183 } |
| 168 dispatchSubtreeModifiedEvent(); | 184 dispatchSubtreeModifiedEvent(); |
| 169 } | 185 } |
| 170 | 186 |
| 171 class ContainerNode::AdoptAndInsertBefore { | 187 class ContainerNode::AdoptAndInsertBefore { |
| 172 public: | 188 public: |
| 173 bool operator()(ContainerNode& container, Node& child, Node* next) const | 189 bool operator()(ContainerNode& container, Node& child, Node* next) const |
| 174 { | 190 { |
| 175 DCHECK(next); | 191 DCHECK(next); |
| 176 // Due to arbitrary code running in response to a DOM mutation event | 192 // Due to arbitrary code running in response to a DOM mutation event |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1163 } | 1179 } |
| 1164 | 1180 |
| 1165 // Dispatch the DOMNodeRemovedFromDocument event to all descendants. | 1181 // Dispatch the DOMNodeRemovedFromDocument event to all descendants. |
| 1166 if (c->isConnected() && document->hasListenerType(Document::DOMNODEREMOVEDFR OMDOCUMENT_LISTENER)) { | 1182 if (c->isConnected() && document->hasListenerType(Document::DOMNODEREMOVEDFR OMDOCUMENT_LISTENER)) { |
| 1167 NodeChildRemovalTracker scope(child); | 1183 NodeChildRemovalTracker scope(child); |
| 1168 for (; c; c = NodeTraversal::next(*c, &child)) | 1184 for (; c; c = NodeTraversal::next(*c, &child)) |
| 1169 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false)); | 1185 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false)); |
| 1170 } | 1186 } |
| 1171 } | 1187 } |
| 1172 | 1188 |
| 1173 void ContainerNode::updateTreeAfterInsertion(Node& child) | |
| 1174 { | |
| 1175 ChildListMutationScope(*this).childAdded(child); | |
| 1176 | |
| 1177 notifyNodeInserted(child); | |
| 1178 | |
| 1179 dispatchChildInsertionEvents(child); | |
| 1180 } | |
| 1181 | |
| 1182 bool ContainerNode::hasRestyleFlagInternal(DynamicRestyleFlags mask) const | 1189 bool ContainerNode::hasRestyleFlagInternal(DynamicRestyleFlags mask) const |
| 1183 { | 1190 { |
| 1184 return rareData()->hasRestyleFlag(mask); | 1191 return rareData()->hasRestyleFlag(mask); |
| 1185 } | 1192 } |
| 1186 | 1193 |
| 1187 bool ContainerNode::hasRestyleFlagsInternal() const | 1194 bool ContainerNode::hasRestyleFlagsInternal() const |
| 1188 { | 1195 { |
| 1189 return rareData()->hasRestyleFlags(); | 1196 return rareData()->hasRestyleFlags(); |
| 1190 } | 1197 } |
| 1191 | 1198 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1373 return true; | 1380 return true; |
| 1374 | 1381 |
| 1375 if (node->isElementNode() && toElement(node)->shadow()) | 1382 if (node->isElementNode() && toElement(node)->shadow()) |
| 1376 return true; | 1383 return true; |
| 1377 | 1384 |
| 1378 return false; | 1385 return false; |
| 1379 } | 1386 } |
| 1380 #endif | 1387 #endif |
| 1381 | 1388 |
| 1382 } // namespace blink | 1389 } // namespace blink |
| OLD | NEW |