mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 19:25:43 +00:00
Bug 1122781 part 2 - Generate dependencies table of style structs for runtime check. r=dbaron
--HG-- extra : source : ed2baad25b34094f5c8abfe42ebe2cd77c1f2bab
This commit is contained in:
parent
fe4b058303
commit
a437cdb720
@ -32,6 +32,35 @@ using namespace mozilla;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
// Check that the style struct IDs are in the same order as they are
|
||||
// in nsStyleStructList.h, since when we set up the IDs, we include
|
||||
// the inherited and reset structs spearately from nsStyleStructList.h
|
||||
enum DebugStyleStruct {
|
||||
#define STYLE_STRUCT(name, checkdata_cb) eDebugStyleStruct_##name,
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
};
|
||||
|
||||
#define STYLE_STRUCT(name, checkdata_cb) \
|
||||
static_assert(static_cast<int>(eDebugStyleStruct_##name) == \
|
||||
static_cast<int>(eStyleStruct_##name), \
|
||||
"Style struct IDs are not declared in order?");
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
|
||||
const uint32_t nsStyleContext::sDependencyTable[] = {
|
||||
#define STYLE_STRUCT(name, checkdata_cb)
|
||||
#define STYLE_STRUCT_DEP(dep) NS_STYLE_INHERIT_BIT(dep) |
|
||||
#define STYLE_STRUCT_END() 0,
|
||||
#include "nsStyleStructList.h"
|
||||
#undef STYLE_STRUCT
|
||||
#undef STYLE_STRUCT_DEP
|
||||
#undef STYLE_STRUCT_END
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
||||
nsIAtom* aPseudoTag,
|
||||
@ -54,6 +83,12 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
|
||||
"pseudo element bits no longer fit in a uint64_t");
|
||||
MOZ_ASSERT(aRuleNode);
|
||||
|
||||
#ifdef DEBUG
|
||||
static_assert(MOZ_ARRAY_LENGTH(nsStyleContext::sDependencyTable)
|
||||
== nsStyleStructID_Length,
|
||||
"Number of items in dependency table doesn't match IDs");
|
||||
#endif
|
||||
|
||||
mNextSibling = this;
|
||||
mPrevSibling = this;
|
||||
if (mParent) {
|
||||
|
@ -517,6 +517,17 @@ private:
|
||||
uint64_t mBits; // Which structs are inherited from the
|
||||
// parent context or owned by mRuleNode.
|
||||
uint32_t mRefCnt;
|
||||
|
||||
#ifdef DEBUG
|
||||
static bool DependencyAllowed(nsStyleStructID aOuterSID,
|
||||
nsStyleStructID aInnerSID)
|
||||
{
|
||||
return !!(sDependencyTable[aOuterSID] &
|
||||
nsCachedStyleData::GetBitForSID(aInnerSID));
|
||||
}
|
||||
|
||||
static const uint32_t sDependencyTable[];
|
||||
#endif
|
||||
};
|
||||
|
||||
already_AddRefed<nsStyleContext>
|
||||
|
Loading…
Reference in New Issue
Block a user