зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1338927 - Part 4: Templatize BuildProperties(). r=birtles
We'd like to use template to manage functions that have almost the same functionality both on stylo and gecko instead of branching in each functions because it will be easier to maintain stylo and gecko for a while. MozReview-Commit-ID: 25ukMpOeqLj --HG-- extra : rebase_source : 145b66695f9772f5cb527bbcf15b5a3fc2e34510
This commit is contained in:
Родитель
b5a2377fb5
Коммит
c7df70030a
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
|
||||
#include "mozilla/KeyframeUtils.h"
|
||||
#include "mozilla/ServoBindings.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "Layers.h" // For Layer
|
||||
#include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetStyleContextForElement
|
||||
#include "nsContentUtils.h" // nsContentUtils::ReportToConsole
|
||||
|
@ -283,7 +284,7 @@ KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
|
|||
return;
|
||||
}
|
||||
|
||||
nsTArray<AnimationProperty> properties = BuildProperties(aStyleContext);
|
||||
nsTArray<AnimationProperty> properties = BuildProperties(Move(aStyleContext));
|
||||
|
||||
// We need to update base styles even if any properties are not changed at all
|
||||
// since base styles might have been changed due to parent style changes, etc.
|
||||
|
@ -853,10 +854,16 @@ KeyframeEffectReadOnly::ConstructKeyframeEffect(const GlobalObject& aGlobal,
|
|||
return effect.forget();
|
||||
}
|
||||
|
||||
template<typename StyleType>
|
||||
nsTArray<AnimationProperty>
|
||||
KeyframeEffectReadOnly::BuildProperties(nsStyleContext* aStyleContext)
|
||||
KeyframeEffectReadOnly::BuildProperties(StyleType&& aStyle)
|
||||
{
|
||||
MOZ_ASSERT(aStyleContext);
|
||||
static_assert(IsSame<StyleType, nsStyleContext*>::value ||
|
||||
IsSame<StyleType, const ServoComputedStyleValues&>::value,
|
||||
"StyleType should be nsStyleContext* or "
|
||||
"const ServoComputedStyleValues&");
|
||||
|
||||
MOZ_ASSERT(aStyle);
|
||||
|
||||
nsTArray<AnimationProperty> result;
|
||||
// If mTarget is null, return an empty property array.
|
||||
|
@ -875,15 +882,15 @@ KeyframeEffectReadOnly::BuildProperties(nsStyleContext* aStyleContext)
|
|||
nsTArray<ComputedKeyframeValues> computedValues =
|
||||
KeyframeUtils::GetComputedKeyframeValues(keyframesCopy,
|
||||
mTarget->mElement,
|
||||
aStyleContext);
|
||||
aStyle);
|
||||
|
||||
// FIXME: Bug 1332633: we have to implement ComputeDistance for
|
||||
// RawServoAnimationValue.
|
||||
if (mEffectOptions.mSpacingMode == SpacingMode::paced &&
|
||||
aStyleContext->PresContext()->StyleSet()->IsGecko()) {
|
||||
!mDocument->IsStyledByServo()) {
|
||||
KeyframeUtils::ApplySpacing(keyframesCopy, SpacingMode::paced,
|
||||
mEffectOptions.mPacedProperty,
|
||||
computedValues, aStyleContext);
|
||||
computedValues, aStyle);
|
||||
}
|
||||
|
||||
result =
|
||||
|
|
|
@ -331,7 +331,8 @@ protected:
|
|||
// Build properties by recalculating from |mKeyframes| using |aStyleContext|
|
||||
// to resolve specified values. This function also applies paced spacing if
|
||||
// needed.
|
||||
nsTArray<AnimationProperty> BuildProperties(nsStyleContext* aStyleContext);
|
||||
template<typename StyleType>
|
||||
nsTArray<AnimationProperty> BuildProperties(StyleType&& aStyle);
|
||||
|
||||
// This effect is registered with its target element so long as:
|
||||
//
|
||||
|
|
|
@ -113,6 +113,14 @@ public:
|
|||
nsCSSPropertyID aProperty,
|
||||
nsTArray<ComputedKeyframeValues>& aComputedValues,
|
||||
nsStyleContext* aStyleContext);
|
||||
static void ApplySpacing(nsTArray<Keyframe>& aKeyframes,
|
||||
SpacingMode aSpacingMode,
|
||||
nsCSSPropertyID aProperty,
|
||||
nsTArray<ComputedKeyframeValues>& aComputedValues,
|
||||
const ServoComputedStyleValues& aServoValues)
|
||||
{
|
||||
NS_WARNING("stylo: ApplySpacing not implemented yet");
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for ApplySpacing to simplify using distribute spacing.
|
||||
|
|
Загрузка…
Ссылка в новой задаче