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_SVGANIMATEDCLASS_H_
8 #define DOM_SVG_SVGANIMATEDCLASS_H_
10 #include "nsCycleCollectionParticipant.h"
11 #include "mozilla/SVGAnimatedClassOrString.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/SMILAttr.h"
14 #include "mozilla/UniquePtr.h"
21 class DOMSVGAnimatedString
;
25 class SVGAnimatedClass final
: public SVGAnimatedClassOrString
{
27 using SVGElement
= dom::SVGElement
;
29 void Init() { mAnimVal
= nullptr; }
31 void SetBaseValue(const nsAString
& aValue
, SVGElement
* aSVGElement
,
32 bool aDoSetAttr
) override
;
33 void GetBaseValue(nsAString
& aValue
,
34 const SVGElement
* aSVGElement
) const override
;
36 void SetAnimValue(const nsAString
& aValue
, SVGElement
* aSVGElement
);
37 void GetAnimValue(nsAString
& aResult
,
38 const SVGElement
* aSVGElement
) const override
;
39 bool IsAnimated() const { return !!mAnimVal
; }
41 UniquePtr
<SMILAttr
> ToSMILAttr(SVGElement
* aSVGElement
);
44 UniquePtr
<nsString
> mAnimVal
;
47 struct SMILString
: public SMILAttr
{
49 SMILString(SVGAnimatedClass
* aVal
, SVGElement
* aSVGElement
)
50 : mVal(aVal
), mSVGElement(aSVGElement
) {}
52 // These will stay alive because a SMILAttr only lives as long
53 // as the Compositing step, and DOM elements don't get a chance to
55 SVGAnimatedClass
* mVal
;
56 SVGElement
* mSVGElement
;
59 nsresult
ValueFromString(const nsAString
& aStr
,
60 const dom::SVGAnimationElement
* aSrcElement
,
62 bool& aPreventCachingOfSandwich
) const override
;
63 SMILValue
GetBaseValue() const override
;
64 void ClearAnimValue() override
;
65 nsresult
SetAnimValue(const SMILValue
& aValue
) override
;
69 } // namespace mozilla
71 #endif // DOM_SVG_SVGANIMATEDCLASS_H_