summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/CustomElementRegistry.cpp1
-rw-r--r--dom/base/nsContentUtils.cpp46
-rw-r--r--dom/base/nsContentUtils.h25
-rw-r--r--dom/base/nsDocument.cpp13
-rw-r--r--dom/base/nsJSUtils.cpp11
5 files changed, 18 insertions, 78 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index 2d7907bd7..ab1e60366 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -6,6 +6,7 @@
#include "mozilla/dom/CustomElementRegistry.h"
+#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/CustomElementRegistryBinding.h"
#include "mozilla/dom/HTMLElementBinding.h"
#include "mozilla/dom/WebComponentsBinding.h"
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index 87c879746..402dfd1c5 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -259,7 +259,6 @@ nsIWordBreaker *nsContentUtils::sWordBreaker;
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
uint32_t nsContentUtils::sScriptBlockerCount = 0;
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
-uint32_t nsContentUtils::sMicroTaskLevel = 0;
AutoTArray<nsCOMPtr<nsIRunnable>, 8>* nsContentUtils::sBlockedScriptRunners = nullptr;
uint32_t nsContentUtils::sRunnersCountAtFirstBlocker = 0;
nsIInterfaceRequestor* nsContentUtils::sSameOriginChecker = nullptr;
@@ -5302,51 +5301,6 @@ nsContentUtils::RunInMetastableState(already_AddRefed<nsIRunnable> aRunnable)
CycleCollectedJSContext::Get()->RunInMetastableState(Move(aRunnable));
}
-void
-nsContentUtils::EnterMicroTask()
-{
- MOZ_ASSERT(NS_IsMainThread());
- ++sMicroTaskLevel;
-}
-
-void
-nsContentUtils::LeaveMicroTask()
-{
- MOZ_ASSERT(NS_IsMainThread());
- if (--sMicroTaskLevel == 0) {
- PerformMainThreadMicroTaskCheckpoint();
- }
-}
-
-bool
-nsContentUtils::IsInMicroTask()
-{
- MOZ_ASSERT(NS_IsMainThread());
- return sMicroTaskLevel != 0;
-}
-
-uint32_t
-nsContentUtils::MicroTaskLevel()
-{
- MOZ_ASSERT(NS_IsMainThread());
- return sMicroTaskLevel;
-}
-
-void
-nsContentUtils::SetMicroTaskLevel(uint32_t aLevel)
-{
- MOZ_ASSERT(NS_IsMainThread());
- sMicroTaskLevel = aLevel;
-}
-
-void
-nsContentUtils::PerformMainThreadMicroTaskCheckpoint()
-{
- MOZ_ASSERT(NS_IsMainThread());
-
- nsDOMMutationObserver::HandleMutations();
-}
-
/*
* Helper function for nsContentUtils::ProcessViewportInfo.
*
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
index 19b007591..4200a0621 100644
--- a/dom/base/nsContentUtils.h
+++ b/dom/base/nsContentUtils.h
@@ -1740,17 +1740,6 @@ public:
*/
static void RunInMetastableState(already_AddRefed<nsIRunnable> aRunnable);
- // Call EnterMicroTask when you're entering JS execution.
- // Usually the best way to do this is to use nsAutoMicroTask.
- static void EnterMicroTask();
- static void LeaveMicroTask();
-
- static bool IsInMicroTask();
- static uint32_t MicroTaskLevel();
- static void SetMicroTaskLevel(uint32_t aLevel);
-
- static void PerformMainThreadMicroTaskCheckpoint();
-
/* Process viewport META data. This gives us information for the scale
* and zoom of a page on mobile devices. We stick the information in
* the document header and use it later on after rendering.
@@ -2850,7 +2839,6 @@ private:
static bool sInitialized;
static uint32_t sScriptBlockerCount;
static uint32_t sDOMNodeRemovedSuppressCount;
- static uint32_t sMicroTaskLevel;
// Not an nsCOMArray because removing elements from those is slower
static AutoTArray<nsCOMPtr<nsIRunnable>, 8>* sBlockedScriptRunners;
static uint32_t sRunnersCountAtFirstBlocker;
@@ -2928,19 +2916,6 @@ public:
}
};
-class MOZ_STACK_CLASS nsAutoMicroTask
-{
-public:
- nsAutoMicroTask()
- {
- nsContentUtils::EnterMicroTask();
- }
- ~nsAutoMicroTask()
- {
- nsContentUtils::LeaveMicroTask();
- }
-};
-
namespace mozilla {
namespace dom {
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index f3e492589..293e48eb0 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -12610,8 +12610,12 @@ MarkDocumentTreeToBeInSyncOperation(nsIDocument* aDoc, void* aData)
nsAutoSyncOperation::nsAutoSyncOperation(nsIDocument* aDoc)
{
- mMicroTaskLevel = nsContentUtils::MicroTaskLevel();
- nsContentUtils::SetMicroTaskLevel(0);
+ mMicroTaskLevel = 0;
+ CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
+ if (ccjs) {
+ mMicroTaskLevel = ccjs->MicroTaskLevel();
+ ccjs->SetMicroTaskLevel(0);
+ }
if (aDoc) {
if (nsPIDOMWindowOuter* win = aDoc->GetWindow()) {
if (nsCOMPtr<nsPIDOMWindowOuter> top = win->GetTop()) {
@@ -12627,7 +12631,10 @@ nsAutoSyncOperation::~nsAutoSyncOperation()
for (int32_t i = 0; i < mDocuments.Count(); ++i) {
mDocuments[i]->SetIsInSyncOperation(false);
}
- nsContentUtils::SetMicroTaskLevel(mMicroTaskLevel);
+ CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get();
+ if (ccjs) {
+ ccjs->SetMicroTaskLevel(mMicroTaskLevel);
+ }
}
gfxUserFontSet*
diff --git a/dom/base/nsJSUtils.cpp b/dom/base/nsJSUtils.cpp
index 98b367b66..b6c843065 100644
--- a/dom/base/nsJSUtils.cpp
+++ b/dom/base/nsJSUtils.cpp
@@ -25,7 +25,7 @@
#include "xpcpublic.h"
#include "nsContentUtils.h"
#include "nsGlobalWindow.h"
-
+#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Date.h"
#include "mozilla/dom/Element.h"
@@ -159,7 +159,8 @@ nsJSUtils::EvaluateString(JSContext* aCx,
aEvaluationGlobal);
MOZ_ASSERT_IF(aOffThreadToken, aCompileOptions.noScriptRval);
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(nsContentUtils::IsInMicroTask());
+ MOZ_ASSERT(CycleCollectedJSContext::Get() &&
+ CycleCollectedJSContext::Get()->MicroTaskLevel());
// Unfortunately, the JS engine actually compiles scripts with a return value
// in a different, less efficient way. Furthermore, it can't JIT them in many
@@ -293,7 +294,8 @@ nsJSUtils::CompileModule(JSContext* aCx,
aEvaluationGlobal);
MOZ_ASSERT(JS::CurrentGlobalOrNull(aCx) == aEvaluationGlobal);
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(nsContentUtils::IsInMicroTask());
+ MOZ_ASSERT(CycleCollectedJSContext::Get() &&
+ CycleCollectedJSContext::Get()->MicroTaskLevel());
NS_ENSURE_TRUE(xpc::Scriptability::Get(aEvaluationGlobal).Allowed(), NS_OK);
@@ -330,7 +332,8 @@ nsJSUtils::ModuleEvaluation(JSContext* aCx, JS::Handle<JSObject*> aModule)
MOZ_ASSERT(aCx == nsContentUtils::GetCurrentJSContext());
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(nsContentUtils::IsInMicroTask());
+ MOZ_ASSERT(CycleCollectedJSContext::Get() &&
+ CycleCollectedJSContext::Get()->MicroTaskLevel());
NS_ENSURE_TRUE(xpc::Scriptability::Get(aModule).Allowed(), NS_OK);