Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/svg/nsSVGBoolean.h
Line
Count
Source (jump to first uncovered line)
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/. */
6
7
#ifndef __NS_SVGBOOLEAN_H__
8
#define __NS_SVGBOOLEAN_H__
9
10
#include "nsCOMPtr.h"
11
#include "nsError.h"
12
#include "nsISMILAttr.h"
13
#include "mozilla/Attributes.h"
14
#include "mozilla/UniquePtr.h"
15
16
class nsAtom;
17
class nsSMILValue;
18
class nsSVGElement;
19
20
namespace mozilla {
21
namespace dom {
22
class SVGAnimationElement;
23
class SVGAnimatedBoolean;
24
} // namespace dom
25
} // namespace mozilla
26
27
class nsSVGBoolean
28
{
29
30
public:
31
0
  void Init(uint8_t aAttrEnum = 0xff, bool aValue = false) {
32
0
    mAnimVal = mBaseVal = aValue;
33
0
    mAttrEnum = aAttrEnum;
34
0
    mIsAnimated = false;
35
0
  }
36
37
  nsresult SetBaseValueAtom(const nsAtom* aValue, nsSVGElement *aSVGElement);
38
  nsAtom* GetBaseValueAtom() const;
39
40
  void SetBaseValue(bool aValue, nsSVGElement *aSVGElement);
41
  bool GetBaseValue() const
42
0
    { return mBaseVal; }
43
44
  void SetAnimValue(bool aValue, nsSVGElement *aSVGElement);
45
  bool GetAnimValue() const
46
0
    { return mAnimVal; }
47
48
  already_AddRefed<mozilla::dom::SVGAnimatedBoolean>
49
    ToDOMAnimatedBoolean(nsSVGElement* aSVGElement);
50
  mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement* aSVGElement);
51
52
private:
53
54
  bool mAnimVal;
55
  bool mBaseVal;
56
  bool mIsAnimated;
57
  uint8_t mAttrEnum; // element specified tracking for attribute
58
59
public:
60
  struct SMILBool : public nsISMILAttr
61
  {
62
  public:
63
    SMILBool(nsSVGBoolean* aVal, nsSVGElement* aSVGElement)
64
0
      : mVal(aVal), mSVGElement(aSVGElement) {}
65
66
    // These will stay alive because a nsISMILAttr only lives as long
67
    // as the Compositing step, and DOM elements don't get a chance to
68
    // die during that.
69
    nsSVGBoolean* mVal;
70
    nsSVGElement* mSVGElement;
71
72
    // nsISMILAttr methods
73
    virtual nsresult ValueFromString(const nsAString& aStr,
74
                                     const mozilla::dom::SVGAnimationElement* aSrcElement,
75
                                     nsSMILValue& aValue,
76
                                     bool& aPreventCachingOfSandwich) const override;
77
    virtual nsSMILValue GetBaseValue() const override;
78
    virtual void ClearAnimValue() override;
79
    virtual nsresult SetAnimValue(const nsSMILValue& aValue) override;
80
  };
81
};
82
#endif //__NS_SVGBOOLEAN_H__