Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/smil/nsSMILTimedElement.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_SMILTIMEDELEMENT_H_
8
#define NS_SMILTIMEDELEMENT_H_
9
10
#include "mozilla/EventForwards.h"
11
#include "mozilla/Move.h"
12
#include "mozilla/UniquePtr.h"
13
#include "nsSMILInterval.h"
14
#include "nsSMILInstanceTime.h"
15
#include "nsSMILMilestone.h"
16
#include "nsSMILTimeValueSpec.h"
17
#include "nsSMILRepeatCount.h"
18
#include "nsSMILTypes.h"
19
#include "nsTArray.h"
20
#include "nsTHashtable.h"
21
#include "nsHashKeys.h"
22
#include "nsAutoPtr.h"
23
#include "nsAttrValue.h"
24
25
class nsSMILAnimationFunction;
26
class nsSMILTimeContainer;
27
class nsSMILTimeValue;
28
class nsAtom;
29
30
namespace mozilla {
31
namespace dom {
32
class SVGAnimationElement;
33
} // namespace dom
34
} // namespace mozilla
35
36
//----------------------------------------------------------------------
37
// nsSMILTimedElement
38
39
class nsSMILTimedElement
40
{
41
public:
42
  nsSMILTimedElement();
43
  ~nsSMILTimedElement();
44
45
  typedef mozilla::dom::Element Element;
46
47
  /*
48
   * Sets the owning animation element which this class uses to convert between
49
   * container times and to register timebase elements.
50
   */
51
  void SetAnimationElement(mozilla::dom::SVGAnimationElement* aElement);
52
53
  /*
54
   * Returns the time container with which this timed element is associated or
55
   * nullptr if it is not associated with a time container.
56
   */
57
  nsSMILTimeContainer* GetTimeContainer();
58
59
  /*
60
   * Returns the element targeted by the animation element. Needed for
61
   * registering event listeners against the appropriate element.
62
   */
63
  Element* GetTargetElement();
64
65
  /**
66
   * Methods for supporting the ElementTimeControl interface.
67
   */
68
69
  /*
70
   * Adds a new begin instance time at the current container time plus or minus
71
   * the specified offset.
72
   *
73
   * @param aOffsetSeconds A real number specifying the number of seconds to add
74
   *                       to the current container time.
75
   * @return NS_OK if the operation succeeeded, or an error code otherwise.
76
   */
77
  nsresult BeginElementAt(double aOffsetSeconds);
78
79
  /*
80
   * Adds a new end instance time at the current container time plus or minus
81
   * the specified offset.
82
   *
83
   * @param aOffsetSeconds A real number specifying the number of seconds to add
84
   *                       to the current container time.
85
   * @return NS_OK if the operation succeeeded, or an error code otherwise.
86
   */
87
  nsresult EndElementAt(double aOffsetSeconds);
88
89
  /**
90
   * Methods for supporting the nsSVGAnimationElement interface.
91
   */
92
93
  /**
94
   * According to SVG 1.1 SE this returns
95
   *
96
   *   the begin time, in seconds, for this animation element's current
97
   *   interval, if it exists, regardless of whether the interval has begun yet.
98
   *
99
   * @return the start time as defined above in milliseconds or an unresolved
100
   * time if there is no current interval.
101
   */
102
  nsSMILTimeValue GetStartTime() const;
103
104
  /**
105
   * Returns the simple duration of this element.
106
   *
107
   * @return the simple duration in milliseconds or INDEFINITE.
108
   */
109
  nsSMILTimeValue GetSimpleDuration() const
110
0
  {
111
0
    return mSimpleDur;
112
0
  }
113
114
  /**
115
   * Methods for supporting hyperlinking
116
   */
117
118
  /**
119
   * Internal SMIL methods
120
   */
121
122
  /**
123
   * Returns the time to seek the document to when this element is targetted by
124
   * a hyperlink.
125
   *
126
   * The behavior is defined here:
127
   *   http://www.w3.org/TR/smil-animation/#HyperlinkSemantics
128
   *
129
   * It is very similar to GetStartTime() with the exception that when the
130
   * element is not active, the begin time of the *first* interval is returned.
131
   *
132
   * @return the time to seek the documen to in milliseconds or an unresolved
133
   * time if there is no resolved interval.
134
   */
135
  nsSMILTimeValue GetHyperlinkTime() const;
136
137
  /**
138
   * Adds an instance time object this element's list of instance times.
139
   * These instance times are used when creating intervals.
140
   *
141
   * This method is typically called by an nsSMILTimeValueSpec.
142
   *
143
   * @param aInstanceTime   The time to add, expressed in container time.
144
   * @param aIsBegin        true if the time to be added represents a begin
145
   *                        time or false if it represents an end time.
146
   */
147
  void AddInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
148
149
  /**
150
   * Requests this element update the given instance time.
151
   *
152
   * This method is typically called by a child nsSMILTimeValueSpec.
153
   *
154
   * @param aInstanceTime   The instance time to update.
155
   * @param aUpdatedTime    The time to update aInstanceTime with.
156
   * @param aDependentTime  The instance time upon which aInstanceTime should be
157
   *                        based.
158
   * @param aIsBegin        true if the time to be updated represents a begin
159
   *                        instance time or false if it represents an end
160
   *                        instance time.
161
   */
162
  void UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime,
163
                          nsSMILTimeValue& aUpdatedTime,
164
                          bool aIsBegin);
