Bug 1122781 part 2 - Generate dependencies table of style structs for runtime check. r=dbaron

--HG--
extra : source : ed2baad25b34094f5c8abfe42ebe2cd77c1f2bab
This commit is contained in:
Xidorn Quan 2015-02-07 13:25:21 +11:00
Родитель fe4b058303
Коммит a437cdb720
2 изменённых файлов: 46 добавлений и 0 удалений

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

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