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.
This commit is contained in:
Cameron McCormack 2013-12-12 13:09:40 +11:00
Родитель a8cf86e4b7
Коммит dd8ce60c6d
4 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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<uint64_t>(nsCachedStyleData::GetBitForSID(aSID));
return result;
}

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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_ */