From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- dom/base/CustomElementRegistry.h | 259 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 dom/base/CustomElementRegistry.h (limited to 'dom/base/CustomElementRegistry.h') diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h new file mode 100644 index 000000000..ff803a054 --- /dev/null +++ b/dom/base/CustomElementRegistry.h @@ -0,0 +1,259 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_CustomElementRegistry_h +#define mozilla_dom_CustomElementRegistry_h + +#include "js/TypeDecls.h" +#include "mozilla/Attributes.h" +#include "mozilla/ErrorResult.h" +#include "mozilla/dom/BindingDeclarations.h" +#include "nsCycleCollectionParticipant.h" +#include "nsWrapperCache.h" +#include "mozilla/dom/FunctionBinding.h" + +class nsDocument; + +namespace mozilla { +namespace dom { + +struct CustomElementData; +struct ElementDefinitionOptions; +struct LifecycleCallbacks; +class CallbackFunction; +class Function; +class Promise; + +struct LifecycleCallbackArgs +{ + nsString name; + nsString oldValue; + nsString newValue; +}; + +class CustomElementCallback +{ +public: + CustomElementCallback(Element* aThisObject, + nsIDocument::ElementCallbackType aCallbackType, + CallbackFunction* aCallback, + CustomElementData* aOwnerData); + void Traverse(nsCycleCollectionTraversalCallback& aCb) const; + void Call(); + void SetArgs(LifecycleCallbackArgs& aArgs) + { + MOZ_ASSERT(mType == nsIDocument::eAttributeChanged, + "Arguments are only used by attribute changed callback."); + mArgs = aArgs; + } + +private: + // The this value to use for invocation of the callback. + RefPtr mThisObject; + RefPtr mCallback; + // The type of callback (eCreated, eAttached, etc.) + nsIDocument::ElementCallbackType mType; + // Arguments to be passed to the callback, + // used by the attribute changed callback. + LifecycleCallbackArgs mArgs; + // CustomElementData that contains this callback in the + // callback queue. + CustomElementData* mOwnerData; +}; + +// Each custom element has an associated callback queue and an element is +// 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. + nsTArray> mCallbackQueue; + // Custom element type, for