From dd8ce60c6dc359dfb028afb873945dba53a50af2 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Thu, 12 Dec 2013 13:09:40 +1100 Subject: [PATCH] Bug 773296 - Part 3: Allow more than 27 style structs. r=dbaron This bumps up nsStyleContext::mBits to a uint64_t so that it can fit another style struct. If we're going to need to keep at least 27 style structs, it might be better to split mBits up into two uint32_ts: one for the flags and one for the style struct bits. --- layout/style/nsRuleNode.h | 8 ++++---- layout/style/nsStyleContext.cpp | 8 ++++---- layout/style/nsStyleContext.h | 4 ++-- layout/style/nsStyleStructFwd.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index d87cda72a213..7398fa2fc0ee 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -55,7 +55,7 @@ struct nsInheritedStyleData return aContext->AllocateFromShell(sz); } - void DestroyStructs(uint32_t aBits, nsPresContext* aContext) { + void DestroyStructs(uint64_t aBits, nsPresContext* aContext) { #define STYLE_STRUCT_INHERITED(name, checkdata_cb) \ void *name##Data = mStyleStructs[eStyleStruct_##name]; \ if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \ @@ -68,7 +68,7 @@ struct nsInheritedStyleData #undef STYLE_STRUCT_RESET } - void Destroy(uint32_t aBits, nsPresContext* aContext) { + void Destroy(uint64_t aBits, nsPresContext* aContext) { DestroyStructs(aBits, aContext); aContext->FreeToShell(sizeof(nsInheritedStyleData), this); } @@ -100,7 +100,7 @@ struct nsResetStyleData return aContext->AllocateFromShell(sz); } - void Destroy(uint32_t aBits, nsPresContext* aContext) { + void Destroy(uint64_t aBits, nsPresContext* aContext) { #define STYLE_STRUCT_RESET(name, checkdata_cb) \ void *name##Data = mStyleStructs[eStyleStruct_##name]; \ if (name##Data && !(aBits & NS_STYLE_INHERIT_BIT(name))) \ @@ -178,7 +178,7 @@ struct nsCachedStyleData #undef STYLE_STRUCT_RESET #undef STYLE_STRUCT_INHERITED - void Destroy(uint32_t aBits, nsPresContext* aContext) { + void Destroy(uint64_t aBits, nsPresContext* aContext) { if (mResetData) mResetData->Destroy(aBits, aContext); if (mInheritedData) diff --git a/layout/style/nsStyleContext.cpp b/layout/style/nsStyleContext.cpp index df8bc327675b..ed1ef013476b 100644 --- a/layout/style/nsStyleContext.cpp +++ b/layout/style/nsStyleContext.cpp @@ -43,14 +43,14 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent, mRuleNode(aRuleNode), mAllocations(nullptr), mCachedResetData(nullptr), - mBits(((uint32_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT), + mBits(((uint64_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT), mRefCnt(0) { // This check has to be done "backward", because if it were written the // more natural way it wouldn't fail even when it needed to. - static_assert((UINT32_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >= + static_assert((UINT64_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >= nsCSSPseudoElements::ePseudo_MAX, - "pseudo element bits no longer fit in a uint32_t"); + "pseudo element bits no longer fit in a uint64_t"); MOZ_ASSERT(aRuleNode); mNextSibling = this; @@ -262,7 +262,7 @@ nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID) } SetStyle(aSID, result); - mBits &= ~nsCachedStyleData::GetBitForSID(aSID); + mBits &= ~static_cast(nsCachedStyleData::GetBitForSID(aSID)); return result; } diff --git a/layout/style/nsStyleContext.h b/layout/style/nsStyleContext.h index da20c04f8959..d0b94ee61c59 100644 --- a/layout/style/nsStyleContext.h +++ b/layout/style/nsStyleContext.h @@ -211,7 +211,7 @@ public: #undef STYLE_STRUCT_INHERITED nsRuleNode* RuleNode() { return mRuleNode; } - void AddStyleBit(const uint32_t& aBit) { mBits |= aBit; } + void AddStyleBit(const uint64_t& aBit) { mBits |= aBit; } /* * Mark this style context's rule node (and its ancestors) to prevent @@ -430,7 +430,7 @@ protected: // sometimes allocate the mCachedResetData. nsResetStyleData* mCachedResetData; // Cached reset style data. nsInheritedStyleData mCachedInheritedData; // Cached inherited style data - uint32_t mBits; // Which structs are inherited from the + uint64_t mBits; // Which structs are inherited from the // parent context or owned by mRuleNode. uint32_t mRefCnt; }; diff --git a/layout/style/nsStyleStructFwd.h b/layout/style/nsStyleStructFwd.h index d6e845da94d2..ee5087358e55 100644 --- a/layout/style/nsStyleStructFwd.h +++ b/layout/style/nsStyleStructFwd.h @@ -62,6 +62,6 @@ eStyleStruct_BackendOnly = nsStyleStructID_Length }; // A bit corresponding to each struct ID -#define NS_STYLE_INHERIT_BIT(sid_) (1 << int32_t(eStyleStruct_##sid_)) +#define NS_STYLE_INHERIT_BIT(sid_) (1 << uint64_t(eStyleStruct_##sid_)) #endif /* nsStyleStructFwd_h_ */