Bug 1305325 - Part 2: Add AnimValuesStyleRule::GetValue and HasValue to get the last composed style. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sun, 04 Dec 2016 08:07:39 +0900
changeset 447337 84fd425b9c4440a5c15dde73c2a83f0fd6889903
parent 447336 247695dc2ec50f18487ac1198bb4164d8429d515
child 447338 cf93726d1c8b12db6b8bd384213db13d3c4df1b3
push id38039
push userhiikezoe@mozilla-japan.org
push dateSat, 03 Dec 2016 23:26:35 +0000
reviewersbirtles
bugs1305325
milestone53.0a1
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
dom/animation/AnimValuesStyleRule.cpp
dom/animation/AnimValuesStyleRule.h
--- 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;
 };