Bug 1349004 part 3 - Remove unnecessary UpdateProperties. r?hiro
MozReview-Commit-ID: 9WhgoBF9m7L
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -1170,18 +1170,18 @@ size_t
EffectCompositor::AnimationStyleRuleProcessor::SizeOfIncludingThis(
MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}
template
void
-EffectCompositor::UpdateEffectProperties<RefPtr<nsStyleContext>&>(
- RefPtr<nsStyleContext>& aStyleContext,
+EffectCompositor::UpdateEffectProperties<nsStyleContext*&>(
+ nsStyleContext*& aStyleContext,
Element* aElement,
CSSPseudoElementType aPseudoType);
template
void
EffectCompositor::UpdateEffectProperties<const ServoComputedValuesWithParent&>(
const ServoComputedValuesWithParent& aServoValues,
Element* aElement,
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -244,16 +244,17 @@ KeyframeEffect::UpdatePropertiesFromCurr
GetCurrentServoComputedValues(presContext);
RefPtr<ServoComputedValues> parentValue =
GetParentServoComputedValues(presContext);
const ServoComputedValuesWithParent value = { currentValue, parentValue };
UpdateProperties(value);
} else {
RefPtr<nsStyleContext> styleContext = GetTargetStyleContext();
+ nsStyleContext* rawStyleContext = styleContext.get();
if (styleContext) {
- UpdateProperties(styleContext);
+ UpdateProperties(rawStyleContext);
}
}
}
} // namespace dom
} // namespace mozilla
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -216,17 +216,17 @@ KeyframeEffectReadOnly::SetKeyframes(JSC
template<typename StyleType>
void
KeyframeEffectReadOnly::SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
StyleType&& aStyle)
{
static_assert(IsSame<StyleType, nsStyleContext*&>::value ||
IsSame<StyleType, const ServoComputedValuesWithParent&>::value,
- "StyleType should be nsStyleContext* or "
+ "StyleType should be nsStyleContext*& or "
"const ServoComputedValuesWithParent&");
if (KeyframesEqualIgnoringComputedOffsets(aKeyframes, mKeyframes)) {
return;
}
mKeyframes = Move(aKeyframes);
// Apply distribute spacing irrespective of the spacing mode. We will apply
@@ -236,17 +236,17 @@ KeyframeEffectReadOnly::SetKeyframes(nsT
KeyframeUtils::ApplyDistributeSpacing(mKeyframes);
if (mAnimation && mAnimation->IsRelevant()) {
nsNodeUtils::AnimationChanged(mAnimation);
}
// We need to call UpdateProperties() if the StyleType is not nullptr.
if (aStyle) {
- UpdateProperties(aStyle);
+ UpdateProperties(Forward<StyleType>(aStyle));
MaybeUpdateFrameForCompositor();
}
}
const AnimationProperty*
KeyframeEffectReadOnly::GetEffectiveAnimationOfProperty(
nsCSSPropertyID aProperty) const
{
@@ -300,36 +300,34 @@ SpecifiedKeyframeArraysAreEqual(const ns
return false;
}
}
return true;
}
#endif
+template
void
-KeyframeEffectReadOnly::UpdateProperties(nsStyleContext* aStyleContext)
-{
- MOZ_ASSERT(aStyleContext);
- MOZ_ASSERT(mDocument->IsStyledByServo());
+KeyframeEffectReadOnly::UpdateProperties(nsStyleContext*& aStyleContext);
- DoUpdateProperties(Move(aStyleContext));
-}
-
+template
void
KeyframeEffectReadOnly::UpdateProperties(
- const ServoComputedValuesWithParent& aServoValues)
-{
- DoUpdateProperties(aServoValues);
-}
+ const ServoComputedValuesWithParent& aServoValues);
template<typename StyleType>
void
-KeyframeEffectReadOnly::DoUpdateProperties(StyleType&& aStyle)
+KeyframeEffectReadOnly::UpdateProperties(StyleType&& aStyle)
{
+ static_assert(IsSame<StyleType, nsStyleContext*&>::value ||
+ IsSame<StyleType, const ServoComputedValuesWithParent&>::value,
+ "StyleType should be nsStyleContext*& or "
+ "const ServoComputedValuesWithParent&");
+
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
// nsStyleContext without resolving animating style.
MOZ_DIAGNOSTIC_ASSERT(!mIsComposingStyle,
"Should not be called while processing ComposeStyle()");
if (mIsComposingStyle) {
@@ -933,19 +931,19 @@ KeyframeEffectReadOnly::ConstructKeyfram
effect->mProperties = aSource.mProperties;
return effect.forget();
}
template<typename StyleType>
nsTArray<AnimationProperty>
KeyframeEffectReadOnly::BuildProperties(StyleType&& aStyle)
{
- static_assert(IsSame<StyleType, nsStyleContext*>::value ||
+ static_assert(IsSame<StyleType, nsStyleContext*&>::value ||
IsSame<StyleType, const ServoComputedValuesWithParent&>::value,
- "StyleType should be nsStyleContext* or "
+ "StyleType should be nsStyleContext*& or "
"const ServoComputedValuesWithParent&");
MOZ_ASSERT(aStyle);
nsTArray<AnimationProperty> result;
// If mTarget is null, return an empty property array.
if (!mTarget) {
return result;
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -189,20 +189,19 @@ public:
nsCSSPropertyID aProperty) const;
const InfallibleTArray<AnimationProperty>& Properties() const
{
return mProperties;
}
// 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 ServoComputedValuesWithParent& aServoValues);
+ // |aStyle| to resolve specified values.
+ template<typename StyleType>
+ void UpdateProperties(StyleType&& aStyle);
// Update various bits of state related to running ComposeStyle().
// We need to update this outside ComposeStyle() because we should avoid
// mutating any state in ComposeStyle() since it might be called during
// parallel traversal.
void WillComposeStyle();
// Updates |aComposeResult| with the animation values produced by this
@@ -418,19 +417,16 @@ protected:
// We only want to record telemetry data for "ContentTooLarge" warnings once
// per effect:target pair so we use this member to record if we have already
// reported a "ContentTooLarge" warning for the current target.
bool mRecordedContentTooLarge = false;
private:
nsChangeHint mCumulativeChangeHint;
- template<typename StyleType>
- void DoUpdateProperties(StyleType&& aStyle);
-
void ComposeStyleRule(RefPtr<AnimValuesStyleRule>& aStyleRule,
const AnimationProperty& aProperty,
const AnimationPropertySegment& aSegment,
const ComputedTiming& aComputedTiming);
void ComposeStyleRule(RawServoAnimationValueMap& aAnimationValues,
const AnimationProperty& aProperty,
const AnimationPropertySegment& aSegment,
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -964,18 +964,19 @@ nsStyleSet::GetContext(nsStyleContext* a
// Ignore animations for print or print preview, and for elements
// that are not attached to the document tree.
if (PresContext()->IsDynamic() &&
aElementForAnimation->IsInComposedDoc()) {
// Update CSS animations in case the animation-name has just changed.
PresContext()->AnimationManager()->UpdateAnimations(result,
aElementForAnimation);
+ nsStyleContext* rawStyleContext = result.get();
PresContext()->EffectCompositor()->UpdateEffectProperties(
- result, aElementForAnimation, result->GetPseudoType());
+ rawStyleContext, aElementForAnimation, result->GetPseudoType());
animRule = PresContext()->EffectCompositor()->
GetAnimationRule(aElementForAnimation,
result->GetPseudoType(),
EffectCompositor::CascadeLevel::Animations,
result);
}