Bug 1311257 - Store base styles for stylo. r?birtles
MozReview-Commit-ID: DcEx4aTDOY0
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -507,16 +507,77 @@ KeyframeEffectReadOnly::EnsureBaseStyle(
MOZ_ASSERT(success, "Should be able to extract computed animation value");
MOZ_ASSERT(!result.IsNull(), "Should have a valid StyleAnimationValue");
mBaseStyleValues.Put(aProperty, result);
}
void
+KeyframeEffectReadOnly::EnsureBaseStyles(
+ const ServoComputedValuesWithParent& aServoValues,
+ const nsTArray<AnimationProperty>& aProperties)
+{
+ if (!mTarget) {
+ return;
+ }
+
+ mBaseStyleValuesForServo.Clear();
+
+ nsPresContext* presContext =
+ nsContentUtils::GetContextForContent(mTarget->mElement);
+ MOZ_ASSERT(presContext,
+ "nsPresContext should not be nullptr since this EnsureBaseStyles "
+ "supposed to be called right after getting computed values with "
+ "a valid nsPresContext");
+
+ RefPtr<ServoComputedValues> baseComputedValues;
+ nsIAtom* pseudoAtom = mTarget->mPseudoType < CSSPseudoElementType::Count
+ ? nsCSSPseudoElements::GetPseudoAtom(mTarget->mPseudoType)
+ : nullptr;
+ for (const AnimationProperty& property : aProperties) {
+ EnsureBaseStyle(property,
+ pseudoAtom,
+ presContext,
+ baseComputedValues);
+ }
+}
+
+void
+KeyframeEffectReadOnly::EnsureBaseStyle(
+ const AnimationProperty& aProperty,
+ nsIAtom* aPseudoAtom,
+ nsPresContext* aPresContext,
+ RefPtr<ServoComputedValues>& aBaseComputedValues)
+{
+ bool hasAdditiveValues = false;
+
+ for (const AnimationPropertySegment& segment : aProperty.mSegments) {
+ if (!segment.HasReplaceableValues()) {
+ hasAdditiveValues = true;
+ break;
+ }
+ }
+
+ if (!hasAdditiveValues) {
+ return;
+ }
+
+ if (!aBaseComputedValues) {
+ aBaseComputedValues =
+ aPresContext->StyleSet()->AsServo()->
+ GetBaseComputedValuesForElement(mTarget->mElement, aPseudoAtom);
+ }
+ RefPtr<RawServoAnimationValue> baseValue =
+ Servo_ComputedValues_ExtractAnimationValue(aBaseComputedValues,
+ aProperty.mProperty).Consume();
+ mBaseStyleValuesForServo.Put(aProperty.mProperty, baseValue);
+}
+
+void
KeyframeEffectReadOnly::WillComposeStyle()
{
ComputedTiming computedTiming = GetComputedTiming();
mProgressOnLastCompose = computedTiming.mProgress;
mCurrentIterationOnLastCompose = computedTiming.mCurrentIteration;
}
void
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -7,16 +7,17 @@
#ifndef mozilla_dom_KeyframeEffectReadOnly_h
#define mozilla_dom_KeyframeEffectReadOnly_h
#include "nsChangeHint.h"
#include "nsCSSPropertyID.h"
#include "nsCSSPropertyIDSet.h"
#include "nsCSSValue.h"
#include "nsCycleCollectionParticipant.h"
+#include "nsRefPtrHashtable.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
#include "mozilla/AnimationPerformanceWarning.h"
#include "mozilla/AnimationTarget.h"
#include "mozilla/Attributes.h"
#include "mozilla/ComputedTimingFunction.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/Keyframe.h"
@@ -407,29 +408,32 @@ protected:
StyleAnimationValue GetUnderlyingStyle(
nsCSSPropertyID aProperty,
const RefPtr<AnimValuesStyleRule>& aAnimationRule);
// Ensure the base styles is available for any properties in |aProperties|.
void EnsureBaseStyles(nsStyleContext* aStyleContext,
const nsTArray<AnimationProperty>& aProperties);
void EnsureBaseStyles(const ServoComputedValuesWithParent& aServoValues,
- const nsTArray<AnimationProperty>& aProperties)
- {
- // FIXME: Bug 1311257: Support missing keyframes.
- }
+ const nsTArray<AnimationProperty>& aProperties);
// If no base style is already stored for |aProperty|, resolves the base style
// for |aProperty| using |aStyleContext| and stores it in mBaseStyleValues.
// If |aCachedBaseStyleContext| is non-null, it will be used, otherwise the
// base style context will be resolved and stored in
// |aCachedBaseStyleContext|.
void EnsureBaseStyle(nsCSSPropertyID aProperty,
nsStyleContext* aStyleContext,
RefPtr<nsStyleContext>& aCachedBaseStyleContext);
+ // Stylo version of the above function that also first checks for an additive
+ // value in |aProperty|'s list of segments.
+ void EnsureBaseStyle(const AnimationProperty& aProperty,
+ nsIAtom* aPseudoAtom,
+ nsPresContext* aPresContext,
+ RefPtr<ServoComputedValues>& aBaseComputedValues);
Maybe<OwningAnimationTarget> mTarget;
KeyframeEffectParams mEffectOptions;
// The specified keyframes.
nsTArray<Keyframe> mKeyframes;
@@ -449,16 +453,18 @@ protected:
// We need to track when we go to or from being "in effect" since
// we need to re-evaluate the cascade of animations when that changes.
bool mInEffectOnLastAnimationTimingUpdate;
// The non-animated values for properties in this effect that contain at
// least one animation value that is composited with the underlying value
// (i.e. it uses the additive or accumulate composite mode).
nsDataHashtable<nsUint32HashKey, StyleAnimationValue> mBaseStyleValues;
+ nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>
+ mBaseStyleValuesForServo;
// 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;