2016-01-13 20:37:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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 "mozilla/dom/AnimationEffectTimingReadOnly.h"
|
2016-01-29 04:37:52 +03:00
|
|
|
|
2016-01-13 20:37:00 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectTimingReadOnlyBinding.h"
|
2016-01-29 04:37:52 +03:00
|
|
|
#include "mozilla/dom/KeyframeEffectBinding.h"
|
2016-01-13 20:37:00 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-01-29 04:37:52 +03:00
|
|
|
TimingParams::TimingParams(const dom::AnimationEffectTimingProperties& aRhs)
|
|
|
|
: mDuration(aRhs.mDuration)
|
|
|
|
, mDelay(TimeDuration::FromMilliseconds(aRhs.mDelay))
|
|
|
|
, mIterations(aRhs.mIterations)
|
|
|
|
, mDirection(aRhs.mDirection)
|
|
|
|
, mFill(aRhs.mFill)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TimingParams::TimingParams(double aDuration)
|
2016-01-13 20:42:00 +03:00
|
|
|
{
|
2016-01-29 04:37:52 +03:00
|
|
|
mDuration.SetAsUnrestrictedDouble() = aDuration;
|
|
|
|
}
|
2016-01-13 20:42:00 +03:00
|
|
|
|
2016-01-29 04:37:52 +03:00
|
|
|
/* static */ TimingParams
|
|
|
|
TimingParams::FromOptionsUnion(
|
|
|
|
const dom::UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
|
|
|
|
{
|
|
|
|
if (aOptions.IsUnrestrictedDouble()) {
|
|
|
|
return TimingParams(aOptions.GetAsUnrestrictedDouble());
|
|
|
|
} else {
|
|
|
|
MOZ_ASSERT(aOptions.IsKeyframeEffectOptions());
|
|
|
|
return TimingParams(aOptions.GetAsKeyframeEffectOptions());
|
|
|
|
}
|
2016-01-13 20:42:00 +03:00
|
|
|
}
|
|
|
|
|
2016-01-13 20:37:00 +03:00
|
|
|
bool
|
2016-01-13 20:41:00 +03:00
|
|
|
TimingParams::operator==(const TimingParams& aOther) const
|
2016-01-13 20:37:00 +03:00
|
|
|
{
|
|
|
|
bool durationEqual;
|
|
|
|
if (mDuration.IsUnrestrictedDouble()) {
|
|
|
|
durationEqual = aOther.mDuration.IsUnrestrictedDouble() &&
|
|
|
|
(mDuration.GetAsUnrestrictedDouble() ==
|
|
|
|
aOther.mDuration.GetAsUnrestrictedDouble());
|
|
|
|
} else {
|
2016-01-13 20:38:00 +03:00
|
|
|
// We consider all string values and uninitialized values as meaning "auto".
|
|
|
|
// Since mDuration is either a string or uninitialized, we consider it equal
|
|
|
|
// if aOther.mDuration is also either a string or uninitialized.
|
|
|
|
durationEqual = !aOther.mDuration.IsUnrestrictedDouble();
|
2016-01-13 20:37:00 +03:00
|
|
|
}
|
|
|
|
return durationEqual &&
|
|
|
|
mDelay == aOther.mDelay &&
|
|
|
|
mIterations == aOther.mIterations &&
|
|
|
|
mDirection == aOther.mDirection &&
|
|
|
|
mFill == aOther.mFill;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationEffectTimingReadOnly, mParent)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationEffectTimingReadOnly, AddRef)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationEffectTimingReadOnly, Release)
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
AnimationEffectTimingReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
return AnimationEffectTimingReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|