165
166
  /**
167
   * Removes an instance time object from this element's list of instance times.
168
   *
169
   * This method is typically called by a child nsSMILTimeValueSpec.
170
   *
171
   * @param aInstanceTime   The instance time to remove.
172
   * @param aIsBegin        true if the time to be removed represents a begin
173
   *                        time or false if it represents an end time.
174
   */
175
  void RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
176
177
  /**
178
   * Removes all the instance times associated with the given
179
   * nsSMILTimeValueSpec object. Used when an ID assignment changes and hence
180
   * all the previously associated instance times become invalid.
181
   *
182
   * @param aSpec    The nsSMILTimeValueSpec object whose created
183
   *                 nsSMILInstanceTime's should be removed.
184
   * @param aIsBegin true if the times to be removed represent begin
185
   *                 times or false if they are end times.
186
   */
187
  void RemoveInstanceTimesForCreator(const nsSMILTimeValueSpec* aSpec,
188
                                     bool aIsBegin);
189
190
  /**
191
   * Sets the object that will be called by this timed element each time it is
192
   * sampled.
193
   *
194
   * In Schmitz's model it is possible to associate several time clients with
195
   * a timed element but for now we only allow one.
196
   *
197
   * @param aClient   The time client to associate. Any previous time client
198
   *                  will be disassociated and no longer sampled. Setting this
199
   *                  to nullptr will simply disassociate the previous client, if
200
   *                  any.
201
   */
202
  void SetTimeClient(nsSMILAnimationFunction* aClient);
203
204
  /**
205
   * Samples the object at the given container time. Timing intervals are
206
   * updated and if this element is active at the given time the associated time
207
   * client will be sampled with the appropriate simple time.
208
   *
209
   * @param aContainerTime The container time at which to sample.
210
   */
211
  void SampleAt(nsSMILTime aContainerTime);
212
213
  /**
214
   * Performs a special sample for the end of an interval. Such a sample should
215
   * only advance the timed element (and any dependent elements) to the waiting
216
   * or postactive state. It should not cause a transition to the active state.
217
   * Transition to the active state is only performed on a regular SampleAt.
218
   *
219
   * This allows all interval ends at a given time to be processed first and
220
   * hence the new interval can be established based on full information of the
221
   * available instance times.
222
   *
223
   * @param aContainerTime The container time at which to sample.
224
   */
225
  void SampleEndAt(nsSMILTime aContainerTime);
226
227
  /**
228
   * Informs the timed element that its time container has changed time
229
   * relative to document time. The timed element therefore needs to update its
230
   * dependent elements (which may belong to a different time container) so they
231
   * can re-resolve their times.
232
   */
233
  void HandleContainerTimeChange();
234
235
  /**
236
   * Resets this timed element's accumulated times and intervals back to start
237
   * up state.
238
   *
239
   * This is used for backwards seeking where rather than accumulating
240
   * historical timing state and winding it back, we reset the element and seek
241
   * forwards.
242
   */
243
  void Rewind();
244
245
  /**
246
   * Marks this element as disabled or not. If the element is disabled, it
247
   * will ignore any future samples and discard any accumulated timing state.
248
   *
249
   * This is used by SVG to "turn off" timed elements when the associated
250
   * animation element has failing conditional processing tests.
251
   *
252
   * Returns true if the disabled state of the timed element was changed
253
   * as a result of this call (i.e. it was not a redundant call).
254
   */
255
  bool SetIsDisabled(bool aIsDisabled);
