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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |