2015-05-03 22:32:37 +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: */
|
2014-08-10 11:06:46 +04: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/. */
|
|
|
|
|
2015-04-15 02:48:21 +03:00
|
|
|
#include "mozilla/dom/KeyframeEffect.h"
|
2015-11-20 08:12:00 +03:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
#include "mozilla/ComputedStyle.h"
|
2016-09-08 23:38:53 +03:00
|
|
|
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
2016-09-04 10:34:21 +03:00
|
|
|
// For UnrestrictedDoubleOrKeyframeAnimationOptions
|
2016-09-04 10:33:38 +03:00
|
|
|
#include "mozilla/dom/AnimationEffectTiming.h"
|
2015-04-15 02:48:21 +03:00
|
|
|
#include "mozilla/dom/KeyframeEffectBinding.h"
|
2017-11-20 08:18:43 +03:00
|
|
|
#include "nsDocument.h" // For nsDocument::IsWebAnimationsEnabled
|
2016-02-27 00:39:49 +03:00
|
|
|
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
|
2014-08-10 11:06:46 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-02-15 03:34:47 +03:00
|
|
|
KeyframeEffect::KeyframeEffect(nsIDocument* aDocument,
|
2016-04-28 18:22:44 +03:00
|
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
2016-05-05 10:41:03 +03:00
|
|
|
const TimingParams& aTiming,
|
|
|
|
const KeyframeEffectParams& aOptions)
|
2016-04-28 18:22:44 +03:00
|
|
|
: KeyframeEffectReadOnly(aDocument, aTarget,
|
2016-05-05 10:41:03 +03:00
|
|
|
new AnimationEffectTiming(aDocument, aTiming, this),
|
|
|
|
aOptions)
|
2016-02-15 03:34:47 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-02-15 03:34:47 +03:00
|
|
|
JSObject*
|
|
|
|
KeyframeEffect::WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
return KeyframeEffectBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
}
|
|
|
|
|
2016-03-11 11:27:16 +03:00
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
|
|
KeyframeEffect::Constructor(
|
|
|
|
const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-03-11 11:27:16 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2016-05-13 03:40:52 +03:00
|
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aKeyframes,
|
2016-03-11 11:27:16 +03:00
|
|
|
aOptions, aRv);
|
|
|
|
}
|
|
|
|
|
2016-10-28 10:41:08 +03:00
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
|
|
KeyframeEffect::Constructor(const GlobalObject& aGlobal,
|
|
|
|
KeyframeEffectReadOnly& aSource,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2016-11-01 13:39:06 +03:00
|
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aSource, aRv);
|
2016-10-28 10:41:08 +03:00
|
|
|
}
|
|
|
|
|
2016-03-11 11:27:16 +03:00
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
|
|
KeyframeEffect::Constructor(
|
|
|
|
const GlobalObject& aGlobal,
|
|
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
2016-05-13 03:40:52 +03:00
|
|
|
JS::Handle<JSObject*> aKeyframes,
|
2016-03-12 16:14:10 +03:00
|
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
2016-03-11 11:27:16 +03:00
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2016-05-13 03:40:52 +03:00
|
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aKeyframes,
|
2016-03-12 16:14:10 +03:00
|
|
|
aOptions, aRv);
|
2016-03-11 11:27:16 +03:00
|
|
|
}
|
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
void
|
|
|
|
KeyframeEffect::NotifySpecifiedTimingUpdated()
|
2016-02-27 00:39:49 +03:00
|
|
|
{
|
2016-03-21 11:49:50 +03:00
|
|
|
// Use the same document for a pseudo element and its parent element.
|
2016-04-28 18:22:42 +03:00
|
|
|
// Use nullptr if we don't have mTarget, so disable the mutation batch.
|
2016-04-28 18:22:43 +03:00
|
|
|
nsAutoAnimationMutationBatch mb(mTarget ? mTarget->mElement->OwnerDoc()
|
|
|
|
: nullptr);
|
2016-02-27 00:39:49 +03:00
|
|
|
|
|
|
|
if (mAnimation) {
|
|
|
|
mAnimation->NotifyEffectTimingUpdated();
|
|
|
|
|
|
|
|
if (mAnimation->IsRelevant()) {
|
|
|
|
nsNodeUtils::AnimationChanged(mAnimation);
|
|
|
|
}
|
|
|
|
|
2016-04-28 18:22:43 +03:00
|
|
|
RequestRestyle(EffectCompositor::RestyleType::Layer);
|
2016-02-27 00:39:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-10 11:06:46 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|