Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/smil/nsSMILValue.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_SMILVALUE_H_
8
#define NS_SMILVALUE_H_
9
10
#include "nsISMILType.h"
11
#include "nsSMILNullType.h"
12
13
/**
14
 * Although objects of this type are generally only created on the stack and
15
 * only exist during the taking of a new time sample, that's not always the
16
 * case. The nsSMILValue objects obtained from attributes' base values are
17
 * cached so that the SMIL engine can make certain optimizations during a
18
 * sample if the base value has not changed since the last sample (potentially
19
 * avoiding recomposing). These nsSMILValue objects typically live much longer
20
 * than a single sample.
21
 */
22
class nsSMILValue
23
{
24
public:
25
0
  nsSMILValue() : mU(), mType(nsSMILNullType::Singleton()) { }
26
  explicit nsSMILValue(const nsISMILType* aType);
27
  nsSMILValue(const nsSMILValue& aVal);
28
29
  ~nsSMILValue()
30
0
  {
31
0
    mType->Destroy(*this);
32
0
  }
33
34
  const nsSMILValue& operator=(const nsSMILValue& aVal);
35
36
  // Move constructor / reassignment operator:
37
  nsSMILValue(nsSMILValue&& aVal);
38
  nsSMILValue& operator=(nsSMILValue&& aVal);
39
40
  // Equality operators. These are allowed to be conservative (return false
41
  // more than you'd expect) - see comment above nsISMILType::IsEqual.
42
  bool operator==(const nsSMILValue& aVal) const;
43
0
  bool operator!=(const nsSMILValue& aVal) const {
44
0
    return !(*this == aVal);
45
0
  }
46
47
  bool IsNull() const
48
0
  {
49
0
    return (mType == nsSMILNullType::Singleton());
50
0
  }
51
52
  nsresult Add(const nsSMILValue& aValueToAdd, uint32_t aCount = 1);
53
  nsresult SandwichAdd(const nsSMILValue& aValueToAdd);
54
  nsresult ComputeDistance(const nsSMILValue& aTo, double& aDistance) const;
55
  nsresult Interpolate(const nsSMILValue& aEndVal,
56
                       double aUnitDistance,
57
                       nsSMILValue& aResult) const;
58
59
  union {
60
    bool mBool;
61
    uint64_t mUint;
62
    int64_t mInt;
63
    double mDouble;
64
    struct {
65
      float mAngle;
66
      uint16_t mUnit;
67
      uint16_t mOrientType;
68
    } mOrient;
69
    int32_t mIntPair[2];
70
    float mNumberPair[2];
71
    void* mPtr;
72
  } mU;
73
  const nsISMILType* mType;
74
75
protected:
76
  void InitAndCheckPostcondition(const nsISMILType* aNewType);
77
  void DestroyAndCheckPostcondition();
78
  void DestroyAndReinit(const nsISMILType* aNewType);
79
};
80
81
#endif  // NS_SMILVALUE_H_