summaryrefslogtreecommitdiff
path: root/dom/smil/nsSMILInterval.h
blob: 63ff243cd925f8f5af179cd3e7d2b9ff0e6735f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef NS_SMILINTERVAL_H_
#define NS_SMILINTERVAL_H_

#include "nsSMILInstanceTime.h"
#include "nsTArray.h"

//----------------------------------------------------------------------
// nsSMILInterval class
//
// A structure consisting of a begin and end time. The begin time must be
// resolved (i.e. not indefinite or unresolved).
//
// For an overview of how this class is related to other SMIL time classes see
// the documentation in nsSMILTimeValue.h

class nsSMILInterval
{
public:
  nsSMILInterval();
  nsSMILInterval(const nsSMILInterval& aOther);
  ~nsSMILInterval();
  void Unlink(bool aFiltered = false);

  const nsSMILInstanceTime* Begin() const
  {
    MOZ_ASSERT(mBegin && mEnd,
               "Requesting Begin() on un-initialized instance time");
    return mBegin;
  }
  nsSMILInstanceTime* Begin();

  const nsSMILInstanceTime* End() const
  {
    MOZ_ASSERT(mBegin && mEnd,
               "Requesting End() on un-initialized instance time");
    return mEnd;
  }
  nsSMILInstanceTime* End();

  void SetBegin(nsSMILInstanceTime& aBegin);
  void SetEnd(nsSMILInstanceTime& aEnd);
  void Set(nsSMILInstanceTime& aBegin, nsSMILInstanceTime& aEnd)
  {
    SetBegin(aBegin);
    SetEnd(aEnd);
  }

  void FixBegin();
  void FixEnd();

  typedef nsTArray<RefPtr<nsSMILInstanceTime> > InstanceTimeList;

  void AddDependentTime(nsSMILInstanceTime& aTime);
  void RemoveDependentTime(const nsSMILInstanceTime& aTime);
  void GetDependentTimes(InstanceTimeList& aTimes);

  // Cue for assessing if this interval can be filtered
  bool IsDependencyChainLink() const;

private:
  RefPtr<nsSMILInstanceTime> mBegin;
  RefPtr<nsSMILInstanceTime> mEnd;

  // nsSMILInstanceTimes to notify when this interval is changed or deleted.
  InstanceTimeList mDependentTimes;

  // Indicates if the end points of the interval are fixed or not.
  //
  // Note that this is not the same as having an end point whose TIME is fixed
  // (i.e. nsSMILInstanceTime::IsFixed() returns true). This is because it is
  // possible to have an end point with a fixed TIME and yet still update the
  // end point to refer to a different nsSMILInstanceTime object.
  //
  // However, if mBegin/EndFixed is true, then BOTH the nsSMILInstanceTime
  // OBJECT returned for that end point and its TIME value will not change.
  bool mBeginFixed;
  bool mEndFixed;
};

#endif // NS_SMILINTERVAL_H_