OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 class MutationObserverInterestGroup; | 44 class MutationObserverInterestGroup; |
45 | 45 |
46 // 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. |
47 // | 47 // |
48 // One ChildListMutationAccumulator for a given Node is shared between all the | 48 // One ChildListMutationAccumulator for a given Node is shared between all the |
49 // active ChildListMutationScopes for that Node. Once the last ChildListMutation
Scope | 49 // active ChildListMutationScopes for that Node. Once the last ChildListMutation
Scope |
50 // is destructed the accumulator enqueues a mutation record for the recorded | 50 // is destructed the accumulator enqueues a mutation record for the recorded |
51 // mutations and the accumulator can be garbage collected. | 51 // mutations and the accumulator can be garbage collected. |
52 class ChildListMutationAccumulator FINAL : public RefCountedWillBeGarbageCollect
ed<ChildListMutationAccumulator> { | 52 class ChildListMutationAccumulator final : public RefCountedWillBeGarbageCollect
ed<ChildListMutationAccumulator> { |
53 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ChildListMutationAccumulator); | 53 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(ChildListMutationAccumulator); |
54 public: | 54 public: |
55 static PassRefPtrWillBeRawPtr<ChildListMutationAccumulator> getOrCreate(Node
&); | 55 static PassRefPtrWillBeRawPtr<ChildListMutationAccumulator> getOrCreate(Node
&); |
56 | 56 |
57 void childAdded(PassRefPtrWillBeRawPtr<Node>); | 57 void childAdded(PassRefPtrWillBeRawPtr<Node>); |
58 void willRemoveChild(PassRefPtrWillBeRawPtr<Node>); | 58 void willRemoveChild(PassRefPtrWillBeRawPtr<Node>); |
59 | 59 |
60 bool hasObservers() const { return m_observers; } | 60 bool hasObservers() const { return m_observers; } |
61 | 61 |
62 // Register and unregister mutation scopes that are using this mutation | 62 // Register and unregister mutation scopes that are using this mutation |
(...skipping 17 matching lines...) Expand all Loading... |
80 WillBeHeapVector<RefPtrWillBeMember<Node> > m_addedNodes; | 80 WillBeHeapVector<RefPtrWillBeMember<Node> > m_addedNodes; |
81 RefPtrWillBeMember<Node> m_previousSibling; | 81 RefPtrWillBeMember<Node> m_previousSibling; |
82 RefPtrWillBeMember<Node> m_nextSibling; | 82 RefPtrWillBeMember<Node> m_nextSibling; |
83 RawPtrWillBeMember<Node> m_lastAdded; | 83 RawPtrWillBeMember<Node> m_lastAdded; |
84 | 84 |
85 OwnPtrWillBeMember<MutationObserverInterestGroup> m_observers; | 85 OwnPtrWillBeMember<MutationObserverInterestGroup> m_observers; |
86 | 86 |
87 unsigned m_mutationScopes; | 87 unsigned m_mutationScopes; |
88 }; | 88 }; |
89 | 89 |
90 class ChildListMutationScope FINAL { | 90 class ChildListMutationScope final { |
91 WTF_MAKE_NONCOPYABLE(ChildListMutationScope); | 91 WTF_MAKE_NONCOPYABLE(ChildListMutationScope); |
92 STACK_ALLOCATED(); | 92 STACK_ALLOCATED(); |
93 public: | 93 public: |
94 explicit ChildListMutationScope(Node& target) | 94 explicit ChildListMutationScope(Node& target) |
95 { | 95 { |
96 if (target.document().hasMutationObserversOfType(MutationObserver::Child
List)) { | 96 if (target.document().hasMutationObserversOfType(MutationObserver::Child
List)) { |
97 m_accumulator = ChildListMutationAccumulator::getOrCreate(target); | 97 m_accumulator = ChildListMutationAccumulator::getOrCreate(target); |
98 // Register another user of the accumulator. | 98 // Register another user of the accumulator. |
99 m_accumulator->enterMutationScope(); | 99 m_accumulator->enterMutationScope(); |
100 } | 100 } |
(...skipping 20 matching lines...) Expand all Loading... |
121 m_accumulator->willRemoveChild(&child); | 121 m_accumulator->willRemoveChild(&child); |
122 } | 122 } |
123 | 123 |
124 private: | 124 private: |
125 RefPtrWillBeMember<ChildListMutationAccumulator> m_accumulator; | 125 RefPtrWillBeMember<ChildListMutationAccumulator> m_accumulator; |
126 }; | 126 }; |
127 | 127 |
128 } // namespace blink | 128 } // namespace blink |
129 | 129 |
130 #endif // ChildListMutationScope_h | 130 #endif // ChildListMutationScope_h |
OLD | NEW |