Bug 1474766 - Merge the three-argument form of KeyframeEffect::Constructor and ConstructKeyframeEffect; r=hiro

There doesn't appear to be any need to separate these anymore.

MozReview-Commit-ID: GHR259JJHJV
This commit is contained in:
Brian Birtles
2018-07-11 10:27:56 +09:00
parent 2378b45b2a
commit c7f0a4b352
2 changed files with 34 additions and 47 deletions

View File

@@ -679,40 +679,6 @@ KeyframeEffect::ConstructKeyframeEffect(
return effect.forget();
}
/* static */ already_AddRefed<KeyframeEffect>
KeyframeEffect::ConstructKeyframeEffect(const GlobalObject& aGlobal,
KeyframeEffect& aSource,
ErrorResult& aRv)
{
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!doc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
// Create a new KeyframeEffect object with aSource's target,
// iteration composite operation, composite operation, and spacing mode.
// The constructor creates a new AnimationEffect object by
// aSource's TimingParams.
// Note: we don't need to re-throw exceptions since the value specified on
// aSource's timing object can be assumed valid.
RefPtr<KeyframeEffect> effect =
new KeyframeEffect(doc,
aSource.mTarget,
aSource.SpecifiedTiming(),
aSource.mEffectOptions);
// Copy cumulative change hint. mCumulativeChangeHint should be the same as
// the source one because both of targets are the same.
effect->mCumulativeChangeHint = aSource.mCumulativeChangeHint;
// Copy aSource's keyframes and animation properties.
// Note: We don't call SetKeyframes directly, which might revise the
// computed offsets and rebuild the animation properties.
effect->mKeyframes = aSource.mKeyframes;
effect->mProperties = aSource.mProperties;
return effect.forget();
}
nsTArray<AnimationProperty>
KeyframeEffect::BuildProperties(const ComputedStyle* aStyle)
{
@@ -884,14 +850,6 @@ KeyframeEffect::Constructor(
return ConstructKeyframeEffect(aGlobal, aTarget, aKeyframes, aOptions, aRv);
}
/* static */ already_AddRefed<KeyframeEffect>
KeyframeEffect::Constructor(const GlobalObject& aGlobal,
KeyframeEffect& aSource,
ErrorResult& aRv)
{
return ConstructKeyframeEffect(aGlobal, aSource, aRv);
}
/* static */ already_AddRefed<KeyframeEffect>
KeyframeEffect::Constructor(
const GlobalObject& aGlobal,
@@ -903,6 +861,40 @@ KeyframeEffect::Constructor(
return ConstructKeyframeEffect(aGlobal, aTarget, aKeyframes, aOptions, aRv);
}
/* static */ already_AddRefed<KeyframeEffect>
KeyframeEffect::Constructor(const GlobalObject& aGlobal,
KeyframeEffect& aSource,
ErrorResult& aRv)
{
nsIDocument* doc = AnimationUtils::GetCurrentRealmDocument(aGlobal.Context());
if (!doc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
// Create a new KeyframeEffect object with aSource's target,
// iteration composite operation, composite operation, and spacing mode.
// The constructor creates a new AnimationEffect object by
// aSource's TimingParams.
// Note: we don't need to re-throw exceptions since the value specified on
// aSource's timing object can be assumed valid.
RefPtr<KeyframeEffect> effect =
new KeyframeEffect(doc,
aSource.mTarget,
aSource.SpecifiedTiming(),
aSource.mEffectOptions);
// Copy cumulative change hint. mCumulativeChangeHint should be the same as
// the source one because both of targets are the same.
effect->mCumulativeChangeHint = aSource.mCumulativeChangeHint;
// Copy aSource's keyframes and animation properties.
// Note: We don't call SetKeyframes directly, which might revise the
// computed offsets and rebuild the animation properties.
effect->mKeyframes = aSource.mKeyframes;
effect->mProperties = aSource.mProperties;
return effect.forget();
}
void
KeyframeEffect::GetTarget(Nullable<OwningElementOrCSSPseudoElement>& aRv) const
{

View File

@@ -313,11 +313,6 @@ protected:
const OptionsType& aOptions,
ErrorResult& aRv);
static already_AddRefed<KeyframeEffect>
ConstructKeyframeEffect(const GlobalObject& aGlobal,
KeyframeEffect& aSource,
ErrorResult& aRv);
// Build properties by recalculating from |mKeyframes| using |aComputedStyle|
// to resolve specified values. This function also applies paced spacing if
// needed.