256
257
  /**
258
   * Attempts to set an attribute on this timed element.
259
   *
260
   * @param aAttribute  The name of the attribute to set. The namespace of this
261
   *                    attribute is not specified as it is checked by the host
262
   *                    element. Only attributes in the namespace defined for
263
   *                    SMIL attributes in the host language are passed to the
264
   *                    timed element.
265
   * @param aValue      The attribute value.
266
   * @param aResult     The nsAttrValue object that may be used for storing the
267
   *                    parsed result.
268
   * @param aContextElement The element to use for context when resolving
269
   *                        references to other elements.
270
   * @param[out] aParseResult The result of parsing the attribute. Will be set
271
   *                          to NS_OK if parsing is successful.
272
   *
273
   * @return true if the given attribute is a timing attribute, false
274
   * otherwise.
275
   */
276
  bool SetAttr(nsAtom* aAttribute, const nsAString& aValue,
277
               nsAttrValue& aResult, Element& aContextElement,
278
               nsresult* aParseResult = nullptr);
279
280
  /**
281
   * Attempts to unset an attribute on this timed element.
282
   *
283
   * @param aAttribute  The name of the attribute to set. As with SetAttr the
284
   *                    namespace of the attribute is not specified (see
285
   *                    SetAttr).
286
   *
287
   * @return true if the given attribute is a timing attribute, false
288
   * otherwise.
289
   */
290
  bool UnsetAttr(nsAtom* aAttribute);
291
292
  /**
293
   * Adds a syncbase dependency to the list of dependents that will be notified
294
   * when this timed element creates, deletes, or updates its current interval.
295
   *
296
   * @param aDependent  The nsSMILTimeValueSpec object to notify. A raw pointer
297
   *                    to this object will be stored. Therefore it is necessary
298
   *                    for the object to be explicitly unregistered (with
299
   *                    RemoveDependent) when it is destroyed.
300
   */
301
  void AddDependent(nsSMILTimeValueSpec& aDependent);
302
303
  /**
304
   * Removes a syncbase dependency from the list of dependents that are notified
305
   * when the current interval is modified.
306
   *
307
   * @param aDependent  The nsSMILTimeValueSpec object to unregister.
308
   */
309
  void RemoveDependent(nsSMILTimeValueSpec& aDependent);
310
311
  /**
312
   * Determines if this timed element is dependent on the given timed element's
313
   * begin time for the interval currently in effect. Whilst the element is in
314
   * the active state this is the current interval and in the postactive or
315
   * waiting state this is the previous interval if one exists. In all other
316
   * cases the element is not considered a time dependent of any other element.
317
   *
318
   * @param aOther    The potential syncbase element.
319
   * @return true if this timed element's begin time for the currently
320
   * effective interval is directly or indirectly derived from aOther, false
321
   * otherwise.
322
   */
323
  bool IsTimeDependent(const nsSMILTimedElement& aOther) const;
324
325
  /**
326
   * Called when the timed element has been bound to the document so that
327
   * references from this timed element to other elements can be resolved.
328
   *
329
   * @param aContextElement The element which provides the necessary context for
330
   *                        resolving references. This is typically the element
331
   *                        in the host language that owns this timed element.
332
   */
333
  void BindToTree(Element& aContextElement);
334
335
  /**
336
   * Called when the target of the animation has changed so that event
337
   * registrations can be updated.
338
   */
339
  void HandleTargetElementChange(Element* aNewTarget);
340
341
  /**
342
   * Called when the timed element has been removed from a document so that
343
   * references to other elements can be broken.
344
   */
345
0
  void DissolveReferences() { Unlink(); }
346
347
  // Cycle collection
348
  void Traverse(nsCycleCollectionTraversalCallback* aCallback);
349
  void Unlink();
350
351
  typedef bool (*RemovalTestFunction)(nsSMILInstanceTime* aInstance);
352
353
protected:
354
  // Typedefs
355
  typedef nsTArray<mozilla::UniquePtr<nsSMILTimeValueSpec>> TimeValueSpecList;
356
  typedef nsTArray<RefPtr<nsSMILInstanceTime> >   InstanceTimeList;
357
  typedef nsTArray<mozilla::UniquePtr<nsSMILInterval>> IntervalList;
358
  typedef nsPtrHashKey<nsSMILTimeValueSpec> TimeValueSpecPtrKey;
359
  typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
360
361
  // Helper classes
