Bug 1305325 - Part 2: Add AnimValuesStyleRule::GetValue and HasValue to get the last composed style. r?birtles
HasValue() will be used to check that we have already composed style
for a given property or not.
MozReview-Commit-ID: L8lezGyON5o
--- a/dom/animation/AnimValuesStyleRule.cpp
+++ b/dom/animation/AnimValuesStyleRule.cpp
@@ -78,16 +78,23 @@ AnimValuesStyleRule::AddValue(nsCSSPrope
{
MOZ_ASSERT(aProperty != eCSSProperty_UNKNOWN,
"Unexpected css property");
mAnimationValues.Put(aProperty, Move(aValue));
mStyleBits |=
nsCachedStyleData::GetBitForSID(nsCSSProps::kSIDTable[aProperty]);
}
+bool
+AnimValuesStyleRule::GetValue(nsCSSPropertyID aProperty,
+ StyleAnimationValue& aValue) const
+{
+ return mAnimationValues.Get(aProperty, &aValue);
+}
+
#ifdef DEBUG
void
AnimValuesStyleRule::List(FILE* out, int32_t aIndent) const
{
nsAutoCString str;
for (int32_t index = aIndent; --index >= 0; ) {
str.AppendLiteral(" ");
}
--- a/dom/animation/AnimValuesStyleRule.h
+++ b/dom/animation/AnimValuesStyleRule.h
@@ -40,16 +40,21 @@ public:
void List(FILE* out = stdout, int32_t aIndent = 0) const override;
#endif
// For the following functions, it there is already a value for |aProperty| it
// will be replaced with |aValue|.
void AddValue(nsCSSPropertyID aProperty, const StyleAnimationValue &aValue);
void AddValue(nsCSSPropertyID aProperty, StyleAnimationValue&& aValue);
+ bool HasValue(nsCSSPropertyID aProperty) const {
+ return mAnimationValues.Contains(aProperty);
+ }
+ bool GetValue(nsCSSPropertyID aProperty, StyleAnimationValue& aValue) const;
+
private:
~AnimValuesStyleRule() {}
nsDataHashtable<nsUint32HashKey, StyleAnimationValue> mAnimationValues;
uint32_t mStyleBits;
};