2017-10-27 01:08:41 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2016-02-15 03:34:47 +03:00
|
|
|
/* 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"
|
2016-09-04 10:34:21 +03:00
|
|
|
#include "mozilla/dom/KeyframeEffect.h"
|
2016-03-09 08:01:45 +03:00
|
|
|
#include "mozilla/TimingParams.h"
|
2016-03-22 23:43:00 +03:00
|
|
|
#include "nsAString.h"
|
2016-02-15 03:34:47 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
AnimationEffectTiming::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
return AnimationEffectTimingBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
}
|
|
|
|
|
2016-03-11 09:40:32 +03:00
|
|
|
static inline void
|
|
|
|
PostSpecifiedTimingUpdated(KeyframeEffect* aEffect)
|
2016-03-08 04:31:10 +03:00
|
|
|
{
|
2016-03-11 09:40:32 +03:00
|
|
|
if (aEffect) {
|
|
|
|
aEffect->NotifySpecifiedTimingUpdated();
|
2016-03-08 04:31:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 23:43:00 +03:00
|
|
|
void
|
|
|
|
AnimationEffectTiming::SetDelay(double aDelay)
|
|
|
|
{
|
2016-04-02 12:25:02 +03:00
|
|
|
TimeDuration delay = TimeDuration::FromMilliseconds(aDelay);
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.Delay() == delay) {
|
2016-04-02 12:25:02 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetDelay(delay);
|
2016-04-02 12:25:02 +03:00
|
|
|
|
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-22 23:43:00 +03:00
|
|
|
}
|
|
|
|
|
2016-03-08 04:31:10 +03:00
|
|
|
void
|
|
|
|
AnimationEffectTiming::SetEndDelay(double aEndDelay)
|
|
|
|
{
|
|
|
|
TimeDuration endDelay = TimeDuration::FromMilliseconds(aEndDelay);
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.EndDelay() == endDelay) {
|
2016-03-08 04:31:10 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetEndDelay(endDelay);
|
2016-03-08 04:31:10 +03:00
|
|
|
|
2016-03-11 09:40:32 +03:00
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-08 04:31:10 +03:00
|
|
|
}
|
|
|
|
|
2016-03-22 23:43:00 +03:00
|
|
|
void
|
|
|
|
AnimationEffectTiming::SetFill(const FillMode& aFill)
|
|
|
|
{
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.Fill() == aFill) {
|
2016-04-10 05:35:52 +03:00
|
|
|
return;
|
|
|
|
}
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetFill(aFill);
|
2016-04-10 05:35:52 +03:00
|
|
|
|
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-22 23:43:00 +03:00
|
|
|
}
|
|
|
|
|
2016-03-11 11:22:32 +03:00
|
|
|
void
|
2016-03-11 12:04:39 +03:00
|
|
|
AnimationEffectTiming::SetIterationStart(double aIterationStart,
|
|
|
|
ErrorResult& aRv)
|
2016-03-11 11:22:32 +03:00
|
|
|
{
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.IterationStart() == aIterationStart) {
|
2016-03-11 11:22:32 +03:00
|
|
|
return;
|
|
|
|
}
|
2016-03-11 12:04:39 +03:00
|
|
|
|
|
|
|
TimingParams::ValidateIterationStart(aIterationStart, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return;
|
2016-03-11 11:22:32 +03:00
|
|
|
}
|
2016-03-11 12:04:39 +03:00
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetIterationStart(aIterationStart);
|
2016-03-11 12:04:39 +03:00
|
|
|
|
2016-03-11 09:40:32 +03:00
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-11 11:22:32 +03:00
|
|
|
}
|
|
|
|
|
2016-03-22 23:43:00 +03:00
|
|
|
void
|
|
|
|
AnimationEffectTiming::SetIterations(double aIterations, ErrorResult& aRv)
|
|
|
|
{
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.Iterations() == aIterations) {
|
2016-03-26 08:41:37 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimingParams::ValidateIterations(aIterations, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetIterations(aIterations);
|
2016-03-26 08:41:37 +03:00
|
|
|
|
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-22 23:43:00 +03:00
|
|
|
}
|
|
|
|
|
2016-02-27 00:39:39 +03:00
|
|
|
void
|
2016-03-09 08:01:45 +03:00
|
|
|
AnimationEffectTiming::SetDuration(const UnrestrictedDoubleOrString& aDuration,
|
|
|
|
ErrorResult& aRv)
|
2016-02-27 00:39:39 +03:00
|
|
|
{
|
2016-03-09 08:01:45 +03:00
|
|
|
Maybe<StickyTimeDuration> newDuration =
|
|
|
|
TimingParams::ParseDuration(aDuration, aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return;
|
2016-02-27 00:39:39 +03:00
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.Duration() == newDuration) {
|
2016-02-27 00:39:39 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetDuration(Move(newDuration));
|
2016-02-27 00:39:49 +03:00
|
|
|
|
2016-03-11 09:40:32 +03:00
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-02-27 00:39:39 +03:00
|
|
|
}
|
|
|
|
|
2016-03-22 23:43:00 +03:00
|
|
|
void
|
|
|
|
AnimationEffectTiming::SetDirection(const PlaybackDirection& aDirection)
|
|
|
|
{
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.Direction() == aDirection) {
|
2016-03-26 10:20:25 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetDirection(aDirection);
|
2016-03-26 10:20:25 +03:00
|
|
|
|
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-22 23:43:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-07-13 07:22:13 +03:00
|
|
|
AnimationEffectTiming::SetEasing(const nsAString& aEasing, ErrorResult& aRv)
|
2016-03-22 23:43:00 +03:00
|
|
|
{
|
2016-04-14 03:08:08 +03:00
|
|
|
Maybe<ComputedTimingFunction> newFunction =
|
2016-07-13 07:22:13 +03:00
|
|
|
TimingParams::ParseEasing(aEasing, mDocument, aRv);
|
2016-04-14 03:08:08 +03:00
|
|
|
if (aRv.Failed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
if (mTiming.TimingFunction() == newFunction) {
|
2016-04-14 03:08:08 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 06:12:43 +03:00
|
|
|
mTiming.SetTimingFunction(Move(newFunction));
|
2016-04-14 03:08:08 +03:00
|
|
|
|
|
|
|
PostSpecifiedTimingUpdated(mEffect);
|
2016-03-22 23:43:00 +03:00
|
|
|
}
|
|
|
|
|
2016-02-15 03:34:47 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|