Bug 1299741 part 7 - Make unit of StyleAnimationValue and nsCSSValue uint16_t and add an extra data field. r?dbaron draft
authorXidorn Quan <xidorn+moz@upsuper.org>
Thu, 01 Sep 2016 11:49:34 +1000
changeset 408660 9885f90d3ec07eda1ba3197b13d32a448d023cf5
parent 408659 f2ff862ed716ff6b275ae7a2378fcb9e2934a875
child 408661 e26e5fcc5c3b7e93836d1432f8fe7d9f5d5f78b7
push id28267
push userxquan@mozilla.com
push dateThu, 01 Sep 2016 14:00:40 +0000
reviewersdbaron
bugs1299741
milestone51.0a1
Bug 1299741 part 7 - Make unit of StyleAnimationValue and nsCSSValue uint16_t and add an extra data field. r?dbaron So that we can make use of the padding space in StyleAnimationValue and nsCSSValue to store extra data up to 16 bits. This would be useful to avoid additional allocation for storing StyleComplexColor introduced in some later patch. MozReview-Commit-ID: 7OL9Fwuq2
layout/style/StyleAnimationValue.h
layout/style/nsCSSValue.h
--- a/layout/style/StyleAnimationValue.h
+++ b/layout/style/StyleAnimationValue.h
@@ -264,17 +264,17 @@ public:
 
   static already_AddRefed<nsCSSValue::Array>
     AppendTransformFunction(nsCSSKeyword aTransformFunction,
                             nsCSSValueList**& aListTail);
 
   /**
    * The types and values for the values that we extract and animate.
    */
-  enum Unit {
+  enum Unit : uint16_t {
     eUnit_Null, // not initialized
     eUnit_Normal,
     eUnit_Auto,
     eUnit_None,
     eUnit_Enumerated,
     eUnit_Visibility, // special case for transitions (which converts
                       // Enumerated to Visibility as needed)
     eUnit_Integer,
@@ -299,16 +299,17 @@ public:
     eUnit_Transform, // nsCSSValueList* (never null)
     eUnit_BackgroundPositionCoord, // nsCSSValueList* (never null)
     eUnit_CSSValuePairList, // nsCSSValuePairList* (never null)
     eUnit_UnparsedString // nsStringBuffer* (never null)
   };
 
 private:
   Unit mUnit;
+  uint16_t mExtra;
   union {
     int32_t mInt;
     nscoord mCoord;
     float mFloat;
     nscolor mColor;
     nsCSSValue* mCSSValue;
     nsCSSValuePair* mCSSValuePair;
     nsCSSValueTriplet* mCSSValueTriplet;
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -292,17 +292,17 @@ private:
     ~FontFamilyListRefCnt() {
         MOZ_COUNT_DTOR(FontFamilyListRefCnt);
     }
 };
 
 } // namespace css
 } // namespace mozilla
 
-enum nsCSSUnit {
+enum nsCSSUnit : uint16_t {
   eCSSUnit_Null         = 0,      // (n/a) null unit, value is not specified
   eCSSUnit_Auto         = 1,      // (n/a) value is algorithmic
   eCSSUnit_Inherit      = 2,      // (n/a) value is inherited
   eCSSUnit_Initial      = 3,      // (n/a) value is default UA value
   eCSSUnit_Unset        = 4,      // (n/a) value equivalent to 'initial' if on a reset property, 'inherit' otherwise
   eCSSUnit_None         = 5,      // (n/a) value is none
   eCSSUnit_Normal       = 6,      // (n/a) value is normal (algorithmic, different than auto)
   eCSSUnit_System_Font  = 7,      // (n/a) value is -moz-use-system-font
@@ -833,16 +833,17 @@ private:
            Serialization aValueSerialization) const;
   void AppendBasicShapePositionToString(
            nsAString& aResult,
            Serialization aValueSerialization) const;
   void AppendInsetToString(nsCSSPropertyID aProperty, nsAString& aResult,
                            Serialization aValueSerialization) const;
 protected:
   nsCSSUnit mUnit;
+  uint16_t mExtra;
   union {
     int32_t    mInt;
     float      mFloat;
     // Note: the capacity of the buffer may exceed the length of the string.
     // If we're of a string type, mString is not null.
     nsStringBuffer* MOZ_OWNING_REF mString;
     nscolor    mColor;
     Array* MOZ_OWNING_REF mArray;