Backed out 4 changesets (bug 1825722) for causing reftest failures CLOSED TREE
[gecko.git] / dom / svg / SVGAnimatedBoolean.h
blobdb6dbb1189fcfa110aacdd5b988f637ab9a26f66
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_
10 #include "nsError.h"
11 #include "mozilla/SMILAttr.h"
12 #include "mozilla/AlreadyAddRefed.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/UniquePtr.h"
16 class nsAtom;
18 namespace mozilla {
20 class SMILValue;
22 namespace dom {
23 class DOMSVGAnimatedBoolean;
24 class SVGAnimationElement;
25 class SVGElement;
26 } // namespace dom
28 class SVGAnimatedBoolean {
29 public:
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;
36 mIsAnimated = false;
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);
52 private:
53 bool mAnimVal;
54 bool mBaseVal;
55 bool mIsAnimated;
56 uint8_t mAttrEnum; // element specified tracking for attribute
58 public:
59 struct SMILBool : public SMILAttr {
60 public:
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
66 // die during that.
67 SVGAnimatedBoolean* mVal;
68 SVGElement* mSVGElement;
70 // SMILAttr methods
71 nsresult ValueFromString(const nsAString& aStr,
72 const dom::SVGAnimationElement* aSrcElement,
73 SMILValue& aValue,
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_