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

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

Powered by Google App Engine
This is Rietveld 408576698