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

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

Issue 305603003: Merge ChildNodeInsertionNotifier and ChildNodeRemovalNotifier into ContainerNode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Don't mess with RefPtr protects yet Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/shadow/ElementShadow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Google Inc. All rights reserved.
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
19 *
20 * You should have received a copy of the GNU Library General Public License
21 * along with this library; see the file COPYING.LIB. If not, write to
22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
24 */
25
26 #include "config.h"
27 #include "core/dom/ContainerNodeAlgorithms.h"
28
29 #include "core/dom/Element.h"
30 #include "core/dom/NodeTraversal.h"
31 #include "core/dom/shadow/ElementShadow.h"
32 #include "core/dom/shadow/ShadowRoot.h"
33
34 namespace WebCore {
35
36 void ChildNodeInsertionNotifier::notifyNodeInserted(Node& root)
37 {
38 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
39 // As an optimization we don't notify leaf nodes when when inserting
40 // into detached subtrees.
41 if (!m_insertionPoint.inDocument() && !node->isContainerNode())
42 continue;
43 if (Node::InsertionShouldCallDidNotifySubtreeInsertions == node->inserte dInto(&m_insertionPoint))
44 m_postInsertionNotificationTargets.append(node);
45 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; sh adowRoot = shadowRoot->olderShadowRoot())
46 notifyNodeInserted(*shadowRoot);
47 }
48 }
49
50 void ChildNodeRemovalNotifier::notifyNodeRemoved(Node& root)
51 {
52 Document& document = root.document();
53 for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
54 // As an optimization we skip notifying Text nodes and other leaf nodes
55 // of removal when they're not in the Document tree since the virtual
56 // call to removedFrom is not needed.
57 if (!node->inDocument() && !node->isContainerNode())
58 continue;
59 if (document.cssTarget() == node)
60 document.setCSSTarget(0);
61 node->removedFrom(&m_insertionPoint);
62 for (ShadowRoot* shadowRoot = node->youngestShadowRoot(); shadowRoot; sh adowRoot = shadowRoot->olderShadowRoot())
63 notifyNodeRemoved(*shadowRoot);
64 }
65 }
66
67 }
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNodeAlgorithms.h ('k') | Source/core/dom/shadow/ElementShadow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698