362
  class InstanceTimeComparator {
363
    public:
364
      bool Equals(const nsSMILInstanceTime* aElem1,
365
                    const nsSMILInstanceTime* aElem2) const;
366
      bool LessThan(const nsSMILInstanceTime* aElem1,
367
                      const nsSMILInstanceTime* aElem2) const;
368
  };
369
370
  // Templated helper functions
371
  template <class TestFunctor>
372
  void RemoveInstanceTimes(InstanceTimeList& aArray, TestFunctor& aTest);
373
374
  //
375
  // Implementation helpers
376
  //
377
378
  nsresult          SetBeginSpec(const nsAString& aBeginSpec,
379
                                 Element& aContextElement,
380
                                 RemovalTestFunction aRemove);
381
  nsresult          SetEndSpec(const nsAString& aEndSpec,
382
                               Element& aContextElement,
383
                               RemovalTestFunction aRemove);
384
  nsresult          SetSimpleDuration(const nsAString& aDurSpec);
385
  nsresult          SetMin(const nsAString& aMinSpec);
386
  nsresult          SetMax(const nsAString& aMaxSpec);
387
  nsresult          SetRestart(const nsAString& aRestartSpec);
388
  nsresult          SetRepeatCount(const nsAString& aRepeatCountSpec);
389
  nsresult          SetRepeatDur(const nsAString& aRepeatDurSpec);
390
  nsresult          SetFillMode(const nsAString& aFillModeSpec);
391
392
  void              UnsetBeginSpec(RemovalTestFunction aRemove);
393
  void              UnsetEndSpec(RemovalTestFunction aRemove);
394
  void              UnsetSimpleDuration();
395
  void              UnsetMin();
396
  void              UnsetMax();
397
  void              UnsetRestart();
398
  void              UnsetRepeatCount();
399
  void              UnsetRepeatDur();
400
  void              UnsetFillMode();
401
402
  nsresult          SetBeginOrEndSpec(const nsAString& aSpec,
403
                                      Element& aContextElement,
404
                                      bool aIsBegin,
405
                                      RemovalTestFunction aRemove);
406
  void              ClearSpecs(TimeValueSpecList& aSpecs,
407
                               InstanceTimeList& aInstances,
408
                               RemovalTestFunction aRemove);
409
  void              ClearIntervals();
410
  void              DoSampleAt(nsSMILTime aContainerTime, bool aEndOnly);
411
412
  /**
413
   * Helper function to check for an early end and, if necessary, update the
414
   * current interval accordingly.
415
   *
416
   * See SMIL 3.0, section 5.4.5, Element life cycle, "Active Time - Playing an
417
   * interval" for a description of ending early.
418
   *
419
   * @param aSampleTime The current sample time. Early ends should only be
420
   *                    applied at the last possible moment (i.e. if they are at
421
   *                    or before the current sample time) and only if the
422
   *                    current interval is not already ending.
423
   * @return true if the end time of the current interval was updated,
424
   *         false otherwise.
425
   */
426
  bool ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime);
427
428
  /**
429
   * Clears certain state in response to the element restarting.
430
   *
431
   * This state is described in SMIL 3.0, section 5.4.3, Resetting element state
432
   */
433
  void Reset();
434
435
  /**
436
   * Clears all accumulated timing state except for those instance times for
437
   * which aRemove does not return true.
438
   *
439
   * Unlike the Reset method which only clears instance times, this clears the
440
   * element's state, intervals (including current interval), and tells the
441
   * client animation function to stop applying a result. In effect, it returns
442
   * the element to its initial state but preserves any instance times excluded
443
   * by the passed-in function.
444
   */
445
  void ClearTimingState(RemovalTestFunction aRemove);
446
447
  /**
448
   * Recreates timing state by re-applying begin/end attributes specified on
449
   * the associated animation element.
450
   *
451
   * Note that this does not completely restore the information cleared by
452
   * ClearTimingState since it leaves the element in the startup state.
453
   * The element state will be updated on the next sample.
454
   */
455
  void RebuildTimingState(RemovalTestFunction aRemove);
456
457
  /**
458
   * Completes a seek operation by sending appropriate events and, in the case
459
   * of a backwards seek, updating the state of timing information that was
460
   * previously considered historical.
461
   */
462
  void DoPostSeek();
463
464
  /**
465
   * Unmarks instance times that were previously preserved because they were
466
   * considered important historical milestones but are no longer such because
467
   * a backwards seek has been performed.
468
   */
469
  void UnpreserveInstanceTimes(InstanceTimeList& aList);
