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

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

Issue 23874007: Rename AttachBehavior to RecalcStyleBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix enum usage Created 7 years, 3 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
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 static NodeCallbackQueue* s_postAttachCallbackQueue; 57 static NodeCallbackQueue* s_postAttachCallbackQueue;
58 58
59 static size_t s_attachDepth; 59 static size_t s_attachDepth;
60 60
61 ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot = 0; 61 ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot = 0;
62 62
63 #ifndef NDEBUG 63 #ifndef NDEBUG
64 unsigned NoEventDispatchAssertion::s_count = 0; 64 unsigned NoEventDispatchAssertion::s_count = 0;
65 #endif 65 #endif
66 66
67 static inline void attachAfterInsertion(Node* node, AttachBehavior attachBehavio r = AttachLazily) 67 static inline void attachAfterInsertion(Node* node)
68 { 68 {
69 if (node->attached() || !node->parentNode() || !node->parentNode()->attached ()) 69 if (node->attached() || !node->parentNode() || !node->parentNode()->attached ())
70 return; 70 return;
71 71
72 if (attachBehavior == AttachLazily) 72 node->lazyAttach();
73 node->lazyAttach();
74 else
75 node->attach();
76 73
77 if (StyleResolver* resolver = node->document().styleResolverIfExists()) 74 if (StyleResolver* resolver = node->document().styleResolverIfExists())
78 resolver->clearStyleSharingList(); 75 resolver->clearStyleSharingList();
79 } 76 }
80 77
81 static void collectChildrenAndRemoveFromOldParent(Node* node, NodeVector& nodes, ExceptionState& es) 78 static void collectChildrenAndRemoveFromOldParent(Node* node, NodeVector& nodes, ExceptionState& es)
82 { 79 {
83 if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) { 80 if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
84 nodes.append(node); 81 nodes.append(node);
85 if (ContainerNode* oldParent = node->parentNode()) 82 if (ContainerNode* oldParent = node->parentNode())
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 prev->setNextSibling(newChild); 308 prev->setNextSibling(newChild);
312 } else { 309 } else {
313 ASSERT(m_firstChild == nextChild); 310 ASSERT(m_firstChild == nextChild);
314 m_firstChild = newChild; 311 m_firstChild = newChild;
315 } 312 }
316 newChild->setParentOrShadowHostNode(this); 313 newChild->setParentOrShadowHostNode(this);
317 newChild->setPreviousSibling(prev); 314 newChild->setPreviousSibling(prev);
318 newChild->setNextSibling(nextChild); 315 newChild->setNextSibling(nextChild);
319 } 316 }
320 317
321 void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChil d, AttachBehavior attachBehavior) 318 void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChil d)
322 { 319 {
323 ASSERT(newChild); 320 ASSERT(newChild);
324 ASSERT(nextChild); 321 ASSERT(nextChild);
325 ASSERT(nextChild->parentNode() == this); 322 ASSERT(nextChild->parentNode() == this);
326 ASSERT(!newChild->isDocumentFragment()); 323 ASSERT(!newChild->isDocumentFragment());
327 ASSERT(!hasTagName(HTMLNames::templateTag)); 324 ASSERT(!hasTagName(HTMLNames::templateTag));
328 325
329 if (nextChild->previousSibling() == newChild || nextChild == newChild) // no thing to do 326 if (nextChild->previousSibling() == newChild || nextChild == newChild) // no thing to do
330 return; 327 return;
331 328
332 if (&document() != &newChild->document()) 329 if (&document() != &newChild->document())
333 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); 330 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
334 331
335 insertBeforeCommon(nextChild, newChild.get()); 332 insertBeforeCommon(nextChild, newChild.get());
336 333
337 newChild->updateAncestorConnectedSubframeCountForInsertion(); 334 newChild->updateAncestorConnectedSubframeCountForInsertion();
338 335
339 ChildListMutationScope(this).childAdded(newChild.get()); 336 ChildListMutationScope(this).childAdded(newChild.get());
340 337
341 childrenChanged(true, newChild->previousSibling(), nextChild, 1); 338 childrenChanged(true, newChild->previousSibling(), nextChild, 1);
342 339
343 ChildNodeInsertionNotifier(this).notify(newChild.get()); 340 ChildNodeInsertionNotifier(this).notify(newChild.get());
344 341
345 attachAfterInsertion(newChild.get(), attachBehavior); 342 attachAfterInsertion(newChild.get());
346 } 343 }
347 344
348 void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce ptionState& es) 345 void ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, Exce ptionState& es)
349 { 346 {
350 // Check that this node is not "floating". 347 // Check that this node is not "floating".
351 // If it is, it can be deleted as a side effect of sending mutation events. 348 // If it is, it can be deleted as a side effect of sending mutation events.
352 ASSERT(refCount() || parentOrShadowHostNode()); 349 ASSERT(refCount() || parentOrShadowHostNode());
353 350
354 RefPtr<Node> protect(this); 351 RefPtr<Node> protect(this);
355 352
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 NoEventDispatchAssertion assertNoEventDispatch; 647 NoEventDispatchAssertion assertNoEventDispatch;
651 appendChildToContainer(child, this); 648 appendChildToContainer(child, this);
652 } 649 }
653 650
654 updateTreeAfterInsertion(this, child); 651 updateTreeAfterInsertion(this, child);
655 } 652 }
656 653
657 dispatchSubtreeModifiedEvent(); 654 dispatchSubtreeModifiedEvent();
658 } 655 }
659 656
660 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild, AttachBehavior attachBehavior) 657 void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild)
661 { 658 {
662 ASSERT(newChild); 659 ASSERT(newChild);
663 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re parenting (and want DOM mutation events). 660 ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle re parenting (and want DOM mutation events).
664 ASSERT(!newChild->isDocumentFragment()); 661 ASSERT(!newChild->isDocumentFragment());
665 ASSERT(!hasTagName(HTMLNames::templateTag)); 662 ASSERT(!hasTagName(HTMLNames::templateTag));
666 663
667 if (&document() != &newChild->document()) 664 if (&document() != &newChild->document())
668 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); 665 document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
669 666
670 Node* last = m_lastChild; 667 Node* last = m_lastChild;
671 { 668 {
672 NoEventDispatchAssertion assertNoEventDispatch; 669 NoEventDispatchAssertion assertNoEventDispatch;
673 // FIXME: This method should take a PassRefPtr. 670 // FIXME: This method should take a PassRefPtr.
674 appendChildToContainer(newChild.get(), this); 671 appendChildToContainer(newChild.get(), this);
675 treeScope().adoptIfNeeded(newChild.get()); 672 treeScope().adoptIfNeeded(newChild.get());
676 } 673 }
677 674
678 newChild->updateAncestorConnectedSubframeCountForInsertion(); 675 newChild->updateAncestorConnectedSubframeCountForInsertion();
679 676
680 ChildListMutationScope(this).childAdded(newChild.get()); 677 ChildListMutationScope(this).childAdded(newChild.get());
681 678
682 childrenChanged(true, last, 0, 1); 679 childrenChanged(true, last, 0, 1);
683 ChildNodeInsertionNotifier(this).notify(newChild.get()); 680 ChildNodeInsertionNotifier(this).notify(newChild.get());
684 681
685 attachAfterInsertion(newChild.get(), attachBehavior); 682 attachAfterInsertion(newChild.get());
686 } 683 }
687 684
688 void ContainerNode::suspendPostAttachCallbacks() 685 void ContainerNode::suspendPostAttachCallbacks()
689 { 686 {
690 ++s_attachDepth; 687 ++s_attachDepth;
691 } 688 }
692 689
693 void ContainerNode::resumePostAttachCallbacks() 690 void ContainerNode::resumePostAttachCallbacks()
694 { 691 {
695 if (s_attachDepth == 1) { 692 if (s_attachDepth == 1) {
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 return true; 1057 return true;
1061 1058
1062 if (node->isElementNode() && toElement(node)->shadow()) 1059 if (node->isElementNode() && toElement(node)->shadow())
1063 return true; 1060 return true;
1064 1061
1065 return false; 1062 return false;
1066 } 1063 }
1067 #endif 1064 #endif
1068 1065
1069 } // namespace WebCore 1066 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698