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 24 matching lines...) Expand all Loading... | |
35 #include "bindings/v8/Dictionary.h" | 35 #include "bindings/v8/Dictionary.h" |
36 #include "bindings/v8/ExceptionState.h" | 36 #include "bindings/v8/ExceptionState.h" |
37 #include "core/dom/Document.h" | 37 #include "core/dom/Document.h" |
38 #include "core/dom/ExceptionCode.h" | 38 #include "core/dom/ExceptionCode.h" |
39 #include "core/dom/Microtask.h" | 39 #include "core/dom/Microtask.h" |
40 #include "core/dom/MutationCallback.h" | 40 #include "core/dom/MutationCallback.h" |
41 #include "core/dom/MutationObserverRegistration.h" | 41 #include "core/dom/MutationObserverRegistration.h" |
42 #include "core/dom/MutationRecord.h" | 42 #include "core/dom/MutationRecord.h" |
43 #include "core/dom/Node.h" | 43 #include "core/dom/Node.h" |
44 #include "core/inspector/InspectorInstrumentation.h" | 44 #include "core/inspector/InspectorInstrumentation.h" |
45 #include "platform/Task.h" | |
45 #include "wtf/MainThread.h" | 46 #include "wtf/MainThread.h" |
46 | 47 |
47 namespace WebCore { | 48 namespace WebCore { |
48 | 49 |
49 static unsigned s_observerPriority = 0; | 50 static unsigned s_observerPriority = 0; |
50 | 51 |
51 struct MutationObserver::ObserverLessThan { | 52 struct MutationObserver::ObserverLessThan { |
52 bool operator()(const RefPtr<MutationObserver>& lhs, const RefPtr<MutationOb server>& rhs) | 53 bool operator()(const RefPtr<MutationObserver>& lhs, const RefPtr<MutationOb server>& rhs) |
53 { | 54 { |
54 return lhs->m_priority < rhs->m_priority; | 55 return lhs->m_priority < rhs->m_priority; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 180 |
180 static MutationObserverSet& suspendedMutationObservers() | 181 static MutationObserverSet& suspendedMutationObservers() |
181 { | 182 { |
182 DEFINE_STATIC_LOCAL(MutationObserverSet, suspendedObservers, ()); | 183 DEFINE_STATIC_LOCAL(MutationObserverSet, suspendedObservers, ()); |
183 return suspendedObservers; | 184 return suspendedObservers; |
184 } | 185 } |
185 | 186 |
186 static void activateObserver(PassRefPtr<MutationObserver> observer) | 187 static void activateObserver(PassRefPtr<MutationObserver> observer) |
187 { | 188 { |
188 if (activeMutationObservers().isEmpty()) | 189 if (activeMutationObservers().isEmpty()) |
189 Microtask::enqueueMicrotask(&MutationObserver::deliverMutations); | 190 Microtask::enqueueMicrotask(new Task(WTF::bind(&MutationObserver::delive rMutations))); |
abarth-chromium
2014/04/18 16:01:04
Maybe Microtask::enqueueMicrotask should have an o
| |
190 | 191 |
191 activeMutationObservers().add(observer); | 192 activeMutationObservers().add(observer); |
192 } | 193 } |
193 | 194 |
194 void MutationObserver::enqueueMutationRecord(PassRefPtr<MutationRecord> mutation ) | 195 void MutationObserver::enqueueMutationRecord(PassRefPtr<MutationRecord> mutation ) |
195 { | 196 { |
196 ASSERT(isMainThread()); | 197 ASSERT(isMainThread()); |
197 m_records.append(mutation); | 198 m_records.append(mutation); |
198 activateObserver(this); | 199 activateObserver(this); |
199 InspectorInstrumentation::didEnqueueMutationRecord(m_callback->executionCont ext(), this); | 200 InspectorInstrumentation::didEnqueueMutationRecord(m_callback->executionCont ext(), this); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 std::sort(observers.begin(), observers.end(), ObserverLessThan()); | 269 std::sort(observers.begin(), observers.end(), ObserverLessThan()); |
269 for (size_t i = 0; i < observers.size(); ++i) { | 270 for (size_t i = 0; i < observers.size(); ++i) { |
270 if (observers[i]->canDeliver()) | 271 if (observers[i]->canDeliver()) |
271 observers[i]->deliver(); | 272 observers[i]->deliver(); |
272 else | 273 else |
273 suspendedMutationObservers().add(observers[i]); | 274 suspendedMutationObservers().add(observers[i]); |
274 } | 275 } |
275 } | 276 } |
276 | 277 |
277 } // namespace WebCore | 278 } // namespace WebCore |
OLD | NEW |