Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: third_party/WebKit/Source/core/dom/ContainerNode.cpp

Issue 1858163002: Rename inDocument() to inShadowIncludingDocument() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ASSERT_WITH_SECURITY_IMPLICATION(!n->m_deletionHasBegun); 507 ASSERT_WITH_SECURITY_IMPLICATION(!n->m_deletionHasBegun);
508 508
509 next = n->nextSibling(); 509 next = n->nextSibling();
510 n->setNextSibling(nullptr); 510 n->setNextSibling(nullptr);
511 n->setParentOrShadowHostNode(nullptr); 511 n->setParentOrShadowHostNode(nullptr);
512 container.setFirstChild(next); 512 container.setFirstChild(next);
513 if (next) 513 if (next)
514 next->setPreviousSibling(nullptr); 514 next->setPreviousSibling(nullptr);
515 515
516 if (!n->refCount()) { 516 if (!n->refCount()) {
517 if (n->inDocument()) 517 if (n->inShadowIncludingDocument())
518 container.document().decrementNodeCount(); 518 container.document().decrementNodeCount();
519 519
520 #if ENABLE(SECURITY_ASSERT) 520 #if ENABLE(SECURITY_ASSERT)
521 n->m_deletionHasBegun = true; 521 n->m_deletionHasBegun = true;
522 #endif 522 #endif
523 // Add the node to the list of nodes to be deleted. 523 // Add the node to the list of nodes to be deleted.
524 // Reuse the nextSibling pointer for this purpose. 524 // Reuse the nextSibling pointer for this purpose.
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 RawPtr<Node> protect(n); // removedFromDocument may remove all refer ences to this node. 532 RawPtr<Node> protect(n); // removedFromDocument may remove all refer ences to this node.
533 container.document().adoptIfNeeded(*n); 533 container.document().adoptIfNeeded(*n);
534 if (n->inDocument()) 534 if (n->inShadowIncludingDocument())
535 container.notifyNodeRemoved(*n); 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 {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 823
824 RawPtr<Node> protect(this); 824 RawPtr<Node> protect(this);
825 RawPtr<Node> protectNode(root); 825 RawPtr<Node> protectNode(root);
826 826
827 NodeVector postInsertionNotificationTargets; 827 NodeVector postInsertionNotificationTargets;
828 notifyNodeInsertedInternal(root, postInsertionNotificationTargets); 828 notifyNodeInsertedInternal(root, postInsertionNotificationTargets);
829 829
830 childrenChanged(ChildrenChange::forInsertion(root, source)); 830 childrenChanged(ChildrenChange::forInsertion(root, source));
831 831
832 for (const auto& targetNode : postInsertionNotificationTargets) { 832 for (const auto& targetNode : postInsertionNotificationTargets) {
833 if (targetNode->inDocument()) 833 if (targetNode->inShadowIncludingDocument())
834 targetNode->didNotifySubtreeInsertionsToDocument(); 834 targetNode->didNotifySubtreeInsertionsToDocument();
835 } 835 }
836 } 836 }
837 837
838 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser tionNotificationTargets) 838 void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser tionNotificationTargets)
839 { 839 {
840 EventDispatchForbiddenScope assertNoEventDispatch; 840 EventDispatchForbiddenScope assertNoEventDispatch;
841 ScriptForbiddenScope forbidScript; 841 ScriptForbiddenScope forbidScript;
842 842
843 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) { 843 for (Node& node : NodeTraversal::inclusiveDescendantsOf(root)) {
844 // As an optimization we don't notify leaf nodes when when inserting 844 // As an optimization we don't notify leaf nodes when when inserting
845 // into detached subtrees that are not in a shadow tree. 845 // into detached subtrees that are not in a shadow tree.
846 if (!inDocument() && !isInShadowTree() && !node.isContainerNode()) 846 if (!inShadowIncludingDocument() && !isInShadowTree() && !node.isContain erNode())
847 continue; 847 continue;
848 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted Into(this)) 848 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node.inserted Into(this))
849 postInsertionNotificationTargets.append(&node); 849 postInsertionNotificationTargets.append(&node);
850 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha dowRoot = shadowRoot->olderShadowRoot()) 850 for (ShadowRoot* shadowRoot = node.youngestShadowRoot(); shadowRoot; sha dowRoot = shadowRoot->olderShadowRoot())
851 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar gets); 851 notifyNodeInsertedInternal(*shadowRoot, postInsertionNotificationTar gets);
852 } 852 }
853 } 853 }
854 854
855 void ContainerNode::notifyNodeRemoved(Node& root) 855 void ContainerNode::notifyNodeRemoved(Node& root)
856 { 856 {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1241
1242 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 1242 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
1243 1243
1244 RawPtr<Node> c(child); 1244 RawPtr<Node> c(child);
1245 RawPtr<Document> document(child.document()); 1245 RawPtr<Document> document(child.document());
1246 1246
1247 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L ISTENER)) 1247 if (c->parentNode() && document->hasListenerType(Document::DOMNODEINSERTED_L ISTENER))
1248 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse rted, true, c->parentNode())); 1248 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeInse rted, true, c->parentNode()));
1249 1249
1250 // dispatch the DOMNodeInsertedIntoDocument event to all descendants 1250 // dispatch the DOMNodeInsertedIntoDocument event to all descendants
1251 if (c->inDocument() && document->hasListenerType(Document::DOMNODEINSERTEDIN TODOCUMENT_LISTENER)) { 1251 if (c->inShadowIncludingDocument() && document->hasListenerType(Document::DO MNODEINSERTEDINTODOCUMENT_LISTENER)) {
1252 for (; c; c = NodeTraversal::next(*c, &child)) 1252 for (; c; c = NodeTraversal::next(*c, &child))
1253 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode InsertedIntoDocument, false)); 1253 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode InsertedIntoDocument, false));
1254 } 1254 }
1255 } 1255 }
1256 1256
1257 static void dispatchChildRemovalEvents(Node& child) 1257 static void dispatchChildRemovalEvents(Node& child)
1258 { 1258 {
1259 if (child.isInShadowTree()) { 1259 if (child.isInShadowTree()) {
1260 InspectorInstrumentation::willRemoveDOMNode(&child); 1260 InspectorInstrumentation::willRemoveDOMNode(&child);
1261 return; 1261 return;
1262 } 1262 }
1263 1263
1264 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden()); 1264 ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
1265 1265
1266 InspectorInstrumentation::willRemoveDOMNode(&child); 1266 InspectorInstrumentation::willRemoveDOMNode(&child);
1267 1267
1268 RawPtr<Node> c(child); 1268 RawPtr<Node> c(child);
1269 RawPtr<Document> document(child.document()); 1269 RawPtr<Document> document(child.document());
1270 1270
1271 // Dispatch pre-removal mutation events. 1271 // Dispatch pre-removal mutation events.
1272 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI STENER)) { 1272 if (c->parentNode() && document->hasListenerType(Document::DOMNODEREMOVED_LI STENER)) {
1273 NodeChildRemovalTracker scope(child); 1273 NodeChildRemovalTracker scope(child);
1274 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo ved, true, c->parentNode())); 1274 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNodeRemo ved, true, c->parentNode()));
1275 } 1275 }
1276 1276
1277 // Dispatch the DOMNodeRemovedFromDocument event to all descendants. 1277 // Dispatch the DOMNodeRemovedFromDocument event to all descendants.
1278 if (c->inDocument() && document->hasListenerType(Document::DOMNODEREMOVEDFRO MDOCUMENT_LISTENER)) { 1278 if (c->inShadowIncludingDocument() && document->hasListenerType(Document::DO MNODEREMOVEDFROMDOCUMENT_LISTENER)) {
1279 NodeChildRemovalTracker scope(child); 1279 NodeChildRemovalTracker scope(child);
1280 for (; c; c = NodeTraversal::next(*c, &child)) 1280 for (; c; c = NodeTraversal::next(*c, &child))
1281 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false)); 1281 c->dispatchScopedEvent(MutationEvent::create(EventTypeNames::DOMNode RemovedFromDocument, false));
1282 } 1282 }
1283 } 1283 }
1284 1284
1285 void ContainerNode::updateTreeAfterInsertion(Node& child) 1285 void ContainerNode::updateTreeAfterInsertion(Node& child)
1286 { 1286 {
1287 #if !ENABLE(OILPAN) 1287 #if !ENABLE(OILPAN)
1288 ASSERT(refCount()); 1288 ASSERT(refCount());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 return true; 1509 return true;
1510 1510
1511 if (node->isElementNode() && toElement(node)->shadow()) 1511 if (node->isElementNode() && toElement(node)->shadow())
1512 return true; 1512 return true;
1513 1513
1514 return false; 1514 return false;
1515 } 1515 }
1516 #endif 1516 #endif
1517 1517
1518 } // namespace blink 1518 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataTransfer.cpp ('k') | third_party/WebKit/Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698