SVGAngle.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_dom_SVGAngle_h
  6. #define mozilla_dom_SVGAngle_h
  7. #include "nsWrapperCache.h"
  8. #include "nsSVGElement.h"
  9. #include "mozilla/Attributes.h"
  10. class nsSVGAngle;
  11. namespace mozilla {
  12. namespace dom {
  13. class SVGAngle final : public nsWrapperCache
  14. {
  15. public:
  16. typedef enum {
  17. BaseValue,
  18. AnimValue,
  19. CreatedValue
  20. } AngleType;
  21. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGAngle)
  22. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGAngle)
  23. SVGAngle(nsSVGAngle* aVal, nsSVGElement *aSVGElement, AngleType aType)
  24. : mVal(aVal), mSVGElement(aSVGElement), mType(aType)
  25. {
  26. }
  27. // WebIDL
  28. nsSVGElement* GetParentObject() { return mSVGElement; }
  29. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  30. uint16_t UnitType() const;
  31. float Value() const;
  32. void GetValueAsString(nsAString& aValue);
  33. void SetValue(float aValue, ErrorResult& rv);
  34. float ValueInSpecifiedUnits() const;
  35. void SetValueInSpecifiedUnits(float aValue, ErrorResult& rv);
  36. void SetValueAsString(const nsAString& aValue, ErrorResult& rv);
  37. void NewValueSpecifiedUnits(uint16_t unitType, float value, ErrorResult& rv);
  38. void ConvertToSpecifiedUnits(uint16_t unitType, ErrorResult& rv);
  39. protected:
  40. ~SVGAngle();
  41. nsSVGAngle* mVal; // if mType is CreatedValue, we own the angle. Otherwise, the element does.
  42. RefPtr<nsSVGElement> mSVGElement;
  43. AngleType mType;
  44. };
  45. } //namespace dom
  46. } //namespace mozilla
  47. #endif // mozilla_dom_SVGAngle_h