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

Side by Side Diff: third_party/WebKit/Source/core/dom/MutationObserver.cpp

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 28 matching lines...) Expand all
39 #include "core/dom/MutationRecord.h" 39 #include "core/dom/MutationRecord.h"
40 #include "core/dom/Node.h" 40 #include "core/dom/Node.h"
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include <algorithm> 42 #include <algorithm>
43 43
44 namespace blink { 44 namespace blink {
45 45
46 static unsigned s_observerPriority = 0; 46 static unsigned s_observerPriority = 0;
47 47
48 struct MutationObserver::ObserverLessThan { 48 struct MutationObserver::ObserverLessThan {
49 bool operator()(const RefPtrWillBeMember<MutationObserver>& lhs, const RefPt rWillBeMember<MutationObserver>& rhs) 49 bool operator()(const Member<MutationObserver>& lhs, const Member<MutationOb server>& rhs)
50 { 50 {
51 return lhs->m_priority < rhs->m_priority; 51 return lhs->m_priority < rhs->m_priority;
52 } 52 }
53 }; 53 };
54 54
55 PassRefPtrWillBeRawPtr<MutationObserver> MutationObserver::create(PassOwnPtrWill BeRawPtr<MutationCallback> callback) 55 RawPtr<MutationObserver> MutationObserver::create(RawPtr<MutationCallback> callb ack)
56 { 56 {
57 ASSERT(isMainThread()); 57 ASSERT(isMainThread());
58 return adoptRefWillBeNoop(new MutationObserver(callback)); 58 return new MutationObserver(callback);
59 } 59 }
60 60
61 MutationObserver::MutationObserver(PassOwnPtrWillBeRawPtr<MutationCallback> call back) 61 MutationObserver::MutationObserver(RawPtr<MutationCallback> callback)
62 : m_callback(callback) 62 : m_callback(callback)
63 , m_priority(s_observerPriority++) 63 , m_priority(s_observerPriority++)
64 { 64 {
65 } 65 }
66 66
67 MutationObserver::~MutationObserver() 67 MutationObserver::~MutationObserver()
68 { 68 {
69 #if !ENABLE(OILPAN) 69 #if !ENABLE(OILPAN)
70 ASSERT(m_registrations.isEmpty()); 70 ASSERT(m_registrations.isEmpty());
71 #endif 71 #endif
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 159 }
160 160
161 void MutationObserver::observationEnded(MutationObserverRegistration* registrati on) 161 void MutationObserver::observationEnded(MutationObserverRegistration* registrati on)
162 { 162 {
163 ASSERT(m_registrations.contains(registration)); 163 ASSERT(m_registrations.contains(registration));
164 m_registrations.remove(registration); 164 m_registrations.remove(registration);
165 } 165 }
166 166
167 static MutationObserverSet& activeMutationObservers() 167 static MutationObserverSet& activeMutationObservers()
168 { 168 {
169 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<MutationObserverSet>, activeObser vers, (adoptPtrWillBeNoop(new MutationObserverSet()))); 169 DEFINE_STATIC_LOCAL(Persistent<MutationObserverSet>, activeObservers, (new M utationObserverSet()));
170 return *activeObservers; 170 return *activeObservers;
171 } 171 }
172 172
173 static MutationObserverSet& suspendedMutationObservers() 173 static MutationObserverSet& suspendedMutationObservers()
174 { 174 {
175 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<MutationObserverSet>, suspendedOb servers, (adoptPtrWillBeNoop(new MutationObserverSet()))); 175 DEFINE_STATIC_LOCAL(Persistent<MutationObserverSet>, suspendedObservers, (ne w MutationObserverSet()));
176 return *suspendedObservers; 176 return *suspendedObservers;
177 } 177 }
178 178
179 static void activateObserver(PassRefPtrWillBeRawPtr<MutationObserver> observer) 179 static void activateObserver(RawPtr<MutationObserver> observer)
180 { 180 {
181 if (activeMutationObservers().isEmpty()) 181 if (activeMutationObservers().isEmpty())
182 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutation s)); 182 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutation s));
183 183
184 activeMutationObservers().add(observer); 184 activeMutationObservers().add(observer);
185 } 185 }
186 186
187 void MutationObserver::enqueueMutationRecord(PassRefPtrWillBeRawPtr<MutationReco rd> mutation) 187 void MutationObserver::enqueueMutationRecord(RawPtr<MutationRecord> mutation)
188 { 188 {
189 ASSERT(isMainThread()); 189 ASSERT(isMainThread());
190 m_records.append(mutation); 190 m_records.append(mutation);
191 activateObserver(this); 191 activateObserver(this);
192 InspectorInstrumentation::didEnqueueMutationRecord(m_callback->getExecutionC ontext(), this); 192 InspectorInstrumentation::didEnqueueMutationRecord(m_callback->getExecutionC ontext(), this);
193 } 193 }
194 194
195 void MutationObserver::setHasTransientRegistration() 195 void MutationObserver::setHasTransientRegistration()
196 { 196 {
197 ASSERT(isMainThread()); 197 ASSERT(isMainThread());
198 activateObserver(this); 198 activateObserver(this);
199 } 199 }
200 200
201 WillBeHeapHashSet<RawPtrWillBeMember<Node>> MutationObserver::getObservedNodes() const 201 HeapHashSet<Member<Node>> MutationObserver::getObservedNodes() const
202 { 202 {
203 WillBeHeapHashSet<RawPtrWillBeMember<Node>> observedNodes; 203 HeapHashSet<Member<Node>> observedNodes;
204 for (const auto& registration : m_registrations) 204 for (const auto& registration : m_registrations)
205 registration->addRegistrationNodesToSet(observedNodes); 205 registration->addRegistrationNodesToSet(observedNodes);
206 return observedNodes; 206 return observedNodes;
207 } 207 }
208 208
209 bool MutationObserver::shouldBeSuspended() const 209 bool MutationObserver::shouldBeSuspended() const
210 { 210 {
211 return m_callback->getExecutionContext() && m_callback->getExecutionContext( )->activeDOMObjectsAreSuspended(); 211 return m_callback->getExecutionContext() && m_callback->getExecutionContext( )->activeDOMObjectsAreSuspended();
212 } 212 }
213 213
214 void MutationObserver::deliver() 214 void MutationObserver::deliver()
215 { 215 {
216 ASSERT(!shouldBeSuspended()); 216 ASSERT(!shouldBeSuspended());
217 217
218 // Calling clearTransientRegistrations() can modify m_registrations, so it's necessary 218 // Calling clearTransientRegistrations() can modify m_registrations, so it's necessary
219 // to make a copy of the transient registrations before operating on them. 219 // to make a copy of the transient registrations before operating on them.
220 WillBeHeapVector<RawPtrWillBeMember<MutationObserverRegistration>, 1> transi entRegistrations; 220 HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations;
221 for (auto& registration : m_registrations) { 221 for (auto& registration : m_registrations) {
222 if (registration->hasTransientRegistrations()) 222 if (registration->hasTransientRegistrations())
223 transientRegistrations.append(registration); 223 transientRegistrations.append(registration);
224 } 224 }
225 for (size_t i = 0; i < transientRegistrations.size(); ++i) 225 for (size_t i = 0; i < transientRegistrations.size(); ++i)
226 transientRegistrations[i]->clearTransientRegistrations(); 226 transientRegistrations[i]->clearTransientRegistrations();
227 227
228 if (m_records.isEmpty()) 228 if (m_records.isEmpty())
229 return; 229 return;
230 230
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 { 271 {
272 #if ENABLE(OILPAN) 272 #if ENABLE(OILPAN)
273 visitor->trace(m_callback); 273 visitor->trace(m_callback);
274 visitor->trace(m_records); 274 visitor->trace(m_records);
275 visitor->trace(m_registrations); 275 visitor->trace(m_registrations);
276 visitor->trace(m_callback); 276 visitor->trace(m_callback);
277 #endif 277 #endif
278 } 278 }
279 279
280 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MutationObserver.h ('k') | third_party/WebKit/Source/core/dom/MutationObserver.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698