Bug 1338927 - Part 5: Templatize UpdateProperties(). r=birtles

We had to implement UpdateProperties(nsStyleContext*) explicitly
since there are some calls of UpdateProperties() with RefPtr<nsStyleContext>.
Without this compiler tries to use template function instead.

MozReview-Commit-ID: 72NgwmJ4kcx

--HG--
extra : rebase_source : 30ac40c8ebc6d5e6bdf4326e6436daa95645ffc7
This commit is contained in:
Hiroyuki Ikezoe 2017-02-23 09:52:44 +09:00
parent c7df70030a
commit deb07d6f55
2 changed files with 37 additions and 7 deletions

View File

@ -273,7 +273,21 @@ SpecifiedKeyframeArraysAreEqual(const nsTArray<Keyframe>& aA,
void
KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
{
MOZ_ASSERT(aStyleContext);
DoUpdateProperties(Move(aStyleContext));
}
void
KeyframeEffectReadOnly::UpdateProperties(
const ServoComputedStyleValues& aServoValues)
{
DoUpdateProperties(aServoValues);
}
template<typename StyleType>
void
KeyframeEffectReadOnly::DoUpdateProperties(StyleType&& aStyle)
{
MOZ_ASSERT_IF(IsPointer<StyleType>::value, aStyle);
// Skip updating properties when we are composing style.
// FIXME: Bug 1324966. Drop this check once we have a function to get
@ -284,11 +298,12 @@ KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
return;
}
nsTArray<AnimationProperty> properties = BuildProperties(Move(aStyleContext));
nsTArray<AnimationProperty> properties =
BuildProperties(Forward<StyleType>(aStyle));
// 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.
EnsureBaseStyles(aStyleContext, properties);
EnsureBaseStyles(aStyle, properties);
if (mProperties == properties) {
return;
@ -310,10 +325,7 @@ KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
runningOnCompositorProperties.HasProperty(property.mProperty);
}
// FIXME (bug 1303235): Do this for Servo too
if (aStyleContext->PresContext()->StyleSet()->IsGecko()) {
CalculateCumulativeChangeHint(aStyleContext);
}
CalculateCumulativeChangeHint(aStyle);
MarkCascadeNeedsUpdate();
@ -1574,6 +1586,10 @@ void
KeyframeEffectReadOnly::CalculateCumulativeChangeHint(
nsStyleContext *aStyleContext)
{
if (aStyleContext->PresContext()->StyleSet()->IsServo()) {
// FIXME (bug 1303235): Do this for Servo too
return;
}
mCumulativeChangeHint = nsChangeHint(0);
for (const AnimationProperty& property : mProperties) {

View File

@ -230,6 +230,8 @@ public:
// Update |mProperties| by recalculating from |mKeyframes| using
// |aStyleContext| to resolve specified values.
void UpdateProperties(nsStyleContext* aStyleContext);
// Servo version of the above function.
void UpdateProperties(const ServoComputedStyleValues& aServoValues);
// Updates |aStyleRule| with the animation values produced by this
// AnimationEffect for the current time except any properties contained
@ -284,6 +286,10 @@ public:
// Cumulative change hint on each segment for each property.
// This is used for deciding the animation is paint-only.
void CalculateCumulativeChangeHint(nsStyleContext* aStyleContext);
void CalculateCumulativeChangeHint(
const ServoComputedStyleValues& aServoValues)
{
}
// Returns true if all of animation properties' change hints
// can ignore painting if the animation is not visible.
@ -385,6 +391,11 @@ protected:
// Ensure the base styles is available for any properties in |aProperties|.
void EnsureBaseStyles(nsStyleContext* aStyleContext,
const nsTArray<AnimationProperty>& aProperties);
void EnsureBaseStyles(const ServoComputedStyleValues& aServoValues,
const nsTArray<AnimationProperty>& aProperties)
{
// FIXME: Bug 1311257: Support missing keyframes.
}
// Returns the base style resolved by |aStyleContext| for |aProperty|.
StyleAnimationValue ResolveBaseStyle(nsCSSPropertyID aProperty,
@ -422,6 +433,9 @@ protected:
private:
nsChangeHint mCumulativeChangeHint;
template<typename StyleType>
void DoUpdateProperties(StyleType&& aStyle);
nsIFrame* GetAnimationFrame() const;
bool CanThrottle() const;