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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 m_registrations.insert(registration); | 160 m_registrations.insert(registration); |
161 } | 161 } |
162 | 162 |
163 void MutationObserver::observationEnded( | 163 void MutationObserver::observationEnded( |
164 MutationObserverRegistration* registration) { | 164 MutationObserverRegistration* registration) { |
165 DCHECK(m_registrations.contains(registration)); | 165 DCHECK(m_registrations.contains(registration)); |
166 m_registrations.remove(registration); | 166 m_registrations.remove(registration); |
167 } | 167 } |
168 | 168 |
169 static MutationObserverSet& activeMutationObservers() { | 169 static MutationObserverSet& activeMutationObservers() { |
| 170 ALLOW_UNSAFE_SINGLETON() |
170 DEFINE_STATIC_LOCAL(MutationObserverSet, activeObservers, | 171 DEFINE_STATIC_LOCAL(MutationObserverSet, activeObservers, |
171 (new MutationObserverSet)); | 172 (new MutationObserverSet)); |
172 return activeObservers; | 173 return activeObservers; |
173 } | 174 } |
174 | 175 |
175 using SlotChangeList = HeapVector<Member<HTMLSlotElement>>; | 176 using SlotChangeList = HeapVector<Member<HTMLSlotElement>>; |
176 | 177 |
177 // TODO(hayato): We should have a SlotChangeList for each unit of related | 178 // TODO(hayato): We should have a SlotChangeList for each unit of related |
178 // similar-origin browsing context. | 179 // similar-origin browsing context. |
179 // https://html.spec.whatwg.org/multipage/browsers.html#unit-of-related-similar-
origin-browsing-contexts | 180 // https://html.spec.whatwg.org/multipage/browsers.html#unit-of-related-similar-
origin-browsing-contexts |
180 static SlotChangeList& activeSlotChangeList() { | 181 static SlotChangeList& activeSlotChangeList() { |
| 182 ALLOW_UNSAFE_SINGLETON() |
181 DEFINE_STATIC_LOCAL(SlotChangeList, slotChangeList, (new SlotChangeList)); | 183 DEFINE_STATIC_LOCAL(SlotChangeList, slotChangeList, (new SlotChangeList)); |
182 return slotChangeList; | 184 return slotChangeList; |
183 } | 185 } |
184 | 186 |
185 static MutationObserverSet& suspendedMutationObservers() { | 187 static MutationObserverSet& suspendedMutationObservers() { |
| 188 ALLOW_UNSAFE_SINGLETON() |
186 DEFINE_STATIC_LOCAL(MutationObserverSet, suspendedObservers, | 189 DEFINE_STATIC_LOCAL(MutationObserverSet, suspendedObservers, |
187 (new MutationObserverSet)); | 190 (new MutationObserverSet)); |
188 return suspendedObservers; | 191 return suspendedObservers; |
189 } | 192 } |
190 | 193 |
191 static void ensureEnqueueMicrotask() { | 194 static void ensureEnqueueMicrotask() { |
192 if (activeMutationObservers().isEmpty() && activeSlotChangeList().isEmpty()) | 195 if (activeMutationObservers().isEmpty() && activeSlotChangeList().isEmpty()) |
193 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutations)); | 196 Microtask::enqueueMicrotask(WTF::bind(&MutationObserver::deliverMutations)); |
194 } | 197 } |
195 | 198 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 315 } |
313 | 316 |
314 DEFINE_TRACE(MutationObserver) { | 317 DEFINE_TRACE(MutationObserver) { |
315 visitor->trace(m_callback); | 318 visitor->trace(m_callback); |
316 visitor->trace(m_records); | 319 visitor->trace(m_records); |
317 visitor->trace(m_registrations); | 320 visitor->trace(m_registrations); |
318 visitor->trace(m_callback); | 321 visitor->trace(m_callback); |
319 } | 322 } |
320 | 323 |
321 } // namespace blink | 324 } // namespace blink |
OLD | NEW |