Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / svg / DOMSVGAngle.h
blobed2cb23b64a16672631e65d1210eb0e028906444
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 DOM_SVG_DOMSVGANGLE_H_
8 #define DOM_SVG_DOMSVGANGLE_H_
10 #include "nsWrapperCache.h"
11 #include "SVGElement.h"
12 #include "mozilla/Attributes.h"
14 namespace mozilla {
16 class SVGAnimatedOrient;
18 namespace dom {
19 class SVGSVGElement;
21 class DOMSVGAngle final : public nsWrapperCache {
22 public:
23 enum class AngleType : int8_t { BaseValue, AnimValue, CreatedValue };
25 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGAngle)
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGAngle)
28 /**
29 * Generic ctor for DOMSVGAngle objects that are created for an attribute.
31 DOMSVGAngle(SVGAnimatedOrient* aVal, SVGElement* aSVGElement, AngleType aType)
32 : mVal(aVal), mSVGElement(aSVGElement), mType(aType) {}
34 /**
35 * Ctor for creating the objects returned by SVGSVGElement.createSVGAngle(),
36 * which do not initially belong to an attribute.
38 explicit DOMSVGAngle(SVGSVGElement* aSVGElement);
40 // WebIDL
41 SVGElement* GetParentObject() { return mSVGElement; }
42 JSObject* WrapObject(JSContext* aCx,
43 JS::Handle<JSObject*> aGivenProto) override;
44 uint16_t UnitType() const;
45 float Value() const;
46 void GetValueAsString(nsAString& aValue);
47 void SetValue(float aValue, ErrorResult& rv);
48 float ValueInSpecifiedUnits() const;
49 void SetValueInSpecifiedUnits(float aValue, ErrorResult& rv);
50 void SetValueAsString(const nsAString& aValue, ErrorResult& rv);
51 void NewValueSpecifiedUnits(uint16_t unitType, float value, ErrorResult& rv);
52 void ConvertToSpecifiedUnits(uint16_t unitType, ErrorResult& rv);
54 protected:
55 ~DOMSVGAngle();
57 SVGAnimatedOrient* mVal; // if mType is CreatedValue, we own the angle.
58 // Otherwise, the element does.
59 RefPtr<SVGElement> mSVGElement;
60 AngleType mType;
63 } // namespace dom
64 } // namespace mozilla
66 #endif // DOM_SVG_DOMSVGANGLE_H_