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

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

Issue 1039523003: MutationObserver: add a check that iterating registration still exists in original set (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comment Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 records.swap(m_records); 149 records.swap(m_records);
150 InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionCo ntext(), this); 150 InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionCo ntext(), this);
151 return records; 151 return records;
152 } 152 }
153 153
154 void MutationObserver::disconnect() 154 void MutationObserver::disconnect()
155 { 155 {
156 m_records.clear(); 156 m_records.clear();
157 InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionCo ntext(), this); 157 InspectorInstrumentation::didClearAllMutationRecords(m_callback->executionCo ntext(), this);
158 MutationObserverRegistrationSet registrations(m_registrations); 158 MutationObserverRegistrationSet registrations(m_registrations);
159 for (auto& registration : registrations) 159 for (auto& registration : registrations) {
160 registration->unregister(); 160 // The registration may be already unregistered while iteration.
161 // Only call unregister if it is still in the original set.
162 if (m_registrations.contains(registration))
163 registration->unregister();
164 }
161 ASSERT(m_registrations.isEmpty()); 165 ASSERT(m_registrations.isEmpty());
162 } 166 }
163 167
164 void MutationObserver::observationStarted(MutationObserverRegistration* registra tion) 168 void MutationObserver::observationStarted(MutationObserverRegistration* registra tion)
165 { 169 {
166 ASSERT(!m_registrations.contains(registration)); 170 ASSERT(!m_registrations.contains(registration));
167 m_registrations.add(registration); 171 m_registrations.add(registration);
168 } 172 }
169 173
170 void MutationObserver::observationEnded(MutationObserverRegistration* registrati on) 174 void MutationObserver::observationEnded(MutationObserverRegistration* registrati on)
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 { 284 {
281 #if ENABLE(OILPAN) 285 #if ENABLE(OILPAN)
282 visitor->trace(m_callback); 286 visitor->trace(m_callback);
283 visitor->trace(m_records); 287 visitor->trace(m_records);
284 visitor->trace(m_registrations); 288 visitor->trace(m_registrations);
285 visitor->trace(m_callback); 289 visitor->trace(m_callback);
286 #endif 290 #endif
287 } 291 }
288 292
289 } // namespace blink 293 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698