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

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

Issue 2574773002: Migrate WTF::Vector::append() to ::push_back() [part 4 of N] (Closed)
Patch Set: rebase Created 4 years 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 static void activateObserver(MutationObserver* observer) { 180 static void activateObserver(MutationObserver* observer) {
181 if (activeMutationObservers().isEmpty()) 181 if (activeMutationObservers().isEmpty())
182 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutations)); 182 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutations));
183 183
184 activeMutationObservers().add(observer); 184 activeMutationObservers().add(observer);
185 } 185 }
186 186
187 void MutationObserver::enqueueMutationRecord(MutationRecord* mutation) { 187 void MutationObserver::enqueueMutationRecord(MutationRecord* mutation) {
188 DCHECK(isMainThread()); 188 DCHECK(isMainThread());
189 m_records.append(mutation); 189 m_records.push_back(mutation);
190 activateObserver(this); 190 activateObserver(this);
191 InspectorInstrumentation::asyncTaskScheduled( 191 InspectorInstrumentation::asyncTaskScheduled(
192 m_callback->getExecutionContext(), mutation->type(), mutation); 192 m_callback->getExecutionContext(), mutation->type(), mutation);
193 } 193 }
194 194
195 void MutationObserver::setHasTransientRegistration() { 195 void MutationObserver::setHasTransientRegistration() {
196 DCHECK(isMainThread()); 196 DCHECK(isMainThread());
197 activateObserver(this); 197 activateObserver(this);
198 } 198 }
199 199
(...skipping 17 matching lines...) Expand all
217 217
218 void MutationObserver::deliver() { 218 void MutationObserver::deliver() {
219 DCHECK(!shouldBeSuspended()); 219 DCHECK(!shouldBeSuspended());
220 220
221 // Calling clearTransientRegistrations() can modify m_registrations, so it's 221 // Calling clearTransientRegistrations() can modify m_registrations, so it's
222 // necessary to make a copy of the transient registrations before operating on 222 // necessary to make a copy of the transient registrations before operating on
223 // them. 223 // them.
224 HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations; 224 HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations;
225 for (auto& registration : m_registrations) { 225 for (auto& registration : m_registrations) {
226 if (registration->hasTransientRegistrations()) 226 if (registration->hasTransientRegistrations())
227 transientRegistrations.append(registration); 227 transientRegistrations.push_back(registration);
228 } 228 }
229 for (const auto& registration : transientRegistrations) 229 for (const auto& registration : transientRegistrations)
230 registration->clearTransientRegistrations(); 230 registration->clearTransientRegistrations();
231 231
232 if (m_records.isEmpty()) 232 if (m_records.isEmpty())
233 return; 233 return;
234 234
235 MutationRecordVector records; 235 MutationRecordVector records;
236 records.swap(m_records); 236 records.swap(m_records);
237 237
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 272
273 DEFINE_TRACE(MutationObserver) { 273 DEFINE_TRACE(MutationObserver) {
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 } 278 }
279 279
280 } // namespace blink 280 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/IntersectionObserverController.cpp ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698