Bug 1147766 - Part 2: Replace FixedStyleStructArray with mozilla::RangedArray. r=dbaron

This commit is contained in:
Cameron McCormack 2015-05-23 12:50:44 +10:00
parent 35b469559c
commit 58e208a670

View File

@ -11,6 +11,7 @@
#ifndef nsRuleNode_h___
#define nsRuleNode_h___
#include "mozilla/RangedArray.h"
#include "nsPresContext.h"
#include "nsStyleStruct.h"
@ -24,29 +25,11 @@ 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()->
@ -83,8 +66,9 @@ struct nsInheritedStyleData
struct nsResetStyleData
{
FixedStyleStructArray<nsStyleStructID_Reset_Start,
nsStyleStructID_Reset_Count> mStyleStructs;
mozilla::RangedArray<void*,
nsStyleStructID_Reset_Start,
nsStyleStructID_Reset_Count> mStyleStructs;
nsResetStyleData()
{