Bug 1147766 - Part 2: Replace FixedStyleStructArray with mozilla::RangedArray. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sat, 23 May 2015 12:50:44 +1000
changeset 264919 5d5bd8ed66c93249a375605660e20ada9d38e766
parent 264918 3cb74142cd09fdb9b12d2a8bfb02be2ae0346f27
child 264920 13b7d0d6301a942e70b36f2e5f272ac3b2b5a978
push id8157
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:36:23 +0000
treeherdermozilla-aurora@d480e05bd276 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1147766
milestone41.0a1
Bug 1147766 - Part 2: Replace FixedStyleStructArray with mozilla::RangedArray. r=dbaron
layout/style/nsRuleNode.h
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -6,52 +6,35 @@
 /*
  * a node in the lexicographic tree of rules that match an element,
  * responsible for converting the rules' information into computed style
  */
 
 #ifndef nsRuleNode_h___
 #define nsRuleNode_h___
 
+#include "mozilla/RangedArray.h"
 #include "nsPresContext.h"
 #include "nsStyleStruct.h"
 
 class nsStyleContext;
 struct nsRuleData;
 class nsIStyleRule;
 struct nsCSSValueList;
 class nsCSSPropertySet;
 class nsCSSValue;
 
 class nsStyleCoord;
 struct nsCSSValuePairList;
 
-template <nsStyleStructID MinIndex, nsStyleStructID Count>
-class FixedStyleStructArray
-{
-private:
-  void* mArray[Count];
-public:
-  void*& operator[](nsStyleStructID aIndex) {
-    MOZ_ASSERT(MinIndex <= aIndex && aIndex < (MinIndex + Count),
-               "out of range");
-    return mArray[aIndex - MinIndex];
-  }
-
-  const void* operator[](nsStyleStructID aIndex) const {
-    MOZ_ASSERT(MinIndex <= aIndex && aIndex < (MinIndex + Count),
-               "out of range");
-    return mArray[aIndex - MinIndex];
-  }
-};
-
 struct nsInheritedStyleData
 {
-  FixedStyleStructArray<nsStyleStructID_Inherited_Start,
-                        nsStyleStructID_Inherited_Count> mStyleStructs;
+  mozilla::RangedArray<void*,
+                       nsStyleStructID_Inherited_Start,
+                       nsStyleStructID_Inherited_Count> mStyleStructs;
 
   void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW {
     return aContext->PresShell()->
       AllocateByObjectID(nsPresArena::nsInheritedStyleData_id, sz);
   }
 
   void DestroyStructs(uint64_t aBits, nsPresContext* aContext) {
 #define STYLE_STRUCT_INHERITED(name, checkdata_cb) \
@@ -78,18 +61,19 @@ struct nsInheritedStyleData
          i = nsStyleStructID(i + 1)) {
       mStyleStructs[i] = nullptr;
     }
   }
 };
 
 struct nsResetStyleData
 {
-  FixedStyleStructArray<nsStyleStructID_Reset_Start,
-                        nsStyleStructID_Reset_Count> mStyleStructs;
+  mozilla::RangedArray<void*,
+                       nsStyleStructID_Reset_Start,
+                       nsStyleStructID_Reset_Count> mStyleStructs;
 
   nsResetStyleData()
   {
     for (nsStyleStructID i = nsStyleStructID_Reset_Start;
          i < nsStyleStructID_Reset_Start + nsStyleStructID_Reset_Count;
          i = nsStyleStructID(i + 1)) {
       mStyleStructs[i] = nullptr;
     }