Bug 1338927 - Part 3: Introduce ServoComputedStyleValues. r?birtles
The operator bool() will be used in the case where we call
MOZ_ASSERT() for const ref of this struct.
MozReview-Commit-ID: tCtpXmPJvV
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -125,16 +125,23 @@ struct AnimationProperty
mSegments == aOther.mSegments;
}
bool operator!=(const AnimationProperty& aOther) const
{
return !(*this == aOther);
}
};
+struct ServoComputedStyleValues
+{
+ const ServoComputedValues* mCurrentStyle;
+ const ServoComputedValues* mParentStyle;
+ explicit operator bool() const { return true; }
+};
+
struct ElementPropertyTransition;
namespace dom {
class Animation;
class KeyframeEffectReadOnly : public AnimationEffectReadOnly
{
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -590,33 +590,32 @@ KeyframeUtils::ApplyDistributeSpacing(ns
ApplySpacing(aKeyframes, SpacingMode::distribute, eCSSProperty_UNKNOWN,
emptyArray, nullptr);
}
/* static */ nsTArray<ComputedKeyframeValues>
KeyframeUtils::GetComputedKeyframeValues(
const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
- const ServoComputedValues* aCurrentStyle,
- const ServoComputedValues* aParentStyle)
+ const ServoComputedStyleValues& aServoValues)
{
MOZ_ASSERT(aElement);
MOZ_ASSERT(aElement->OwnerDoc()->IsStyledByServo());
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
MOZ_ASSERT(presContext);
nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
// Construct each nsTArray<PropertyStyleAnimationValuePair> here.
result.AppendElements(aKeyframes.Length());
Servo_GetComputedKeyframeValues(&aKeyframes,
- aCurrentStyle,
- aParentStyle,
+ aServoValues.mCurrentStyle,
+ aServoValues.mParentStyle,
presContext,
&result);
return result;
}
/* static */ nsTArray<ComputedKeyframeValues>
KeyframeUtils::GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
--- a/dom/animation/KeyframeUtils.h
+++ b/dom/animation/KeyframeUtils.h
@@ -18,16 +18,17 @@ class nsStyleContext;
struct ServoComputedValues;
namespace mozilla {
struct AnimationProperty;
enum class CSSPseudoElementType : uint8_t;
class ErrorResult;
struct Keyframe;
struct PropertyStyleAnimationValuePair;
+struct ServoComputedStyleValues;
namespace dom {
class Element;
} // namespace dom
} // namespace mozilla
namespace mozilla {
@@ -82,18 +83,17 @@ public:
static nsTArray<ComputedKeyframeValues>
GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
nsStyleContext* aStyleContext);
static nsTArray<ComputedKeyframeValues>
GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
dom::Element* aElement,
- const ServoComputedValues* aCurrentStyle,
- const ServoComputedValues* aParentStyle);
+ const ServoComputedStyleValues& aServoValues);
/**
* Fills in the mComputedOffset member of each keyframe in the given array
* using the specified spacing mode.
*
* https://w3c.github.io/web-animations/#spacing-keyframes
*
* @param aKeyframes The set of keyframes to adjust.