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.
continue;
nsSMILTimeValue containerTimeValue =
SMILTimeValue containerTimeValue =
container->ParentToContainerTime(sampleTime);
if (!containerTimeValue.IsDefinite()) continue;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,7 +7,7 @@
#ifndef NS_SMILINTERVAL_H_
#define NS_SMILINTERVAL_H_
#include "nsSMILInstanceTime.h"
#include "mozilla/SMILInstanceTime.h"
#include "nsTArray.h"
namespace mozilla {
@@ -19,7 +19,7 @@ namespace mozilla {
// resolved (i.e. not indefinite or unresolved).
//
// 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 {
public:
@@ -28,23 +28,23 @@ class SMILInterval {
~SMILInterval();
void Unlink(bool aFiltered = false);
const nsSMILInstanceTime* Begin() const {
const SMILInstanceTime* Begin() const {
MOZ_ASSERT(mBegin && mEnd,
"Requesting Begin() on un-initialized instance time");
return mBegin;
}
nsSMILInstanceTime* Begin();
SMILInstanceTime* Begin();
const nsSMILInstanceTime* End() const {
const SMILInstanceTime* End() const {
MOZ_ASSERT(mBegin && mEnd,
"Requesting End() on un-initialized instance time");
return mEnd;
}
nsSMILInstanceTime* End();
SMILInstanceTime* End();
void SetBegin(nsSMILInstanceTime& aBegin);
void SetEnd(nsSMILInstanceTime& aEnd);
void Set(nsSMILInstanceTime& aBegin, nsSMILInstanceTime& aEnd) {
void SetBegin(SMILInstanceTime& aBegin);
void SetEnd(SMILInstanceTime& aEnd);
void Set(SMILInstanceTime& aBegin, SMILInstanceTime& aEnd) {
SetBegin(aBegin);
SetEnd(aEnd);
}
@@ -52,30 +52,30 @@ class SMILInterval {
void FixBegin();
void FixEnd();
typedef nsTArray<RefPtr<nsSMILInstanceTime> > InstanceTimeList;
typedef nsTArray<RefPtr<SMILInstanceTime> > InstanceTimeList;
void AddDependentTime(nsSMILInstanceTime& aTime);
void RemoveDependentTime(const nsSMILInstanceTime& aTime);
void AddDependentTime(SMILInstanceTime& aTime);
void RemoveDependentTime(const SMILInstanceTime& aTime);
void GetDependentTimes(InstanceTimeList& aTimes);
// Cue for assessing if this interval can be filtered
bool IsDependencyChainLink() const;
private:
RefPtr<nsSMILInstanceTime> mBegin;
RefPtr<nsSMILInstanceTime> mEnd;
RefPtr<SMILInstanceTime> mBegin;
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;
// 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
// (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
// 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.
bool mBeginFixed;
bool mEndFixed;

View File

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

View File

@@ -11,13 +11,13 @@
#include "nsStringFwd.h"
class nsISMILAttr;
class nsSMILTimeValue;
class nsSMILValue;
class nsSMILTimeValueSpecParams;
namespace mozilla {
class SMILKeySpline;
class SMILRepeatCount;
class SMILTimeValue;
class SMILTimeValueSpecParams;
namespace dom {
class SVGAnimationElement;
} // namespace dom
@@ -60,7 +60,7 @@ class SMILParserUtils {
SMILRepeatCount& aResult);
static bool ParseTimeValueSpecParams(const nsAString& aSpec,
nsSMILTimeValueSpecParams& aResult);
SMILTimeValueSpecParams& aResult);
/*
* Parses a clock value as defined in the SMIL Animation specification.
@@ -71,7 +71,7 @@ class SMILParserUtils {
* @param aResult The parsed result. [OUT]
* @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.

View File

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

View File

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

View File

@@ -13,10 +13,10 @@
#include "nsSMILTypes.h"
#include "nsTPriorityQueue.h"
class nsSMILTimeValue;
namespace mozilla {
class SMILTimeValue;
//----------------------------------------------------------------------
// SMILTimeContainer
//
@@ -107,7 +107,7 @@ class SMILTimeContainer {
* @return The equivalent parent time or indefinite if the container is
* 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.
@@ -116,7 +116,7 @@ class SMILTimeContainer {
* @return The equivalent container time or indefinite if the container is
* 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

View File

@@ -4,19 +4,21 @@
* 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/. */
#include "nsSMILTimeValue.h"
#include "SMILTimeValue.h"
const nsSMILTime nsSMILTimeValue::kUnresolvedMillis =
namespace mozilla {
const nsSMILTime SMILTimeValue::kUnresolvedMillis =
std::numeric_limits<nsSMILTime>::max();
//----------------------------------------------------------------------
// nsSMILTimeValue methods:
// SMILTimeValue methods:
static inline int8_t Cmp(int64_t aA, int64_t aB) {
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;
if (mState == STATE_DEFINITE) {
@@ -36,3 +38,5 @@ int8_t nsSMILTimeValue::CompareTo(const nsSMILTimeValue& aOther) const {
return result;
}
} // namespace mozilla

View File

@@ -10,25 +10,27 @@
#include "nsSMILTypes.h"
#include "nsDebug.h"
namespace mozilla {
/*----------------------------------------------------------------------
* nsSMILTimeValue class
* SMILTimeValue class
*
* A tri-state time value.
*
* First a quick overview of the SMIL time data types:
*
* 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'
* nsSMILInstanceTime -- an nsSMILTimeValue used for constructing intervals. It
* SMILInstanceTime -- an SMILTimeValue used for constructing intervals. It
* contains additional fields to govern reset behavior
* 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.
* 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
* 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.
*
* Objects of this class may be in one of three states:
@@ -40,28 +42,28 @@
* In summary:
*
* State | GetMillis | IsDefinite | IsIndefinite | IsResolved
* -----------+-----------------+------------+--------------+------------
* Definite | nsSMILTimeValue | true | false | true
* -----------+-----------------+------------+--------------+------------
* -----------+---------------+------------+--------------+------------
* Definite | SMILTimeValue | true | false | true
* -----------+---------------+------------+--------------+------------
* Indefinite | -- | false | true | true
* -----------+-----------------+------------+--------------+------------
* -----------+---------------+------------+--------------+------------
* Unresolved | -- | false | false | false
*
*/
class nsSMILTimeValue {
class SMILTimeValue {
public:
// Creates an unresolved time value
nsSMILTimeValue()
SMILTimeValue()
: mMilliseconds(kUnresolvedMillis), mState(STATE_UNRESOLVED) {}
// Creates a resolved time value
explicit nsSMILTimeValue(nsSMILTime aMillis)
explicit SMILTimeValue(nsSMILTime aMillis)
: mMilliseconds(aMillis), mState(STATE_DEFINITE) {}
// Named constructor to create an indefinite time value
static nsSMILTimeValue Indefinite() {
nsSMILTimeValue value;
static SMILTimeValue Indefinite() {
SMILTimeValue value;
value.SetIndefinite();
return value;
}
@@ -91,29 +93,29 @@ class nsSMILTimeValue {
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;
}
bool operator!=(const nsSMILTimeValue& aOther) const {
bool operator!=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) != 0;
}
bool operator<(const nsSMILTimeValue& aOther) const {
bool operator<(const SMILTimeValue& aOther) const {
return CompareTo(aOther) < 0;
}
bool operator>(const nsSMILTimeValue& aOther) const {
bool operator>(const SMILTimeValue& aOther) const {
return CompareTo(aOther) > 0;
}
bool operator<=(const nsSMILTimeValue& aOther) const {
bool operator<=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) <= 0;
}
bool operator>=(const nsSMILTimeValue& aOther) const {
bool operator>=(const SMILTimeValue& aOther) const {
return CompareTo(aOther) >= 0;
}
@@ -124,4 +126,6 @@ class nsSMILTimeValue {
enum { STATE_DEFINITE, STATE_INDEFINITE, STATE_UNRESOLVED } mState;
};
} // namespace mozilla
#endif // NS_SMILTIMEVALUE_H_

View File

@@ -5,29 +5,30 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EventListenerManager.h"
#include "mozilla/SMILInstanceTime.h"
#include "mozilla/SMILInterval.h"
#include "mozilla/SMILParserUtils.h"
#include "mozilla/SMILTimeContainer.h"
#include "mozilla/SMILTimedElement.h"
#include "mozilla/SMILTimeValueSpec.h"
#include "mozilla/SMILTimeValue.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/SVGAnimationElement.h"
#include "mozilla/dom/TimeEvent.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILTimeValue.h"
#include "nsSMILInstanceTime.h"
#include "nsString.h"
#include <limits>
using namespace mozilla;
using namespace mozilla::dom;
namespace mozilla {
//----------------------------------------------------------------------
// Nested class: EventListener
NS_IMPL_ISUPPORTS(nsSMILTimeValueSpec::EventListener, nsIDOMEventListener)
NS_IMPL_ISUPPORTS(SMILTimeValueSpec::EventListener, nsIDOMEventListener)
NS_IMETHODIMP
nsSMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) {
SMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) {
if (mSpec) {
mSpec->HandleEvent(aEvent);
}
@@ -37,11 +38,10 @@ nsSMILTimeValueSpec::EventListener::HandleEvent(Event* aEvent) {
//----------------------------------------------------------------------
// Implementation
nsSMILTimeValueSpec::nsSMILTimeValueSpec(SMILTimedElement& aOwner,
bool aIsBegin)
SMILTimeValueSpec::SMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin)
: mOwner(&aOwner), mIsBegin(aIsBegin), mReferencedElement(this) {}
nsSMILTimeValueSpec::~nsSMILTimeValueSpec() {
SMILTimeValueSpec::~SMILTimeValueSpec() {
UnregisterFromReferencedElement(mReferencedElement.get());
if (mEventListener) {
mEventListener->Disconnect();
@@ -49,9 +49,9 @@ nsSMILTimeValueSpec::~nsSMILTimeValueSpec() {
}
}
nsresult nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
nsresult SMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
Element& aContextElement) {
nsSMILTimeValueSpecParams params;
SMILTimeValueSpecParams params;
if (!SMILParserUtils::ParseTimeValueSpecParams(aStringSpec, params))
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
// 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.
if (mParams.mType == nsSMILTimeValueSpecParams::OFFSET ||
(!mIsBegin && mParams.mType == nsSMILTimeValueSpecParams::INDEFINITE)) {
mOwner->AddInstanceTime(new nsSMILInstanceTime(mParams.mOffset), mIsBegin);
if (mParams.mType == SMILTimeValueSpecParams::OFFSET ||
(!mIsBegin && mParams.mType == SMILTimeValueSpecParams::INDEFINITE)) {
mOwner->AddInstanceTime(new SMILInstanceTime(mParams.mOffset), mIsBegin);
}
// Fill in the event symbol to simplify handling later
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT) {
if (mParams.mType == SMILTimeValueSpecParams::REPEAT) {
mParams.mEventSymbol = nsGkAtoms::repeatEvent;
}
@@ -77,8 +77,8 @@ nsresult nsSMILTimeValueSpec::SetSpec(const nsAString& aStringSpec,
return NS_OK;
}
void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
if (mParams.mType != nsSMILTimeValueSpecParams::SYNCBASE && !IsEventBased()) {
void SMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
if (mParams.mType != SMILTimeValueSpecParams::SYNCBASE && !IsEventBased()) {
return;
}
@@ -93,7 +93,7 @@ void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
if (mParams.mDependentElemID) {
mReferencedElement.ResetWithID(aContextElement, mParams.mDependentElemID);
} else if (mParams.mType == nsSMILTimeValueSpecParams::EVENT) {
} else if (mParams.mType == SMILTimeValueSpecParams::EVENT) {
Element* target = mOwner->GetTargetElement();
mReferencedElement.ResetWithElement(target);
} else {
@@ -102,16 +102,16 @@ void nsSMILTimeValueSpec::ResolveReferences(Element& aContextElement) {
UpdateReferencedElement(oldReferencedElement, mReferencedElement.get());
}
bool nsSMILTimeValueSpec::IsEventBased() const {
return mParams.mType == nsSMILTimeValueSpecParams::EVENT ||
mParams.mType == nsSMILTimeValueSpecParams::REPEAT;
bool SMILTimeValueSpec::IsEventBased() const {
return mParams.mType == SMILTimeValueSpecParams::EVENT ||
mParams.mType == SMILTimeValueSpecParams::REPEAT;
}
void nsSMILTimeValueSpec::HandleNewInterval(
void SMILTimeValueSpec::HandleNewInterval(
SMILInterval& aInterval, const SMILTimeContainer* aSrcContainer) {
const nsSMILInstanceTime& baseInstance =
const SMILInstanceTime& baseInstance =
mParams.mSyncBegin ? *aInterval.Begin() : *aInterval.End();
nsSMILTimeValue newTime =
SMILTimeValue newTime =
ConvertBetweenTimeContainers(baseInstance.Time(), aSrcContainer);
// Apply offset
@@ -121,25 +121,25 @@ void nsSMILTimeValueSpec::HandleNewInterval(
}
// Create the instance time and register it with the interval
RefPtr<nsSMILInstanceTime> newInstance = new nsSMILInstanceTime(
newTime, nsSMILInstanceTime::SOURCE_SYNCBASE, this, &aInterval);
RefPtr<SMILInstanceTime> newInstance = new SMILInstanceTime(
newTime, SMILInstanceTime::SOURCE_SYNCBASE, this, &aInterval);
mOwner->AddInstanceTime(newInstance, mIsBegin);
}
void nsSMILTimeValueSpec::HandleTargetElementChange(Element* aNewTarget) {
void SMILTimeValueSpec::HandleTargetElementChange(Element* aNewTarget) {
if (!IsEventBased() || mParams.mDependentElemID) return;
mReferencedElement.ResetWithElement(aNewTarget);
}
void nsSMILTimeValueSpec::HandleChangedInstanceTime(
const nsSMILInstanceTime& aBaseTime, const SMILTimeContainer* aSrcContainer,
nsSMILInstanceTime& aInstanceTimeToUpdate, bool aObjectChanged) {
void SMILTimeValueSpec::HandleChangedInstanceTime(
const SMILInstanceTime& aBaseTime, const SMILTimeContainer* aSrcContainer,
SMILInstanceTime& aInstanceTimeToUpdate, bool aObjectChanged) {
// 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.
if (aInstanceTimeToUpdate.IsFixedTime()) return;
nsSMILTimeValue updatedTime =
SMILTimeValue updatedTime =
ConvertBetweenTimeContainers(aBaseTime.Time(), aSrcContainer);
// Apply offset
@@ -155,19 +155,19 @@ void nsSMILTimeValueSpec::HandleChangedInstanceTime(
}
}
void nsSMILTimeValueSpec::HandleDeletedInstanceTime(
nsSMILInstanceTime& aInstanceTime) {
void SMILTimeValueSpec::HandleDeletedInstanceTime(
SMILInstanceTime& aInstanceTime) {
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) {
mReferencedElement.Traverse(aCallback);
}
void nsSMILTimeValueSpec::Unlink() {
void SMILTimeValueSpec::Unlink() {
UnregisterFromReferencedElement(mReferencedElement.get());
mReferencedElement.Unlink();
}
@@ -175,22 +175,21 @@ void nsSMILTimeValueSpec::Unlink() {
//----------------------------------------------------------------------
// Implementation helpers
void nsSMILTimeValueSpec::UpdateReferencedElement(Element* aFrom,
Element* aTo) {
void SMILTimeValueSpec::UpdateReferencedElement(Element* aFrom, Element* aTo) {
if (aFrom == aTo) return;
UnregisterFromReferencedElement(aFrom);
switch (mParams.mType) {
case nsSMILTimeValueSpecParams::SYNCBASE: {
case SMILTimeValueSpecParams::SYNCBASE: {
SMILTimedElement* to = GetTimedElement(aTo);
if (to) {
to->AddDependent(*this);
}
} break;
case nsSMILTimeValueSpecParams::EVENT:
case nsSMILTimeValueSpecParams::REPEAT:
case SMILTimeValueSpecParams::EVENT:
case SMILTimeValueSpecParams::REPEAT:
RegisterEventListener(aTo);
break;
@@ -200,10 +199,10 @@ void nsSMILTimeValueSpec::UpdateReferencedElement(Element* aFrom,
}
}
void nsSMILTimeValueSpec::UnregisterFromReferencedElement(Element* aElement) {
void SMILTimeValueSpec::UnregisterFromReferencedElement(Element* aElement) {
if (!aElement) return;
if (mParams.mType == nsSMILTimeValueSpecParams::SYNCBASE) {
if (mParams.mType == SMILTimeValueSpecParams::SYNCBASE) {
SMILTimedElement* timedElement = GetTimedElement(aElement);
if (timedElement) {
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)
? &static_cast<SVGAnimationElement*>(aElement)->TimedElement()
: nullptr;
@@ -222,14 +221,14 @@ SMILTimedElement* nsSMILTimeValueSpec::GetTimedElement(Element* aElement) {
// Indicates whether we're allowed to register an event-listener
// when scripting is disabled.
bool nsSMILTimeValueSpec::IsWhitelistedEvent() {
bool SMILTimeValueSpec::IsWhitelistedEvent() {
// The category of (SMIL-specific) "repeat(n)" events are allowed.
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT) {
if (mParams.mType == SMILTimeValueSpecParams::REPEAT) {
return true;
}
// 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::repeatEvent ||
mParams.mEventSymbol == nsGkAtoms::beginEvent ||
@@ -240,10 +239,10 @@ bool nsSMILTimeValueSpec::IsWhitelistedEvent() {
return false;
}
void nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget) {
void SMILTimeValueSpec::RegisterEventListener(Element* aTarget) {
MOZ_ASSERT(IsEventBased(),
"Attempting to register event-listener for unexpected "
"nsSMILTimeValueSpec type");
"SMILTimeValueSpec type");
MOZ_ASSERT(mParams.mEventSymbol,
"Attempting to register event-listener but there is no event "
"name");
@@ -270,7 +269,7 @@ void nsSMILTimeValueSpec::RegisterEventListener(Element* aTarget) {
AllEventsAtSystemGroupBubble());
}
void nsSMILTimeValueSpec::UnregisterEventListener(Element* aTarget) {
void SMILTimeValueSpec::UnregisterEventListener(Element* aTarget) {
if (!aTarget || !mEventListener) {
return;
}
@@ -285,9 +284,9 @@ void nsSMILTimeValueSpec::UnregisterEventListener(Element* aTarget) {
AllEventsAtSystemGroupBubble());
}
void nsSMILTimeValueSpec::HandleEvent(Event* aEvent) {
void SMILTimeValueSpec::HandleEvent(Event* aEvent) {
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");
// 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();
if (!container) return;
if (mParams.mType == nsSMILTimeValueSpecParams::REPEAT &&
if (mParams.mType == SMILTimeValueSpecParams::REPEAT &&
!CheckRepeatEventDetail(aEvent)) {
return;
}
nsSMILTime currentTime = container->GetCurrentTimeAsSMILTime();
nsSMILTimeValue newTime(currentTime);
SMILTimeValue newTime(currentTime);
if (!ApplyOffset(newTime)) {
NS_WARNING("New time generated from event overflows nsSMILTime, ignoring");
return;
}
RefPtr<nsSMILInstanceTime> newInstance =
new nsSMILInstanceTime(newTime, nsSMILInstanceTime::SOURCE_EVENT);
RefPtr<SMILInstanceTime> newInstance =
new SMILInstanceTime(newTime, SMILInstanceTime::SOURCE_EVENT);
mOwner->AddInstanceTime(newInstance, mIsBegin);
}
bool nsSMILTimeValueSpec::CheckRepeatEventDetail(Event* aEvent) {
bool SMILTimeValueSpec::CheckRepeatEventDetail(Event* aEvent) {
TimeEvent* timeEvent = aEvent->AsTimeEvent();
if (!timeEvent) {
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;
}
nsSMILTimeValue nsSMILTimeValueSpec::ConvertBetweenTimeContainers(
const nsSMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer) {
SMILTimeValue SMILTimeValueSpec::ConvertBetweenTimeContainers(
const SMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer) {
// If the source time is either indefinite or unresolved the result is going
// to be the same
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
// any meaningful conversion
if (!aSrcContainer || !dstContainer) return nsSMILTimeValue(); // unresolved
if (!aSrcContainer || !dstContainer) return SMILTimeValue(); // unresolved
nsSMILTimeValue docTime =
SMILTimeValue docTime =
aSrcContainer->ContainerToParentTime(aSrcTime.GetMillis());
if (docTime.IsIndefinite())
@@ -352,7 +351,7 @@ nsSMILTimeValue nsSMILTimeValueSpec::ConvertBetweenTimeContainers(
return dstContainer->ParentToContainerTime(docTime.GetMillis());
}
bool nsSMILTimeValueSpec::ApplyOffset(nsSMILTimeValue& aTime) const {
bool SMILTimeValueSpec::ApplyOffset(SMILTimeValue& aTime) const {
// indefinite + offset = indefinite. Likewise for unresolved times.
if (!aTime.IsDefinite()) {
return true;
@@ -367,3 +366,5 @@ bool nsSMILTimeValueSpec::ApplyOffset(nsSMILTimeValue& aTime) const {
aTime.SetMillis(aTime.GetMillis() + mParams.mOffset.GetMillis());
return true;
}
} // namespace mozilla

View File

@@ -8,27 +8,26 @@
#define NS_SMILTIMEVALUESPEC_H_
#include "mozilla/Attributes.h"
#include "mozilla/SMILTimeValueSpecParams.h"
#include "mozilla/dom/IDTracker.h"
#include "nsSMILTimeValueSpecParams.h"
#include "nsStringFwd.h"
#include "nsIDOMEventListener.h"
class nsSMILTimeValue;
class nsSMILInstanceTime;
namespace mozilla {
class EventListenerManager;
class SMILInstanceTime;
class SMILInterval;
class SMILTimeContainer;
class SMILTimedElement;
class SMILTimeValue;
namespace dom {
class Event;
} // namespace dom
class EventListenerManager;
} // namespace mozilla
//----------------------------------------------------------------------
// nsSMILTimeValueSpec class
// SMILTimeValueSpec class
//
// 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
@@ -36,19 +35,16 @@ class EventListenerManager;
// and synchronisation (for syncbase specifications).
//
// 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:
typedef mozilla::SMILInterval SMILInterval;
typedef mozilla::SMILTimeContainer SMILTimeContainer;
typedef mozilla::SMILTimedElement SMILTimedElement;
typedef mozilla::dom::Element Element;
typedef mozilla::dom::Event Event;
typedef mozilla::dom::IDTracker IDTracker;
nsSMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin);
~nsSMILTimeValueSpec();
SMILTimeValueSpec(SMILTimedElement& aOwner, bool aIsBegin);
~SMILTimeValueSpec();
nsresult SetSpec(const nsAString& aStringSpec, Element& aContextElement);
void ResolveReferences(Element& aContextElement);
@@ -58,13 +54,13 @@ class nsSMILTimeValueSpec {
const SMILTimeContainer* aSrcContainer);
void HandleTargetElementChange(Element* aNewTarget);
// For created nsSMILInstanceTime objects
// For created SMILInstanceTime objects
bool DependsOnBegin() const;
void HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime,
void HandleChangedInstanceTime(const SMILInstanceTime& aBaseTime,
const SMILTimeContainer* aSrcContainer,
nsSMILInstanceTime& aInstanceTimeToUpdate,
SMILInstanceTime& aInstanceTimeToUpdate,
bool aObjectChanged);
void HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime);
void HandleDeletedInstanceTime(SMILInstanceTime& aInstanceTime);
// Cycle-collection support
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
@@ -79,9 +75,9 @@ class nsSMILTimeValueSpec {
void UnregisterEventListener(Element* aElement);
void HandleEvent(Event* aEvent);
bool CheckRepeatEventDetail(Event* aEvent);
nsSMILTimeValue ConvertBetweenTimeContainers(
const nsSMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer);
bool ApplyOffset(nsSMILTimeValue& aTime) const;
SMILTimeValue ConvertBetweenTimeContainers(
const SMILTimeValue& aSrcTime, const SMILTimeContainer* aSrcContainer);
bool ApplyOffset(SMILTimeValue& aTime) const;
SMILTimedElement* mOwner;
bool mIsBegin; // Indicates if *we* are a begin spec,
@@ -89,22 +85,21 @@ class nsSMILTimeValueSpec {
// mParams.mSyncBegin which indicates
// if we're synced with the begin of
// 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
* 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
* 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).
*/
class TimeReferenceTracker final : public IDTracker {
public:
explicit TimeReferenceTracker(nsSMILTimeValueSpec* aOwner)
: mSpec(aOwner) {}
explicit TimeReferenceTracker(SMILTimeValueSpec* aOwner) : mSpec(aOwner) {}
void ResetWithElement(Element* aTo) {
RefPtr<Element> from = get();
Unlink();
@@ -119,7 +114,7 @@ class nsSMILTimeValueSpec {
virtual bool IsPersistent() override { return true; }
private:
nsSMILTimeValueSpec* mSpec;
SMILTimeValueSpec* mSpec;
};
TimeReferenceTracker mReferencedElement;
@@ -128,16 +123,18 @@ class nsSMILTimeValueSpec {
~EventListener() {}
public:
explicit EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) {}
explicit EventListener(SMILTimeValueSpec* aOwner) : mSpec(aOwner) {}
void Disconnect() { mSpec = nullptr; }
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMEVENTLISTENER
private:
nsSMILTimeValueSpec* mSpec;
SMILTimeValueSpec* mSpec;
};
RefPtr<EventListener> mEventListener;
};
} // namespace mozilla
#endif // NS_SMILTIMEVALUESPEC_H_

View File

@@ -7,18 +7,20 @@
#ifndef NS_SMILTIMEVALUESPECPARAMS_H_
#define NS_SMILTIMEVALUESPECPARAMS_H_
#include "nsSMILTimeValue.h"
#include "mozilla/SMILTimeValue.h"
#include "nsAtom.h"
namespace mozilla {
//----------------------------------------------------------------------
// nsSMILTimeValueSpecParams
// SMILTimeValueSpecParams
//
// 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").
class nsSMILTimeValueSpecParams {
class SMILTimeValueSpecParams {
public:
nsSMILTimeValueSpecParams()
SMILTimeValueSpecParams()
: mType(INDEFINITE), mSyncBegin(false), mRepeatIteration(0) {}
// The type of value this specification describes
@@ -30,7 +32,7 @@ class nsSMILTimeValueSpecParams {
// - type EVENT: the event time
// - type REPEAT: the repeat time
// It is not used for WALLCLOCK or INDEFINITE times
nsSMILTimeValue mOffset;
SMILTimeValue mOffset;
// The base element that this specification refers to.
// For SYNCBASE types, this is the timebase
@@ -51,4 +53,6 @@ class nsSMILTimeValueSpecParams {
uint32_t mRepeatIteration;
};
} // namespace mozilla
#endif // NS_SMILTIMEVALUESPECPARAMS_H_

View File

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

View File

@@ -10,11 +10,11 @@
#include "mozilla/EventForwards.h"
#include "mozilla/Move.h"
#include "mozilla/SMILMilestone.h"
#include "mozilla/SMILInstanceTime.h"
#include "mozilla/SMILInterval.h"
#include "mozilla/SMILRepeatCount.h"
#include "mozilla/SMILTimeValueSpec.h"
#include "mozilla/UniquePtr.h"
#include "nsSMILInstanceTime.h"
#include "nsSMILTimeValueSpec.h"
#include "nsSMILTypes.h"
#include "nsTArray.h"
#include "nsTHashtable.h"
@@ -22,12 +22,14 @@
#include "nsAutoPtr.h"
#include "nsAttrValue.h"
class nsSMILTimeValue;
class nsAtom;
namespace mozilla {
class SMILAnimationFunction;
class SMILTimeContainer;
class SMILTimeValue;
namespace dom {
class SVGAnimationElement;
} // namespace dom
@@ -97,14 +99,14 @@ class SMILTimedElement {
* @return the start time as defined above in milliseconds or an unresolved
* time if there is no current interval.
*/
nsSMILTimeValue GetStartTime() const;
SMILTimeValue GetStartTime() const;
/**
* Returns the simple duration of this element.
*
* @return the simple duration in milliseconds or INDEFINITE.
*/
nsSMILTimeValue GetSimpleDuration() const { return mSimpleDur; }
SMILTimeValue GetSimpleDuration() const { return mSimpleDur; }
/**
* Methods for supporting hyperlinking
@@ -127,24 +129,24 @@ class SMILTimedElement {
* @return the time to seek the documen to in milliseconds or an unresolved
* 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.
* 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 aIsBegin true if the time to be added represents a begin
* 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.
*
* 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 aUpdatedTime The time to update aInstanceTime with.
@@ -154,31 +156,31 @@ class SMILTimedElement {
* instance time or false if it represents an end
* instance time.
*/
void UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime,
nsSMILTimeValue& aUpdatedTime, bool aIsBegin);
void UpdateInstanceTime(SMILInstanceTime* aInstanceTime,
SMILTimeValue& aUpdatedTime, bool aIsBegin);
/**
* 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 aIsBegin true if the time to be removed represents a begin
* 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
* 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.
*
* @param aSpec The nsSMILTimeValueSpec object whose created
* nsSMILInstanceTime's should be removed.
* @param aSpec The SMILTimeValueSpec object whose created
* SMILInstanceTime's should be removed.
* @param aIsBegin true if the times to be removed represent begin
* times or false if they are end times.
*/
void RemoveInstanceTimesForCreator(const nsSMILTimeValueSpec* aSpec,
void RemoveInstanceTimesForCreator(const SMILTimeValueSpec* aSpec,
bool aIsBegin);
/**
@@ -287,20 +289,20 @@ class SMILTimedElement {
* Adds a syncbase dependency to the list of dependents that will be notified
* 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
* for the object to be explicitly unregistered (with
* 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
* 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
@@ -342,23 +344,23 @@ class SMILTimedElement {
void Traverse(nsCycleCollectionTraversalCallback* aCallback);
void Unlink();
typedef bool (*RemovalTestFunction)(nsSMILInstanceTime* aInstance);
typedef bool (*RemovalTestFunction)(SMILInstanceTime* aInstance);
protected:
// Typedefs
typedef nsTArray<UniquePtr<nsSMILTimeValueSpec>> TimeValueSpecList;
typedef nsTArray<RefPtr<nsSMILInstanceTime>> InstanceTimeList;
typedef nsTArray<UniquePtr<SMILTimeValueSpec>> TimeValueSpecList;
typedef nsTArray<RefPtr<SMILInstanceTime>> InstanceTimeList;
typedef nsTArray<UniquePtr<SMILInterval>> IntervalList;
typedef nsPtrHashKey<nsSMILTimeValueSpec> TimeValueSpecPtrKey;
typedef nsPtrHashKey<SMILTimeValueSpec> TimeValueSpecPtrKey;
typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
// Helper classes
class InstanceTimeComparator {
public:
bool Equals(const nsSMILInstanceTime* aElem1,
const nsSMILInstanceTime* aElem2) const;
bool LessThan(const nsSMILInstanceTime* aElem1,
const nsSMILInstanceTime* aElem2) const;
bool Equals(const SMILInstanceTime* aElem1,
const SMILInstanceTime* aElem2) const;
bool LessThan(const SMILInstanceTime* aElem1,
const SMILInstanceTime* aElem2) const;
};
// Templated helper functions
@@ -412,7 +414,7 @@ class SMILTimedElement {
* @return true if the end time of the current interval was updated,
* false otherwise.
*/
bool ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime);
bool ApplyEarlyEnd(const SMILTimeValue& aSampleTime);
/**
* Clears certain state in response to the element restarting.
@@ -466,7 +468,7 @@ class SMILTimedElement {
void FilterHistory();
// Helper functions for FilterHistory to clear old SMILIntervals and
// nsSMILInstanceTimes respectively.
// SMILInstanceTimes respectively.
void FilterIntervals();
void FilterInstanceTimes(InstanceTimeList& aList);
@@ -494,22 +496,21 @@ class SMILTimedElement {
*/
bool GetNextInterval(const SMILInterval* aPrevInterval,
const SMILInterval* aReplacedInterval,
const nsSMILInstanceTime* aFixedBeginTime,
const SMILInstanceTime* aFixedBeginTime,
SMILInterval& aResult) const;
nsSMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
const nsSMILTimeValue& aBase,
SMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
const SMILTimeValue& aBase,
int32_t& aPosition) const;
nsSMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
const nsSMILTimeValue& aBase,
SMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
const SMILTimeValue& aBase,
int32_t& aPosition) const;
nsSMILTimeValue CalcActiveEnd(const nsSMILTimeValue& aBegin,
const nsSMILTimeValue& aEnd) const;
nsSMILTimeValue GetRepeatDuration() const;
nsSMILTimeValue ApplyMinAndMax(const nsSMILTimeValue& aDuration) const;
SMILTimeValue CalcActiveEnd(const SMILTimeValue& aBegin,
const SMILTimeValue& aEnd) const;
SMILTimeValue GetRepeatDuration() const;
SMILTimeValue ApplyMinAndMax(const SMILTimeValue& aDuration) const;
nsSMILTime ActiveTimeToSimpleTime(nsSMILTime aActiveTime,
uint32_t& aRepeatIteration);
nsSMILInstanceTime* CheckForEarlyEnd(
const nsSMILTimeValue& aContainerTime) const;
SMILInstanceTime* CheckForEarlyEnd(const SMILTimeValue& aContainerTime) const;
void UpdateCurrentInterval(bool aForceChangeNotice = false);
void SampleSimpleTime(nsSMILTime aActiveTime);
void SampleFillValue();
@@ -529,12 +530,12 @@ class SMILTimedElement {
bool aEndObjectChanged);
void FireTimeEventAsync(EventMessage aMsg, int32_t aDetail);
const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
const SMILInstanceTime* GetEffectiveBeginInstance() const;
const SMILInterval* GetPreviousInterval() const;
bool HasPlayed() const { return !mOldIntervals.IsEmpty(); }
bool HasClientInFillRange() 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
// variable so that if Unlink() results in us receiving a callback,
@@ -555,13 +556,13 @@ class SMILTimedElement {
TimeValueSpecList mBeginSpecs; // [strong]
TimeValueSpecList mEndSpecs; // [strong]
nsSMILTimeValue mSimpleDur;
SMILTimeValue mSimpleDur;
SMILRepeatCount mRepeatCount;
nsSMILTimeValue mRepeatDur;
SMILTimeValue mRepeatDur;
nsSMILTimeValue mMin;
nsSMILTimeValue mMax;
SMILTimeValue mMin;
SMILTimeValue mMax;
enum nsSMILFillMode : uint8_t { FILL_REMOVE, FILL_FREEZE };
nsSMILFillMode mFillMode;
@@ -592,7 +593,7 @@ class SMILTimedElement {
// current interval. Change notifications and delete notifications are handled
// 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.
TimeValueSpecHashSet mTimeDependents;

View File

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

View File

@@ -19,7 +19,7 @@
// wallclock time -- "real" time -- offset since the epoch
//
// 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;

View File

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