It might seem a bit odd to move the setters to the read-only class that we are
ultimately planning to drop but the reason for doing this is that
KeyframeEffectReadOnly.cpp has a *lot* more code than KeyframeEffect.cpp.
In order to simplify code archaeology we take the following approach:
1. Move code from KeyframeEffect.{h,cpp} to KeyframeEffectReadOnly.{h,cpp}.
2. Delete KeyframeEffect.{h,cpp}.
3. Rename KeyframeEffectReadOnly.{h,cpp} to KeyframeEffect.{h,cpp}.
Note that at least steps 2 and 3 must be performed in separate patches as
mercurial does not successfully track renames when the target name already
exists.
MozReview-Commit-ID: LwJoxGJitKR
90 lines
3.1 KiB
C++
90 lines
3.1 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/KeyframeEffect.h"
|
|
|
|
#include "mozilla/ComputedStyle.h"
|
|
#include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
|
|
// For UnrestrictedDoubleOrKeyframeAnimationOptions
|
|
#include "mozilla/dom/AnimationEffectTiming.h"
|
|
#include "mozilla/dom/KeyframeEffectBinding.h"
|
|
#include "nsDocument.h" // For nsDocument::IsWebAnimationsEnabled
|
|
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
KeyframeEffect::KeyframeEffect(nsIDocument* aDocument,
|
|
const Maybe<OwningAnimationTarget>& aTarget,
|
|
const TimingParams& aTiming,
|
|
const KeyframeEffectParams& aOptions)
|
|
: KeyframeEffectReadOnly(aDocument, aTarget,
|
|
new AnimationEffectTiming(aDocument, aTiming, this),
|
|
aOptions)
|
|
{
|
|
}
|
|
|
|
JSObject*
|
|
KeyframeEffect::WrapObject(JSContext* aCx,
|
|
JS::Handle<JSObject*> aGivenProto)
|
|
{
|
|
return KeyframeEffectBinding::Wrap(aCx, this, aGivenProto);
|
|
}
|
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
KeyframeEffect::Constructor(
|
|
const GlobalObject& aGlobal,
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
JS::Handle<JSObject*> aKeyframes,
|
|
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
|
ErrorResult& aRv)
|
|
{
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aKeyframes,
|
|
aOptions, aRv);
|
|
}
|
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
KeyframeEffect::Constructor(const GlobalObject& aGlobal,
|
|
KeyframeEffectReadOnly& aSource,
|
|
ErrorResult& aRv)
|
|
{
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aSource, aRv);
|
|
}
|
|
|
|
/* static */ already_AddRefed<KeyframeEffect>
|
|
KeyframeEffect::Constructor(
|
|
const GlobalObject& aGlobal,
|
|
const Nullable<ElementOrCSSPseudoElement>& aTarget,
|
|
JS::Handle<JSObject*> aKeyframes,
|
|
const UnrestrictedDoubleOrKeyframeAnimationOptions& aOptions,
|
|
ErrorResult& aRv)
|
|
{
|
|
return ConstructKeyframeEffect<KeyframeEffect>(aGlobal, aTarget, aKeyframes,
|
|
aOptions, aRv);
|
|
}
|
|
|
|
void
|
|
KeyframeEffect::NotifySpecifiedTimingUpdated()
|
|
{
|
|
// Use the same document for a pseudo element and its parent element.
|
|
// Use nullptr if we don't have mTarget, so disable the mutation batch.
|
|
nsAutoAnimationMutationBatch mb(mTarget ? mTarget->mElement->OwnerDoc()
|
|
: nullptr);
|
|
|
|
if (mAnimation) {
|
|
mAnimation->NotifyEffectTimingUpdated();
|
|
|
|
if (mAnimation->IsRelevant()) {
|
|
nsNodeUtils::AnimationChanged(mAnimation);
|
|
}
|
|
|
|
RequestRestyle(EffectCompositor::RestyleType::Layer);
|
|
}
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|