DOMSVGAngle.h (2201B)
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/. */ 6 7 #ifndef DOM_SVG_DOMSVGANGLE_H_ 8 #define DOM_SVG_DOMSVGANGLE_H_ 9 10 #include "SVGElement.h" 11 #include "nsWrapperCache.h" 12 13 namespace mozilla { 14 15 class SVGAnimatedOrient; 16 17 namespace dom { 18 class SVGSVGElement; 19 20 class DOMSVGAngle final : public nsWrapperCache { 21 public: 22 enum class AngleType : int8_t { BaseValue, AnimValue, CreatedValue }; 23 24 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMSVGAngle) 25 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DOMSVGAngle) 26 27 /** 28 * Generic ctor for DOMSVGAngle objects that are created for an attribute. 29 */ 30 DOMSVGAngle(SVGAnimatedOrient* aVal, SVGElement* aSVGElement, AngleType aType) 31 : mVal(aVal), mSVGElement(aSVGElement), mType(aType) {} 32 33 /** 34 * Ctor for creating the objects returned by SVGSVGElement.createSVGAngle(), 35 * which do not initially belong to an attribute. 36 */ 37 explicit DOMSVGAngle(SVGSVGElement* aSVGElement); 38 39 // WebIDL 40 SVGElement* GetParentObject() { return mSVGElement; } 41 JSObject* WrapObject(JSContext* aCx, 42 JS::Handle<JSObject*> aGivenProto) override; 43 uint16_t UnitType() const; 44 float Value() const; 45 void GetValueAsString(nsAString& aValue); 46 void SetValue(float aValue, ErrorResult& aRv); 47 float ValueInSpecifiedUnits() const; 48 void SetValueInSpecifiedUnits(float aValue, ErrorResult& aRv); 49 void SetValueAsString(const nsAString& aValue, ErrorResult& aRv); 50 void NewValueSpecifiedUnits(uint16_t aUnitType, float aValue, 51 ErrorResult& aRv); 52 void ConvertToSpecifiedUnits(uint16_t aUnitType, ErrorResult& aRv); 53 54 protected: 55 ~DOMSVGAngle(); 56 57 SVGAnimatedOrient* mVal; // if mType is CreatedValue, we own the angle. 58 // Otherwise, the element does. 59 RefPtr<SVGElement> mSVGElement; 60 AngleType mType; 61 }; 62 63 } // namespace dom 64 } // namespace mozilla 65 66 #endif // DOM_SVG_DOMSVGANGLE_H_