From 7cfc82e138a9e6eddd09874e2592e682bfd38628 Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Fri, 3 Nov 2017 17:38:46 +0800 Subject: [PATCH] Bug 1419305 - Part 1: Use MicroTask on CustomElements correctly; r=smaug MozReview-Commit-ID: EPMfr6hr5fS --HG-- extra : rebase_source : 51784f7d8b74978847901f57f23730fb0f547ce5 --- dom/base/CustomElementRegistry.cpp | 5 ++--- dom/base/CustomElementRegistry.h | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index ee421eb360f8..a4cdfcf12b5d 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -1018,9 +1018,8 @@ CustomElementReactionsStack::Enqueue(Element* aElement, } CycleCollectedJSContext* context = CycleCollectedJSContext::Get(); - RefPtr processBackupQueueRunnable = - new ProcessBackupQueueRunnable(this); - context->DispatchToMicroTask(processBackupQueueRunnable.forget()); + RefPtr bqmt = new BackupQueueMicroTask(this); + context->DispatchMicroTaskRunnable(bqmt.forget()); } void diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 72174be12be0..37da2aee2f96 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -313,12 +313,11 @@ private: void Enqueue(Element* aElement, CustomElementReaction* aReaction); private: - class ProcessBackupQueueRunnable : public mozilla::Runnable { + class BackupQueueMicroTask final : public mozilla::MicroTaskRunnable { public: - explicit ProcessBackupQueueRunnable( + explicit BackupQueueMicroTask( CustomElementReactionsStack* aReactionStack) - : Runnable( - "dom::CustomElementReactionsStack::ProcessBackupQueueRunnable") + : MicroTaskRunnable() , mReactionStack(aReactionStack) { MOZ_ASSERT(!mReactionStack->mIsBackupQueueProcessing, @@ -326,11 +325,10 @@ private: mReactionStack->mIsBackupQueueProcessing = true; } - NS_IMETHOD Run() override + virtual void Run(AutoSlowOperation& aAso) override { mReactionStack->InvokeBackupQueue(); mReactionStack->mIsBackupQueueProcessing = false; - return NS_OK; } private: