Bug 1067769 - Part 12: Use Maybe<OwningAnimationTarget> in KeyframeEffect(ReadOnly) constructors. r=birtles
MozReview-Commit-ID: Euv76D6sIFX
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -70,38 +70,34 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(KeyframeEffectReadOnly)
NS_INTERFACE_MAP_END_INHERITING(AnimationEffectReadOnly)
NS_IMPL_ADDREF_INHERITED(KeyframeEffectReadOnly, AnimationEffectReadOnly)
NS_IMPL_RELEASE_INHERITED(KeyframeEffectReadOnly, AnimationEffectReadOnly)
KeyframeEffectReadOnly::KeyframeEffectReadOnly(
nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
const TimingParams& aTiming)
- : KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType,
+ : KeyframeEffectReadOnly(aDocument, aTarget,
new AnimationEffectTimingReadOnly(aDocument,
aTiming))
{
}
KeyframeEffectReadOnly::KeyframeEffectReadOnly(
nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
AnimationEffectTimingReadOnly* aTiming)
: AnimationEffectReadOnly(aDocument)
+ , mTarget(aTarget)
, mTiming(aTiming)
, mInEffectOnLastAnimationTimingUpdate(false)
{
MOZ_ASSERT(aTiming);
- if (aTarget) {
- mTarget.emplace(aTarget, aPseudoType);
- }
}
JSObject*
KeyframeEffectReadOnly::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
return KeyframeEffectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
}
@@ -746,21 +742,17 @@ KeyframeEffectReadOnly::ConstructKeyfram
TimingParams timingParams =
TimingParams::FromOptionsUnion(aOptions, doc, aRv);
if (aRv.Failed()) {
return nullptr;
}
Maybe<OwningAnimationTarget> target = ConvertTarget(aTarget);
RefPtr<KeyframeEffectType> effect =
- new KeyframeEffectType(doc,
- target ? target->mElement.get() : nullptr,
- target ? target->mPseudoType
- : CSSPseudoElementType::NotPseudo,
- timingParams);
+ new KeyframeEffectType(doc, target, timingParams);
effect->SetFrames(aGlobal.Context(), aFrames, aRv);
if (aRv.Failed()) {
return nullptr;
}
return effect.forget();
}
@@ -1340,20 +1332,19 @@ KeyframeEffectReadOnly::SetPerformanceWa
//---------------------------------------------------------------------
//
// KeyframeEffect
//
//---------------------------------------------------------------------
KeyframeEffect::KeyframeEffect(nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
const TimingParams& aTiming)
- : KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType,
+ : KeyframeEffectReadOnly(aDocument, aTarget,
new AnimationEffectTiming(aDocument, aTiming, this))
{
}
JSObject*
KeyframeEffect::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto)
{
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -186,18 +186,17 @@ struct ElementPropertyTransition;
namespace dom {
class Animation;
class KeyframeEffectReadOnly : public AnimationEffectReadOnly
{
public:
KeyframeEffectReadOnly(nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
const TimingParams& aTiming);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadOnly,
AnimationEffectReadOnly)
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
@@ -333,18 +332,17 @@ public:
// compositor. |aParams| and |aParamsLength| are optional parameters which
// will be used to generate a localized message for devtools.
void SetPerformanceWarning(
nsCSSProperty aProperty,
const AnimationPerformanceWarning& aWarning);
protected:
KeyframeEffectReadOnly(nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
AnimationEffectTimingReadOnly* aTiming);
virtual ~KeyframeEffectReadOnly();
template<class KeyframeEffectType, class OptionsType>
static already_AddRefed<KeyframeEffectType>
ConstructKeyframeEffect(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
@@ -407,18 +405,17 @@ private:
static const TimeDuration OverflowRegionRefreshInterval();
};
class KeyframeEffect : public KeyframeEffectReadOnly
{
public:
KeyframeEffect(nsIDocument* aDocument,
- Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ const Maybe<OwningAnimationTarget>& aTarget,
const TimingParams& aTiming);
JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) override;
static already_AddRefed<KeyframeEffect>
Constructor(const GlobalObject& aGlobal,
const Nullable<ElementOrCSSPseudoElement>& aTarget,
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -632,19 +632,21 @@ CSSAnimationBuilder::Build(nsPresContext
UpdateOldAnimationPropertiesWithNew(*oldAnim,
timing,
keyframes,
isStylePaused,
mStyleContext);
return oldAnim.forget();
}
+ // mTarget is non-null here, so we emplace it directly.
+ Maybe<OwningAnimationTarget> target;
+ target.emplace(mTarget, mStyleContext->GetPseudoType());
RefPtr<KeyframeEffectReadOnly> effect =
- new KeyframeEffectReadOnly(aPresContext->Document(), mTarget,
- mStyleContext->GetPseudoType(), timing);
+ new KeyframeEffectReadOnly(aPresContext->Document(), target, timing);
effect->SetFrames(Move(keyframes), mStyleContext);
RefPtr<CSSAnimation> animation =
new CSSAnimation(aPresContext->Document()->GetScopeObject(),
aSrc.GetName());
animation->SetOwningElement(
OwningElementRef(*mTarget, mStyleContext->GetPseudoType()));
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -683,19 +683,21 @@ nsTransitionManager::ConsiderStartingTra
TimingParams timing;
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(duration));
timing.mDelay = TimeDuration::FromMilliseconds(delay);
timing.mIterations = 1.0;
timing.mDirection = dom::PlaybackDirection::Normal;
timing.mFill = dom::FillMode::Backwards;
+ // aElement is non-null here, so we emplace it directly.
+ Maybe<OwningAnimationTarget> target;
+ target.emplace(aElement, aNewStyleContext->GetPseudoType());
RefPtr<ElementPropertyTransition> pt =
- new ElementPropertyTransition(aElement->OwnerDoc(), aElement,
- aNewStyleContext->GetPseudoType(), timing,
+ new ElementPropertyTransition(aElement->OwnerDoc(), target, timing,
startForReversingTest, reversePortion);
pt->SetFrames(GetTransitionKeyframes(aNewStyleContext, aProperty,
Move(startValue), Move(endValue), tf),
aNewStyleContext);
MOZ_ASSERT(mPresContext->RestyleManager()->IsGecko(),
"ServoRestyleManager should not use nsTransitionManager "
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -31,22 +31,21 @@ struct StyleTransition;
* Per-Element data *
*****************************************************************************/
namespace mozilla {
struct ElementPropertyTransition : public dom::KeyframeEffectReadOnly
{
ElementPropertyTransition(nsIDocument* aDocument,
- dom::Element* aTarget,
- CSSPseudoElementType aPseudoType,
+ Maybe<OwningAnimationTarget>& aTarget,
const TimingParams &aTiming,
StyleAnimationValue aStartForReversingTest,
double aReversePortion)
- : dom::KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, aTiming)
+ : dom::KeyframeEffectReadOnly(aDocument, aTarget, aTiming)
, mStartForReversingTest(aStartForReversingTest)
, mReversePortion(aReversePortion)
{ }
ElementPropertyTransition* AsTransition() override { return this; }
const ElementPropertyTransition* AsTransition() const override
{
return this;