Bug 1698238 return default dictionary from GetUserMediaRequest#getConstraints() if...
[gecko.git] / dom / animation / CSSPseudoElement.h
blob6bf8dbaa09772e07ca68f0189ab2828c1db877c4
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_CSSPseudoElement_h
8 #define mozilla_dom_CSSPseudoElement_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/dom/BindingDeclarations.h"
13 #include "mozilla/RefPtr.h"
14 #include "nsCSSPseudoElements.h"
15 #include "nsWrapperCache.h"
17 namespace mozilla {
18 namespace dom {
20 class Animation;
21 class Element;
22 class UnrestrictedDoubleOrKeyframeAnimationOptions;
24 class CSSPseudoElement final : public nsWrapperCache {
25 public:
26 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CSSPseudoElement)
27 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CSSPseudoElement)
29 protected:
30 virtual ~CSSPseudoElement();
32 public:
33 ParentObject GetParentObject() const;
35 virtual JSObject* WrapObject(JSContext* aCx,
36 JS::Handle<JSObject*> aGivenProto) override;
38 PseudoStyleType GetType() const { return mPseudoType; }
39 void GetType(nsString& aRetVal) const {
40 MOZ_ASSERT(nsCSSPseudoElements::GetPseudoAtom(mPseudoType),
41 "All pseudo-types allowed by this class should have a"
42 " corresponding atom");
43 // Our atoms use one colon and we would like to return two colons syntax
44 // for the returned pseudo type string, so serialize this to the
45 // non-deprecated two colon syntax.
46 aRetVal.Assign(char16_t(':'));
47 aRetVal.Append(
48 nsDependentAtomString(nsCSSPseudoElements::GetPseudoAtom(mPseudoType)));
50 dom::Element* Element() const { return mOriginatingElement.get(); }
52 // Given an element:pseudoType pair, returns the CSSPseudoElement stored as a
53 // property on |aElement|. If there is no CSSPseudoElement for the specified
54 // pseudo-type on element, a new CSSPseudoElement will be created and stored
55 // on the element.
56 static already_AddRefed<CSSPseudoElement> GetCSSPseudoElement(
57 dom::Element* aElement, PseudoStyleType aType);
59 private:
60 // Only ::before, ::after and ::marker are supported.
61 CSSPseudoElement(dom::Element* aElement, PseudoStyleType aType);
63 static nsAtom* GetCSSPseudoElementPropertyAtom(PseudoStyleType aType);
65 // mOriginatingElement needs to be an owning reference since if script is
66 // holding on to the pseudo-element, it needs to continue to be able to refer
67 // to the originating element.
68 RefPtr<dom::Element> mOriginatingElement;
69 PseudoStyleType mPseudoType;
72 } // namespace dom
73 } // namespace mozilla
75 #endif // mozilla_dom_CSSPseudoElement_h