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

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

Issue 236653002: Oilpan: move mutation observers to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased + explicitly dispose() mutation observer registrations always (non-Oilpan also.) Created 6 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) 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ChildListMutationScope_h 31 #ifndef ChildListMutationScope_h
32 #define ChildListMutationScope_h 32 #define ChildListMutationScope_h
33 33
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/MutationObserver.h" 35 #include "core/dom/MutationObserver.h"
36 #include "core/dom/Node.h" 36 #include "core/dom/Node.h"
37 #include "platform/heap/Handle.h"
37 #include "wtf/Noncopyable.h" 38 #include "wtf/Noncopyable.h"
38 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
39 #include "wtf/RefCounted.h" 40 #include "wtf/RefCounted.h"
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 class MutationObserverInterestGroup; 44 class MutationObserverInterestGroup;
44 45
45 // ChildListMutationAccumulator is not meant to be used directly; ChildListMutat ionScope is the public interface. 46 // ChildListMutationAccumulator is not meant to be used directly; ChildListMutat ionScope is the public interface.
46 class ChildListMutationAccumulator : public RefCounted<ChildListMutationAccumula tor> { 47 class ChildListMutationAccumulator FINAL : public RefCounted<ChildListMutationAc cumulator> {
47 public: 48 public:
48 static PassRefPtr<ChildListMutationAccumulator> getOrCreate(Node&); 49 static PassRefPtr<ChildListMutationAccumulator> getOrCreate(Node&);
49 ~ChildListMutationAccumulator(); 50 ~ChildListMutationAccumulator();
50 51
51 void childAdded(PassRefPtr<Node>); 52 void childAdded(PassRefPtr<Node>);
52 void willRemoveChild(PassRefPtr<Node>); 53 void willRemoveChild(PassRefPtr<Node>);
53 54
54 bool hasObservers() const { return m_observers; } 55 bool hasObservers() const { return m_observers; }
55 56
56 private: 57 private:
57 ChildListMutationAccumulator(PassRefPtr<Node>, PassOwnPtr<MutationObserverIn terestGroup>); 58 ChildListMutationAccumulator(PassRefPtr<Node>, PassOwnPtrWillBeRawPtr<Mutati onObserverInterestGroup>);
58 59
59 void enqueueMutationRecord(); 60 void enqueueMutationRecord();
60 bool isEmpty(); 61 bool isEmpty();
61 bool isAddedNodeInOrder(Node*); 62 bool isAddedNodeInOrder(Node*);
62 bool isRemovedNodeInOrder(Node*); 63 bool isRemovedNodeInOrder(Node*);
63 64
64 RefPtr<Node> m_target; 65 RefPtr<Node> m_target;
65 66
66 Vector<RefPtr<Node> > m_removedNodes; 67 Vector<RefPtr<Node> > m_removedNodes;
67 Vector<RefPtr<Node> > m_addedNodes; 68 Vector<RefPtr<Node> > m_addedNodes;
68 RefPtr<Node> m_previousSibling; 69 RefPtr<Node> m_previousSibling;
69 RefPtr<Node> m_nextSibling; 70 RefPtr<Node> m_nextSibling;
70 Node* m_lastAdded; 71 Node* m_lastAdded;
71 72
72 OwnPtr<MutationObserverInterestGroup> m_observers; 73 OwnPtrWillBePersistent<MutationObserverInterestGroup> m_observers;
73 }; 74 };
74 75
75 class ChildListMutationScope { 76 class ChildListMutationScope FINAL {
76 WTF_MAKE_NONCOPYABLE(ChildListMutationScope); 77 WTF_MAKE_NONCOPYABLE(ChildListMutationScope);
78 STACK_ALLOCATED();
77 public: 79 public:
78 explicit ChildListMutationScope(Node& target) 80 explicit ChildListMutationScope(Node& target)
79 { 81 {
80 if (target.document().hasMutationObserversOfType(MutationObserver::Child List)) 82 if (target.document().hasMutationObserversOfType(MutationObserver::Child List))
81 m_accumulator = ChildListMutationAccumulator::getOrCreate(target); 83 m_accumulator = ChildListMutationAccumulator::getOrCreate(target);
82 } 84 }
83 85
84 void childAdded(Node& child) 86 void childAdded(Node& child)
85 { 87 {
86 if (m_accumulator && m_accumulator->hasObservers()) 88 if (m_accumulator && m_accumulator->hasObservers())
87 m_accumulator->childAdded(PassRefPtr<Node>(child)); 89 m_accumulator->childAdded(PassRefPtr<Node>(child));
88 } 90 }
89 91
90 void willRemoveChild(Node& child) 92 void willRemoveChild(Node& child)
91 { 93 {
92 if (m_accumulator && m_accumulator->hasObservers()) 94 if (m_accumulator && m_accumulator->hasObservers())
93 m_accumulator->willRemoveChild(PassRefPtr<Node>(child)); 95 m_accumulator->willRemoveChild(PassRefPtr<Node>(child));
94 } 96 }
95 97
96 private: 98 private:
97 RefPtr<ChildListMutationAccumulator> m_accumulator; 99 RefPtr<ChildListMutationAccumulator> m_accumulator;
98 }; 100 };
99 101
100 } // namespace WebCore 102 } // namespace WebCore
101 103
102 #endif // ChildListMutationScope_h 104 #endif // ChildListMutationScope_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698