| Index: third_party/WebKit/Source/core/dom/MutationObserver.cpp
|
| diff --git a/third_party/WebKit/Source/core/dom/MutationObserver.cpp b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
|
| index 5ba305a1067c2855facb56d94d4f3cdd3ace9420..7ac89771cb61f884e0e01ecb5c0d4d41168466af 100644
|
| --- a/third_party/WebKit/Source/core/dom/MutationObserver.cpp
|
| +++ b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
|
| @@ -69,8 +69,7 @@ MutationObserver::~MutationObserver()
|
| #if !ENABLE(OILPAN)
|
| ASSERT(m_registrations.isEmpty());
|
| #endif
|
| - if (!m_records.isEmpty())
|
| - InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
|
| + cancelInspectorAsyncTasks();
|
| }
|
|
|
| void MutationObserver::observe(Node* node, const MutationObserverInit& observerInit, ExceptionState& exceptionState)
|
| @@ -133,15 +132,15 @@ void MutationObserver::observe(Node* node, const MutationObserverInit& observerI
|
| MutationRecordVector MutationObserver::takeRecords()
|
| {
|
| MutationRecordVector records;
|
| + cancelInspectorAsyncTasks();
|
| records.swap(m_records);
|
| - InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
|
| return records;
|
| }
|
|
|
| void MutationObserver::disconnect()
|
| {
|
| + cancelInspectorAsyncTasks();
|
| m_records.clear();
|
| - InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
|
| MutationObserverRegistrationSet registrations(m_registrations);
|
| for (auto& registration : registrations) {
|
| // The registration may be already unregistered while iteration.
|
| @@ -189,7 +188,7 @@ void MutationObserver::enqueueMutationRecord(RawPtr<MutationRecord> mutation)
|
| ASSERT(isMainThread());
|
| m_records.append(mutation);
|
| activateObserver(this);
|
| - InspectorInstrumentation::didEnqueueMutationRecord(m_callback->getExecutionContext(), this);
|
| + InspectorInstrumentation::scheduleAsyncTask(m_callback->getExecutionContext(), "Mutation", mutation);
|
| }
|
|
|
| void MutationObserver::setHasTransientRegistration()
|
| @@ -211,6 +210,12 @@ bool MutationObserver::shouldBeSuspended() const
|
| return m_callback->getExecutionContext() && m_callback->getExecutionContext()->activeDOMObjectsAreSuspended();
|
| }
|
|
|
| +void MutationObserver::cancelInspectorAsyncTasks()
|
| +{
|
| + for (auto& record : m_records)
|
| + InspectorInstrumentation::cancelAsyncTask(m_callback->getExecutionContext(), record);
|
| +}
|
| +
|
| void MutationObserver::deliver()
|
| {
|
| ASSERT(!shouldBeSuspended());
|
| @@ -231,9 +236,15 @@ void MutationObserver::deliver()
|
| MutationRecordVector records;
|
| records.swap(m_records);
|
|
|
| - InspectorInstrumentation::willDeliverMutationRecords(m_callback->getExecutionContext(), this);
|
| + if (InspectorInstrumentation::hasFrontends()) {
|
| + for (size_t i = 0; i < m_records.size(); ++i)
|
| + InspectorInstrumentation::asyncTaskStarted(m_callback->getExecutionContext(), m_records[i]);
|
| + }
|
| m_callback->call(records, this);
|
| - InspectorInstrumentation::didDeliverMutationRecords(m_callback->getExecutionContext());
|
| + if (InspectorInstrumentation::hasFrontends()) {
|
| + for (size_t i = m_records.size(); i > 0; --i)
|
| + InspectorInstrumentation::asyncTaskFinished(m_callback->getExecutionContext(), m_records[i - 1]);
|
| + }
|
| }
|
|
|
| void MutationObserver::resumeSuspendedObservers()
|
|
|