470
471
  /**
472
   * Helper function to iterate through this element's accumulated timing
473
   * information (specifically old nsSMILIntervals and nsSMILTimeInstanceTimes)
474
   * and discard items that are no longer needed or exceed some threshold of
475
   * accumulated state.
476
   */
477
  void FilterHistory();
478
479
  // Helper functions for FilterHistory to clear old nsSMILIntervals and
480
  // nsSMILInstanceTimes respectively.
481
  void FilterIntervals();
482
  void FilterInstanceTimes(InstanceTimeList& aList);
483
484
  /**
485
   * Calculates the next acceptable interval for this element after the
486
   * specified interval, or, if no previous interval is specified, it will be
487
   * the first interval with an end time after t=0.
488
   *
489
   * @see SMILANIM 3.6.8
490
   *
491
   * @param aPrevInterval   The previous interval used. If supplied, the first
492
   *                        interval that begins after aPrevInterval will be
493
   *                        returned. May be nullptr.
494
   * @param aReplacedInterval The interval that is being updated (if any). This
495
   *                        used to ensure we don't return interval endpoints
496
   *                        that are dependent on themselves. May be nullptr.
497
   * @param aFixedBeginTime The time to use for the start of the interval. This
498
   *                        is used when only the endpoint of the interval
499
   *                        should be updated such as when the animation is in
500
   *                        the ACTIVE state. May be nullptr.
501
   * @param[out] aResult    The next interval. Will be unchanged if no suitable
502
   *                        interval was found (in which case false will be
503
   *                        returned).
504
   * @return  true if a suitable interval was found, false otherwise.
505
   */
506
  bool              GetNextInterval(const nsSMILInterval* aPrevInterval,
507
                                    const nsSMILInterval* aReplacedInterval,
508
                                    const nsSMILInstanceTime* aFixedBeginTime,
509
                                    nsSMILInterval& aResult) const;
510
  nsSMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
511
                                     const nsSMILTimeValue& aBase,
512
                                     int32_t& aPosition) const;
513
  nsSMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
514
                                            const nsSMILTimeValue& aBase,
515
                                            int32_t& aPosition) const;
516
  nsSMILTimeValue   CalcActiveEnd(const nsSMILTimeValue& aBegin,
517
                                  const nsSMILTimeValue& aEnd) const;
518
  nsSMILTimeValue   GetRepeatDuration() const;
519
  nsSMILTimeValue   ApplyMinAndMax(const nsSMILTimeValue& aDuration) const;
520
  nsSMILTime        ActiveTimeToSimpleTime(nsSMILTime aActiveTime,
521
                                           uint32_t& aRepeatIteration);
522
  nsSMILInstanceTime* CheckForEarlyEnd(
523
                        const nsSMILTimeValue& aContainerTime) const;
524
  void              UpdateCurrentInterval(bool aForceChangeNotice = false);
525
  void              SampleSimpleTime(nsSMILTime aActiveTime);
526
  void              SampleFillValue();
527
  nsresult          AddInstanceTimeFromCurrentTime(nsSMILTime aCurrentTime,
528
                        double aOffsetSeconds, bool aIsBegin);
529
  void              RegisterMilestone();
530
  bool              GetNextMilestone(nsSMILMilestone& aNextMilestone) const;
531
532
  // Notification methods. Note that these notifications can result in nested
533
  // calls to this same object. Therefore,
534
  // (i)  we should not perform notification until this object is in
535
  //      a consistent state to receive callbacks, and
536
  // (ii) after calling these methods we must assume that the state of the
537
  //      element may have changed.
538
  void              NotifyNewInterval();
539
  void              NotifyChangedInterval(nsSMILInterval* aInterval,
540
                                          bool aBeginObjectChanged,
541
                                          bool aEndObjectChanged);
542
543
  void              FireTimeEventAsync(mozilla::EventMessage aMsg,
544
                                       int32_t aDetail);
545
  const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
546
  const nsSMILInterval* GetPreviousInterval() const;
547
0
  bool              HasPlayed() const { return !mOldIntervals.IsEmpty(); }
548
  bool              HasClientInFillRange() const;
549
  bool              EndHasEventConditions() const;
550
  bool              AreEndTimesDependentOn(
551
                      const nsSMILInstanceTime* aBase) const;
552
553
  // Reset the current interval by first passing ownership to a temporary
554
  // variable so that if Unlink() results in us receiving a callback,
555
  // mCurrentInterval will be nullptr and we will be in a consistent state.
556
  void ResetCurrentInterval()
