2009-01-14 20:38:07 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is the Mozilla SMIL module.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Brian Birtles.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Brian Birtles <birtles@gmail.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#ifndef NS_SMILINSTANCETIME_H_
|
|
|
|
#define NS_SMILINSTANCETIME_H_
|
|
|
|
|
|
|
|
#include "nsSMILTimeValue.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
|
2010-03-01 11:31:50 -08:00
|
|
|
class nsSMILInterval;
|
|
|
|
class nsSMILTimeContainer;
|
2009-01-14 20:38:07 -08:00
|
|
|
class nsSMILTimeValueSpec;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsSMILInstanceTime
|
|
|
|
//
|
|
|
|
// An instant in document simple time that may be used in creating a new
|
2010-01-12 12:00:49 -08:00
|
|
|
// interval.
|
2009-01-14 20:38:07 -08:00
|
|
|
//
|
|
|
|
// For an overview of how this class is related to other SMIL time classes see
|
2010-01-12 12:00:49 -08:00
|
|
|
// the documentation in nsSMILTimeValue.h
|
|
|
|
//
|
2010-05-20 17:18:29 -07:00
|
|
|
// These objects are owned by an nsSMILTimedElement but MAY also be referenced
|
|
|
|
// by:
|
2010-01-12 12:00:49 -08:00
|
|
|
//
|
2010-05-20 17:18:29 -07:00
|
|
|
// a) nsSMILIntervals that belong to the same nsSMILTimedElement and which refer
|
|
|
|
// to the nsSMILInstanceTimes which form the interval endpoints; and/or
|
|
|
|
// b) nsSMILIntervals that belong to other nsSMILTimedElements but which need to
|
|
|
|
// update dependent instance times when they change or are deleted.
|
|
|
|
// E.g. for begin='a.begin', 'a' needs to inform dependent
|
|
|
|
// nsSMILInstanceTimes if its begin time changes. This notification is
|
|
|
|
// performed by the nsSMILInterval.
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
class nsSMILInstanceTime
|
|
|
|
{
|
|
|
|
public:
|
2010-01-12 12:00:49 -08:00
|
|
|
// Instance time source. Times generated by events, syncbase relationships,
|
|
|
|
// and DOM calls behave differently in some circumstances such as when a timed
|
|
|
|
// element is reset.
|
|
|
|
enum nsSMILInstanceTimeSource {
|
|
|
|
// No particularly significant source, e.g. offset time, 'indefinite'
|
|
|
|
SOURCE_NONE,
|
|
|
|
// Generated by a DOM call such as beginElement
|
|
|
|
SOURCE_DOM,
|
|
|
|
// Generated by a syncbase relationship
|
|
|
|
SOURCE_SYNCBASE,
|
|
|
|
// Generated by an event
|
|
|
|
SOURCE_EVENT
|
|
|
|
};
|
2009-01-14 20:38:07 -08:00
|
|
|
|
2010-01-12 12:00:49 -08:00
|
|
|
nsSMILInstanceTime(const nsSMILTimeValue& aTime,
|
2010-03-01 11:31:50 -08:00
|
|
|
nsSMILInstanceTimeSource aSource = SOURCE_NONE,
|
|
|
|
nsSMILTimeValueSpec* aCreator = nsnull,
|
|
|
|
nsSMILInterval* aBaseInterval = nsnull);
|
|
|
|
~nsSMILInstanceTime();
|
|
|
|
void Unlink();
|
|
|
|
void HandleChangedInterval(const nsSMILTimeContainer* aSrcContainer,
|
|
|
|
PRBool aBeginObjectChanged,
|
|
|
|
PRBool aEndObjectChanged);
|
|
|
|
void HandleDeletedInterval();
|
2010-07-02 22:52:50 -07:00
|
|
|
void HandleFilteredInterval();
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
const nsSMILTimeValue& Time() const { return mTime; }
|
2010-03-01 11:31:50 -08:00
|
|
|
const nsSMILTimeValueSpec* GetCreator() const { return mCreator; }
|
2010-01-12 12:00:49 -08:00
|
|
|
|
2010-07-02 22:52:50 -07:00
|
|
|
PRBool IsDynamic() const { return !!(mFlags & kDynamic); }
|
|
|
|
PRBool IsFixedTime() const { return !(mFlags & kMayUpdate); }
|
2010-01-12 12:00:49 -08:00
|
|
|
PRBool FromDOM() const { return !!(mFlags & kFromDOM); }
|
2010-07-02 22:52:51 -07:00
|
|
|
|
|
|
|
PRBool ShouldPreserve() const;
|
|
|
|
void UnmarkShouldPreserve();
|
2010-01-12 12:00:49 -08:00
|
|
|
|
2010-07-02 22:52:50 -07:00
|
|
|
void AddRefFixedEndpoint();
|
|
|
|
void ReleaseFixedEndpoint();
|
2010-01-12 12:00:49 -08:00
|
|
|
|
|
|
|
void DependentUpdate(const nsSMILTimeValue& aNewTime)
|
|
|
|
{
|
2010-07-02 22:52:50 -07:00
|
|
|
NS_ABORT_IF_FALSE(!IsFixedTime(),
|
2010-01-12 12:00:49 -08:00
|
|
|
"Updating an instance time that is not expected to be updated");
|
|
|
|
mTime = aNewTime;
|
|
|
|
}
|
|
|
|
|
2010-07-02 22:52:50 -07:00
|
|
|
PRBool IsDependent() const { return !!mBaseInterval; }
|
|
|
|
PRBool IsDependentOn(const nsSMILInstanceTime& aOther) const;
|
|
|
|
const nsSMILInterval* GetBaseInterval() const { return mBaseInterval; }
|
2010-01-12 12:00:49 -08:00
|
|
|
|
2010-03-01 11:31:50 -08:00
|
|
|
PRBool SameTimeAndBase(const nsSMILInstanceTime& aOther) const
|
2010-01-12 12:00:49 -08:00
|
|
|
{
|
2010-03-01 11:31:50 -08:00
|
|
|
return mTime == aOther.mTime && GetBaseTime() == aOther.GetBaseTime();
|
2010-01-12 12:00:49 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get and set a serial number which may be used by a containing class to
|
|
|
|
// control the sort order of otherwise similar instance times.
|
|
|
|
PRUint32 Serial() const { return mSerial; }
|
|
|
|
void SetSerial(PRUint32 aIndex) { mSerial = aIndex; }
|
|
|
|
|
2010-04-01 11:05:40 -07:00
|
|
|
NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime)
|
2009-01-14 20:38:07 -08:00
|
|
|
|
|
|
|
protected:
|
2010-03-01 11:31:50 -08:00
|
|
|
void SetBaseInterval(nsSMILInterval* aBaseInterval);
|
|
|
|
const nsSMILInstanceTime* GetBaseTime() const;
|
2010-01-12 12:00:49 -08:00
|
|
|
|
|
|
|
nsSMILTimeValue mTime;
|
|
|
|
|
2010-05-20 17:18:29 -07:00
|
|
|
// Internal flags used to represent the behaviour of different instance times
|
2010-01-12 12:00:49 -08:00
|
|
|
enum {
|
2010-07-02 22:52:50 -07:00
|
|
|
// Indicates that this instance time was generated by an event or a DOM
|
|
|
|
// call. Such instance times require special handling when (i) the owning
|
2010-08-18 03:20:24 -07:00
|
|
|
// element is reset, (ii) when they are to be added as a new end instance
|
|
|
|
// times (as per SMIL's event sensitivity contraints), and (iii) when
|
|
|
|
// a backwards seek is performed and the timing model is reconstructed.
|
2010-07-02 22:52:50 -07:00
|
|
|
kDynamic = 1,
|
2010-01-12 12:00:49 -08:00
|
|
|
|
|
|
|
// Indicates that this instance time is referred to by an
|
|
|
|
// nsSMILTimeValueSpec and as such may be updated. Such instance time should
|
|
|
|
// not be filtered out by the nsSMILTimedElement even if they appear to be
|
2010-07-02 22:52:50 -07:00
|
|
|
// in the past as they may be updated to a future time.
|
2010-01-12 12:00:49 -08:00
|
|
|
kMayUpdate = 2,
|
|
|
|
|
|
|
|
// Indicates that this instance time was generated from the DOM as opposed
|
|
|
|
// to an nsSMILTimeValueSpec. When a 'begin' or 'end' attribute is set or
|
|
|
|
// reset we should clear all the instance times that have been generated by
|
|
|
|
// that attribute (and hence an nsSMILTimeValueSpec), but not those from the
|
|
|
|
// DOM.
|
2010-07-02 22:52:51 -07:00
|
|
|
kFromDOM = 4,
|
|
|
|
|
|
|
|
// Indicates that this instance time was used as the endpoint of an interval
|
|
|
|
// that has been filtered or removed. However, since it is a dynamic time it
|
|
|
|
// should be preserved and not filtered.
|
|
|
|
kWasDynamicEndpoint = 8
|
2010-01-12 12:00:49 -08:00
|
|
|
};
|
2010-07-02 22:52:50 -07:00
|
|
|
PRUint8 mFlags; // Combination of kDynamic, kMayUpdate, etc.
|
|
|
|
PRPackedBool mVisited; // (mutable) Cycle tracking
|
|
|
|
|
|
|
|
// Additional reference count to determine if this instance time is currently
|
|
|
|
// used as a fixed endpoint in any intervals. Instance times that are used in
|
|
|
|
// this way should not be removed when the owning nsSMILTimedElement removes
|
|
|
|
// instance times in response to a restart or in an attempt to free up memory
|
|
|
|
// by filtering out old instance times.
|
|
|
|
//
|
|
|
|
// Instance times are only shared in a few cases, namely:
|
|
|
|
// a) early ends,
|
|
|
|
// b) zero-duration intervals, and
|
|
|
|
// c) momentarily whilst establishing new intervals and updating the current
|
|
|
|
// interval
|
|
|
|
// Hence the limited range of a PRUint16 should be more than adequate.
|
|
|
|
PRUint16 mFixedEndpointRefCnt;
|
|
|
|
|
2010-03-01 11:31:50 -08:00
|
|
|
PRUint32 mSerial; // A serial number used by the containing class to
|
|
|
|
// specify the sort order for instance times with the
|
|
|
|
// same mTime.
|
|
|
|
|
|
|
|
nsSMILTimeValueSpec* mCreator; // The nsSMILTimeValueSpec object that created
|
|
|
|
// us. (currently only needed for syncbase
|
|
|
|
// instance times.)
|
|
|
|
nsSMILInterval* mBaseInterval; // Interval from which this time is derived
|
|
|
|
// (only used for syncbase instance times)
|
2009-01-14 20:38:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NS_SMILINSTANCETIME_H_
|