Bug 1521575 - Move nsSMILTimeValue classes and nsSMILInstanceTime to the mozilla namespace r=birtles

This commit is contained in:
longsonr
2019-01-22 07:28:40 +00:00
parent 8f19f6e072
commit 792ebb03f4
22 changed files with 440 additions and 429 deletions

View File

@@ -521,7 +521,7 @@ void SMILAnimationController::DoMilestoneSamples() {
// its parent since registering a milestone. // its parent since registering a milestone.
continue; continue;
nsSMILTimeValue containerTimeValue = SMILTimeValue containerTimeValue =
container->ParentToContainerTime(sampleTime); container->ParentToContainerTime(sampleTime);
if (!containerTimeValue.IsDefinite()) continue; if (!containerTimeValue.IsDefinite()) continue;

View File

@@ -131,7 +131,7 @@ bool SMILAnimationFunction::UnsetAttr(nsAtom* aAttribute) {
} }
void SMILAnimationFunction::SampleAt(nsSMILTime aSampleTime, void SMILAnimationFunction::SampleAt(nsSMILTime aSampleTime,
const nsSMILTimeValue& aSimpleDuration, const SMILTimeValue& aSimpleDuration,
uint32_t aRepeatIteration) { uint32_t aRepeatIteration) {
// * Update mHasChanged ("Might this sample be different from prev one?") // * Update mHasChanged ("Might this sample be different from prev one?")
// Were we previously sampling a fill="freeze" final val? (We're not anymore.) // Were we previously sampling a fill="freeze" final val? (We're not anymore.)

View File

@@ -7,12 +7,12 @@
#ifndef NS_SMILANIMATIONFUNCTION_H_ #ifndef NS_SMILANIMATIONFUNCTION_H_
#define NS_SMILANIMATIONFUNCTION_H_ #define NS_SMILANIMATIONFUNCTION_H_
#include "mozilla/SMILKeySpline.h"
#include "mozilla/SMILTargetIdentifier.h" #include "mozilla/SMILTargetIdentifier.h"
#include "mozilla/SMILTimeValue.h"
#include "nsAttrValue.h" #include "nsAttrValue.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsISMILAttr.h" #include "nsISMILAttr.h"
#include "SMILKeySpline.h"
#include "nsSMILTimeValue.h"
#include "nsSMILTypes.h" #include "nsSMILTypes.h"
#include "nsSMILValue.h" #include "nsSMILValue.h"
#include "nsString.h" #include "nsString.h"
@@ -79,7 +79,7 @@ class SMILAnimationFunction {
* @param aRepeatIteration The repeat iteration for this sample. The first * @param aRepeatIteration The repeat iteration for this sample. The first
* iteration has a value of 0. * iteration has a value of 0.
*/ */
void SampleAt(nsSMILTime aSampleTime, const nsSMILTimeValue& aSimpleDuration, void SampleAt(nsSMILTime aSampleTime, const SMILTimeValue& aSimpleDuration,
uint32_t aRepeatIteration); uint32_t aRepeatIteration);
/** /**
@@ -409,7 +409,7 @@ class SMILAnimationFunction {
// to the animation value and allows the compositor to filter out functions // to the animation value and allows the compositor to filter out functions
// that it determines will not contribute to the final result. // that it determines will not contribute to the final result.
nsSMILTime mSampleTime; // sample time within simple dur nsSMILTime mSampleTime; // sample time within simple dur
nsSMILTimeValue mSimpleDuration; SMILTimeValue mSimpleDuration;
uint32_t mRepeatIteration; uint32_t mRepeatIteration;
nsSMILTime mBeginTime; // document time nsSMILTime mBeginTime; // document time

View File

@@ -4,19 +4,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsSMILInstanceTime.h" #include "SMILInstanceTime.h"
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "mozilla/SMILInterval.h" #include "mozilla/SMILInterval.h"
#include "nsSMILTimeValueSpec.h" #include "mozilla/SMILTimeValueSpec.h"
namespace mozilla {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSMILInstanceTime::nsSMILInstanceTime(const nsSMILTimeValue& aTime, SMILInstanceTime::SMILInstanceTime(const SMILTimeValue& aTime,
nsSMILInstanceTimeSource aSource, SMILInstanceTimeSource aSource,
nsSMILTimeValueSpec* aCreator, SMILTimeValueSpec* aCreator,
SMILInterval* aBaseInterval) SMILInterval* aBaseInterval)
: mTime(aTime), : mTime(aTime),
mFlags(0), mFlags(0),
mVisited(false), mVisited(false),
@@ -47,7 +49,7 @@ nsSMILInstanceTime::nsSMILInstanceTime(const nsSMILTimeValue& aTime,
SetBaseInterval(aBaseInterval); SetBaseInterval(aBaseInterval);
} }
nsSMILInstanceTime::~nsSMILInstanceTime() { SMILInstanceTime::~SMILInstanceTime() {
MOZ_ASSERT(!mBaseInterval, MOZ_ASSERT(!mBaseInterval,
"Destroying instance time without first calling Unlink()"); "Destroying instance time without first calling Unlink()");
MOZ_ASSERT(mFixedEndpointRefCnt == 0, MOZ_ASSERT(mFixedEndpointRefCnt == 0,
@@ -55,8 +57,8 @@ nsSMILInstanceTime::~nsSMILInstanceTime() {
"endpoint of an interval"); "endpoint of an interval");
} }
void nsSMILInstanceTime::Unlink() { void SMILInstanceTime::Unlink() {
RefPtr<nsSMILInstanceTime> deathGrip(this); RefPtr<SMILInstanceTime> deathGrip(this);
if (mBaseInterval) { if (mBaseInterval) {
mBaseInterval->RemoveDependentTime(*this); mBaseInterval->RemoveDependentTime(*this);
mBaseInterval = nullptr; mBaseInterval = nullptr;
@@ -64,7 +66,7 @@ void nsSMILInstanceTime::Unlink() {
mCreator = nullptr; mCreator = nullptr;
} }
void nsSMILInstanceTime::HandleChangedInterval( void SMILInstanceTime::HandleChangedInterval(
const SMILTimeContainer* aSrcContainer, bool aBeginObjectChanged, const SMILTimeContainer* aSrcContainer, bool aBeginObjectChanged,
bool aEndObjectChanged) { bool aEndObjectChanged) {
// It's possible a sequence of notifications might cause our base interval to // It's possible a sequence of notifications might cause our base interval to
@@ -84,7 +86,7 @@ void nsSMILInstanceTime::HandleChangedInterval(
bool objectChanged = bool objectChanged =
mCreator->DependsOnBegin() ? aBeginObjectChanged : aEndObjectChanged; mCreator->DependsOnBegin() ? aBeginObjectChanged : aEndObjectChanged;
RefPtr<nsSMILInstanceTime> deathGrip(this); RefPtr<SMILInstanceTime> deathGrip(this);
mozilla::AutoRestore<bool> setVisited(mVisited); mozilla::AutoRestore<bool> setVisited(mVisited);
mVisited = true; mVisited = true;
@@ -92,7 +94,7 @@ void nsSMILInstanceTime::HandleChangedInterval(
objectChanged); objectChanged);
} }
void nsSMILInstanceTime::HandleDeletedInterval() { void SMILInstanceTime::HandleDeletedInterval() {
MOZ_ASSERT(mBaseInterval, MOZ_ASSERT(mBaseInterval,
"Got call to HandleDeletedInterval on an independent instance " "Got call to HandleDeletedInterval on an independent instance "
"time"); "time");
@@ -101,12 +103,12 @@ void nsSMILInstanceTime::HandleDeletedInterval() {
mBaseInterval = nullptr; mBaseInterval = nullptr;
mFlags &= ~kMayUpdate; // Can't update without a base interval mFlags &= ~kMayUpdate; // Can't update without a base interval
RefPtr<nsSMILInstanceTime> deathGrip(this); RefPtr<SMILInstanceTime> deathGrip(this);
mCreator->HandleDeletedInstanceTime(*this); mCreator->HandleDeletedInstanceTime(*this);
mCreator = nullptr; mCreator = nullptr;
} }
void nsSMILInstanceTime::HandleFilteredInterval() { void SMILInstanceTime::HandleFilteredInterval() {
MOZ_ASSERT(mBaseInterval, MOZ_ASSERT(mBaseInterval,
"Got call to HandleFilteredInterval on an independent instance " "Got call to HandleFilteredInterval on an independent instance "
"time"); "time");
@@ -116,22 +118,22 @@ void nsSMILInstanceTime::HandleFilteredInterval() {
mCreator = nullptr; mCreator = nullptr;
} }
bool nsSMILInstanceTime::ShouldPreserve() const { bool SMILInstanceTime::ShouldPreserve() const {
return mFixedEndpointRefCnt > 0 || (mFlags & kWasDynamicEndpoint); return mFixedEndpointRefCnt > 0 || (mFlags & kWasDynamicEndpoint);
} }
void nsSMILInstanceTime::UnmarkShouldPreserve() { void SMILInstanceTime::UnmarkShouldPreserve() {
mFlags &= ~kWasDynamicEndpoint; mFlags &= ~kWasDynamicEndpoint;
} }
void nsSMILInstanceTime::AddRefFixedEndpoint() { void SMILInstanceTime::AddRefFixedEndpoint() {
MOZ_ASSERT(mFixedEndpointRefCnt < UINT16_MAX, MOZ_ASSERT(mFixedEndpointRefCnt < UINT16_MAX,
"Fixed endpoint reference count upper limit reached"); "Fixed endpoint reference count upper limit reached");
++mFixedEndpointRefCnt; ++mFixedEndpointRefCnt;
mFlags &= ~kMayUpdate; // Once fixed, always fixed mFlags &= ~kMayUpdate; // Once fixed, always fixed
} }
void nsSMILInstanceTime::ReleaseFixedEndpoint() { void SMILInstanceTime::ReleaseFixedEndpoint() {
MOZ_ASSERT(mFixedEndpointRefCnt > 0, "Duplicate release"); MOZ_ASSERT(mFixedEndpointRefCnt > 0, "Duplicate release");
--mFixedEndpointRefCnt; --mFixedEndpointRefCnt;
if (mFixedEndpointRefCnt == 0 && IsDynamic()) { if (mFixedEndpointRefCnt == 0 && IsDynamic()) {
@@ -139,10 +141,10 @@ void nsSMILInstanceTime::ReleaseFixedEndpoint() {
} }
} }
bool nsSMILInstanceTime::IsDependentOn(const nsSMILInstanceTime& aOther) const { bool SMILInstanceTime::IsDependentOn(const SMILInstanceTime& aOther) const {
if (mVisited) return false; if (mVisited) return false;
const nsSMILInstanceTime* myBaseTime = GetBaseTime(); const SMILInstanceTime* myBaseTime = GetBaseTime();
if (!myBaseTime) return false; if (!myBaseTime) return false;
if (myBaseTime == &aOther) return true; if (myBaseTime == &aOther) return true;
@@ -152,7 +154,7 @@ bool nsSMILInstanceTime::IsDependentOn(const nsSMILInstanceTime& aOther) const {
return myBaseTime->IsDependentOn(aOther); return myBaseTime->IsDependentOn(aOther);
} }
const nsSMILInstanceTime* nsSMILInstanceTime::GetBaseTime() const { const SMILInstanceTime* SMILInstanceTime::GetBaseTime() const {
if (!mBaseInterval) { if (!mBaseInterval) {
return nullptr; return nullptr;
} }
@@ -166,7 +168,7 @@ const nsSMILInstanceTime* nsSMILInstanceTime::GetBaseTime() const {
: mBaseInterval->End(); : mBaseInterval->End();
} }
void nsSMILInstanceTime::SetBaseInterval(SMILInterval* aBaseInterval) { void SMILInstanceTime::SetBaseInterval(SMILInterval* aBaseInterval) {
MOZ_ASSERT(!mBaseInterval, MOZ_ASSERT(!mBaseInterval,
"Attempting to reassociate an instance time with a different " "Attempting to reassociate an instance time with a different "
"interval."); "interval.");
@@ -174,7 +176,7 @@ void nsSMILInstanceTime::SetBaseInterval(SMILInterval* aBaseInterval) {
if (aBaseInterval) { if (aBaseInterval) {
MOZ_ASSERT(mCreator, MOZ_ASSERT(mCreator,
"Attempting to create a dependent instance time without " "Attempting to create a dependent instance time without "
"reference to the creating nsSMILTimeValueSpec object."); "reference to the creating SMILTimeValueSpec object.");
if (!mCreator) return; if (!mCreator) return;
aBaseInterval->AddDependentTime(*this); aBaseInterval->AddDependentTime(*this);
@@ -182,3 +184,5 @@ void nsSMILInstanceTime::SetBaseInterval(SMILInterval* aBaseInterval) {
mBaseInterval = aBaseInterval; mBaseInterval = aBaseInterval;
} }
} // namespace mozilla

View File

@@ -8,44 +8,39 @@
#define NS_SMILINSTANCETIME_H_ #define NS_SMILINSTANCETIME_H_
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "nsSMILTimeValue.h" #include "mozilla/SMILTimeValue.h"
class nsSMILTimeValueSpec;
namespace mozilla { namespace mozilla {
class SMILInterval; class SMILInterval;
class SMILTimeContainer; class SMILTimeContainer;
} class SMILTimeValueSpec;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSMILInstanceTime // SMILInstanceTime
// //
// An instant in document simple time that may be used in creating a new // An instant in document simple time that may be used in creating a new
// interval. // interval.
// //
// For an overview of how this class is related to other SMIL time classes see // For an overview of how this class is related to other SMIL time classes see
// the documentation in nsSMILTimeValue.h // the documentation in SMILTimeValue.h
// //
// These objects are owned by an SMILTimedElement but MAY also be referenced // These objects are owned by an SMILTimedElement but MAY also be referenced
// by: // by:
// //
// a) SMILIntervals that belong to the same SMILTimedElement and which refer // a) SMILIntervals that belong to the same SMILTimedElement and which refer
// to the nsSMILInstanceTimes which form the interval endpoints; and/or // to the SMILInstanceTimes which form the interval endpoints; and/or
// b) SMILIntervals that belong to other SMILTimedElements but which need to // b) SMILIntervals that belong to other SMILTimedElements but which need to
// update dependent instance times when they change or are deleted. // update dependent instance times when they change or are deleted.
// E.g. for begin='a.begin', 'a' needs to inform dependent // E.g. for begin='a.begin', 'a' needs to inform dependent
// nsSMILInstanceTimes if its begin time changes. This notification is // SMILInstanceTimes if its begin time changes. This notification is
// performed by the SMILInterval. // performed by the SMILInterval.
class nsSMILInstanceTime final { class SMILInstanceTime final {
typedef mozilla::SMILInterval SMILInterval;
typedef mozilla::SMILTimeContainer SMILTimeContainer;
public: public:
// Instance time source. Times generated by events, syncbase relationships, // Instance time source. Times generated by events, syncbase relationships,
// and DOM calls behave differently in some circumstances such as when a timed // and DOM calls behave differently in some circumstances such as when a timed
// element is reset. // element is reset.
enum nsSMILInstanceTimeSource { enum SMILInstanceTimeSource {
// No particularly significant source, e.g. offset time, 'indefinite' // No particularly significant source, e.g. offset time, 'indefinite'
SOURCE_NONE, SOURCE_NONE,
// Generated by a DOM call such as beginElement // Generated by a DOM call such as beginElement
@@ -56,10 +51,10 @@ class nsSMILInstanceTime final {
SOURCE_EVENT SOURCE_EVENT
}; };
explicit nsSMILInstanceTime(const nsSMILTimeValue& aTime, explicit SMILInstanceTime(const SMILTimeValue& aTime,
nsSMILInstanceTimeSource aSource = SOURCE_NONE, SMILInstanceTimeSource aSource = SOURCE_NONE,
nsSMILTimeValueSpec* aCreator = nullptr, SMILTimeValueSpec* aCreator = nullptr,
SMILInterval* aBaseInterval = nullptr); SMILInterval* aBaseInterval = nullptr);
void Unlink(); void Unlink();
void HandleChangedInterval(const SMILTimeContainer* aSrcContainer, void HandleChangedInterval(const SMILTimeContainer* aSrcContainer,
@@ -67,8 +62,8 @@ class nsSMILInstanceTime final {
void HandleDeletedInterval(); void HandleDeletedInterval();
void HandleFilteredInterval(); void HandleFilteredInterval();
const nsSMILTimeValue& Time() const { return mTime; } const SMILTimeValue& Time() const { return mTime; }
const nsSMILTimeValueSpec* GetCreator() const { return mCreator; } const SMILTimeValueSpec* GetCreator() const { return mCreator; }
bool IsDynamic() const { return !!(mFlags & kDynamic); } bool IsDynamic() const { return !!(mFlags & kDynamic); }
bool IsFixedTime() const { return !(mFlags & kMayUpdate); } bool IsFixedTime() const { return !(mFlags & kMayUpdate); }
@@ -80,18 +75,18 @@ class nsSMILInstanceTime final {
void AddRefFixedEndpoint(); void AddRefFixedEndpoint();
void ReleaseFixedEndpoint(); void ReleaseFixedEndpoint();
void DependentUpdate(const nsSMILTimeValue& aNewTime) { void DependentUpdate(const SMILTimeValue& aNewTime) {
MOZ_ASSERT(!IsFixedTime(), MOZ_ASSERT(!IsFixedTime(),
"Updating an instance time that is not expected to be updated"); "Updating an instance time that is not expected to be updated");
mTime = aNewTime; mTime = aNewTime;
} }
bool IsDependent() const { return !!mBaseInterval; } bool IsDependent() const { return !!mBaseInterval; }
bool IsDependentOn(const nsSMILInstanceTime& aOther) const; bool IsDependentOn(const SMILInstanceTime& aOther) const;
const SMILInterval* GetBaseInterval() const { return mBaseInterval; } const SMILInterval* GetBaseInterval() const { return mBaseInterval; }
const nsSMILInstanceTime* GetBaseTime() const; const SMILInstanceTime* GetBaseTime() const;
bool SameTimeAndBase(const nsSMILInstanceTime& aOther) const { bool SameTimeAndBase(const SMILInstanceTime& aOther) const {
return mTime == aOther.mTime && GetBaseTime() == aOther.GetBaseTime(); return mTime == aOther.mTime && GetBaseTime() == aOther.GetBaseTime();
} }
@@ -100,15 +95,15 @@ class nsSMILInstanceTime final {
uint32_t Serial() const { return mSerial; } uint32_t Serial() const { return mSerial; }
void SetSerial(uint32_t aIndex) { mSerial = aIndex; } void SetSerial(uint32_t aIndex) { mSerial = aIndex; }
NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime) NS_INLINE_DECL_REFCOUNTING(SMILInstanceTime)
private: private:
// Private destructor, to discourage deletion outside of Release(): // Private destructor, to discourage deletion outside of Release():
~nsSMILInstanceTime(); ~SMILInstanceTime();
void SetBaseInterval(SMILInterval* aBaseInterval); void SetBaseInterval(SMILInterval* aBaseInterval);
nsSMILTimeValue mTime; SMILTimeValue mTime;
// Internal flags used to represent the behaviour of different instance times // Internal flags used to represent the behaviour of different instance times
enum { enum {
@@ -120,15 +115,15 @@ class nsSMILInstanceTime final {
kDynamic = 1, kDynamic = 1,
// Indicates that this instance time is referred to by an // Indicates that this instance time is referred to by an
// nsSMILTimeValueSpec and as such may be updated. Such instance time should // SMILTimeValueSpec and as such may be updated. Such instance time should
// not be filtered out by the SMILTimedElement even if they appear to be // not be filtered out by the SMILTimedElement even if they appear to be
// in the past as they may be updated to a future time. // in the past as they may be updated to a future time.
kMayUpdate = 2, kMayUpdate = 2,
// Indicates that this instance time was generated from the DOM as opposed // Indicates that this instance time was generated from the DOM as opposed
// to an nsSMILTimeValueSpec. When a 'begin' or 'end' attribute is set or // to an SMILTimeValueSpec. When a 'begin' or 'end' attribute is set or
// reset we should clear all the instance times that have been generated by // reset we should clear all the instance times that have been generated by
// that attribute (and hence an nsSMILTimeValueSpec), but not those from the // that attribute (and hence an SMILTimeValueSpec), but not those from the
// DOM. // DOM.
kFromDOM = 4, kFromDOM = 4,
@@ -159,11 +154,13 @@ class nsSMILInstanceTime final {
// specify the sort order for instance times with the // specify the sort order for instance times with the
// same mTime. // same mTime.
nsSMILTimeValueSpec* mCreator; // The nsSMILTimeValueSpec object that created SMILTimeValueSpec* mCreator; // The SMILTimeValueSpec object that created
// us. (currently only needed for syncbase // us. (currently only needed for syncbase
// instance times.) // instance times.)
SMILInterval* mBaseInterval; // Interval from which this time is derived SMILInterval* mBaseInterval; // Interval from which this time is derived
// (only used for syncbase instance times) // (only used for syncbase instance times)
}; };
} // namespace mozilla
#endif // NS_SMILINSTANCETIME_H_ #endif // NS_SMILINSTANCETIME_H_

View File

@@ -52,17 +52,17 @@ void SMILInterval::Unlink(bool aFiltered) {
mEnd = nullptr; mEnd = nullptr;
} }
nsSMILInstanceTime* SMILInterval::Begin() { SMILInstanceTime* SMILInterval::Begin() {
MOZ_ASSERT(mBegin && mEnd, "Requesting Begin() on un-initialized interval."); MOZ_ASSERT(mBegin && mEnd, "Requesting Begin() on un-initialized interval.");
return mBegin; return mBegin;
} }
nsSMILInstanceTime* SMILInterval::End() { SMILInstanceTime* SMILInterval::End() {
MOZ_ASSERT(mBegin && mEnd, "Requesting End() on un-initialized interval."); MOZ_ASSERT(mBegin && mEnd, "Requesting End() on un-initialized interval.");
return mEnd; return mEnd;
} }
void SMILInterval::SetBegin(nsSMILInstanceTime& aBegin) { void SMILInterval::SetBegin(SMILInstanceTime& aBegin) {
MOZ_ASSERT(aBegin.Time().IsDefinite(), MOZ_ASSERT(aBegin.Time().IsDefinite(),
"Attempt to set unresolved or indefinite begin time on interval"); "Attempt to set unresolved or indefinite begin time on interval");
MOZ_ASSERT(!mBeginFixed, MOZ_ASSERT(!mBeginFixed,
@@ -76,7 +76,7 @@ void SMILInterval::SetBegin(nsSMILInstanceTime& aBegin) {
mBegin = &aBegin; mBegin = &aBegin;
} }
void SMILInterval::SetEnd(nsSMILInstanceTime& aEnd) { void SMILInterval::SetEnd(SMILInstanceTime& aEnd) {
MOZ_ASSERT(!mEndFixed, "Attempt to set end time but the end point is fixed"); MOZ_ASSERT(!mEndFixed, "Attempt to set end time but the end point is fixed");
// As with SetBegin, check we're not making an instance time dependent on // As with SetBegin, check we're not making an instance time dependent on
// itself. // itself.
@@ -102,15 +102,15 @@ void SMILInterval::FixEnd() {
mEnd->AddRefFixedEndpoint(); mEnd->AddRefFixedEndpoint();
} }
void SMILInterval::AddDependentTime(nsSMILInstanceTime& aTime) { void SMILInterval::AddDependentTime(SMILInstanceTime& aTime) {
RefPtr<nsSMILInstanceTime>* inserted = RefPtr<SMILInstanceTime>* inserted =
mDependentTimes.InsertElementSorted(&aTime); mDependentTimes.InsertElementSorted(&aTime);
if (!inserted) { if (!inserted) {
NS_WARNING("Insufficient memory to insert instance time."); NS_WARNING("Insufficient memory to insert instance time.");
} }
} }
void SMILInterval::RemoveDependentTime(const nsSMILInstanceTime& aTime) { void SMILInterval::RemoveDependentTime(const SMILInstanceTime& aTime) {
#ifdef DEBUG #ifdef DEBUG
bool found = bool found =
#endif #endif

View File

@@ -7,7 +7,7 @@
#ifndef NS_SMILINTERVAL_H_ #ifndef NS_SMILINTERVAL_H_
#define NS_SMILINTERVAL_H_ #define NS_SMILINTERVAL_H_
#include "nsSMILInstanceTime.h" #include "mozilla/SMILInstanceTime.h"
#include "nsTArray.h" #include "nsTArray.h"
namespace mozilla { namespace mozilla {
@@ -19,7 +19,7 @@ namespace mozilla {
// resolved (i.e. not indefinite or unresolved). // resolved (i.e. not indefinite or unresolved).
// //
// For an overview of how this class is related to other SMIL time classes see // For an overview of how this class is related to other SMIL time classes see
// the documentation in nsSMILTimeValue.h // the documentation in SMILTimeValue.h
class SMILInterval { class SMILInterval {
public: public:
@@ -28,23 +28,23 @@ class SMILInterval {
~SMILInterval(); ~SMILInterval();
void Unlink(bool aFiltered = false); void Unlink(bool aFiltered = false);
const nsSMILInstanceTime* Begin() const { const SMILInstanceTime* Begin() const {
MOZ_ASSERT(mBegin && mEnd, MOZ_ASSERT(mBegin && mEnd,
"Requesting Begin() on un-initialized instance time"); "Requesting Begin() on un-initialized instance time");
return mBegin; return mBegin;
} }
nsSMILInstanceTime* Begin(); SMILInstanceTime* Begin();
const nsSMILInstanceTime* End() const { const SMILInstanceTime* End() const {
MOZ_ASSERT(mBegin && mEnd, MOZ_ASSERT(mBegin && mEnd,
"Requesting End() on un-initialized instance time"); "Requesting End() on un-initialized instance time");
return mEnd; return mEnd;
} }
nsSMILInstanceTime* End(); SMILInstanceTime* End();
void SetBegin(nsSMILInstanceTime& aBegin); void SetBegin(SMILInstanceTime& aBegin);
void SetEnd(nsSMILInstanceTime& aEnd); void SetEnd(SMILInstanceTime& aEnd);
void Set(nsSMILInstanceTime& aBegin, nsSMILInstanceTime& aEnd) { void Set(SMILInstanceTime& aBegin, SMILInstanceTime& aEnd) {
SetBegin(aBegin); SetBegin(aBegin);
SetEnd(aEnd); SetEnd(aEnd);
} }
@@ -52,30 +52,30 @@ class SMILInterval {
void FixBegin(); void FixBegin();
void FixEnd(); void FixEnd();
typedef nsTArray<RefPtr<nsSMILInstanceTime> > InstanceTimeList; typedef nsTArray<RefPtr<SMILInstanceTime> > InstanceTimeList;
void AddDependentTime(nsSMILInstanceTime& aTime); void AddDependentTime(SMILInstanceTime& aTime);
void RemoveDependentTime(const nsSMILInstanceTime& aTime); void RemoveDependentTime(const SMILInstanceTime& aTime);
void GetDependentTimes(InstanceTimeList& aTimes); void GetDependentTimes(InstanceTimeList& aTimes);
// Cue for assessing if this interval can be filtered // Cue for assessing if this interval can be filtered
bool IsDependencyChainLink() const; bool IsDependencyChainLink() const;
private: private:
RefPtr<nsSMILInstanceTime> mBegin; RefPtr<SMILInstanceTime> mBegin;
RefPtr<nsSMILInstanceTime> mEnd; RefPtr<SMILInstanceTime> mEnd;
// nsSMILInstanceTimes to notify when this interval is changed or deleted. // SMILInstanceTimes to notify when this interval is changed or deleted.
InstanceTimeList mDependentTimes; InstanceTimeList mDependentTimes;
// Indicates if the end points of the interval are fixed or not. // 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 // 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 // (i.e. SMILInstanceTime::IsFixed() returns true). This is because it is
// possible to have an end point with a fixed TIME and yet still update the // possible to have an end point with a fixed TIME and yet still update the
// end point to refer to a different nsSMILInstanceTime object. // end point to refer to a different SMILInstanceTime object.
// //
// However, if mBegin/EndFixed is true, then BOTH the nsSMILInstanceTime // However, if mBegin/EndFixed is true, then BOTH the SMILInstanceTime
// OBJECT returned for that end point and its TIME value will not change. // OBJECT returned for that end point and its TIME value will not change.
bool mBeginFixed; bool mBeginFixed;
bool mEndFixed; bool mEndFixed;

View File

@@ -8,12 +8,12 @@
#include "mozilla/SMILKeySpline.h" #include "mozilla/SMILKeySpline.h"
#include "mozilla/SMILRepeatCount.h" #include "mozilla/SMILRepeatCount.h"
#include "mozilla/SMILTimeValue.h"
#include "mozilla/SMILTimeValueSpecParams.h"
#include "mozilla/SVGContentUtils.h" #include "mozilla/SVGContentUtils.h"
#include "mozilla/TextUtils.h" #include "mozilla/TextUtils.h"
#include "nsISMILAttr.h" #include "nsISMILAttr.h"
#include "nsSMILValue.h" #include "nsSMILValue.h"
#include "nsSMILTimeValue.h"
#include "nsSMILTimeValueSpecParams.h"
#include "nsSMILTypes.h" #include "nsSMILTypes.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsCharSeparatedTokenizer.h" #include "nsCharSeparatedTokenizer.h"
@@ -128,7 +128,7 @@ inline bool ParseClockMetric(RangedPtr<const char16_t>& aIter,
*/ */
bool ParseClockValue(RangedPtr<const char16_t>& aIter, bool ParseClockValue(RangedPtr<const char16_t>& aIter,
const RangedPtr<const char16_t>& aEnd, const RangedPtr<const char16_t>& aEnd,
nsSMILTimeValue* aResult) { SMILTimeValue* aResult) {
if (aIter == aEnd) { if (aIter == aEnd) {
return false; return false;
} }
@@ -213,7 +213,7 @@ bool ParseClockValue(RangedPtr<const char16_t>& aIter,
bool ParseOffsetValue(RangedPtr<const char16_t>& aIter, bool ParseOffsetValue(RangedPtr<const char16_t>& aIter,
const RangedPtr<const char16_t>& aEnd, const RangedPtr<const char16_t>& aEnd,
nsSMILTimeValue* aResult) { SMILTimeValue* aResult) {
RangedPtr<const char16_t> iter(aIter); RangedPtr<const char16_t> iter(aIter);
int32_t sign; int32_t sign;
@@ -228,7 +228,7 @@ bool ParseOffsetValue(RangedPtr<const char16_t>& aIter,
return true; return true;
} }
bool ParseOffsetValue(const nsAString& aSpec, nsSMILTimeValue* aResult) { bool ParseOffsetValue(const nsAString& aSpec, SMILTimeValue* aResult) {
RangedPtr<const char16_t> iter(SVGContentUtils::GetStartRangedPtr(aSpec)); RangedPtr<const char16_t> iter(SVGContentUtils::GetStartRangedPtr(aSpec));
const RangedPtr<const char16_t> end(SVGContentUtils::GetEndRangedPtr(aSpec)); const RangedPtr<const char16_t> end(SVGContentUtils::GetEndRangedPtr(aSpec));
@@ -237,7 +237,7 @@ bool ParseOffsetValue(const nsAString& aSpec, nsSMILTimeValue* aResult) {
bool ParseOptionalOffset(RangedPtr<const char16_t>& aIter, bool ParseOptionalOffset(RangedPtr<const char16_t>& aIter,
const RangedPtr<const char16_t>& aEnd, const RangedPtr<const char16_t>& aEnd,
nsSMILTimeValue* aResult) { SMILTimeValue* aResult) {
if (aIter == aEnd) { if (aIter == aEnd) {
aResult->SetMillis(0L); aResult->SetMillis(0L);
return true; return true;
@@ -307,8 +307,8 @@ already_AddRefed<nsAtom> ConvertTokenToAtom(const nsAString& aToken,
} }
bool ParseElementBaseTimeValueSpec(const nsAString& aSpec, bool ParseElementBaseTimeValueSpec(const nsAString& aSpec,
nsSMILTimeValueSpecParams& aResult) { SMILTimeValueSpecParams& aResult) {
nsSMILTimeValueSpecParams result; SMILTimeValueSpecParams result;
// //
// The spec will probably look something like one of these // The spec will probably look something like one of these
@@ -353,11 +353,11 @@ bool ParseElementBaseTimeValueSpec(const nsAString& aSpec,
// element-name.begin // element-name.begin
if (token2.EqualsLiteral("begin")) { if (token2.EqualsLiteral("begin")) {
result.mType = nsSMILTimeValueSpecParams::SYNCBASE; result.mType = SMILTimeValueSpecParams::SYNCBASE;
result.mSyncBegin = true; result.mSyncBegin = true;
// element-name.end // element-name.end
} else if (token2.EqualsLiteral("end")) { } else if (token2.EqualsLiteral("end")) {
result.mType = nsSMILTimeValueSpecParams::SYNCBASE; result.mType = SMILTimeValueSpecParams::SYNCBASE;
result.mSyncBegin = false; result.mSyncBegin = false;
// element-name.repeat(digit+) // element-name.repeat(digit+)
} else if (StringBeginsWith(token2, REPEAT_PREFIX)) { } else if (StringBeginsWith(token2, REPEAT_PREFIX)) {
@@ -370,7 +370,7 @@ bool ParseElementBaseTimeValueSpec(const nsAString& aSpec,
if (start == tokenEnd || *start != ')') { if (start == tokenEnd || *start != ')') {
return false; return false;
} }
result.mType = nsSMILTimeValueSpecParams::REPEAT; result.mType = SMILTimeValueSpecParams::REPEAT;
result.mRepeatIteration = repeatValue; result.mRepeatIteration = repeatValue;
// element-name.event-symbol // element-name.event-symbol
} else { } else {
@@ -378,12 +378,12 @@ bool ParseElementBaseTimeValueSpec(const nsAString& aSpec,
if (atom == nullptr) { if (atom == nullptr) {
return false; return false;
} }
result.mType = nsSMILTimeValueSpecParams::EVENT; result.mType = SMILTimeValueSpecParams::EVENT;
result.mEventSymbol = atom; result.mEventSymbol = atom;
} }
} else { } else {
// event-symbol // event-symbol
result.mType = nsSMILTimeValueSpecParams::EVENT; result.mType = SMILTimeValueSpecParams::EVENT;
result.mEventSymbol = atom; result.mEventSymbol = atom;
} }
@@ -569,17 +569,17 @@ bool SMILParserUtils::ParseRepeatCount(const nsAString& aSpec,
} }
bool SMILParserUtils::ParseTimeValueSpecParams( bool SMILParserUtils::ParseTimeValueSpecParams(
const nsAString& aSpec, nsSMILTimeValueSpecParams& aResult) { const nsAString& aSpec, SMILTimeValueSpecParams& aResult) {
const nsAString& spec = TrimWhitespace(aSpec); const nsAString& spec = TrimWhitespace(aSpec);
if (spec.EqualsLiteral("indefinite")) { if (spec.EqualsLiteral("indefinite")) {
aResult.mType = nsSMILTimeValueSpecParams::INDEFINITE; aResult.mType = SMILTimeValueSpecParams::INDEFINITE;
return true; return true;
} }
// offset type // offset type
if (ParseOffsetValue(spec, &aResult.mOffset)) { if (ParseOffsetValue(spec, &aResult.mOffset)) {
aResult.mType = nsSMILTimeValueSpecParams::OFFSET; aResult.mType = SMILTimeValueSpecParams::OFFSET;
return true; return true;
} }
@@ -599,7 +599,7 @@ bool SMILParserUtils::ParseTimeValueSpecParams(
} }
bool SMILParserUtils::ParseClockValue(const nsAString& aSpec, bool SMILParserUtils::ParseClockValue(const nsAString& aSpec,
nsSMILTimeValue* aResult) { SMILTimeValue* aResult) {
RangedPtr<const char16_t> iter(SVGContentUtils::GetStartRangedPtr(aSpec)); RangedPtr<const char16_t> iter(SVGContentUtils::GetStartRangedPtr(aSpec));
RangedPtr<const char16_t> end(SVGContentUtils::GetEndRangedPtr(aSpec)); RangedPtr<const char16_t> end(SVGContentUtils::GetEndRangedPtr(aSpec));

View File

@@ -11,13 +11,13 @@
#include "nsStringFwd.h" #include "nsStringFwd.h"
class nsISMILAttr; class nsISMILAttr;
class nsSMILTimeValue;
class nsSMILValue; class nsSMILValue;
class nsSMILTimeValueSpecParams;
namespace mozilla { namespace mozilla {
class SMILKeySpline; class SMILKeySpline;
class SMILRepeatCount; class SMILRepeatCount;
class SMILTimeValue;
class SMILTimeValueSpecParams;
namespace dom { namespace dom {
class SVGAnimationElement; class SVGAnimationElement;
} // namespace dom } // namespace dom
@@ -60,7 +60,7 @@ class SMILParserUtils {
SMILRepeatCount& aResult); SMILRepeatCount& aResult);
static bool ParseTimeValueSpecParams(const nsAString& aSpec, static bool ParseTimeValueSpecParams(const nsAString& aSpec,
nsSMILTimeValueSpecParams& aResult); SMILTimeValueSpecParams& aResult);
/* /*
* Parses a clock value as defined in the SMIL Animation specification. * Parses a clock value as defined in the SMIL Animation specification.
@@ -71,7 +71,7 @@ class SMILParserUtils {
* @param aResult The parsed result. [OUT] * @param aResult The parsed result. [OUT]
* @return true if parsing succeeded, otherwise false. * @return true if parsing succeeded, otherwise false.
*/ */
static bool ParseClockValue(const nsAString& aSpec, nsSMILTimeValue* aResult); static bool ParseClockValue(const nsAString& aSpec, SMILTimeValue* aResult);
/* /*
* This method checks whether the given string looks like a negative number. * This method checks whether the given string looks like a negative number.

View File

@@ -12,4 +12,3 @@ namespace mozilla {
/*static*/ const double SMILRepeatCount::kIndefinite = -2.0; /*static*/ const double SMILRepeatCount::kIndefinite = -2.0;
} // namespace mozilla } // namespace mozilla

View File

@@ -8,7 +8,7 @@
#include "mozilla/AutoRestore.h" #include "mozilla/AutoRestore.h"
#include "mozilla/SMILTimedElement.h" #include "mozilla/SMILTimedElement.h"
#include "nsSMILTimeValue.h" #include "mozilla/SMILTimeValue.h"
#include <algorithm> #include <algorithm>
namespace mozilla { namespace mozilla {
@@ -33,22 +33,22 @@ SMILTimeContainer::~SMILTimeContainer() {
} }
} }
nsSMILTimeValue SMILTimeContainer::ContainerToParentTime( SMILTimeValue SMILTimeContainer::ContainerToParentTime(
nsSMILTime aContainerTime) const { nsSMILTime aContainerTime) const {
// If we're paused, then future times are indefinite // If we're paused, then future times are indefinite
if (IsPaused() && aContainerTime > mCurrentTime) if (IsPaused() && aContainerTime > mCurrentTime)
return nsSMILTimeValue::Indefinite(); return SMILTimeValue::Indefinite();
return nsSMILTimeValue(aContainerTime + mParentOffset); return SMILTimeValue(aContainerTime + mParentOffset);
} }
nsSMILTimeValue SMILTimeContainer::ParentToContainerTime( SMILTimeValue SMILTimeContainer::ParentToContainerTime(
nsSMILTime aParentTime) const { nsSMILTime aParentTime) const {
// If we're paused, then any time after when we paused is indefinite // If we're paused, then any time after when we paused is indefinite
if (IsPaused() && aParentTime > mPauseStart) if (IsPaused() && aParentTime > mPauseStart)
return nsSMILTimeValue::Indefinite(); return SMILTimeValue::Indefinite();
return nsSMILTimeValue(aParentTime - mParentOffset); return SMILTimeValue(aParentTime - mParentOffset);
} }
void SMILTimeContainer::Begin() { void SMILTimeContainer::Begin() {
@@ -205,7 +205,7 @@ bool SMILTimeContainer::GetNextMilestoneInParentTime(
SMILMilestone& aNextMilestone) const { SMILMilestone& aNextMilestone) const {
if (mMilestoneEntries.IsEmpty()) return false; if (mMilestoneEntries.IsEmpty()) return false;
nsSMILTimeValue parentTime = SMILTimeValue parentTime =
ContainerToParentTime(mMilestoneEntries.Top().mMilestone.mTime); ContainerToParentTime(mMilestoneEntries.Top().mMilestone.mTime);
if (!parentTime.IsDefinite()) return false; if (!parentTime.IsDefinite()) return false;
@@ -219,7 +219,7 @@ bool SMILTimeContainer::PopMilestoneElementsAtMilestone(
const SMILMilestone& aMilestone, AnimElemArray& aMatchedElements) { const SMILMilestone& aMilestone, AnimElemArray& aMatchedElements) {
if (mMilestoneEntries.IsEmpty()) return false; if (mMilestoneEntries.IsEmpty()) return false;
nsSMILTimeValue containerTime = ParentToContainerTime(aMilestone.mTime); SMILTimeValue containerTime = ParentToContainerTime(aMilestone.mTime);
if (!containerTime.IsDefinite()) return false; if (!containerTime.IsDefinite()) return false;
SMILMilestone containerMilestone(containerTime.GetMillis(), SMILMilestone containerMilestone(containerTime.GetMillis(),

View File

@@ -13,10 +13,10 @@
#include "nsSMILTypes.h" #include "nsSMILTypes.h"
#include "nsTPriorityQueue.h" #include "nsTPriorityQueue.h"
class nsSMILTimeValue;
namespace mozilla { namespace mozilla {
class SMILTimeValue;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// SMILTimeContainer // SMILTimeContainer
// //
@@ -107,7 +107,7 @@ class SMILTimeContainer {
* @return The equivalent parent time or indefinite if the container is * @return The equivalent parent time or indefinite if the container is
* paused and the time is in the future. * paused and the time is in the future.
*/ */
nsSMILTimeValue ContainerToParentTime(nsSMILTime aContainerTime) const; SMILTimeValue ContainerToParentTime(nsSMILTime aContainerTime) const;
/* /*
* Convert from parent time to container time. * Convert from parent time to container time.
@@ -116,7 +116,7 @@ class SMILTimeContainer {
* @return The equivalent container time or indefinite if the container is * @return The equivalent container time or indefinite if the container is
* paused and aParentTime is after the time when the pause began. * paused and aParentTime is after the time when the pause began.
*/ */
nsSMILTimeValue ParentToContainerTime(nsSMILTime aParentTime) const; SMILTimeValue ParentToContainerTime(nsSMILTime aParentTime) const;
/* /*
* If the container is paused, causes the pause time to be updated to the * If the container is paused, causes the pause time to be updated to the

View File

@@ -4,19 +4,21 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsSMILTimeValue.h" #include "SMILTimeValue.h"
const nsSMILTime nsSMILTimeValue::kUnresolvedMillis = namespace mozilla {
const nsSMILTime SMILTimeValue::kUnresolvedMillis =
std::numeric_limits<nsSMILTime>::max(); std::numeric_limits<nsSMILTime>::max();
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSMILTimeValue methods: // SMILTimeValue methods:
static inline int8_t Cmp(int64_t aA, int64_t aB) { static inline int8_t Cmp(int64_t aA, int64_t aB) {
return aA == aB ? 0 : (aA > aB ? 1 : -1); return aA == aB ? 0 : (aA > aB ? 1 : -1);
} }
int8_t nsSMILTimeValue::CompareTo(const nsSMILTimeValue& aOther) const { int8_t SMILTimeValue::CompareTo(const SMILTimeValue& aOther) const {
int8_t result; int8_t result;
if (mState == STATE_DEFINITE) { if (mState == STATE_DEFINITE) {
@@ -36,3 +38,5 @@ int8_t nsSMILTimeValue::CompareTo(const nsSMILTimeValue& aOther) const {
return result; return result;
} }
} // namespace mozilla

View File

@@ -10,26 +10,28 @@
#include "nsSMILTypes.h" #include "nsSMILTypes.h"
#include "nsDebug.h" #include "nsDebug.h"
namespace mozilla {
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
* nsSMILTimeValue class * SMILTimeValue class
* *
* A tri-state time value. * A tri-state time value.
* *
* First a quick overview of the SMIL time data types: * First a quick overview of the SMIL time data types:
* *
* nsSMILTime -- a timestamp in milliseconds. * nsSMILTime -- a timestamp in milliseconds.
* nsSMILTimeValue -- (this class) a timestamp that can take the additional * SMILTimeValue -- (this class) a timestamp that can take the additional
* states 'indefinite' and 'unresolved' * states 'indefinite' and 'unresolved'
* nsSMILInstanceTime -- an nsSMILTimeValue used for constructing intervals. It * SMILInstanceTime -- an SMILTimeValue used for constructing intervals. It
* contains additional fields to govern reset behavior * contains additional fields to govern reset behavior
* and track timing dependencies (e.g. syncbase timing). * and track timing dependencies (e.g. syncbase timing).
* SMILInterval -- a pair of nsSMILInstanceTimes that defines a begin and * SMILInterval -- a pair of SMILInstanceTimes that defines a begin and
* an end time for animation. * an end time for animation.
* nsSMILTimeValueSpec -- a component of a begin or end attribute, such as the * SMILTimeValueSpec -- a component of a begin or end attribute, such as the
* '5s' or 'a.end+2m' in begin="5s; a.end+2m". Acts as * '5s' or 'a.end+2m' in begin="5s; a.end+2m". Acts as
* a broker between an SMILTimedElement and its * a broker between an SMILTimedElement and its
* nsSMILInstanceTimes by generating new instance times * SMILInstanceTimes by generating new instance times
* and handling changes to existing times. * and handling changes to existing times.
* *
* Objects of this class may be in one of three states: * Objects of this class may be in one of three states:
* *
@@ -39,29 +41,29 @@
* *
* In summary: * In summary:
* *
* State | GetMillis | IsDefinite | IsIndefinite | IsResolved * State | GetMillis | IsDefinite | IsIndefinite | IsResolved
* -----------+-----------------+------------+--------------+------------ * -----------+---------------+------------+--------------+------------
* Definite | nsSMILTimeValue | true | false | true * Definite | SMILTimeValue | true | false | true
* -----------+-----------------+------------+--------------+------------ * -----------+---------------+------------+--------------+------------
* Indefinite | -- | false | true | true * Indefinite | -- | false | true | true
* -----------+-----------------+------------+--------------+------------ * -----------+---------------+------------+--------------+------------
* Unresolved | -- | false | false | false * Unresolved | -- | false | false | false
* *
*/ */
class nsSMILTimeValue { class SMILTimeValue {
public: public:
// Creates an unresolved time value // Creates an unresolved time value
nsSMILTimeValue() SMILTimeValue()
: mMilliseconds(kUnresolvedMillis), mState(STATE_UNRESOLVED) {} : mMilliseconds(kUnresolvedMillis), mState(STATE_UNRESOLVED) {}
// Creates a resolved time value // Creates a resolved time value
explicit nsSMILTimeValue(nsSMILTime aMillis) explicit SMILTimeValue(nsSMILTime aMillis)
: mMilliseconds(aMillis), mState(STATE_DEFINITE) {} : mMilliseconds(aMillis), mState(STATE_DEFINITE) {}
// Named constructor to create an indefinite time value // Named constructor to create an indefinite time value
static nsSMILTimeValue Indefinite() { static SMILTimeValue Indefinite() {
nsSMILTimeValue value; SMILTimeValue value;
value.SetIndefinite(); value.SetIndefinite();
return value; return value;
} }
@@ -91,29 +93,29 @@ class nsSMILTimeValue {
mMilliseconds = aMillis; mMilliseconds = aMillis;
} }
int8_t CompareTo(const nsSMILTimeValue& aOther) const; int8_t CompareTo(const SMILTimeValue& aOther) const;
bool operator==(const nsSMILTimeValue& aOther) const { bool operator==(const SMILTimeValue& aOther) const {
return CompareTo(aOther) == 0; return CompareTo(aOther) == 0;
} }
bool operator!=(const nsSMILTimeValue& aOther) const { bool operator!=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) != 0; return CompareTo(aOther) != 0;
} }
bool operator<(const nsSMILTimeValue& aOther) const { bool operator<(const SMILTimeValue& aOther) const {
return CompareTo(aOther) < 0; return CompareTo(aOther) < 0;
} }
bool operator>(const nsSMILTimeValue& aOther) const { bool operator>(const SMILTimeValue& aOther) const {
return CompareTo(aOther) > 0; return CompareTo(aOther) > 0;
} }
bool operator<=(const nsSMILTimeValue& aOther) const { bool operator<=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) <= 0; return CompareTo(aOther) <= 0;
} }
bool operator>=(const nsSMILTimeValue& aOther) const { bool operator>=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) >= 0; return CompareTo(aOther) >= 0;
} }
@@ -124,4 +126,6 @@ class nsSMILTimeValue {
enum { STATE_DEFINITE, STATE_INDEFINITE, STATE_UNRESOLVED } mState; enum { STATE_DEFINITE, STATE_INDEFINITE, STATE_UNRESOLVED } mState;
}; };
} // namespace mozilla
#endif // NS_SMILTIMEVALUE_H_ #endif // NS_SMILTIMEVALUE_H_

View File

@@ -5,29 +5,30 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/SMILInstanceTime.h"
#include "mozilla/SMILInterval.h" #include "mozilla/SMILInterval.h"
#include "mozilla/SMILParserUtils.h" #include "mozilla/SMILParserUtils.h"
#include "mozilla/SMILTimeContainer.h" #include "mozilla/SMILTimeContainer.h"
#include "mozilla/SMILTimedElement.h" #include "mozilla/SMILTimedElement.h"
#include "mozilla/SMILTimeValueSpec.h"
#include "mozilla/SMILTimeValue.h"
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "mozilla/dom/SVGAnimationElement.h" #include "mozilla/dom/SVGAnimationElement.h"
#include "mozilla/dom/TimeEvent.h" #include "mozilla/dom/TimeEvent.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILTimeValue.h"
#include "nsSMILInstanceTime.h"
#include "nsString.h" #include "nsString.h"
#include <limits> #include <limits>
using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
namespace mozilla {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Nested class: EventListener // Nested class: EventListener
NS_IMPL_ISUPPORTS(nsSMILTimeValueSpec::EventListener, nsIDOMEventListener) NS_IMPL_ISUPPORTS(SMILTimeValueSpec::EventListener, nsIDOMEventListener)
NS_IMETHODIMP NS_IMETHODIMP
nsSMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) { SMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) {
if (mSpec) { if (mSpec) {
mSpec->HandleEvent(aEvent); mSpec->HandleEvent(aEvent);
} }
@@ -37,11 +38,10 @@ nsSMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation // Implementation
nsSMILTimeValueSpec::nsSMILTimeValueSpec(SMILTimedElement& aOwner, SMILTimeValueSpec::SMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin)
bool aIsBegin)
: mOwner(&aOwner), mIsBegin(aIsBegin), mReferencedElement(this) {} : mOwner(&aOwner), mIsBegin(aIsBegin), mReferencedElement(this) {}
nsSMILTimeValueSpec::~nsSMILTimeValueSpec() { SMILTimeValueSpec::~SMILTimeValueSpec() {
UnregisterFromReferencedElement(mReferencedElement.get()); UnregisterFromReferencedElement(mReferencedElement.get());
if (mEventListener) { if (mEventListener) {
mEventListener->Disconnect(); mEventListener->Disconnect();
@@ -49,9 +49,9 @@ nsSMILTimeValueSpec::~nsSMILTimeValueSpec() {
} }
} }
nsresult nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec, nsresult SMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
Element& aContextElement) { Element& aContextElement) {
nsSMILTimeValueSpecParams params; SMILTimeValueSpecParams params;
if (!SMILParserUtils::ParseTimeValueSpecParams(aStringSpec, params)) if (!SMILParserUtils::ParseTimeValueSpecParams(aStringSpec, params))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@@ -62,13 +62,13 @@ nsresult nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
// The special value "indefinite" does not yield an instance time in the // The special value "indefinite" does not yield an instance time in the
// begin list. It will, however yield a single instance with the value // begin list. It will, however yield a single instance with the value
// "indefinite" in an end list. This value is not removed by a reset. // "indefinite" in an end list. This value is not removed by a reset.
if (mParams.mType == nsSMILTimeValueSpecParams::OFFSET || if (mParams.mType == SMILTimeValueSpecParams::OFFSET ||
(!mIsBegin && mParams.mType == nsSMILTimeValueSpecParams::INDEFINITE)) { (!mIsBegin && mParams.mType == SMILTimeValueSpecParams::INDEFINITE)) {
mOwner->AddInstanceTime(new nsSMILInstanceTime(mParams.mOffset), mIsBegin); mOwner->AddInstanceTime(new SMILInstanceTime(mParams.mOffset), mIsBegin);
} }
// Fill in the event symbol to simplify handling later // Fill in the event symbol to simplify handling later
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT) { if (mParams.mType == SMILTimeValueSpecParams::REPEAT) {
mParams.mEventSymbol = nsGkAtoms::repeatEvent; mParams.mEventSymbol = nsGkAtoms::repeatEvent;
} }
@@ -77,8 +77,8 @@ nsresult nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
return NS_OK; return NS_OK;
} }
void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) { void SMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
if (mParams.mType != nsSMILTimeValueSpecParams::SYNCBASE && !IsEventBased()) { if (mParams.mType != SMILTimeValueSpecParams::SYNCBASE && !IsEventBased()) {
return; return;
} }
@@ -93,7 +93,7 @@ void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
if (mParams.mDependentElemID) { if (mParams.mDependentElemID) {
mReferencedElement.ResetWithID(aContextElement, mParams.mDependentElemID); mReferencedElement.ResetWithID(aContextElement, mParams.mDependentElemID);
} else if (mParams.mType == nsSMILTimeValueSpecParams::EVENT) { } else if (mParams.mType == SMILTimeValueSpecParams::EVENT) {
Element* target = mOwner->GetTargetElement(); Element* target = mOwner->GetTargetElement();
mReferencedElement.ResetWithElement(target); mReferencedElement.ResetWithElement(target);
} else { } else {
@@ -102,16 +102,16 @@ void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
UpdateReferencedElement(oldReferencedElement, mReferencedElement.get()); UpdateReferencedElement(oldReferencedElement, mReferencedElement.get());
} }
bool nsSMILTimeValueSpec::IsEventBased() const { bool SMILTimeValueSpec::IsEventBased() const {
return mParams.mType == nsSMILTimeValueSpecParams::EVENT || return mParams.mType == SMILTimeValueSpecParams::EVENT ||
mParams.mType == nsSMILTimeValueSpecParams::REPEAT; mParams.mType == SMILTimeValueSpecParams::REPEAT;
} }
void nsSMILTimeValueSpec::HandleNewInterval( void SMILTimeValueSpec::HandleNewInterval(
SMILInterval& aInterval, const SMILTimeContainer* aSrcContainer) { SMILInterval& aInterval, const SMILTimeContainer* aSrcContainer) {
const nsSMILInstanceTime& baseInstance = const SMILInstanceTime& baseInstance =
mParams.mSyncBegin ? *aInterval.Begin() : *aInterval.End(); mParams.mSyncBegin ? *aInterval.Begin() : *aInterval.End();
nsSMILTimeValue newTime = SMILTimeValue newTime =
ConvertBetweenTimeContainers(baseInstance.Time(), aSrcContainer); ConvertBetweenTimeContainers(baseInstance.Time(), aSrcContainer);
// Apply offset // Apply offset
@@ -121,25 +121,25 @@ void nsSMILTimeValueSpec::HandleNewInterval(
} }
// Create the instance time and register it with the interval // Create the instance time and register it with the interval
RefPtr<nsSMILInstanceTime> newInstance = new nsSMILInstanceTime( RefPtr<SMILInstanceTime> newInstance = new SMILInstanceTime(
newTime, nsSMILInstanceTime::SOURCE_SYNCBASE, this, &aInterval); newTime, SMILInstanceTime::SOURCE_SYNCBASE, this, &aInterval);
mOwner->AddInstanceTime(newInstance, mIsBegin); mOwner->AddInstanceTime(newInstance, mIsBegin);
} }
void nsSMILTimeValueSpec::HandleTargetElementChange(Element* aNewTarget) { void SMILTimeValueSpec::HandleTargetElementChange(Element* aNewTarget) {
if (!IsEventBased() || mParams.mDependentElemID) return; if (!IsEventBased() || mParams.mDependentElemID) return;
mReferencedElement.ResetWithElement(aNewTarget); mReferencedElement.ResetWithElement(aNewTarget);
} }
void nsSMILTimeValueSpec::HandleChangedInstanceTime( void SMILTimeValueSpec::HandleChangedInstanceTime(
const nsSMILInstanceTime& aBaseTime, const SMILTimeContainer* aSrcContainer, const SMILInstanceTime& aBaseTime, const SMILTimeContainer* aSrcContainer,
nsSMILInstanceTime& aInstanceTimeToUpdate, bool aObjectChanged) { SMILInstanceTime& aInstanceTimeToUpdate, bool aObjectChanged) {
// If the instance time is fixed (e.g. because it's being used as the begin // If the instance time is fixed (e.g. because it's being used as the begin
// time of an active or postactive interval) we just ignore the change. // time of an active or postactive interval) we just ignore the change.
if (aInstanceTimeToUpdate.IsFixedTime()) return; if (aInstanceTimeToUpdate.IsFixedTime()) return;
nsSMILTimeValue updatedTime = SMILTimeValue updatedTime =
ConvertBetweenTimeContainers(aBaseTime.Time(), aSrcContainer); ConvertBetweenTimeContainers(aBaseTime.Time(), aSrcContainer);
// Apply offset // Apply offset
@@ -155,19 +155,19 @@ void nsSMILTimeValueSpec::HandleChangedInstanceTime(
} }
} }
void nsSMILTimeValueSpec::HandleDeletedInstanceTime( void SMILTimeValueSpec::HandleDeletedInstanceTime(
nsSMILInstanceTime& aInstanceTime) { SMILInstanceTime& aInstanceTime) {
mOwner->RemoveInstanceTime(&aInstanceTime, mIsBegin); mOwner->RemoveInstanceTime(&aInstanceTime, mIsBegin);
} }
bool nsSMILTimeValueSpec::DependsOnBegin() const { return mParams.mSyncBegin; } bool SMILTimeValueSpec::DependsOnBegin() const { return mParams.mSyncBegin; }
void nsSMILTimeValueSpec::Traverse( void SMILTimeValueSpec::Traverse(
nsCycleCollectionTraversalCallback* aCallback) { nsCycleCollectionTraversalCallback* aCallback) {
mReferencedElement.Traverse(aCallback); mReferencedElement.Traverse(aCallback);
} }
void nsSMILTimeValueSpec::Unlink() { void SMILTimeValueSpec::Unlink() {
UnregisterFromReferencedElement(mReferencedElement.get()); UnregisterFromReferencedElement(mReferencedElement.get());
mReferencedElement.Unlink(); mReferencedElement.Unlink();
} }
@@ -175,22 +175,21 @@ void nsSMILTimeValueSpec::Unlink() {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Implementation helpers // Implementation helpers
void nsSMILTimeValueSpec::UpdateReferencedElement(Element* aFrom, void SMILTimeValueSpec::UpdateReferencedElement(Element* aFrom, Element* aTo) {
Element* aTo) {
if (aFrom == aTo) return; if (aFrom == aTo) return;
UnregisterFromReferencedElement(aFrom); UnregisterFromReferencedElement(aFrom);
switch (mParams.mType) { switch (mParams.mType) {
case nsSMILTimeValueSpecParams::SYNCBASE: { case SMILTimeValueSpecParams::SYNCBASE: {
SMILTimedElement* to = GetTimedElement(aTo); SMILTimedElement* to = GetTimedElement(aTo);
if (to) { if (to) {
to->AddDependent(*this); to->AddDependent(*this);
} }
} break; } break;
case nsSMILTimeValueSpecParams::EVENT: case SMILTimeValueSpecParams::EVENT:
case nsSMILTimeValueSpecParams::REPEAT: case SMILTimeValueSpecParams::REPEAT:
RegisterEventListener(aTo); RegisterEventListener(aTo);
break; break;
@@ -200,10 +199,10 @@ void nsSMILTimeValueSpec::UpdateReferencedElement(Element* aFrom,
} }
} }
void nsSMILTimeValueSpec::UnregisterFromReferencedElement(Element* aElement) { void SMILTimeValueSpec::UnregisterFromReferencedElement(Element* aElement) {
if (!aElement) return; if (!aElement) return;
if (mParams.mType == nsSMILTimeValueSpecParams::SYNCBASE) { if (mParams.mType == SMILTimeValueSpecParams::SYNCBASE) {
SMILTimedElement* timedElement = GetTimedElement(aElement); SMILTimedElement* timedElement = GetTimedElement(aElement);
if (timedElement) { if (timedElement) {
timedElement->RemoveDependent(*this); timedElement->RemoveDependent(*this);
@@ -214,7 +213,7 @@ void nsSMILTimeValueSpec::UnregisterFromReferencedElement(Element* aElement) {
} }
} }
SMILTimedElement* nsSMILTimeValueSpec::GetTimedElement(Element* aElement) { SMILTimedElement* SMILTimeValueSpec::GetTimedElement(Element* aElement) {
return aElement && aElement->IsNodeOfType(nsINode::eANIMATION) return aElement && aElement->IsNodeOfType(nsINode::eANIMATION)
? &static_cast<SVGAnimationElement*>(aElement)->TimedElement() ? &static_cast<SVGAnimationElement*>(aElement)->TimedElement()
: nullptr; : nullptr;
@@ -222,14 +221,14 @@ SMILTimedElement* nsSMILTimeValueSpec::GetTimedElement(Element* aElement) {
// Indicates whether we're allowed to register an event-listener // Indicates whether we're allowed to register an event-listener
// when scripting is disabled. // when scripting is disabled.
bool nsSMILTimeValueSpec::IsWhitelistedEvent() { bool SMILTimeValueSpec::IsWhitelistedEvent() {
// The category of (SMIL-specific) "repeat(n)" events are allowed. // The category of (SMIL-specific) "repeat(n)" events are allowed.
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT) { if (mParams.mType == SMILTimeValueSpecParams::REPEAT) {
return true; return true;
} }
// A specific list of other SMIL-related events are allowed, too. // A specific list of other SMIL-related events are allowed, too.
if (mParams.mType == nsSMILTimeValueSpecParams::EVENT && if (mParams.mType == SMILTimeValueSpecParams::EVENT &&
(mParams.mEventSymbol == nsGkAtoms::repeat || (mParams.mEventSymbol == nsGkAtoms::repeat ||
mParams.mEventSymbol == nsGkAtoms::repeatEvent || mParams.mEventSymbol == nsGkAtoms::repeatEvent ||
mParams.mEventSymbol == nsGkAtoms::beginEvent || mParams.mEventSymbol == nsGkAtoms::beginEvent ||
@@ -240,10 +239,10 @@ bool nsSMILTimeValueSpec::IsWhitelistedEvent() {
return false; return false;
} }
void nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget) { void SMILTimeValueSpec::RegisterEventListener(Element* aTarget) {
MOZ_ASSERT(IsEventBased(), MOZ_ASSERT(IsEventBased(),
"Attempting to register event-listener for unexpected " "Attempting to register event-listener for unexpected "
"nsSMILTimeValueSpec type"); "SMILTimeValueSpec type");
MOZ_ASSERT(mParams.mEventSymbol, MOZ_ASSERT(mParams.mEventSymbol,
"Attempting to register event-listener but there is no event " "Attempting to register event-listener but there is no event "
"name"); "name");
@@ -270,7 +269,7 @@ void nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget) {
AllEventsAtSystemGroupBubble()); AllEventsAtSystemGroupBubble());
} }
void nsSMILTimeValueSpec::UnregisterEventListener(Element* aTarget) { void SMILTimeValueSpec::UnregisterEventListener(Element* aTarget) {
if (!aTarget || !mEventListener) { if (!aTarget || !mEventListener) {
return; return;
} }
@@ -285,9 +284,9 @@ void nsSMILTimeValueSpec::UnregisterEventListener(Element* aTarget) {
AllEventsAtSystemGroupBubble()); AllEventsAtSystemGroupBubble());
} }
void nsSMILTimeValueSpec::HandleEvent(Event* aEvent) { void SMILTimeValueSpec::HandleEvent(Event* aEvent) {
MOZ_ASSERT(mEventListener, "Got event without an event listener"); MOZ_ASSERT(mEventListener, "Got event without an event listener");
MOZ_ASSERT(IsEventBased(), "Got event for non-event nsSMILTimeValueSpec"); MOZ_ASSERT(IsEventBased(), "Got event for non-event SMILTimeValueSpec");
MOZ_ASSERT(aEvent, "No event supplied"); MOZ_ASSERT(aEvent, "No event supplied");
// XXX In the long run we should get the time from the event itself which will // XXX In the long run we should get the time from the event itself which will
@@ -296,24 +295,24 @@ void nsSMILTimeValueSpec::HandleEvent(Event* aEvent) {
SMILTimeContainer* container = mOwner->GetTimeContainer(); SMILTimeContainer* container = mOwner->GetTimeContainer();
if (!container) return; if (!container) return;
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT && if (mParams.mType == SMILTimeValueSpecParams::REPEAT &&
!CheckRepeatEventDetail(aEvent)) { !CheckRepeatEventDetail(aEvent)) {
return; return;
} }
nsSMILTime currentTime = container->GetCurrentTimeAsSMILTime(); nsSMILTime currentTime = container->GetCurrentTimeAsSMILTime();
nsSMILTimeValue newTime(currentTime); SMILTimeValue newTime(currentTime);
if (!ApplyOffset(newTime)) { if (!ApplyOffset(newTime)) {
NS_WARNING("New time generated from event overflows nsSMILTime, ignoring"); NS_WARNING("New time generated from event overflows nsSMILTime, ignoring");
return; return;
} }
RefPtr<nsSMILInstanceTime> newInstance = RefPtr<SMILInstanceTime> newInstance =
new nsSMILInstanceTime(newTime, nsSMILInstanceTime::SOURCE_EVENT); new SMILInstanceTime(newTime, SMILInstanceTime::SOURCE_EVENT);
mOwner->AddInstanceTime(newInstance, mIsBegin); mOwner->AddInstanceTime(newInstance, mIsBegin);
} }
bool nsSMILTimeValueSpec::CheckRepeatEventDetail(Event* aEvent) { bool SMILTimeValueSpec::CheckRepeatEventDetail(Event* aEvent) {
TimeEvent* timeEvent = aEvent->AsTimeEvent(); TimeEvent* timeEvent = aEvent->AsTimeEvent();
if (!timeEvent) { if (!timeEvent) {
NS_WARNING("Received a repeat event that was not a DOMTimeEvent"); NS_WARNING("Received a repeat event that was not a DOMTimeEvent");
@@ -324,8 +323,8 @@ bool nsSMILTimeValueSpec::CheckRepeatEventDetail(Event* aEvent) {
return detail > 0 && (uint32_t)detail == mParams.mRepeatIteration; return detail > 0 && (uint32_t)detail == mParams.mRepeatIteration;
} }
nsSMILTimeValue nsSMILTimeValueSpec::ConvertBetweenTimeContainers( SMILTimeValue SMILTimeValueSpec::ConvertBetweenTimeContainers(
const nsSMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer) { const SMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer) {
// If the source time is either indefinite or unresolved the result is going // If the source time is either indefinite or unresolved the result is going
// to be the same // to be the same
if (!aSrcTime.IsDefinite()) return aSrcTime; if (!aSrcTime.IsDefinite()) return aSrcTime;
@@ -336,9 +335,9 @@ nsSMILTimeValue nsSMILTimeValueSpec::ConvertBetweenTimeContainers(
// If one of the elements is not attached to a time container then we can't do // If one of the elements is not attached to a time container then we can't do
// any meaningful conversion // any meaningful conversion
if (!aSrcContainer || !dstContainer) return nsSMILTimeValue(); // unresolved if (!aSrcContainer || !dstContainer) return SMILTimeValue(); // unresolved
nsSMILTimeValue docTime = SMILTimeValue docTime =
aSrcContainer->ContainerToParentTime(aSrcTime.GetMillis()); aSrcContainer->ContainerToParentTime(aSrcTime.GetMillis());
if (docTime.IsIndefinite()) if (docTime.IsIndefinite())
@@ -352,7 +351,7 @@ nsSMILTimeValue nsSMILTimeValueSpec::ConvertBetweenTimeContainers(
return dstContainer->ParentToContainerTime(docTime.GetMillis()); return dstContainer->ParentToContainerTime(docTime.GetMillis());
} }
bool nsSMILTimeValueSpec::ApplyOffset(nsSMILTimeValue& aTime) const { bool SMILTimeValueSpec::ApplyOffset(SMILTimeValue& aTime) const {
// indefinite + offset = indefinite. Likewise for unresolved times. // indefinite + offset = indefinite. Likewise for unresolved times.
if (!aTime.IsDefinite()) { if (!aTime.IsDefinite()) {
return true; return true;
@@ -367,3 +366,5 @@ bool nsSMILTimeValueSpec::ApplyOffset(nsSMILTimeValue& aTime) const {
aTime.SetMillis(aTime.GetMillis() + mParams.mOffset.GetMillis()); aTime.SetMillis(aTime.GetMillis() + mParams.mOffset.GetMillis());
return true; return true;
} }
} // namespace mozilla

View File

@@ -8,27 +8,26 @@
#define NS_SMILTIMEVALUESPEC_H_ #define NS_SMILTIMEVALUESPEC_H_
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/SMILTimeValueSpecParams.h"
#include "mozilla/dom/IDTracker.h" #include "mozilla/dom/IDTracker.h"
#include "nsSMILTimeValueSpecParams.h"
#include "nsStringFwd.h" #include "nsStringFwd.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
class nsSMILTimeValue;
class nsSMILInstanceTime;
namespace mozilla { namespace mozilla {
class EventListenerManager;
class SMILInstanceTime;
class SMILInterval; class SMILInterval;
class SMILTimeContainer; class SMILTimeContainer;
class SMILTimedElement; class SMILTimedElement;
class SMILTimeValue;
namespace dom { namespace dom {
class Event; class Event;
} // namespace dom } // namespace dom
class EventListenerManager;
} // namespace mozilla
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSMILTimeValueSpec class // SMILTimeValueSpec class
// //
// An individual element of a 'begin' or 'end' attribute, e.g. '5s', 'a.end'. // An individual element of a 'begin' or 'end' attribute, e.g. '5s', 'a.end'.
// This class handles the parsing of such specifications and performs the // This class handles the parsing of such specifications and performs the
@@ -36,19 +35,16 @@ class EventListenerManager;
// and synchronisation (for syncbase specifications). // and synchronisation (for syncbase specifications).
// //
// For an overview of how this class is related to other SMIL time classes see // For an overview of how this class is related to other SMIL time classes see
// the documentation in nsSMILTimeValue.h // the documentation in SMILTimeValue.h
class nsSMILTimeValueSpec { class SMILTimeValueSpec {
public: public:
typedef mozilla::SMILInterval SMILInterval;
typedef mozilla::SMILTimeContainer SMILTimeContainer;
typedef mozilla::SMILTimedElement SMILTimedElement;
typedef mozilla::dom::Element Element; typedef mozilla::dom::Element Element;
typedef mozilla::dom::Event Event; typedef mozilla::dom::Event Event;
typedef mozilla::dom::IDTracker IDTracker; typedef mozilla::dom::IDTracker IDTracker;
nsSMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin); SMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin);
~nsSMILTimeValueSpec(); ~SMILTimeValueSpec();
nsresult SetSpec(const nsAString& aStringSpec, Element& aContextElement); nsresult SetSpec(const nsAString& aStringSpec, Element& aContextElement);
void ResolveReferences(Element& aContextElement); void ResolveReferences(Element& aContextElement);
@@ -58,13 +54,13 @@ class nsSMILTimeValueSpec {
const SMILTimeContainer* aSrcContainer); const SMILTimeContainer* aSrcContainer);
void HandleTargetElementChange(Element* aNewTarget); void HandleTargetElementChange(Element* aNewTarget);
// For created nsSMILInstanceTime objects // For created SMILInstanceTime objects
bool DependsOnBegin() const; bool DependsOnBegin() const;
void HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime, void HandleChangedInstanceTime(const SMILInstanceTime& aBaseTime,
const SMILTimeContainer* aSrcContainer, const SMILTimeContainer* aSrcContainer,
nsSMILInstanceTime& aInstanceTimeToUpdate, SMILInstanceTime& aInstanceTimeToUpdate,
bool aObjectChanged); bool aObjectChanged);
void HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime); void HandleDeletedInstanceTime(SMILInstanceTime& aInstanceTime);
// Cycle-collection support // Cycle-collection support
void Traverse(nsCycleCollectionTraversalCallback* aCallback); void Traverse(nsCycleCollectionTraversalCallback* aCallback);
@@ -79,9 +75,9 @@ class nsSMILTimeValueSpec {
void UnregisterEventListener(Element* aElement); void UnregisterEventListener(Element* aElement);
void HandleEvent(Event* aEvent); void HandleEvent(Event* aEvent);
bool CheckRepeatEventDetail(Event* aEvent); bool CheckRepeatEventDetail(Event* aEvent);
nsSMILTimeValue ConvertBetweenTimeContainers( SMILTimeValue ConvertBetweenTimeContainers(
const nsSMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer); const SMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer);
bool ApplyOffset(nsSMILTimeValue& aTime) const; bool ApplyOffset(SMILTimeValue& aTime) const;
SMILTimedElement* mOwner; SMILTimedElement* mOwner;
bool mIsBegin; // Indicates if *we* are a begin spec, bool mIsBegin; // Indicates if *we* are a begin spec,
@@ -89,22 +85,21 @@ class nsSMILTimeValueSpec {
// mParams.mSyncBegin which indicates // mParams.mSyncBegin which indicates
// if we're synced with the begin of // if we're synced with the begin of
// the target. // the target.
nsSMILTimeValueSpecParams mParams; SMILTimeValueSpecParams mParams;
/** /**
* If our nsSMILTimeValueSpec exists for a 'begin' or 'end' attribute with a * If our SMILTimeValueSpec exists for a 'begin' or 'end' attribute with a
* value that specifies a time that is relative to the animation of some * value that specifies a time that is relative to the animation of some
* other element, it will create an instance of this class to reference and * other element, it will create an instance of this class to reference and
* track that other element. For example, if the nsSMILTimeValueSpec is for * track that other element. For example, if the SMILTimeValueSpec is for
* end='a.end+2s', an instance of this class will be created to track the * end='a.end+2s', an instance of this class will be created to track the
* element associated with the element ID "a". This class will notify the * element associated with the element ID "a". This class will notify the
* nsSMILTimeValueSpec if the element that that ID identifies changes to a * SMILTimeValueSpec if the element that that ID identifies changes to a
* different element (or none). * different element (or none).
*/ */
class TimeReferenceTracker final : public IDTracker { class TimeReferenceTracker final : public IDTracker {
public: public:
explicit TimeReferenceTracker(nsSMILTimeValueSpec* aOwner) explicit TimeReferenceTracker(SMILTimeValueSpec* aOwner) : mSpec(aOwner) {}
: mSpec(aOwner) {}
void ResetWithElement(Element* aTo) { void ResetWithElement(Element* aTo) {
RefPtr<Element> from = get(); RefPtr<Element> from = get();
Unlink(); Unlink();
@@ -119,7 +114,7 @@ class nsSMILTimeValueSpec {
virtual bool IsPersistent() override { return true; } virtual bool IsPersistent() override { return true; }
private: private:
nsSMILTimeValueSpec* mSpec; SMILTimeValueSpec* mSpec;
}; };
TimeReferenceTracker mReferencedElement; TimeReferenceTracker mReferencedElement;
@@ -128,16 +123,18 @@ class nsSMILTimeValueSpec {
~EventListener() {} ~EventListener() {}
public: public:
explicit EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) {} explicit EventListener(SMILTimeValueSpec* aOwner) : mSpec(aOwner) {}
void Disconnect() { mSpec = nullptr; } void Disconnect() { mSpec = nullptr; }
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER NS_DECL_NSIDOMEVENTLISTENER
private: private:
nsSMILTimeValueSpec* mSpec; SMILTimeValueSpec* mSpec;
}; };
RefPtr<EventListener> mEventListener; RefPtr<EventListener> mEventListener;
}; };
} // namespace mozilla
#endif // NS_SMILTIMEVALUESPEC_H_ #endif // NS_SMILTIMEVALUESPEC_H_

View File

@@ -7,18 +7,20 @@
#ifndef NS_SMILTIMEVALUESPECPARAMS_H_ #ifndef NS_SMILTIMEVALUESPECPARAMS_H_
#define NS_SMILTIMEVALUESPECPARAMS_H_ #define NS_SMILTIMEVALUESPECPARAMS_H_
#include "nsSMILTimeValue.h" #include "mozilla/SMILTimeValue.h"
#include "nsAtom.h" #include "nsAtom.h"
namespace mozilla {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSMILTimeValueSpecParams // SMILTimeValueSpecParams
// //
// A simple data type for storing the result of parsing a single begin or end // A simple data type for storing the result of parsing a single begin or end
// value (e.g. the '5s' in begin="5s; indefinite; a.begin+2s"). // value (e.g. the '5s' in begin="5s; indefinite; a.begin+2s").
class nsSMILTimeValueSpecParams { class SMILTimeValueSpecParams {
public: public:
nsSMILTimeValueSpecParams() SMILTimeValueSpecParams()
: mType(INDEFINITE), mSyncBegin(false), mRepeatIteration(0) {} : mType(INDEFINITE), mSyncBegin(false), mRepeatIteration(0) {}
// The type of value this specification describes // The type of value this specification describes
@@ -30,7 +32,7 @@ class nsSMILTimeValueSpecParams {
// - type EVENT: the event time // - type EVENT: the event time
// - type REPEAT: the repeat time // - type REPEAT: the repeat time
// It is not used for WALLCLOCK or INDEFINITE times // It is not used for WALLCLOCK or INDEFINITE times
nsSMILTimeValue mOffset; SMILTimeValue mOffset;
// The base element that this specification refers to. // The base element that this specification refers to.
// For SYNCBASE types, this is the timebase // For SYNCBASE types, this is the timebase
@@ -51,4 +53,6 @@ class nsSMILTimeValueSpecParams {
uint32_t mRepeatIteration; uint32_t mRepeatIteration;
}; };
} // namespace mozilla
#endif // NS_SMILTIMEVALUESPECPARAMS_H_ #endif // NS_SMILTIMEVALUESPECPARAMS_H_

View File

@@ -11,14 +11,14 @@
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/SMILAnimationFunction.h" #include "mozilla/SMILAnimationFunction.h"
#include "mozilla/SMILInstanceTime.h"
#include "mozilla/SMILParserUtils.h" #include "mozilla/SMILParserUtils.h"
#include "mozilla/SMILTimeContainer.h" #include "mozilla/SMILTimeContainer.h"
#include "mozilla/SMILTimeValue.h"
#include "mozilla/SMILTimeValueSpec.h"
#include "mozilla/TaskCategory.h" #include "mozilla/TaskCategory.h"
#include "mozilla/dom/SVGAnimationElement.h" #include "mozilla/dom/SVGAnimationElement.h"
#include "nsAttrValueInlines.h" #include "nsAttrValueInlines.h"
#include "nsSMILTimeValue.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILInstanceTime.h"
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsReadableUtils.h" #include "nsReadableUtils.h"
#include "nsMathUtils.h" #include "nsMathUtils.h"
@@ -47,7 +47,7 @@ namespace mozilla {
// The serial number also means that every instance time has an unambiguous // The serial number also means that every instance time has an unambiguous
// position in the array so we can use RemoveElementSorted and the like. // position in the array so we can use RemoveElementSorted and the like.
bool SMILTimedElement::InstanceTimeComparator::Equals( bool SMILTimedElement::InstanceTimeComparator::Equals(
const nsSMILInstanceTime* aElem1, const nsSMILInstanceTime* aElem2) const { const SMILInstanceTime* aElem1, const SMILInstanceTime* aElem2) const {
MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null instance time pointers"); MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null instance time pointers");
MOZ_ASSERT(aElem1->Serial() && aElem2->Serial(), MOZ_ASSERT(aElem1->Serial() && aElem2->Serial(),
"Instance times have not been assigned serial numbers"); "Instance times have not been assigned serial numbers");
@@ -58,7 +58,7 @@ bool SMILTimedElement::InstanceTimeComparator::Equals(
} }
bool SMILTimedElement::InstanceTimeComparator::LessThan( bool SMILTimedElement::InstanceTimeComparator::LessThan(
const nsSMILInstanceTime* aElem1, const nsSMILInstanceTime* aElem2) const { const SMILInstanceTime* aElem1, const SMILInstanceTime* aElem2) const {
MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null instance time pointers"); MOZ_ASSERT(aElem1 && aElem2, "Trying to compare null instance time pointers");
MOZ_ASSERT(aElem1->Serial() && aElem2->Serial(), MOZ_ASSERT(aElem1->Serial() && aElem2->Serial(),
"Instance times have not been assigned serial numbers"); "Instance times have not been assigned serial numbers");
@@ -158,13 +158,13 @@ class MOZ_STACK_CLASS SMILTimedElement::AutoIntervalUpdater {
// Templated helper functions // Templated helper functions
// Selectively remove elements from an array of type // Selectively remove elements from an array of type
// nsTArray<RefPtr<nsSMILInstanceTime> > with O(n) performance. // nsTArray<RefPtr<SMILInstanceTime> > with O(n) performance.
template <class TestFunctor> template <class TestFunctor>
void SMILTimedElement::RemoveInstanceTimes(InstanceTimeList& aArray, void SMILTimedElement::RemoveInstanceTimes(InstanceTimeList& aArray,
TestFunctor& aTest) { TestFunctor& aTest) {
InstanceTimeList newArray; InstanceTimeList newArray;
for (uint32_t i = 0; i < aArray.Length(); ++i) { for (uint32_t i = 0; i < aArray.Length(); ++i) {
nsSMILInstanceTime* item = aArray[i].get(); SMILInstanceTime* item = aArray[i].get();
if (aTest(item, i)) { if (aTest(item, i)) {
// As per bugs 665334 and 669225 we should be careful not to remove the // As per bugs 665334 and 669225 we should be careful not to remove the
// instance time that corresponds to the previous interval's end time. // instance time that corresponds to the previous interval's end time.
@@ -313,17 +313,17 @@ nsresult SMILTimedElement::EndElementAt(double aOffsetSeconds) {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// nsSVGAnimationElement methods // nsSVGAnimationElement methods
nsSMILTimeValue SMILTimedElement::GetStartTime() const { SMILTimeValue SMILTimedElement::GetStartTime() const {
return mElementState == STATE_WAITING || mElementState == STATE_ACTIVE return mElementState == STATE_WAITING || mElementState == STATE_ACTIVE
? mCurrentInterval->Begin()->Time() ? mCurrentInterval->Begin()->Time()
: nsSMILTimeValue(); : SMILTimeValue();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Hyperlinking support // Hyperlinking support
nsSMILTimeValue SMILTimedElement::GetHyperlinkTime() const { SMILTimeValue SMILTimedElement::GetHyperlinkTime() const {
nsSMILTimeValue hyperlinkTime; // Default ctor creates unresolved time SMILTimeValue hyperlinkTime; // Default ctor creates unresolved time
if (mElementState == STATE_ACTIVE) { if (mElementState == STATE_ACTIVE) {
hyperlinkTime = mCurrentInterval->Begin()->Time(); hyperlinkTime = mCurrentInterval->Begin()->Time();
@@ -337,7 +337,7 @@ nsSMILTimeValue SMILTimedElement::GetHyperlinkTime() const {
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// SMILTimedElement // SMILTimedElement
void SMILTimedElement::AddInstanceTime(nsSMILInstanceTime* aInstanceTime, void SMILTimedElement::AddInstanceTime(SMILInstanceTime* aInstanceTime,
bool aIsBegin) { bool aIsBegin) {
MOZ_ASSERT(aInstanceTime, "Attempting to add null instance time"); MOZ_ASSERT(aInstanceTime, "Attempting to add null instance time");
@@ -355,7 +355,7 @@ void SMILTimedElement::AddInstanceTime(nsSMILInstanceTime* aInstanceTime,
aInstanceTime->SetSerial(++mInstanceSerialIndex); aInstanceTime->SetSerial(++mInstanceSerialIndex);
InstanceTimeList& instanceList = aIsBegin ? mBeginInstances : mEndInstances; InstanceTimeList& instanceList = aIsBegin ? mBeginInstances : mEndInstances;
RefPtr<nsSMILInstanceTime>* inserted = RefPtr<SMILInstanceTime>* inserted =
instanceList.InsertElementSorted(aInstanceTime, InstanceTimeComparator()); instanceList.InsertElementSorted(aInstanceTime, InstanceTimeComparator());
if (!inserted) { if (!inserted) {
NS_WARNING("Insufficient memory to insert instance time"); NS_WARNING("Insufficient memory to insert instance time");
@@ -365,12 +365,12 @@ void SMILTimedElement::AddInstanceTime(nsSMILInstanceTime* aInstanceTime,
UpdateCurrentInterval(); UpdateCurrentInterval();
} }
void SMILTimedElement::UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime, void SMILTimedElement::UpdateInstanceTime(SMILInstanceTime* aInstanceTime,
nsSMILTimeValue& aUpdatedTime, SMILTimeValue& aUpdatedTime,
bool aIsBegin) { bool aIsBegin) {
MOZ_ASSERT(aInstanceTime, "Attempting to update null instance time"); MOZ_ASSERT(aInstanceTime, "Attempting to update null instance time");
// The reason we update the time here and not in the nsSMILTimeValueSpec is // The reason we update the time here and not in the SMILTimeValueSpec is
// that it means we *could* re-sort more efficiently by doing a sorted remove // that it means we *could* re-sort more efficiently by doing a sorted remove
// and insert but currently this doesn't seem to be necessary given how // and insert but currently this doesn't seem to be necessary given how
// infrequently we get these change notices. // infrequently we get these change notices.
@@ -396,7 +396,7 @@ void SMILTimedElement::UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime,
UpdateCurrentInterval(changedCurrentInterval); UpdateCurrentInterval(changedCurrentInterval);
} }
void SMILTimedElement::RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime, void SMILTimedElement::RemoveInstanceTime(SMILInstanceTime* aInstanceTime,
bool aIsBegin) { bool aIsBegin) {
MOZ_ASSERT(aInstanceTime, "Attempting to remove null instance time"); MOZ_ASSERT(aInstanceTime, "Attempting to remove null instance time");
@@ -418,10 +418,10 @@ void SMILTimedElement::RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime,
namespace { namespace {
class MOZ_STACK_CLASS RemoveByCreator { class MOZ_STACK_CLASS RemoveByCreator {
public: public:
explicit RemoveByCreator(const nsSMILTimeValueSpec* aCreator) explicit RemoveByCreator(const SMILTimeValueSpec* aCreator)
: mCreator(aCreator) {} : mCreator(aCreator) {}
bool operator()(nsSMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) { bool operator()(SMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) {
if (aInstanceTime->GetCreator() != mCreator) return false; if (aInstanceTime->GetCreator() != mCreator) return false;
// If the instance time should be kept (because it is or was the fixed end // If the instance time should be kept (because it is or was the fixed end
@@ -435,12 +435,12 @@ class MOZ_STACK_CLASS RemoveByCreator {
} }
private: private:
const nsSMILTimeValueSpec* mCreator; const SMILTimeValueSpec* mCreator;
}; };
} // namespace } // namespace
void SMILTimedElement::RemoveInstanceTimesForCreator( void SMILTimedElement::RemoveInstanceTimesForCreator(
const nsSMILTimeValueSpec* aCreator, bool aIsBegin) { const SMILTimeValueSpec* aCreator, bool aIsBegin) {
MOZ_ASSERT(aCreator, "Creator not set"); MOZ_ASSERT(aCreator, "Creator not set");
InstanceTimeList& instances = aIsBegin ? mBeginInstances : mEndInstances; InstanceTimeList& instances = aIsBegin ? mBeginInstances : mEndInstances;
@@ -529,7 +529,7 @@ void SMILTimedElement::DoSampleAt(nsSMILTime aContainerTime, bool aEndOnly) {
} }
bool stateChanged; bool stateChanged;
nsSMILTimeValue sampleTime(aContainerTime); SMILTimeValue sampleTime(aContainerTime);
do { do {
#ifdef DEBUG #ifdef DEBUG
@@ -628,7 +628,7 @@ void SMILTimedElement::DoSampleAt(nsSMILTime aContainerTime, bool aEndOnly) {
// The 'min' attribute can cause the active interval to be longer than // The 'min' attribute can cause the active interval to be longer than
// the 'repeating interval'. // the 'repeating interval'.
// In that extended period we apply the fill mode. // In that extended period we apply the fill mode.
if (GetRepeatDuration() <= nsSMILTimeValue(activeTime)) { if (GetRepeatDuration() <= SMILTimeValue(activeTime)) {
if (mClient && mClient->IsActive()) { if (mClient && mClient->IsActive()) {
mClient->Inactivate(mFillMode == FILL_FREEZE); mClient->Inactivate(mFillMode == FILL_FREEZE);
} }
@@ -681,7 +681,7 @@ void SMILTimedElement::HandleContainerTimeChange() {
// In future we could possibly introduce a separate change notice for time // In future we could possibly introduce a separate change notice for time
// container changes and only notify those dependents who live in other time // container changes and only notify those dependents who live in other time
// containers. For now we don't bother because when we re-resolve the time in // containers. For now we don't bother because when we re-resolve the time in
// the nsSMILTimeValueSpec we'll check if anything has changed and if not, we // the SMILTimeValueSpec we'll check if anything has changed and if not, we
// won't go any further. // won't go any further.
if (mElementState == STATE_WAITING || mElementState == STATE_ACTIVE) { if (mElementState == STATE_WAITING || mElementState == STATE_ACTIVE) {
NotifyChangedInterval(mCurrentInterval.get(), false, false); NotifyChangedInterval(mCurrentInterval.get(), false, false);
@@ -689,9 +689,9 @@ void SMILTimedElement::HandleContainerTimeChange() {
} }
namespace { namespace {
bool RemoveNonDynamic(nsSMILInstanceTime* aInstanceTime) { bool RemoveNonDynamic(SMILInstanceTime* aInstanceTime) {
// Generally dynamically-generated instance times (DOM calls, event-based // Generally dynamically-generated instance times (DOM calls, event-based
// times) are not associated with their creator nsSMILTimeValueSpec since // times) are not associated with their creator SMILTimeValueSpec since
// they may outlive them. // they may outlive them.
MOZ_ASSERT(!aInstanceTime->IsDynamic() || !aInstanceTime->GetCreator(), MOZ_ASSERT(!aInstanceTime->IsDynamic() || !aInstanceTime->GetCreator(),
"Dynamic instance time should be unlinked from its creator"); "Dynamic instance time should be unlinked from its creator");
@@ -729,7 +729,7 @@ void SMILTimedElement::Rewind() {
} }
namespace { namespace {
bool RemoveAll(nsSMILInstanceTime* aInstanceTime) { return true; } bool RemoveAll(SMILInstanceTime* aInstanceTime) { return true; }
} // namespace } // namespace
bool SMILTimedElement::SetIsDisabled(bool aIsDisabled) { bool SMILTimedElement::SetIsDisabled(bool aIsDisabled) {
@@ -746,7 +746,7 @@ bool SMILTimedElement::SetIsDisabled(bool aIsDisabled) {
} }
namespace { namespace {
bool RemoveNonDOM(nsSMILInstanceTime* aInstanceTime) { bool RemoveNonDOM(SMILInstanceTime* aInstanceTime) {
return !aInstanceTime->FromDOM() && !aInstanceTime->ShouldPreserve(); return !aInstanceTime->FromDOM() && !aInstanceTime->ShouldPreserve();
} }
} // namespace } // namespace
@@ -848,7 +848,7 @@ nsresult SMILTimedElement::SetSimpleDuration(const nsAString& aDurSpec) {
// Update the current interval before returning // Update the current interval before returning
AutoIntervalUpdater updater(*this); AutoIntervalUpdater updater(*this);
nsSMILTimeValue duration; SMILTimeValue duration;
const nsAString& dur = SMILParserUtils::TrimWhitespace(aDurSpec); const nsAString& dur = SMILParserUtils::TrimWhitespace(aDurSpec);
// SVG-specific: "For SVG's animation elements, if "media" is specified, the // SVG-specific: "For SVG's animation elements, if "media" is specified, the
@@ -880,7 +880,7 @@ nsresult SMILTimedElement::SetMin(const nsAString& aMinSpec) {
// Update the current interval before returning // Update the current interval before returning
AutoIntervalUpdater updater(*this); AutoIntervalUpdater updater(*this);
nsSMILTimeValue duration; SMILTimeValue duration;
const nsAString& min = SMILParserUtils::TrimWhitespace(aMinSpec); const nsAString& min = SMILParserUtils::TrimWhitespace(aMinSpec);
if (min.EqualsLiteral("media")) { if (min.EqualsLiteral("media")) {
@@ -908,7 +908,7 @@ nsresult SMILTimedElement::SetMax(const nsAString& aMaxSpec) {
// Update the current interval before returning // Update the current interval before returning
AutoIntervalUpdater updater(*this); AutoIntervalUpdater updater(*this);
nsSMILTimeValue duration; SMILTimeValue duration;
const nsAString& max = SMILParserUtils::TrimWhitespace(aMaxSpec); const nsAString& max = SMILParserUtils::TrimWhitespace(aMaxSpec);
if (max.EqualsLiteral("media") || max.EqualsLiteral("indefinite")) { if (max.EqualsLiteral("media") || max.EqualsLiteral("indefinite")) {
@@ -969,7 +969,7 @@ nsresult SMILTimedElement::SetRepeatDur(const nsAString& aRepeatDurSpec) {
// Update the current interval before returning // Update the current interval before returning
AutoIntervalUpdater updater(*this); AutoIntervalUpdater updater(*this);
nsSMILTimeValue duration; SMILTimeValue duration;
const nsAString& repeatDur = SMILParserUtils::TrimWhitespace(aRepeatDurSpec); const nsAString& repeatDur = SMILParserUtils::TrimWhitespace(aRepeatDurSpec);
@@ -1016,11 +1016,11 @@ void SMILTimedElement::UnsetFillMode() {
} }
} }
void SMILTimedElement::AddDependent(nsSMILTimeValueSpec& aDependent) { void SMILTimedElement::AddDependent(SMILTimeValueSpec& aDependent) {
// There's probably no harm in attempting to register a dependent // There's probably no harm in attempting to register a dependent
// nsSMILTimeValueSpec twice, but we're not expecting it to happen. // SMILTimeValueSpec twice, but we're not expecting it to happen.
MOZ_ASSERT(!mTimeDependents.GetEntry(&aDependent), MOZ_ASSERT(!mTimeDependents.GetEntry(&aDependent),
"nsSMILTimeValueSpec is already registered as a dependency"); "SMILTimeValueSpec is already registered as a dependency");
mTimeDependents.PutEntry(&aDependent); mTimeDependents.PutEntry(&aDependent);
// Add current interval. We could add historical intervals too but that would // Add current interval. We could add historical intervals too but that would
@@ -1035,13 +1035,13 @@ void SMILTimedElement::AddDependent(nsSMILTimeValueSpec& aDependent) {
} }
} }
void SMILTimedElement::RemoveDependent(nsSMILTimeValueSpec& aDependent) { void SMILTimedElement::RemoveDependent(SMILTimeValueSpec& aDependent) {
mTimeDependents.RemoveEntry(&aDependent); mTimeDependents.RemoveEntry(&aDependent);
} }
bool SMILTimedElement::IsTimeDependent(const SMILTimedElement& aOther) const { bool SMILTimedElement::IsTimeDependent(const SMILTimedElement& aOther) const {
const nsSMILInstanceTime* thisBegin = GetEffectiveBeginInstance(); const SMILInstanceTime* thisBegin = GetEffectiveBeginInstance();
const nsSMILInstanceTime* otherBegin = aOther.GetEffectiveBeginInstance(); const SMILInstanceTime* otherBegin = aOther.GetEffectiveBeginInstance();
if (!thisBegin || !otherBegin) return false; if (!thisBegin || !otherBegin) return false;
@@ -1096,15 +1096,15 @@ void SMILTimedElement::HandleTargetElementChange(Element* aNewTarget) {
void SMILTimedElement::Traverse(nsCycleCollectionTraversalCallback* aCallback) { void SMILTimedElement::Traverse(nsCycleCollectionTraversalCallback* aCallback) {
uint32_t count = mBeginSpecs.Length(); uint32_t count = mBeginSpecs.Length();
for (uint32_t i = 0; i < count; ++i) { for (uint32_t i = 0; i < count; ++i) {
nsSMILTimeValueSpec* beginSpec = mBeginSpecs[i].get(); SMILTimeValueSpec* beginSpec = mBeginSpecs[i].get();
MOZ_ASSERT(beginSpec, "null nsSMILTimeValueSpec in list of begin specs"); MOZ_ASSERT(beginSpec, "null SMILTimeValueSpec in list of begin specs");
beginSpec->Traverse(aCallback); beginSpec->Traverse(aCallback);
} }
count = mEndSpecs.Length(); count = mEndSpecs.Length();
for (uint32_t j = 0; j < count; ++j) { for (uint32_t j = 0; j < count; ++j) {
nsSMILTimeValueSpec* endSpec = mEndSpecs[j].get(); SMILTimeValueSpec* endSpec = mEndSpecs[j].get();
MOZ_ASSERT(endSpec, "null nsSMILTimeValueSpec in list of end specs"); MOZ_ASSERT(endSpec, "null SMILTimeValueSpec in list of end specs");
endSpec->Traverse(aCallback); endSpec->Traverse(aCallback);
} }
} }
@@ -1115,15 +1115,15 @@ void SMILTimedElement::Unlink() {
// Remove dependencies on other elements // Remove dependencies on other elements
uint32_t count = mBeginSpecs.Length(); uint32_t count = mBeginSpecs.Length();
for (uint32_t i = 0; i < count; ++i) { for (uint32_t i = 0; i < count; ++i) {
nsSMILTimeValueSpec* beginSpec = mBeginSpecs[i].get(); SMILTimeValueSpec* beginSpec = mBeginSpecs[i].get();
MOZ_ASSERT(beginSpec, "null nsSMILTimeValueSpec in list of begin specs"); MOZ_ASSERT(beginSpec, "null SMILTimeValueSpec in list of begin specs");
beginSpec->Unlink(); beginSpec->Unlink();
} }
count = mEndSpecs.Length(); count = mEndSpecs.Length();
for (uint32_t j = 0; j < count; ++j) { for (uint32_t j = 0; j < count; ++j) {
nsSMILTimeValueSpec* endSpec = mEndSpecs[j].get(); SMILTimeValueSpec* endSpec = mEndSpecs[j].get();
MOZ_ASSERT(endSpec, "null nsSMILTimeValueSpec in list of end specs"); MOZ_ASSERT(endSpec, "null SMILTimeValueSpec in list of end specs");
endSpec->Unlink(); endSpec->Unlink();
} }
@@ -1154,7 +1154,7 @@ nsresult SMILTimedElement::SetBeginOrEndSpec(const nsAString& aSpec,
bool hadFailure = false; bool hadFailure = false;
while (tokenizer.hasMoreTokens()) { while (tokenizer.hasMoreTokens()) {
auto spec = MakeUnique<nsSMILTimeValueSpec>(*this, aIsBegin); auto spec = MakeUnique<SMILTimeValueSpec>(*this, aIsBegin);
nsresult rv = spec->SetSpec(tokenizer.nextToken(), aContextElement); nsresult rv = spec->SetSpec(tokenizer.nextToken(), aContextElement);
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
timeSpecsList.AppendElement(std::move(spec)); timeSpecsList.AppendElement(std::move(spec));
@@ -1179,7 +1179,7 @@ class MOZ_STACK_CLASS RemoveByFunction {
public: public:
explicit RemoveByFunction(SMILTimedElement::RemovalTestFunction aFunction) explicit RemoveByFunction(SMILTimedElement::RemovalTestFunction aFunction)
: mFunction(aFunction) {} : mFunction(aFunction) {}
bool operator()(nsSMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) { bool operator()(SMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) {
return mFunction(aInstanceTime); return mFunction(aInstanceTime);
} }
@@ -1216,7 +1216,7 @@ void SMILTimedElement::ClearIntervals() {
mOldIntervals.Clear(); mOldIntervals.Clear();
} }
bool SMILTimedElement::ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime) { bool SMILTimedElement::ApplyEarlyEnd(const SMILTimeValue& aSampleTime) {
// This should only be called within DoSampleAt as a helper function // This should only be called within DoSampleAt as a helper function
MOZ_ASSERT(mElementState == STATE_ACTIVE, MOZ_ASSERT(mElementState == STATE_ACTIVE,
"Unexpected state to try to apply an early end"); "Unexpected state to try to apply an early end");
@@ -1225,14 +1225,14 @@ bool SMILTimedElement::ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime) {
// Only apply an early end if we're not already ending. // Only apply an early end if we're not already ending.
if (mCurrentInterval->End()->Time() > aSampleTime) { if (mCurrentInterval->End()->Time() > aSampleTime) {
nsSMILInstanceTime* earlyEnd = CheckForEarlyEnd(aSampleTime); SMILInstanceTime* earlyEnd = CheckForEarlyEnd(aSampleTime);
if (earlyEnd) { if (earlyEnd) {
if (earlyEnd->IsDependent()) { if (earlyEnd->IsDependent()) {
// Generate a new instance time for the early end since the // Generate a new instance time for the early end since the
// existing instance time is part of some dependency chain that we // existing instance time is part of some dependency chain that we
// don't want to participate in. // don't want to participate in.
RefPtr<nsSMILInstanceTime> newEarlyEnd = RefPtr<SMILInstanceTime> newEarlyEnd =
new nsSMILInstanceTime(earlyEnd->Time()); new SMILInstanceTime(earlyEnd->Time());
mCurrentInterval->SetEnd(*newEarlyEnd); mCurrentInterval->SetEnd(*newEarlyEnd);
} else { } else {
mCurrentInterval->SetEnd(*earlyEnd); mCurrentInterval->SetEnd(*earlyEnd);
@@ -1246,9 +1246,9 @@ bool SMILTimedElement::ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime) {
namespace { namespace {
class MOZ_STACK_CLASS RemoveReset { class MOZ_STACK_CLASS RemoveReset {
public: public:
explicit RemoveReset(const nsSMILInstanceTime* aCurrentIntervalBegin) explicit RemoveReset(const SMILInstanceTime* aCurrentIntervalBegin)
: mCurrentIntervalBegin(aCurrentIntervalBegin) {} : mCurrentIntervalBegin(aCurrentIntervalBegin) {}
bool operator()(nsSMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) { bool operator()(SMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) {
// SMIL 3.0 section 5.4.3, 'Resetting element state': // SMIL 3.0 section 5.4.3, 'Resetting element state':
// Any instance times associated with past Event-values, Repeat-values, // Any instance times associated with past Event-values, Repeat-values,
// Accesskey-values or added via DOM method calls are removed from the // Accesskey-values or added via DOM method calls are removed from the
@@ -1260,7 +1260,7 @@ class MOZ_STACK_CLASS RemoveReset {
} }
private: private:
const nsSMILInstanceTime* mCurrentIntervalBegin; const SMILInstanceTime* mCurrentIntervalBegin;
}; };
} // namespace } // namespace
@@ -1355,12 +1355,12 @@ void SMILTimedElement::DoPostSeek() {
void SMILTimedElement::UnpreserveInstanceTimes(InstanceTimeList& aList) { void SMILTimedElement::UnpreserveInstanceTimes(InstanceTimeList& aList) {
const SMILInterval* prevInterval = GetPreviousInterval(); const SMILInterval* prevInterval = GetPreviousInterval();
const nsSMILInstanceTime* cutoff = const SMILInstanceTime* cutoff =
mCurrentInterval ? mCurrentInterval->Begin() mCurrentInterval ? mCurrentInterval->Begin()
: prevInterval ? prevInterval->Begin() : nullptr; : prevInterval ? prevInterval->Begin() : nullptr;
uint32_t count = aList.Length(); uint32_t count = aList.Length();
for (uint32_t i = 0; i < count; ++i) { for (uint32_t i = 0; i < count; ++i) {
nsSMILInstanceTime* instance = aList[i].get(); SMILInstanceTime* instance = aList[i].get();
if (!cutoff || cutoff->Time().CompareTo(instance->Time()) < 0) { if (!cutoff || cutoff->Time().CompareTo(instance->Time()) < 0) {
instance->UnmarkShouldPreserve(); instance->UnmarkShouldPreserve();
} }
@@ -1425,8 +1425,8 @@ void SMILTimedElement::FilterIntervals() {
namespace { namespace {
class MOZ_STACK_CLASS RemoveFiltered { class MOZ_STACK_CLASS RemoveFiltered {
public: public:
explicit RemoveFiltered(nsSMILTimeValue aCutoff) : mCutoff(aCutoff) {} explicit RemoveFiltered(SMILTimeValue aCutoff) : mCutoff(aCutoff) {}
bool operator()(nsSMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) { bool operator()(SMILInstanceTime* aInstanceTime, uint32_t /*aIndex*/) {
// We can filter instance times that: // We can filter instance times that:
// a) Precede the end point of the previous interval; AND // a) Precede the end point of the previous interval; AND
// b) Are NOT syncbase times that might be updated to a time after the end // b) Are NOT syncbase times that might be updated to a time after the end
@@ -1437,21 +1437,21 @@ class MOZ_STACK_CLASS RemoveFiltered {
} }
private: private:
nsSMILTimeValue mCutoff; SMILTimeValue mCutoff;
}; };
class MOZ_STACK_CLASS RemoveBelowThreshold { class MOZ_STACK_CLASS RemoveBelowThreshold {
public: public:
RemoveBelowThreshold(uint32_t aThreshold, RemoveBelowThreshold(uint32_t aThreshold,
nsTArray<const nsSMILInstanceTime*>& aTimesToKeep) nsTArray<const SMILInstanceTime*>& aTimesToKeep)
: mThreshold(aThreshold), mTimesToKeep(aTimesToKeep) {} : mThreshold(aThreshold), mTimesToKeep(aTimesToKeep) {}
bool operator()(nsSMILInstanceTime* aInstanceTime, uint32_t aIndex) { bool operator()(SMILInstanceTime* aInstanceTime, uint32_t aIndex) {
return aIndex < mThreshold && !mTimesToKeep.Contains(aInstanceTime); return aIndex < mThreshold && !mTimesToKeep.Contains(aInstanceTime);
} }
private: private:
uint32_t mThreshold; uint32_t mThreshold;
nsTArray<const nsSMILInstanceTime*>& mTimesToKeep; nsTArray<const SMILInstanceTime*>& mTimesToKeep;
}; };
} // namespace } // namespace
@@ -1473,7 +1473,7 @@ void SMILTimedElement::FilterInstanceTimes(InstanceTimeList& aList) {
// - the current interval begin time, // - the current interval begin time,
// - the previous interval end time (see note in RemoveInstanceTimes) // - the previous interval end time (see note in RemoveInstanceTimes)
// - the first interval begin time (see note in FilterIntervals) // - the first interval begin time (see note in FilterIntervals)
nsTArray<const nsSMILInstanceTime*> timesToKeep; nsTArray<const SMILInstanceTime*> timesToKeep;
if (mCurrentInterval) { if (mCurrentInterval) {
timesToKeep.AppendElement(mCurrentInterval->Begin()); timesToKeep.AppendElement(mCurrentInterval->Begin());
} }
@@ -1495,17 +1495,18 @@ void SMILTimedElement::FilterInstanceTimes(InstanceTimeList& aList) {
// See: // See:
// http://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-BeginEnd-LC-Start // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#Timing-BeginEnd-LC-Start
// //
bool SMILTimedElement::GetNextInterval( bool SMILTimedElement::GetNextInterval(const SMILInterval* aPrevInterval,
const SMILInterval* aPrevInterval, const SMILInterval* aReplacedInterval, const SMILInterval* aReplacedInterval,
const nsSMILInstanceTime* aFixedBeginTime, SMILInterval& aResult) const { const SMILInstanceTime* aFixedBeginTime,
SMILInterval& aResult) const {
MOZ_ASSERT(!aFixedBeginTime || aFixedBeginTime->Time().IsDefinite(), MOZ_ASSERT(!aFixedBeginTime || aFixedBeginTime->Time().IsDefinite(),
"Unresolved or indefinite begin time given for interval start"); "Unresolved or indefinite begin time given for interval start");
static const nsSMILTimeValue zeroTime(0L); static const SMILTimeValue zeroTime(0L);
if (mRestartMode == RESTART_NEVER && aPrevInterval) return false; if (mRestartMode == RESTART_NEVER && aPrevInterval) return false;
// Calc starting point // Calc starting point
nsSMILTimeValue beginAfter; SMILTimeValue beginAfter;
bool prevIntervalWasZeroDur = false; bool prevIntervalWasZeroDur = false;
if (aPrevInterval) { if (aPrevInterval) {
beginAfter = aPrevInterval->End()->Time(); beginAfter = aPrevInterval->End()->Time();
@@ -1515,8 +1516,8 @@ bool SMILTimedElement::GetNextInterval(
beginAfter.SetMillis(INT64_MIN); beginAfter.SetMillis(INT64_MIN);
} }
RefPtr<nsSMILInstanceTime> tempBegin; RefPtr<SMILInstanceTime> tempBegin;
RefPtr<nsSMILInstanceTime> tempEnd; RefPtr<SMILInstanceTime> tempEnd;
while (true) { while (true) {
// Calculate begin time // Calculate begin time
@@ -1525,11 +1526,11 @@ bool SMILTimedElement::GetNextInterval(
return false; return false;
} }
// our ref-counting is not const-correct // our ref-counting is not const-correct
tempBegin = const_cast<nsSMILInstanceTime*>(aFixedBeginTime); tempBegin = const_cast<SMILInstanceTime*>(aFixedBeginTime);
} else if ((!mAnimationElement || } else if ((!mAnimationElement ||
!mAnimationElement->HasAttr(nsGkAtoms::begin)) && !mAnimationElement->HasAttr(nsGkAtoms::begin)) &&
beginAfter <= zeroTime) { beginAfter <= zeroTime) {
tempBegin = new nsSMILInstanceTime(nsSMILTimeValue(0)); tempBegin = new SMILInstanceTime(SMILTimeValue(0));
} else { } else {
int32_t beginPos = 0; int32_t beginPos = 0;
do { do {
@@ -1604,12 +1605,11 @@ bool SMILTimedElement::GetNextInterval(
} }
} }
nsSMILTimeValue intervalEnd = SMILTimeValue intervalEnd = tempEnd ? tempEnd->Time() : SMILTimeValue();
tempEnd ? tempEnd->Time() : nsSMILTimeValue(); SMILTimeValue activeEnd = CalcActiveEnd(tempBegin->Time(), intervalEnd);
nsSMILTimeValue activeEnd = CalcActiveEnd(tempBegin->Time(), intervalEnd);
if (!tempEnd || intervalEnd != activeEnd) { if (!tempEnd || intervalEnd != activeEnd) {
tempEnd = new nsSMILInstanceTime(activeEnd); tempEnd = new SMILInstanceTime(activeEnd);
} }
} }
MOZ_ASSERT(tempEnd, "Failed to get end point for next interval"); MOZ_ASSERT(tempEnd, "Failed to get end point for next interval");
@@ -1649,24 +1649,24 @@ bool SMILTimedElement::GetNextInterval(
return false; return false;
} }
nsSMILInstanceTime* SMILTimedElement::GetNextGreater( SMILInstanceTime* SMILTimedElement::GetNextGreater(
const InstanceTimeList& aList, const nsSMILTimeValue& aBase, const InstanceTimeList& aList, const SMILTimeValue& aBase,
int32_t& aPosition) const { int32_t& aPosition) const {
nsSMILInstanceTime* result = nullptr; SMILInstanceTime* result = nullptr;
while ((result = GetNextGreaterOrEqual(aList, aBase, aPosition)) && while ((result = GetNextGreaterOrEqual(aList, aBase, aPosition)) &&
result->Time() == aBase) { result->Time() == aBase) {
} }
return result; return result;
} }
nsSMILInstanceTime* SMILTimedElement::GetNextGreaterOrEqual( SMILInstanceTime* SMILTimedElement::GetNextGreaterOrEqual(
const InstanceTimeList& aList, const nsSMILTimeValue& aBase, const InstanceTimeList& aList, const SMILTimeValue& aBase,
int32_t& aPosition) const { int32_t& aPosition) const {
nsSMILInstanceTime* result = nullptr; SMILInstanceTime* result = nullptr;
int32_t count = aList.Length(); int32_t count = aList.Length();
for (; aPosition < count && !result; ++aPosition) { for (; aPosition < count && !result; ++aPosition) {
nsSMILInstanceTime* val = aList[aPosition].get(); SMILInstanceTime* val = aList[aPosition].get();
MOZ_ASSERT(val, "NULL instance time in list"); MOZ_ASSERT(val, "NULL instance time in list");
if (val->Time() >= aBase) { if (val->Time() >= aBase) {
result = val; result = val;
@@ -1679,9 +1679,9 @@ nsSMILInstanceTime* SMILTimedElement::GetNextGreaterOrEqual(
/** /**
* @see SMILANIM 3.3.4 * @see SMILANIM 3.3.4
*/ */
nsSMILTimeValue SMILTimedElement::CalcActiveEnd( SMILTimeValue SMILTimedElement::CalcActiveEnd(const SMILTimeValue& aBegin,
const nsSMILTimeValue& aBegin, const nsSMILTimeValue& aEnd) const { const SMILTimeValue& aEnd) const {
nsSMILTimeValue result; SMILTimeValue result;
MOZ_ASSERT(mSimpleDur.IsResolved(), MOZ_ASSERT(mSimpleDur.IsResolved(),
"Unresolved simple duration in CalcActiveEnd"); "Unresolved simple duration in CalcActiveEnd");
@@ -1710,8 +1710,8 @@ nsSMILTimeValue SMILTimedElement::CalcActiveEnd(
return result; return result;
} }
nsSMILTimeValue SMILTimedElement::GetRepeatDuration() const { SMILTimeValue SMILTimedElement::GetRepeatDuration() const {
nsSMILTimeValue multipliedDuration; SMILTimeValue multipliedDuration;
if (mRepeatCount.IsDefinite() && mSimpleDur.IsDefinite()) { if (mRepeatCount.IsDefinite() && mSimpleDur.IsDefinite()) {
if (mRepeatCount * double(mSimpleDur.GetMillis()) <= if (mRepeatCount * double(mSimpleDur.GetMillis()) <=
std::numeric_limits<nsSMILTime>::max()) { std::numeric_limits<nsSMILTime>::max()) {
@@ -1722,7 +1722,7 @@ nsSMILTimeValue SMILTimedElement::GetRepeatDuration() const {
multipliedDuration.SetIndefinite(); multipliedDuration.SetIndefinite();
} }
nsSMILTimeValue repeatDuration; SMILTimeValue repeatDuration;
if (mRepeatDur.IsResolved()) { if (mRepeatDur.IsResolved()) {
repeatDuration = std::min(multipliedDuration, mRepeatDur); repeatDuration = std::min(multipliedDuration, mRepeatDur);
@@ -1735,8 +1735,8 @@ nsSMILTimeValue SMILTimedElement::GetRepeatDuration() const {
return repeatDuration; return repeatDuration;
} }
nsSMILTimeValue SMILTimedElement::ApplyMinAndMax( SMILTimeValue SMILTimedElement::ApplyMinAndMax(
const nsSMILTimeValue& aDuration) const { const SMILTimeValue& aDuration) const {
if (!aDuration.IsResolved()) { if (!aDuration.IsResolved()) {
return aDuration; return aDuration;
} }
@@ -1745,7 +1745,7 @@ nsSMILTimeValue SMILTimedElement::ApplyMinAndMax(
return aDuration; return aDuration;
} }
nsSMILTimeValue result; SMILTimeValue result;
if (aDuration > mMax) { if (aDuration > mMax) {
result = mMax; result = mMax;
@@ -1791,14 +1791,14 @@ nsSMILTime SMILTimedElement::ActiveTimeToSimpleTime(
// also send a changed time notice to all time dependents for the current // also send a changed time notice to all time dependents for the current
// interval end.' // interval end.'
// //
nsSMILInstanceTime* SMILTimedElement::CheckForEarlyEnd( SMILInstanceTime* SMILTimedElement::CheckForEarlyEnd(
const nsSMILTimeValue& aContainerTime) const { const SMILTimeValue& aContainerTime) const {
MOZ_ASSERT(mCurrentInterval, MOZ_ASSERT(mCurrentInterval,
"Checking for an early end but the current interval is not set"); "Checking for an early end but the current interval is not set");
if (mRestartMode != RESTART_ALWAYS) return nullptr; if (mRestartMode != RESTART_ALWAYS) return nullptr;
int32_t position = 0; int32_t position = 0;
nsSMILInstanceTime* nextBegin = GetNextGreater( SMILInstanceTime* nextBegin = GetNextGreater(
mBeginInstances, mCurrentInterval->Begin()->Time(), position); mBeginInstances, mCurrentInterval->Begin()->Time(), position);
if (nextBegin && nextBegin->Time() > mCurrentInterval->Begin()->Time() && if (nextBegin && nextBegin->Time() > mCurrentInterval->Begin()->Time() &&
@@ -1857,7 +1857,7 @@ void SMILTimedElement::UpdateCurrentInterval(bool aForceChangeNotice) {
} }
// If the interval is active the begin time is fixed. // If the interval is active the begin time is fixed.
const nsSMILInstanceTime* beginTime = const SMILInstanceTime* beginTime =
mElementState == STATE_ACTIVE ? mCurrentInterval->Begin() : nullptr; mElementState == STATE_ACTIVE ? mCurrentInterval->Begin() : nullptr;
SMILInterval updatedInterval; SMILInterval updatedInterval;
if (GetNextInterval(GetPreviousInterval(), mCurrentInterval.get(), beginTime, if (GetNextInterval(GetPreviousInterval(), mCurrentInterval.get(), beginTime,
@@ -1944,7 +1944,7 @@ void SMILTimedElement::SampleFillValue() {
// If the interval's repeat duration was shorter than its active duration, // If the interval's repeat duration was shorter than its active duration,
// use the end of the repeat duration to determine the frozen animation's // use the end of the repeat duration to determine the frozen animation's
// state. // state.
nsSMILTimeValue repeatDuration = GetRepeatDuration(); SMILTimeValue repeatDuration = GetRepeatDuration();
if (repeatDuration.IsDefinite()) { if (repeatDuration.IsDefinite()) {
activeTime = std::min(repeatDuration.GetMillis(), activeTime); activeTime = std::min(repeatDuration.GetMillis(), activeTime);
} }
@@ -1980,10 +1980,10 @@ nsresult SMILTimedElement::AddInstanceTimeFromCurrentTime(
if (aCurrentTime + offset > std::numeric_limits<nsSMILTime>::max()) if (aCurrentTime + offset > std::numeric_limits<nsSMILTime>::max())
return NS_ERROR_ILLEGAL_VALUE; return NS_ERROR_ILLEGAL_VALUE;
nsSMILTimeValue timeVal(aCurrentTime + int64_t(offset)); SMILTimeValue timeVal(aCurrentTime + int64_t(offset));
RefPtr<nsSMILInstanceTime> instanceTime = RefPtr<SMILInstanceTime> instanceTime =
new nsSMILInstanceTime(timeVal, nsSMILInstanceTime::SOURCE_DOM); new SMILInstanceTime(timeVal, SMILInstanceTime::SOURCE_DOM);
AddInstanceTime(instanceTime, aIsBegin); AddInstanceTime(instanceTime, aIsBegin);
@@ -2042,21 +2042,21 @@ bool SMILTimedElement::GetNextMilestone(SMILMilestone& aNextMilestone) const {
case STATE_ACTIVE: { case STATE_ACTIVE: {
// Work out what comes next: the interval end or the next repeat iteration // Work out what comes next: the interval end or the next repeat iteration
nsSMILTimeValue nextRepeat; SMILTimeValue nextRepeat;
if (mSeekState == SEEK_NOT_SEEKING && mSimpleDur.IsDefinite()) { if (mSeekState == SEEK_NOT_SEEKING && mSimpleDur.IsDefinite()) {
nsSMILTime nextRepeatActiveTime = nsSMILTime nextRepeatActiveTime =
(mCurrentRepeatIteration + 1) * mSimpleDur.GetMillis(); (mCurrentRepeatIteration + 1) * mSimpleDur.GetMillis();
// Check that the repeat fits within the repeat duration // Check that the repeat fits within the repeat duration
if (nsSMILTimeValue(nextRepeatActiveTime) < GetRepeatDuration()) { if (SMILTimeValue(nextRepeatActiveTime) < GetRepeatDuration()) {
nextRepeat.SetMillis(mCurrentInterval->Begin()->Time().GetMillis() + nextRepeat.SetMillis(mCurrentInterval->Begin()->Time().GetMillis() +
nextRepeatActiveTime); nextRepeatActiveTime);
} }
} }
nsSMILTimeValue nextMilestone = SMILTimeValue nextMilestone =
std::min(mCurrentInterval->End()->Time(), nextRepeat); std::min(mCurrentInterval->End()->Time(), nextRepeat);
// Check for an early end before that time // Check for an early end before that time
nsSMILInstanceTime* earlyEnd = CheckForEarlyEnd(nextMilestone); SMILInstanceTime* earlyEnd = CheckForEarlyEnd(nextMilestone);
if (earlyEnd) { if (earlyEnd) {
aNextMilestone.mIsEnd = true; aNextMilestone.mIsEnd = true;
aNextMilestone.mTime = earlyEnd->Time().GetMillis(); aNextMilestone.mTime = earlyEnd->Time().GetMillis();
@@ -2098,7 +2098,7 @@ void SMILTimedElement::NotifyNewInterval() {
if (!interval) { if (!interval) {
break; break;
} }
nsSMILTimeValueSpec* spec = iter.Get()->GetKey(); SMILTimeValueSpec* spec = iter.Get()->GetKey();
spec->HandleNewInterval(*interval, container); spec->HandleNewInterval(*interval, container);
} }
} }
@@ -2133,7 +2133,7 @@ void SMILTimedElement::FireTimeEventAsync(EventMessage aMsg, int32_t aDetail) {
mAnimationElement->OwnerDoc()->Dispatch(TaskCategory::Other, event.forget()); mAnimationElement->OwnerDoc()->Dispatch(TaskCategory::Other, event.forget());
} }
const nsSMILInstanceTime* SMILTimedElement::GetEffectiveBeginInstance() const { const SMILInstanceTime* SMILTimedElement::GetEffectiveBeginInstance() const {
switch (mElementState) { switch (mElementState) {
case STATE_STARTUP: case STATE_STARTUP:
return nullptr; return nullptr;
@@ -2170,7 +2170,7 @@ bool SMILTimedElement::EndHasEventConditions() const {
} }
bool SMILTimedElement::AreEndTimesDependentOn( bool SMILTimedElement::AreEndTimesDependentOn(
const nsSMILInstanceTime* aBase) const { const SMILInstanceTime* aBase) const {
if (mEndInstances.IsEmpty()) return false; if (mEndInstances.IsEmpty()) return false;
for (uint32_t i = 0; i < mEndInstances.Length(); ++i) { for (uint32_t i = 0; i < mEndInstances.Length(); ++i) {

View File

@@ -10,11 +10,11 @@
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
#include "mozilla/Move.h" #include "mozilla/Move.h"
#include "mozilla/SMILMilestone.h" #include "mozilla/SMILMilestone.h"
#include "mozilla/SMILInstanceTime.h"
#include "mozilla/SMILInterval.h" #include "mozilla/SMILInterval.h"
#include "mozilla/SMILRepeatCount.h" #include "mozilla/SMILRepeatCount.h"
#include "mozilla/SMILTimeValueSpec.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsSMILInstanceTime.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILTypes.h" #include "nsSMILTypes.h"
#include "nsTArray.h" #include "nsTArray.h"
#include "nsTHashtable.h" #include "nsTHashtable.h"
@@ -22,12 +22,14 @@
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsAttrValue.h" #include "nsAttrValue.h"
class nsSMILTimeValue;
class nsAtom; class nsAtom;
namespace mozilla { namespace mozilla {
class SMILAnimationFunction; class SMILAnimationFunction;
class SMILTimeContainer; class SMILTimeContainer;
class SMILTimeValue;
namespace dom { namespace dom {
class SVGAnimationElement; class SVGAnimationElement;
} // namespace dom } // namespace dom
@@ -97,14 +99,14 @@ class SMILTimedElement {
* @return the start time as defined above in milliseconds or an unresolved * @return the start time as defined above in milliseconds or an unresolved
* time if there is no current interval. * time if there is no current interval.
*/ */
nsSMILTimeValue GetStartTime() const; SMILTimeValue GetStartTime() const;
/** /**
* Returns the simple duration of this element. * Returns the simple duration of this element.
* *
* @return the simple duration in milliseconds or INDEFINITE. * @return the simple duration in milliseconds or INDEFINITE.
*/ */
nsSMILTimeValue GetSimpleDuration() const { return mSimpleDur; } SMILTimeValue GetSimpleDuration() const { return mSimpleDur; }
/** /**
* Methods for supporting hyperlinking * Methods for supporting hyperlinking
@@ -127,24 +129,24 @@ class SMILTimedElement {
* @return the time to seek the documen to in milliseconds or an unresolved * @return the time to seek the documen to in milliseconds or an unresolved
* time if there is no resolved interval. * time if there is no resolved interval.
*/ */
nsSMILTimeValue GetHyperlinkTime() const; SMILTimeValue GetHyperlinkTime() const;
/** /**
* Adds an instance time object this element's list of instance times. * Adds an instance time object this element's list of instance times.
* These instance times are used when creating intervals. * These instance times are used when creating intervals.
* *
* This method is typically called by an nsSMILTimeValueSpec. * This method is typically called by an SMILTimeValueSpec.
* *
* @param aInstanceTime The time to add, expressed in container time. * @param aInstanceTime The time to add, expressed in container time.
* @param aIsBegin true if the time to be added represents a begin * @param aIsBegin true if the time to be added represents a begin
* time or false if it represents an end time. * time or false if it represents an end time.
*/ */
void AddInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin); void AddInstanceTime(SMILInstanceTime* aInstanceTime, bool aIsBegin);
/** /**
* Requests this element update the given instance time. * Requests this element update the given instance time.
* *
* This method is typically called by a child nsSMILTimeValueSpec. * This method is typically called by a child SMILTimeValueSpec.
* *
* @param aInstanceTime The instance time to update. * @param aInstanceTime The instance time to update.
* @param aUpdatedTime The time to update aInstanceTime with. * @param aUpdatedTime The time to update aInstanceTime with.
@@ -154,31 +156,31 @@ class SMILTimedElement {
* instance time or false if it represents an end * instance time or false if it represents an end
* instance time. * instance time.
*/ */
void UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime, void UpdateInstanceTime(SMILInstanceTime* aInstanceTime,
nsSMILTimeValue& aUpdatedTime, bool aIsBegin); SMILTimeValue& aUpdatedTime, bool aIsBegin);
/** /**
* Removes an instance time object from this element's list of instance times. * Removes an instance time object from this element's list of instance times.
* *
* This method is typically called by a child nsSMILTimeValueSpec. * This method is typically called by a child SMILTimeValueSpec.
* *
* @param aInstanceTime The instance time to remove. * @param aInstanceTime The instance time to remove.
* @param aIsBegin true if the time to be removed represents a begin * @param aIsBegin true if the time to be removed represents a begin
* time or false if it represents an end time. * time or false if it represents an end time.
*/ */
void RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin); void RemoveInstanceTime(SMILInstanceTime* aInstanceTime, bool aIsBegin);
/** /**
* Removes all the instance times associated with the given * Removes all the instance times associated with the given
* nsSMILTimeValueSpec object. Used when an ID assignment changes and hence * SMILTimeValueSpec object. Used when an ID assignment changes and hence
* all the previously associated instance times become invalid. * all the previously associated instance times become invalid.
* *
* @param aSpec The nsSMILTimeValueSpec object whose created * @param aSpec The SMILTimeValueSpec object whose created
* nsSMILInstanceTime's should be removed. * SMILInstanceTime's should be removed.
* @param aIsBegin true if the times to be removed represent begin * @param aIsBegin true if the times to be removed represent begin
* times or false if they are end times. * times or false if they are end times.
*/ */
void RemoveInstanceTimesForCreator(const nsSMILTimeValueSpec* aSpec, void RemoveInstanceTimesForCreator(const SMILTimeValueSpec* aSpec,
bool aIsBegin); bool aIsBegin);
/** /**
@@ -287,20 +289,20 @@ class SMILTimedElement {
* Adds a syncbase dependency to the list of dependents that will be notified * Adds a syncbase dependency to the list of dependents that will be notified
* when this timed element creates, deletes, or updates its current interval. * when this timed element creates, deletes, or updates its current interval.
* *
* @param aDependent The nsSMILTimeValueSpec object to notify. A raw pointer * @param aDependent The SMILTimeValueSpec object to notify. A raw pointer
* to this object will be stored. Therefore it is necessary * to this object will be stored. Therefore it is necessary
* for the object to be explicitly unregistered (with * for the object to be explicitly unregistered (with
* RemoveDependent) when it is destroyed. * RemoveDependent) when it is destroyed.
*/ */
void AddDependent(nsSMILTimeValueSpec& aDependent); void AddDependent(SMILTimeValueSpec& aDependent);
/** /**
* Removes a syncbase dependency from the list of dependents that are notified * Removes a syncbase dependency from the list of dependents that are notified
* when the current interval is modified. * when the current interval is modified.
* *
* @param aDependent The nsSMILTimeValueSpec object to unregister. * @param aDependent The SMILTimeValueSpec object to unregister.
*/ */
void RemoveDependent(nsSMILTimeValueSpec& aDependent); void RemoveDependent(SMILTimeValueSpec& aDependent);
/** /**
* Determines if this timed element is dependent on the given timed element's * Determines if this timed element is dependent on the given timed element's
@@ -342,23 +344,23 @@ class SMILTimedElement {
void Traverse(nsCycleCollectionTraversalCallback* aCallback); void Traverse(nsCycleCollectionTraversalCallback* aCallback);
void Unlink(); void Unlink();
typedef bool (*RemovalTestFunction)(nsSMILInstanceTime* aInstance); typedef bool (*RemovalTestFunction)(SMILInstanceTime* aInstance);
protected: protected:
// Typedefs // Typedefs
typedef nsTArray<UniquePtr<nsSMILTimeValueSpec>> TimeValueSpecList; typedef nsTArray<UniquePtr<SMILTimeValueSpec>> TimeValueSpecList;
typedef nsTArray<RefPtr<nsSMILInstanceTime>> InstanceTimeList; typedef nsTArray<RefPtr<SMILInstanceTime>> InstanceTimeList;
typedef nsTArray<UniquePtr<SMILInterval>> IntervalList; typedef nsTArray<UniquePtr<SMILInterval>> IntervalList;
typedef nsPtrHashKey<nsSMILTimeValueSpec> TimeValueSpecPtrKey; typedef nsPtrHashKey<SMILTimeValueSpec> TimeValueSpecPtrKey;
typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet; typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
// Helper classes // Helper classes
class InstanceTimeComparator { class InstanceTimeComparator {
public: public:
bool Equals(const nsSMILInstanceTime* aElem1, bool Equals(const SMILInstanceTime* aElem1,
const nsSMILInstanceTime* aElem2) const; const SMILInstanceTime* aElem2) const;
bool LessThan(const nsSMILInstanceTime* aElem1, bool LessThan(const SMILInstanceTime* aElem1,
const nsSMILInstanceTime* aElem2) const; const SMILInstanceTime* aElem2) const;
}; };
// Templated helper functions // Templated helper functions
@@ -412,7 +414,7 @@ class SMILTimedElement {
* @return true if the end time of the current interval was updated, * @return true if the end time of the current interval was updated,
* false otherwise. * false otherwise.
*/ */
bool ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime); bool ApplyEarlyEnd(const SMILTimeValue& aSampleTime);
/** /**
* Clears certain state in response to the element restarting. * Clears certain state in response to the element restarting.
@@ -466,7 +468,7 @@ class SMILTimedElement {
void FilterHistory(); void FilterHistory();
// Helper functions for FilterHistory to clear old SMILIntervals and // Helper functions for FilterHistory to clear old SMILIntervals and
// nsSMILInstanceTimes respectively. // SMILInstanceTimes respectively.
void FilterIntervals(); void FilterIntervals();
void FilterInstanceTimes(InstanceTimeList& aList); void FilterInstanceTimes(InstanceTimeList& aList);
@@ -494,22 +496,21 @@ class SMILTimedElement {
*/ */
bool GetNextInterval(const SMILInterval* aPrevInterval, bool GetNextInterval(const SMILInterval* aPrevInterval,
const SMILInterval* aReplacedInterval, const SMILInterval* aReplacedInterval,
const nsSMILInstanceTime* aFixedBeginTime, const SMILInstanceTime* aFixedBeginTime,
SMILInterval& aResult) const; SMILInterval& aResult) const;
nsSMILInstanceTime* GetNextGreater(const InstanceTimeList& aList, SMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
const nsSMILTimeValue& aBase, const SMILTimeValue& aBase,
int32_t& aPosition) const; int32_t& aPosition) const;
nsSMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList, SMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
const nsSMILTimeValue& aBase, const SMILTimeValue& aBase,
int32_t& aPosition) const; int32_t& aPosition) const;
nsSMILTimeValue CalcActiveEnd(const nsSMILTimeValue& aBegin, SMILTimeValue CalcActiveEnd(const SMILTimeValue& aBegin,
const nsSMILTimeValue& aEnd) const; const SMILTimeValue& aEnd) const;
nsSMILTimeValue GetRepeatDuration() const; SMILTimeValue GetRepeatDuration() const;
nsSMILTimeValue ApplyMinAndMax(const nsSMILTimeValue& aDuration) const; SMILTimeValue ApplyMinAndMax(const SMILTimeValue& aDuration) const;
nsSMILTime ActiveTimeToSimpleTime(nsSMILTime aActiveTime, nsSMILTime ActiveTimeToSimpleTime(nsSMILTime aActiveTime,
uint32_t& aRepeatIteration); uint32_t& aRepeatIteration);
nsSMILInstanceTime* CheckForEarlyEnd( SMILInstanceTime* CheckForEarlyEnd(const SMILTimeValue& aContainerTime) const;
const nsSMILTimeValue& aContainerTime) const;
void UpdateCurrentInterval(bool aForceChangeNotice = false); void UpdateCurrentInterval(bool aForceChangeNotice = false);
void SampleSimpleTime(nsSMILTime aActiveTime); void SampleSimpleTime(nsSMILTime aActiveTime);
void SampleFillValue(); void SampleFillValue();
@@ -529,12 +530,12 @@ class SMILTimedElement {
bool aEndObjectChanged); bool aEndObjectChanged);
void FireTimeEventAsync(EventMessage aMsg, int32_t aDetail); void FireTimeEventAsync(EventMessage aMsg, int32_t aDetail);
const nsSMILInstanceTime* GetEffectiveBeginInstance() const; const SMILInstanceTime* GetEffectiveBeginInstance() const;
const SMILInterval* GetPreviousInterval() const; const SMILInterval* GetPreviousInterval() const;
bool HasPlayed() const { return !mOldIntervals.IsEmpty(); } bool HasPlayed() const { return !mOldIntervals.IsEmpty(); }
bool HasClientInFillRange() const; bool HasClientInFillRange() const;
bool EndHasEventConditions() const; bool EndHasEventConditions() const;
bool AreEndTimesDependentOn(const nsSMILInstanceTime* aBase) const; bool AreEndTimesDependentOn(const SMILInstanceTime* aBase) const;
// Reset the current interval by first passing ownership to a temporary // Reset the current interval by first passing ownership to a temporary
// variable so that if Unlink() results in us receiving a callback, // variable so that if Unlink() results in us receiving a callback,
@@ -555,13 +556,13 @@ class SMILTimedElement {
TimeValueSpecList mBeginSpecs; // [strong] TimeValueSpecList mBeginSpecs; // [strong]
TimeValueSpecList mEndSpecs; // [strong] TimeValueSpecList mEndSpecs; // [strong]
nsSMILTimeValue mSimpleDur; SMILTimeValue mSimpleDur;
SMILRepeatCount mRepeatCount; SMILRepeatCount mRepeatCount;
nsSMILTimeValue mRepeatDur; SMILTimeValue mRepeatDur;
nsSMILTimeValue mMin; SMILTimeValue mMin;
nsSMILTimeValue mMax; SMILTimeValue mMax;
enum nsSMILFillMode : uint8_t { FILL_REMOVE, FILL_FREEZE }; enum nsSMILFillMode : uint8_t { FILL_REMOVE, FILL_FREEZE };
nsSMILFillMode mFillMode; nsSMILFillMode mFillMode;
@@ -592,7 +593,7 @@ class SMILTimedElement {
// current interval. Change notifications and delete notifications are handled // current interval. Change notifications and delete notifications are handled
// by the interval. // by the interval.
// //
// [weak] The nsSMILTimeValueSpec objects register themselves and unregister // [weak] The SMILTimeValueSpec objects register themselves and unregister
// on destruction. Likewise, we notify them when we are destroyed. // on destruction. Likewise, we notify them when we are destroyed.
TimeValueSpecHashSet mTimeDependents; TimeValueSpecHashSet mTimeDependents;

View File

@@ -11,10 +11,6 @@ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
EXPORTS += [ EXPORTS += [
'nsISMILAttr.h', 'nsISMILAttr.h',
'nsSMILInstanceTime.h',
'nsSMILTimeValue.h',
'nsSMILTimeValueSpec.h',
'nsSMILTimeValueSpecParams.h',
'nsSMILTypes.h', 'nsSMILTypes.h',
'nsSMILValue.h', 'nsSMILValue.h',
] ]
@@ -24,6 +20,7 @@ EXPORTS.mozilla += [
'SMILAnimationFunction.h', 'SMILAnimationFunction.h',
'SMILCompositorTable.h', 'SMILCompositorTable.h',
'SMILCSSValueType.h', 'SMILCSSValueType.h',
'SMILInstanceTime.h',
'SMILInterval.h', 'SMILInterval.h',
'SMILKeySpline.h', 'SMILKeySpline.h',
'SMILMilestone.h', 'SMILMilestone.h',
@@ -34,6 +31,9 @@ EXPORTS.mozilla += [
'SMILTargetIdentifier.h', 'SMILTargetIdentifier.h',
'SMILTimeContainer.h', 'SMILTimeContainer.h',
'SMILTimedElement.h', 'SMILTimedElement.h',
'SMILTimeValue.h',
'SMILTimeValueSpec.h',
'SMILTimeValueSpecParams.h',
'SMILType.h', 'SMILType.h',
] ]
@@ -42,9 +42,6 @@ EXPORTS.mozilla.dom += [
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'nsSMILInstanceTime.cpp',
'nsSMILTimeValue.cpp',
'nsSMILTimeValueSpec.cpp',
'nsSMILValue.cpp', 'nsSMILValue.cpp',
'SMILAnimationController.cpp', 'SMILAnimationController.cpp',
'SMILAnimationFunction.cpp', 'SMILAnimationFunction.cpp',
@@ -54,6 +51,7 @@ UNIFIED_SOURCES += [
'SMILCSSValueType.cpp', 'SMILCSSValueType.cpp',
'SMILEnumType.cpp', 'SMILEnumType.cpp',
'SMILFloatType.cpp', 'SMILFloatType.cpp',
'SMILInstanceTime.cpp',
'SMILIntegerType.cpp', 'SMILIntegerType.cpp',
'SMILInterval.cpp', 'SMILInterval.cpp',
'SMILKeySpline.cpp', 'SMILKeySpline.cpp',
@@ -64,6 +62,8 @@ UNIFIED_SOURCES += [
'SMILStringType.cpp', 'SMILStringType.cpp',
'SMILTimeContainer.cpp', 'SMILTimeContainer.cpp',
'SMILTimedElement.cpp', 'SMILTimedElement.cpp',
'SMILTimeValue.cpp',
'SMILTimeValueSpec.cpp',
'TimeEvent.cpp', 'TimeEvent.cpp',
] ]

View File

@@ -19,7 +19,7 @@
// wallclock time -- "real" time -- offset since the epoch // wallclock time -- "real" time -- offset since the epoch
// //
// For an overview of how this class is related to other SMIL time classes see // For an overview of how this class is related to other SMIL time classes see
// the documentstation in nsSMILTimeValue.h // the documentation in SMILTimeValue.h
// //
typedef int64_t nsSMILTime; typedef int64_t nsSMILTime;

View File

@@ -98,7 +98,7 @@ SVGElement* SVGAnimationElement::GetTargetElement() {
float SVGAnimationElement::GetStartTime(ErrorResult& rv) { float SVGAnimationElement::GetStartTime(ErrorResult& rv) {
FlushAnimations(); FlushAnimations();
nsSMILTimeValue startTime = mTimedElement.GetStartTime(); SMILTimeValue startTime = mTimedElement.GetStartTime();
if (!startTime.IsDefinite()) { if (!startTime.IsDefinite()) {
rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); rv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return 0.f; return 0.f;
@@ -121,7 +121,7 @@ float SVGAnimationElement::GetCurrentTimeAsFloat() {
float SVGAnimationElement::GetSimpleDuration(ErrorResult& rv) { float SVGAnimationElement::GetSimpleDuration(ErrorResult& rv) {
// Not necessary to call FlushAnimations() for this // Not necessary to call FlushAnimations() for this
nsSMILTimeValue simpleDur = mTimedElement.GetSimpleDuration(); SMILTimeValue simpleDur = mTimedElement.GetSimpleDuration();
if (!simpleDur.IsDefinite()) { if (!simpleDur.IsDefinite()) {
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return 0.f; return 0.f;
@@ -297,7 +297,7 @@ void SVGAnimationElement::ActivateByHyperlink() {
// The behavior for when the target is an animation element is defined in // The behavior for when the target is an animation element is defined in
// SMIL Animation: // SMIL Animation:
// http://www.w3.org/TR/smil-animation/#HyperlinkSemantics // http://www.w3.org/TR/smil-animation/#HyperlinkSemantics
nsSMILTimeValue seekTime = mTimedElement.GetHyperlinkTime(); SMILTimeValue seekTime = mTimedElement.GetHyperlinkTime();
if (seekTime.IsDefinite()) { if (seekTime.IsDefinite()) {
SMILTimeContainer* timeContainer = GetTimeContainer(); SMILTimeContainer* timeContainer = GetTimeContainer();
if (timeContainer) { if (timeContainer) {