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

Side by Side Diff: Source/core/dom/ChildListMutationScope.h

Issue 51273002: Have ChildFrameDisconnector / ChildListMutationScope deal with references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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/CharacterData.cpp ('k') | Source/core/dom/ChildListMutationScope.cpp » ('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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include "wtf/OwnPtr.h" 38 #include "wtf/OwnPtr.h"
39 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
40 40
41 namespace WebCore { 41 namespace WebCore {
42 42
43 class MutationObserverInterestGroup; 43 class MutationObserverInterestGroup;
44 44
45 // ChildListMutationAccumulator is not meant to be used directly; ChildListMutat ionScope is the public interface. 45 // ChildListMutationAccumulator is not meant to be used directly; ChildListMutat ionScope is the public interface.
46 class ChildListMutationAccumulator : public RefCounted<ChildListMutationAccumula tor> { 46 class ChildListMutationAccumulator : public RefCounted<ChildListMutationAccumula tor> {
47 public: 47 public:
48 static PassRefPtr<ChildListMutationAccumulator> getOrCreate(Node*); 48 static PassRefPtr<ChildListMutationAccumulator> getOrCreate(Node&);
49 ~ChildListMutationAccumulator(); 49 ~ChildListMutationAccumulator();
50 50
51 void childAdded(PassRefPtr<Node>); 51 void childAdded(PassRefPtr<Node>);
52 void willRemoveChild(PassRefPtr<Node>); 52 void willRemoveChild(PassRefPtr<Node>);
53 53
54 bool hasObservers() const { return m_observers; } 54 bool hasObservers() const { return m_observers; }
55 55
56 private: 56 private:
57 ChildListMutationAccumulator(PassRefPtr<Node>, PassOwnPtr<MutationObserverIn terestGroup>); 57 ChildListMutationAccumulator(PassRefPtr<Node>, PassOwnPtr<MutationObserverIn terestGroup>);
58 58
59 void enqueueMutationRecord(); 59 void enqueueMutationRecord();
60 bool isEmpty(); 60 bool isEmpty();
61 bool isAddedNodeInOrder(Node*); 61 bool isAddedNodeInOrder(Node*);
62 bool isRemovedNodeInOrder(Node*); 62 bool isRemovedNodeInOrder(Node*);
63 63
64 RefPtr<Node> m_target; 64 RefPtr<Node> m_target;
65 65
66 Vector<RefPtr<Node> > m_removedNodes; 66 Vector<RefPtr<Node> > m_removedNodes;
67 Vector<RefPtr<Node> > m_addedNodes; 67 Vector<RefPtr<Node> > m_addedNodes;
68 RefPtr<Node> m_previousSibling; 68 RefPtr<Node> m_previousSibling;
69 RefPtr<Node> m_nextSibling; 69 RefPtr<Node> m_nextSibling;
70 Node* m_lastAdded; 70 Node* m_lastAdded;
71 71
72 OwnPtr<MutationObserverInterestGroup> m_observers; 72 OwnPtr<MutationObserverInterestGroup> m_observers;
73 }; 73 };
74 74
75 class ChildListMutationScope { 75 class ChildListMutationScope {
76 WTF_MAKE_NONCOPYABLE(ChildListMutationScope); 76 WTF_MAKE_NONCOPYABLE(ChildListMutationScope);
77 public: 77 public:
78 explicit ChildListMutationScope(Node* target) 78 explicit ChildListMutationScope(Node& target)
79 { 79 {
80 if (target->document().hasMutationObserversOfType(MutationObserver::Chil dList)) 80 if (target.document().hasMutationObserversOfType(MutationObserver::Child List))
81 m_accumulator = ChildListMutationAccumulator::getOrCreate(target); 81 m_accumulator = ChildListMutationAccumulator::getOrCreate(target);
82 } 82 }
83 83
84 void childAdded(Node* child) 84 void childAdded(Node& child)
85 { 85 {
86 if (m_accumulator && m_accumulator->hasObservers()) 86 if (m_accumulator && m_accumulator->hasObservers())
87 m_accumulator->childAdded(child); 87 m_accumulator->childAdded(PassRefPtr<Node>(child));
88 } 88 }
89 89
90 void willRemoveChild(Node* child) 90 void willRemoveChild(Node& child)
91 { 91 {
92 if (m_accumulator && m_accumulator->hasObservers()) 92 if (m_accumulator && m_accumulator->hasObservers())
93 m_accumulator->willRemoveChild(child); 93 m_accumulator->willRemoveChild(PassRefPtr<Node>(child));
94 } 94 }
95 95
96 private: 96 private:
97 RefPtr<ChildListMutationAccumulator> m_accumulator; 97 RefPtr<ChildListMutationAccumulator> m_accumulator;
98 }; 98 };
99 99
100 } // namespace WebCore 100 } // namespace WebCore
101 101
102 #endif // ChildListMutationScope_h 102 #endif // ChildListMutationScope_h
OLDNEW
« no previous file with comments | « Source/core/dom/CharacterData.cpp ('k') | Source/core/dom/ChildListMutationScope.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698