SMILInterval.h (2720B)
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 DOM_SMIL_SMILINTERVAL_H_ 8 #define DOM_SMIL_SMILINTERVAL_H_ 9 10 #include "mozilla/SMILInstanceTime.h" 11 #include "nsTArray.h" 12 13 namespace mozilla { 14 15 //---------------------------------------------------------------------- 16 // SMILInterval class 17 // 18 // A structure consisting of a begin and end time. The begin time must be 19 // resolved (i.e. not indefinite or unresolved). 20 // 21 // For an overview of how this class is related to other SMIL time classes see 22 // the documentation in SMILTimeValue.h 23 24 class SMILInterval { 25 public: 26 SMILInterval(); 27 SMILInterval(const SMILInterval& aOther); 28 ~SMILInterval(); 29 void Unlink(bool aFiltered = false); 30 31 const SMILInstanceTime* Begin() const { 32 MOZ_ASSERT(mBegin && mEnd, 33 "Requesting Begin() on un-initialized instance time"); 34 return mBegin; 35 } 36 SMILInstanceTime* Begin(); 37 38 const SMILInstanceTime* End() const { 39 MOZ_ASSERT(mBegin && mEnd, 40 "Requesting End() on un-initialized instance time"); 41 return mEnd; 42 } 43 SMILInstanceTime* End(); 44 45 void SetBegin(SMILInstanceTime& aBegin); 46 void SetEnd(SMILInstanceTime& aEnd); 47 void Set(SMILInstanceTime& aBegin, SMILInstanceTime& aEnd) { 48 SetBegin(aBegin); 49 SetEnd(aEnd); 50 } 51 52 void FixBegin(); 53 void FixEnd(); 54 55 using InstanceTimeList = nsTArray<RefPtr<SMILInstanceTime>>; 56 57 void AddDependentTime(SMILInstanceTime& aTime); 58 void RemoveDependentTime(const SMILInstanceTime& aTime); 59 void GetDependentTimes(InstanceTimeList& aTimes); 60 61 // Cue for assessing if this interval can be filtered 62 bool IsDependencyChainLink() const; 63 64 private: 65 RefPtr<SMILInstanceTime> mBegin; 66 RefPtr<SMILInstanceTime> mEnd; 67 68 // SMILInstanceTimes to notify when this interval is changed or deleted. 69 InstanceTimeList mDependentTimes; 70 71 // Indicates if the end points of the interval are fixed or not. 72 // 73 // Note that this is not the same as having an end point whose TIME is fixed 74 // (i.e. SMILInstanceTime::IsFixed() returns true). This is because it is 75 // possible to have an end point with a fixed TIME and yet still update the 76 // end point to refer to a different SMILInstanceTime object. 77 // 78 // However, if mBegin/EndFixed is true, then BOTH the SMILInstanceTime 79 // OBJECT returned for that end point and its TIME value will not change. 80 bool mBeginFixed; 81 bool mEndFixed; 82 }; 83 84 } // namespace mozilla 85 86 #endif // DOM_SMIL_SMILINTERVAL_H_