gecko-dev/dom/animation/AnimationEffectTiming.cpp
Daisuke Akatsuka b4e46e7179 Bug 1244638 - Part 2: Throw TypeError if iterationStart is NaN, negative value or Infinity. r=birtles, r=smaug
MozReview-Commit-ID: A8zSm6TgwOP

--HG--
extra : rebase_source : 50e88537430cf6cfc5552350a818128f0ff7756f
2016-03-11 18:04:39 +09:00

81 lines
1.9 KiB
C++

/* -*- 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/AnimationEffectTiming.h"
#include "mozilla/dom/AnimatableBinding.h"
#include "mozilla/dom/AnimationEffectTimingBinding.h"
#include "mozilla/TimingParams.h"
namespace mozilla {
namespace dom {
JSObject*
AnimationEffectTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{
return AnimationEffectTimingBinding::Wrap(aCx, this, aGivenProto);
}
static inline void
PostSpecifiedTimingUpdated(KeyframeEffect* aEffect)
{
if (aEffect) {
aEffect->NotifySpecifiedTimingUpdated();
}
}
void
AnimationEffectTiming::SetEndDelay(double aEndDelay)
{
TimeDuration endDelay = TimeDuration::FromMilliseconds(aEndDelay);
if (mTiming.mEndDelay == endDelay) {
return;
}
mTiming.mEndDelay = endDelay;
PostSpecifiedTimingUpdated(mEffect);
}
void
AnimationEffectTiming::SetIterationStart(double aIterationStart,
ErrorResult& aRv)
{
if (mTiming.mIterationStart == aIterationStart) {
return;
}
TimingParams::ValidateIterationStart(aIterationStart, aRv);
if (aRv.Failed()) {
return;
}
mTiming.mIterationStart = aIterationStart;
PostSpecifiedTimingUpdated(mEffect);
}
void
AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration,
ErrorResult& aRv)
{
Maybe<StickyTimeDuration> newDuration =
TimingParams::ParseDuration(aDuration, aRv);
if (aRv.Failed()) {
return;
}
if (mTiming.mDuration == newDuration) {
return;
}
mTiming.mDuration = newDuration;
PostSpecifiedTimingUpdated(mEffect);
}
} // namespace dom
} // namespace mozilla