From 5d32c36de7c67dd194ecea6d0bbbd8460c1e2a0c Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Wed, 7 Sep 2011 09:20:40 +0900 Subject: [PATCH] Bug 682184 part 2 - Add nsSMILTimeValue::IsResolved; r=dholbert --- content/smil/nsSMILAnimationFunction.cpp | 3 +-- content/smil/nsSMILInterval.cpp | 2 +- content/smil/nsSMILTimeValue.h | 12 +++++++++ content/smil/nsSMILTimeValueSpec.cpp | 2 +- content/smil/nsSMILTimedElement.cpp | 33 ++++++++++++------------ content/smil/nsSMILTimedElement.h | 2 +- 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/content/smil/nsSMILAnimationFunction.cpp b/content/smil/nsSMILAnimationFunction.cpp index 7d8d965401dc..d6ce123831e8 100644 --- a/content/smil/nsSMILAnimationFunction.cpp +++ b/content/smil/nsSMILAnimationFunction.cpp @@ -252,8 +252,7 @@ nsSMILAnimationFunction::ComposeResult(const nsISMILAttr& aSMILAttr, // If this interval is active, we must have a non-negative mSampleTime NS_ABORT_IF_FALSE(mSampleTime >= 0 || !mIsActive, "Negative sample time for active animation"); - NS_ABORT_IF_FALSE(mSimpleDuration.IsDefinite() || - mSimpleDuration.IsIndefinite() || mLastValue, + NS_ABORT_IF_FALSE(mSimpleDuration.IsResolved() || mLastValue, "Unresolved simple duration for active or frozen animation"); // If we want to add but don't have a base value then just fail outright. diff --git a/content/smil/nsSMILInterval.cpp b/content/smil/nsSMILInterval.cpp index 5812b15ad605..81aa905c2aa3 100644 --- a/content/smil/nsSMILInterval.cpp +++ b/content/smil/nsSMILInterval.cpp @@ -111,7 +111,7 @@ void nsSMILInterval::SetBegin(nsSMILInstanceTime& aBegin) { NS_ABORT_IF_FALSE(aBegin.Time().IsDefinite(), - "Attempting to set unresolved begin time on interval"); + "Attempting to set unresolved or indefinite begin time on interval"); NS_ABORT_IF_FALSE(!mBeginFixed, "Attempting to set begin time but the begin point is fixed"); // Check that we're not making an instance time dependent on itself. Such an diff --git a/content/smil/nsSMILTimeValue.h b/content/smil/nsSMILTimeValue.h index 841020548be7..58e6c0e039f5 100644 --- a/content/smil/nsSMILTimeValue.h +++ b/content/smil/nsSMILTimeValue.h @@ -69,6 +69,17 @@ * 1) The time is resolved and has a definite millisecond value * 2) The time is resolved and indefinite * 3) The time is unresolved + * + * In summary: + * + * State | GetMillis | IsDefinite | IsIndefinite | IsResolved + * -----------+-----------------+------------+--------------+------------ + * Definite | nsSMILTimeValue | PR_TRUE | PR_FALSE | PR_TRUE + * -----------+-----------------+------------+--------------+------------ + * Indefinite | -- | PR_FALSE | PR_TRUE | PR_TRUE + * -----------+-----------------+------------+--------------+------------ + * Unresolved | -- | PR_FALSE | PR_FALSE | PR_FALSE + * */ class nsSMILTimeValue @@ -101,6 +112,7 @@ public: mMilliseconds = kUnresolvedMillis; } + PRBool IsResolved() const { return mState != STATE_UNRESOLVED; } void SetUnresolved() { mState = STATE_UNRESOLVED; diff --git a/content/smil/nsSMILTimeValueSpec.cpp b/content/smil/nsSMILTimeValueSpec.cpp index 776cf1b49f44..faa88d8c277c 100644 --- a/content/smil/nsSMILTimeValueSpec.cpp +++ b/content/smil/nsSMILTimeValueSpec.cpp @@ -531,7 +531,7 @@ nsSMILTimeValueSpec::ConvertBetweenTimeContainers( return docTime; NS_ABORT_IF_FALSE(docTime.IsDefinite(), - "ContainerToParentTime gave us an unresolved time"); + "ContainerToParentTime gave us an unresolved or indefinite time"); return dstContainer->ParentToContainerTime(docTime.GetMillis()); } diff --git a/content/smil/nsSMILTimedElement.cpp b/content/smil/nsSMILTimedElement.cpp index 3adb68b28668..9a781e8b32da 100644 --- a/content/smil/nsSMILTimedElement.cpp +++ b/content/smil/nsSMILTimedElement.cpp @@ -932,7 +932,7 @@ nsSMILTimedElement::SetSimpleDuration(const nsAString& aDurSpec) // mSimpleDur should never be unresolved. ParseClockValue will either set // duration to resolved/indefinite/media or will return a failure code. - NS_ASSERTION(duration.IsDefinite() || duration.IsIndefinite(), + NS_ABORT_IF_FALSE(duration.IsResolved(), "Setting unresolved simple duration"); mSimpleDur = duration; @@ -997,7 +997,7 @@ nsSMILTimedElement::SetMax(const nsAString& aMaxSpec) if (isMedia) duration.SetIndefinite(); - if (NS_FAILED(rv) || (!duration.IsDefinite() && !duration.IsIndefinite())) { + if (NS_FAILED(rv) || !duration.IsResolved()) { mMax.SetIndefinite(); return NS_ERROR_FAILURE; } @@ -1074,7 +1074,7 @@ nsSMILTimedElement::SetRepeatDur(const nsAString& aRepeatDurSpec) rv = nsSMILParserUtils::ParseClockValue(aRepeatDurSpec, &duration, nsSMILParserUtils::kClockValueAllowIndefinite); - if (NS_FAILED(rv) || (!duration.IsDefinite() && !duration.IsIndefinite())) { + if (NS_FAILED(rv) || !duration.IsResolved()) { mRepeatDur.SetUnresolved(); return NS_ERROR_FAILURE; } @@ -1609,7 +1609,7 @@ nsSMILTimedElement::GetNextInterval(const nsSMILInterval* aPrevInterval, nsSMILInterval& aResult) const { NS_ABORT_IF_FALSE(!aFixedBeginTime || aFixedBeginTime->Time().IsDefinite(), - "Unresolved begin time specified for interval start"); + "Unresolved or indefinite begin time specified for interval start"); static const nsSMILTimeValue zeroTime(0L); if (mRestartMode == RESTART_NEVER && aPrevInterval) @@ -1688,15 +1688,14 @@ nsSMILTimedElement::GetNextInterval(const nsSMILInterval* aPrevInterval, // a) We never had any end attribute to begin with (and hence we should // just use the active duration after allowing for the possibility of // an end instance provided by a DOM call), OR - // b) We have no resolved (not incl. indefinite) end instances - // (SMIL only says "if the instance list is empty"--but if we have - // indefinite/unresolved instance times then there must be a good - // reason we haven't used them (since they'll be >= tempBegin) such as - // avoiding creating a self-referential loop. In any case, the interval - // should be allowed to be open.), OR + // b) We have no definite end instances (SMIL only says "if the instance + // list is empty"--but if we have indefinite/unresolved instance times + // then there must be a good reason we haven't used them (since they + // will be >= tempBegin) such as avoiding creating a self-referential + // loop. In any case, the interval should be allowed to be open.), OR // c) We have end events which leave the interval open-ended. PRBool openEndedIntervalOk = mEndSpecs.IsEmpty() || - !HaveResolvedEndTimes() || + !HaveDefiniteEndTimes() || EndHasEventConditions(); if (!tempEnd && !openEndedIntervalOk) return PR_FALSE; // Bad interval @@ -1781,10 +1780,10 @@ nsSMILTimedElement::CalcActiveEnd(const nsSMILTimeValue& aBegin, { nsSMILTimeValue result; - NS_ABORT_IF_FALSE(mSimpleDur.IsDefinite() || mSimpleDur.IsIndefinite(), + NS_ABORT_IF_FALSE(mSimpleDur.IsResolved(), "Unresolved simple duration in CalcActiveEnd"); NS_ABORT_IF_FALSE(aBegin.IsDefinite(), - "Unresolved begin time in CalcActiveEnd"); + "Indefinite or unresolved begin time in CalcActiveEnd"); if (mRepeatDur.IsIndefinite()) { result.SetIndefinite(); @@ -1843,7 +1842,7 @@ nsSMILTimedElement::GetRepeatDuration() const nsSMILTimeValue nsSMILTimedElement::ApplyMinAndMax(const nsSMILTimeValue& aDuration) const { - if (!aDuration.IsDefinite() && !aDuration.IsIndefinite()) { + if (!aDuration.IsResolved()) { return aDuration; } @@ -1871,7 +1870,7 @@ nsSMILTimedElement::ActiveTimeToSimpleTime(nsSMILTime aActiveTime, { nsSMILTime result; - NS_ASSERTION(mSimpleDur.IsDefinite() || mSimpleDur.IsIndefinite(), + NS_ASSERTION(mSimpleDur.IsResolved(), "Unresolved simple duration in ActiveTimeToSimpleTime"); NS_ASSERTION(aActiveTime >= 0, "Expecting non-negative active time"); // Note that a negative aActiveTime will give us a negative value for @@ -2254,12 +2253,12 @@ nsSMILTimedElement::GetPreviousInterval() const } PRBool -nsSMILTimedElement::HaveResolvedEndTimes() const +nsSMILTimedElement::HaveDefiniteEndTimes() const { if (mEndInstances.IsEmpty()) return PR_FALSE; - // mEndInstances is sorted so if the first time is not resolved then none of + // mEndInstances is sorted so if the first time is not definite then none of // them are return mEndInstances[0]->Time().IsDefinite(); } diff --git a/content/smil/nsSMILTimedElement.h b/content/smil/nsSMILTimedElement.h index 9ecd40dcf695..487c1783ebe1 100644 --- a/content/smil/nsSMILTimedElement.h +++ b/content/smil/nsSMILTimedElement.h @@ -525,7 +525,7 @@ protected: const nsSMILInstanceTime* GetEffectiveBeginInstance() const; const nsSMILInterval* GetPreviousInterval() const; PRBool HasPlayed() const { return !mOldIntervals.IsEmpty(); } - PRBool HaveResolvedEndTimes() const; + PRBool HaveDefiniteEndTimes() const; PRBool EndHasEventConditions() const; // Reset the current interval by first passing ownership to a temporary