Bug 1421170 - Move the declarations of CustomElementUpgradeReaction and CustomElementCallbackReaction to CustomElementRegistry.cpp;
The CustomElementUpgradeReaction and CustomElementCallbackReaction are only used inside CustomElementRegistry.cpp,
so we don't need to expose them in header file.
MozReview-Commit-ID: 9lYwHeFIODi
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -13,16 +13,67 @@
#include "mozilla/dom/WebComponentsBinding.h"
#include "mozilla/dom/DocGroup.h"
#include "nsHTMLTags.h"
#include "jsapi.h"
namespace mozilla {
namespace dom {
+//-----------------------------------------------------
+// CustomElementUpgradeReaction
+
+class CustomElementUpgradeReaction final : public CustomElementReaction
+{
+public:
+ explicit CustomElementUpgradeReaction(CustomElementDefinition* aDefinition)
+ : mDefinition(aDefinition)
+ {
+#if DEBUG
+ mIsUpgradeReaction = true;
+#endif
+ }
+
+private:
+ virtual void Invoke(Element* aElement, ErrorResult& aRv) override
+ {
+ CustomElementRegistry::Upgrade(aElement, mDefinition, aRv);
+ }
+
+ CustomElementDefinition* mDefinition;
+};
+
+//-----------------------------------------------------
+// CustomElementCallbackReaction
+
+class CustomElementCallbackReaction final : public CustomElementReaction
+{
+ public:
+ explicit CustomElementCallbackReaction(UniquePtr<CustomElementCallback> aCustomElementCallback)
+ : mCustomElementCallback(Move(aCustomElementCallback))
+ {
+ }
+
+ virtual void Traverse(nsCycleCollectionTraversalCallback& aCb) const override
+ {
+ mCustomElementCallback->Traverse(aCb);
+ }
+
+ private:
+ virtual void Invoke(Element* aElement, ErrorResult& aRv) override
+ {
+ mCustomElementCallback->Call();
+ }
+
+ UniquePtr<CustomElementCallback> mCustomElementCallback;
+};
+
+//-----------------------------------------------------
+// CustomElementCallback
+
void
CustomElementCallback::Call()
{
IgnoredErrorResult rv;
switch (mType) {
case nsIDocument::eConnected:
static_cast<LifecycleConnectedCallback *>(mCallback.get())->Call(mThisObject, rv);
break;
@@ -82,16 +133,17 @@ CustomElementConstructor::Construct(cons
RefPtr<Element> element;
if (NS_FAILED(UNWRAP_OBJECT(Element, &result, element))) {
return nullptr;
}
return element.forget();
}
+
//-----------------------------------------------------
// CustomElementData
CustomElementData::CustomElementData(nsAtom* aType)
: CustomElementData(aType, CustomElementData::State::eUndefined)
{
}
@@ -1142,29 +1194,10 @@ CustomElementDefinition::CustomElementDe
mConstructor(new CustomElementConstructor(aConstructor)),
mObservedAttributes(Move(aObservedAttributes)),
mPrototype(aPrototype),
mCallbacks(aCallbacks),
mDocOrder(aDocOrder)
{
}
-
-//-----------------------------------------------------
-// CustomElementUpgradeReaction
-
-/* virtual */ void
-CustomElementUpgradeReaction::Invoke(Element* aElement, ErrorResult& aRv)
-{
- CustomElementRegistry::Upgrade(aElement, mDefinition, aRv);
-}
-
-//-----------------------------------------------------
-// CustomElementCallbackReaction
-
-/* virtual */ void
-CustomElementCallbackReaction::Invoke(Element* aElement, ErrorResult& aRv)
-{
- mCustomElementCallback->Call();
-}
-
} // namespace dom
} // namespace mozilla
--- a/dom/base/CustomElementRegistry.h
+++ b/dom/base/CustomElementRegistry.h
@@ -212,51 +212,16 @@ public:
return mIsUpgradeReaction;
}
protected:
bool mIsUpgradeReaction = false;
#endif
};
-class CustomElementUpgradeReaction final : public CustomElementReaction
-{
-public:
- explicit CustomElementUpgradeReaction(CustomElementDefinition* aDefinition)
- : mDefinition(aDefinition)
- {
-#if DEBUG
- mIsUpgradeReaction = true;
-#endif
- }
-
-private:
- virtual void Invoke(Element* aElement, ErrorResult& aRv) override;
-
- CustomElementDefinition* mDefinition;
-};
-
-class CustomElementCallbackReaction final : public CustomElementReaction
-{
- public:
- explicit CustomElementCallbackReaction(UniquePtr<CustomElementCallback> aCustomElementCallback)
- : mCustomElementCallback(Move(aCustomElementCallback))
- {
- }
-
- virtual void Traverse(nsCycleCollectionTraversalCallback& aCb) const override
- {
- mCustomElementCallback->Traverse(aCb);
- }
-
- private:
- virtual void Invoke(Element* aElement, ErrorResult& aRv) override;
- UniquePtr<CustomElementCallback> mCustomElementCallback;
-};
-
// https://html.spec.whatwg.org/multipage/scripting.html#custom-element-reactions-stack
class CustomElementReactionsStack
{
public:
NS_INLINE_DECL_REFCOUNTING(CustomElementReactionsStack)
CustomElementReactionsStack()
: mIsBackupQueueProcessing(false)