diff --git a/content/base/public/FragmentOrElement.h b/content/base/public/FragmentOrElement.h index c53bf789467..95c7299a697 100644 --- a/content/base/public/FragmentOrElement.h +++ b/content/base/public/FragmentOrElement.h @@ -412,7 +412,7 @@ public: /** * Web components custom element data. */ - nsAutoPtr mCustomElementData; + nsRefPtr mCustomElementData; }; protected: diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 9d06af8500b..18833741570 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -5844,12 +5844,7 @@ nsDocument::ProcessTopElementQueue(bool aIsBaseQueue) { MOZ_ASSERT(nsContentUtils::IsSafeToRunScript()); - if (sProcessingStack.isNothing()) { - // If XPCOM shutdown has reset the processing stack, don't do anything. - return; - } - - nsTArray& stack = *sProcessingStack; + nsTArray>& stack = *sProcessingStack; uint32_t firstQueue = stack.LastIndexOf((CustomElementData*) nullptr); if (aIsBaseQueue && firstQueue != 0) { @@ -5886,7 +5881,7 @@ nsDocument::RegisterEnabled() } // static -Maybe> +Maybe>> nsDocument::sProcessingStack; // static diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index dcb52223036..3a9f8a3deab 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -325,6 +325,8 @@ private: // being created flag. struct CustomElementData { + NS_INLINE_DECL_REFCOUNTING(CustomElementData) + explicit CustomElementData(nsIAtom* aType); // Objects in this array are transient and empty after each microtask // checkpoint. @@ -346,6 +348,9 @@ struct CustomElementData // Empties the callback queue. void RunCallbackQueue(); + +private: + virtual ~CustomElementData() {} }; // The required information for a custom element as defined in: @@ -1520,7 +1525,7 @@ private: // CustomElementData in this array, separated by nullptr that // represent the boundaries of the items in the stack. The first // queue in the stack is the base element queue. - static mozilla::Maybe> sProcessingStack; + static mozilla::Maybe>> sProcessingStack; // Flag to prevent re-entrance into base element queue as described in the // custom elements speicification.