SVGAnimatedBoolean.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_SVGAnimatedBoolean_h
  6. #define mozilla_dom_SVGAnimatedBoolean_h
  7. #include "nsWrapperCache.h"
  8. #include "nsSVGElement.h"
  9. #include "mozilla/Attributes.h"
  10. #include "nsSVGBoolean.h"
  11. namespace mozilla {
  12. namespace dom {
  13. class SVGAnimatedBoolean final : public nsWrapperCache
  14. {
  15. NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(SVGAnimatedBoolean)
  16. NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(SVGAnimatedBoolean)
  17. SVGAnimatedBoolean(nsSVGBoolean* aVal, nsSVGElement *aSVGElement)
  18. : mVal(aVal), mSVGElement(aSVGElement)
  19. {
  20. }
  21. // WebIDL
  22. nsSVGElement* GetParentObject() const { return mSVGElement; }
  23. virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
  24. bool BaseVal() const { return mVal->GetBaseValue(); }
  25. void SetBaseVal(bool aValue) { mVal->SetBaseValue(aValue, mSVGElement); }
  26. bool AnimVal() const { mSVGElement->FlushAnimations(); return mVal->GetAnimValue(); }
  27. protected:
  28. ~SVGAnimatedBoolean();
  29. nsSVGBoolean* mVal; // kept alive because it belongs to content
  30. RefPtr<nsSVGElement> mSVGElement;
  31. };
  32. } //namespace dom
  33. } //namespace mozilla
  34. #endif // mozilla_dom_SVGAnimatedBoolean_h