557
0
  {
558
0
    if (mCurrentInterval) {
559
0
      // Transfer ownership to temp var. (This sets mCurrentInterval to null.)
560
0
      auto interval = std::move(mCurrentInterval);
561
0
      interval->Unlink();
562
0
    }
563
0
  }
564
565
  //
566
  // Members
567
  //
568
  mozilla::dom::SVGAnimationElement* mAnimationElement; // [weak] won't outlive
569
                                                        // owner
570
  TimeValueSpecList               mBeginSpecs; // [strong]
571
  TimeValueSpecList               mEndSpecs; // [strong]
572
573
  nsSMILTimeValue                 mSimpleDur;
574
575
  nsSMILRepeatCount               mRepeatCount;
576
  nsSMILTimeValue                 mRepeatDur;
577
578
  nsSMILTimeValue                 mMin;
579
  nsSMILTimeValue                 mMax;
580
581
  enum nsSMILFillMode : uint8_t
582
  {
583
    FILL_REMOVE,
584
    FILL_FREEZE
585
  };
586
  nsSMILFillMode                  mFillMode;
587
  static const nsAttrValue::EnumTable sFillModeTable[];
588
589
  enum nsSMILRestartMode : uint8_t
590
  {
591
    RESTART_ALWAYS,
592
    RESTART_WHENNOTACTIVE,
593
    RESTART_NEVER
594
  };
595
  nsSMILRestartMode               mRestartMode;
596
  static const nsAttrValue::EnumTable sRestartModeTable[];
597
598
  InstanceTimeList                mBeginInstances;
599
  InstanceTimeList                mEndInstances;
600
  uint32_t                        mInstanceSerialIndex;
601
602
  nsSMILAnimationFunction*        mClient;
603
  mozilla::UniquePtr<nsSMILInterval> mCurrentInterval;
604
  IntervalList                    mOldIntervals;
605
  uint32_t                        mCurrentRepeatIteration;
606
  nsSMILMilestone                 mPrevRegisteredMilestone;
607
  static const nsSMILMilestone    sMaxMilestone;
608
  static const uint8_t            sMaxNumIntervals;
609
  static const uint8_t            sMaxNumInstanceTimes;
610
611
  // Set of dependent time value specs to be notified when establishing a new
612
  // current interval. Change notifications and delete notifications are handled
613
  // by the interval.
614
  //
615
  // [weak] The nsSMILTimeValueSpec objects register themselves and unregister
616
  // on destruction. Likewise, we notify them when we are destroyed.
617
  TimeValueSpecHashSet mTimeDependents;
618
619
  /**
620
   * The state of the element in its life-cycle. These states are based on the
621
   * element life-cycle described in SMILANIM 3.6.8
622
   */
623
  enum nsSMILElementState
624
  {
625
    STATE_STARTUP,
626
    STATE_WAITING,
627
    STATE_ACTIVE,
628
    STATE_POSTACTIVE
629
  };
630
  nsSMILElementState              mElementState;
631
632
  enum nsSMILSeekState
633
  {
634
    SEEK_NOT_SEEKING,
635
    SEEK_FORWARD_FROM_ACTIVE,
636
    SEEK_FORWARD_FROM_INACTIVE,
637
    SEEK_BACKWARD_FROM_ACTIVE,
638
    SEEK_BACKWARD_FROM_INACTIVE
639
  };
640
  nsSMILSeekState                 mSeekState;
641
642
  // Used to batch updates to the timing model
643
  class AutoIntervalUpdateBatcher;
644
  bool mDeferIntervalUpdates;
645
  bool mDoDeferredUpdate; // Set if an update to the current interval was
646
                          // requested while mDeferIntervalUpdates was set
647
  bool mIsDisabled;
648
649
  // Stack-based helper class to call UpdateCurrentInterval when it is destroyed
650
  class AutoIntervalUpdater;
651
652
  // Recursion depth checking
653
  uint8_t              mDeleteCount;
654
  uint8_t              mUpdateIntervalRecursionDepth;
655
  static const uint8_t sMaxUpdateIntervalRecursionDepth;
656
};
657
658
inline void
659
ImplCycleCollectionUnlink(nsSMILTimedElement& aField)
660
0
{
661
0
  aField.Unlink();
662
0
}
663
664
inline void
665
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
666
                            nsSMILTimedElement& aField,
667
                            const char* aName,
668
                            uint32_t aFlags = 0)
669
0
{
670
0
  aField.Traverse(&aCallback);
671
0
}
672
673
#endif // NS_SMILTIMEDELEMENT_H_