Bug 1340958 - Templatize ComposeStyle. r=birtles

Later in this patch series we will replace ServoAnimationRule with a hashmap.
At that point, we would like to pass the hashmap to ComposeStyle. In order
to achieve that, this patch templatizes the 'animation rule' parameter of
ComposeStyle in both Animation and KeyframeEffectReadOnly so that it can
represent a hashmap instead.

MozReview-Commit-ID: H5bMxjN3W8n

--HG--
extra : rebase_source : 58cd9ee1cda51970d35c52b39d2cdab12055e24a
This commit is contained in:
Hiroyuki Ikezoe 2017-03-17 13:22:13 +09:00
Родитель 2d5908cdb1
Коммит 2511ac5d4e
5 изменённых файлов: 45 добавлений и 24 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/AsyncEventDispatcher.h" // For AsyncEventDispatcher
#include "mozilla/Maybe.h" // For Maybe
#include "mozilla/AnimationRule.h" // For AnimationRule
#include "mozilla/TypeTraits.h" // For Forward<>
#include "nsAnimationManager.h" // For CSSAnimation
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIDocument.h" // For nsIDocument
@ -942,8 +943,9 @@ Animation::WillComposeStyle()
}
}
template<typename ComposeAnimationResult>
void
Animation::ComposeStyle(AnimationRule& aStyleRule,
Animation::ComposeStyle(ComposeAnimationResult&& aComposeResult,
const nsCSSPropertyIDSet& aPropertiesToSkip)
{
if (!mEffect) {
@ -1005,7 +1007,8 @@ Animation::ComposeStyle(AnimationRule& aStyleRule,
KeyframeEffectReadOnly* keyframeEffect = mEffect->AsKeyframeEffect();
if (keyframeEffect) {
keyframeEffect->ComposeStyle(aStyleRule, aPropertiesToSkip);
keyframeEffect->ComposeStyle(Forward<ComposeAnimationResult>(aComposeResult),
aPropertiesToSkip);
}
}
@ -1506,5 +1509,17 @@ Animation::IsRunningOnCompositor() const
mEffect->AsKeyframeEffect()->IsRunningOnCompositor();
}
template
void
Animation::ComposeStyle<RefPtr<AnimValuesStyleRule>&>(
RefPtr<AnimValuesStyleRule>& aAnimationRule,
const nsCSSPropertyIDSet& aPropertiesToSkip);
template
void
Animation::ComposeStyle<RefPtr<ServoAnimationRule>&>(
RefPtr<ServoAnimationRule>& aAnimationRule,
const nsCSSPropertyIDSet& aPropertiesToSkip);
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -321,12 +321,13 @@ public:
void WillComposeStyle();
/**
* Updates |aStyleRule| with the animation values of this animation's effect,
* if any.
* Updates |aComposeResult| with the animation values of this animation's
* effect, if any.
* Any properties contained in |aPropertiesToSkip| will not be added or
* updated in |aStyleRule|.
* updated in |aComposeResult|.
*/
void ComposeStyle(AnimationRule& aStyleRule,
template<typename ComposeAnimationResult>
void ComposeStyle(ComposeAnimationResult&& aComposeResult,
const nsCSSPropertyIDSet& aPropertiesToSkip);
void NotifyEffectTimingUpdated();

Просмотреть файл

@ -508,7 +508,7 @@ EffectCompositor::GetServoAnimationRule(const dom::Element* aElement,
? effectSet->PropertiesForAnimationsLevel().Inverse()
: effectSet->PropertiesForAnimationsLevel();
for (KeyframeEffectReadOnly* effect : sortedEffectList) {
effect->GetAnimation()->ComposeStyle(animRule, propertiesToSkip);
effect->GetAnimation()->ComposeStyle(animRule.mServo, propertiesToSkip);
}
MOZ_ASSERT(effectSet == EffectSet::GetEffectSet(aElement, aPseudoType),
@ -783,7 +783,7 @@ EffectCompositor::ComposeAnimationRule(dom::Element* aElement,
: effects->PropertiesForAnimationsLevel();
for (KeyframeEffectReadOnly* effect : sortedEffectList) {
effect->GetAnimation()->WillComposeStyle();
effect->GetAnimation()->ComposeStyle(animRule, propertiesToSkip);
effect->GetAnimation()->ComposeStyle(animRule.mGecko, propertiesToSkip);
}
MOZ_ASSERT(effects == EffectSet::GetEffectSet(aElement, aPseudoType),

Просмотреть файл

@ -649,9 +649,10 @@ KeyframeEffectReadOnly::ComposeStyleRule(
}
}
template<typename ComposeAnimationResult>
void
KeyframeEffectReadOnly::ComposeStyle(
AnimationRule& aStyleRule,
ComposeAnimationResult&& aComposeResult,
const nsCSSPropertyIDSet& aPropertiesToSkip)
{
MOZ_DIAGNOSTIC_ASSERT(!mIsComposingStyle,
@ -671,8 +672,6 @@ KeyframeEffectReadOnly::ComposeStyle(
return;
}
bool isServoBackend = mDocument->IsStyledByServo();
for (size_t propIdx = 0, propEnd = mProperties.Length();
propIdx != propEnd; ++propIdx)
{
@ -706,17 +705,10 @@ KeyframeEffectReadOnly::ComposeStyle(
prop.mSegments.Length(),
"out of array bounds");
if (isServoBackend) {
ComposeStyleRule(aStyleRule.mServo,
prop,
*segment,
computedTiming);
} else {
ComposeStyleRule(aStyleRule.mGecko,
prop,
*segment,
computedTiming);
}
ComposeStyleRule(Forward<ComposeAnimationResult>(aComposeResult),
prop,
*segment,
computedTiming);
}
}
@ -1821,5 +1813,17 @@ KeyframeEffectReadOnly::ContainsAnimatedScale(const nsIFrame* aFrame) const
return false;
}
template
void
KeyframeEffectReadOnly::ComposeStyle<RefPtr<AnimValuesStyleRule>&>(
RefPtr<AnimValuesStyleRule>& aAnimationRule,
const nsCSSPropertyIDSet& aPropertiesToSkip);
template
void
KeyframeEffectReadOnly::ComposeStyle<RefPtr<ServoAnimationRule>&>(
RefPtr<ServoAnimationRule>& aAnimationRule,
const nsCSSPropertyIDSet& aPropertiesToSkip);
} // namespace dom
} // namespace mozilla

Просмотреть файл

@ -255,10 +255,11 @@ public:
// parallel traversal.
void WillComposeStyle();
// Updates |aStyleRule| with the animation values produced by this
// Updates |aComposeResult| with the animation values produced by this
// AnimationEffect for the current time except any properties contained
// in |aPropertiesToSkip|.
void ComposeStyle(AnimationRule& aStyleRule,
template<typename ComposeAnimationResult>
void ComposeStyle(ComposeAnimationResult&& aRestultContainer,
const nsCSSPropertyIDSet& aPropertiesToSkip);
// Composite |aValueToComposite| on |aUnderlyingValue| with