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_SVGANIMATEDBOOLEAN_H_
8 #define DOM_SVG_SVGANIMATEDBOOLEAN_H_
11 #include "mozilla/SMILAttr.h"
12 #include "mozilla/AlreadyAddRefed.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/UniquePtr.h"
23 class DOMSVGAnimatedBoolean
;
24 class SVGAnimationElement
;
28 class SVGAnimatedBoolean
{
30 friend class AutoChangeBooleanNotifier
;
31 using SVGElement
= dom::SVGElement
;
33 void Init(uint8_t aAttrEnum
= 0xff, bool aValue
= false) {
34 mAnimVal
= mBaseVal
= aValue
;
35 mAttrEnum
= aAttrEnum
;
39 nsresult
SetBaseValueAtom(const nsAtom
* aValue
, SVGElement
* aSVGElement
);
40 nsAtom
* GetBaseValueAtom() const;
42 void SetBaseValue(bool aValue
, SVGElement
* aSVGElement
);
43 bool GetBaseValue() const { return mBaseVal
; }
45 void SetAnimValue(bool aValue
, SVGElement
* aSVGElement
);
46 bool GetAnimValue() const { return mAnimVal
; }
48 already_AddRefed
<dom::DOMSVGAnimatedBoolean
> ToDOMAnimatedBoolean(
49 SVGElement
* aSVGElement
);
50 UniquePtr
<SMILAttr
> ToSMILAttr(SVGElement
* aSVGElement
);
56 uint8_t mAttrEnum
; // element specified tracking for attribute
59 struct SMILBool
: public SMILAttr
{
61 SMILBool(SVGAnimatedBoolean
* aVal
, SVGElement
* aSVGElement
)
62 : mVal(aVal
), mSVGElement(aSVGElement
) {}
64 // These will stay alive because a SMILAttr only lives as long
65 // as the Compositing step, and DOM elements don't get a chance to
67 SVGAnimatedBoolean
* mVal
;
68 SVGElement
* mSVGElement
;
71 nsresult
ValueFromString(const nsAString
& aStr
,
72 const dom::SVGAnimationElement
* aSrcElement
,
74 bool& aPreventCachingOfSandwich
) const override
;
75 SMILValue
GetBaseValue() const override
;
76 void ClearAnimValue() override
;
77 nsresult
SetAnimValue(const SMILValue
& aValue
) override
;
81 } // namespace mozilla
83 #endif // DOM_SVG_SVGANIMATEDBOOLEAN_H_