Bug 1375153 - Move nsStyleContext::mComputingStruct and AutoCheckDependency to GeckoStyleContext. r?Manishearth
These are only used in Gecko mode.
MozReview-Commit-ID: DKQBwatbu62
--- a/layout/style/GeckoStyleContext.cpp
+++ b/layout/style/GeckoStyleContext.cpp
@@ -22,16 +22,19 @@ GeckoStyleContext::GeckoStyleContext(nsS
CSSPseudoElementType aPseudoType,
already_AddRefed<nsRuleNode> aRuleNode,
bool aSkipParentDisplayBasedStyleFixup)
: nsStyleContext(aParent, aPseudoTag, aPseudoType)
, mCachedResetData(nullptr)
, mChild(nullptr)
, mEmptyChild(nullptr)
, mRuleNode(Move(aRuleNode))
+#ifdef DEBUG
+ , mComputingStruct(nsStyleStructID_None)
+#endif
{
mBits |= NS_STYLE_CONTEXT_IS_GECKO;
if (aParent) {
#ifdef DEBUG
nsRuleNode *r1 = mParent->RuleNode(), *r2 = mRuleNode;
while (r1->GetParent())
r1 = r1->GetParent();
--- a/layout/style/GeckoStyleContext.h
+++ b/layout/style/GeckoStyleContext.h
@@ -186,12 +186,46 @@ private:
// mChild for other children. The order of children is not
// meaningful.
GeckoStyleContext* mChild;
GeckoStyleContext* mEmptyChild;
GeckoStyleContext* mPrevSibling;
GeckoStyleContext* mNextSibling;
RefPtr<nsRuleNode> mRuleNode;
+#ifdef DEBUG
+public:
+ struct AutoCheckDependency {
+
+ GeckoStyleContext* mStyleContext;
+ nsStyleStructID mOuterSID;
+
+ AutoCheckDependency(GeckoStyleContext* aContext, nsStyleStructID aInnerSID)
+ : mStyleContext(aContext)
+ {
+ mOuterSID = aContext->mComputingStruct;
+ MOZ_ASSERT(mOuterSID == nsStyleStructID_None ||
+ DependencyAllowed(mOuterSID, aInnerSID),
+ "Undeclared dependency, see generate-stylestructlist.py");
+ aContext->mComputingStruct = aInnerSID;
+ }
+
+ ~AutoCheckDependency()
+ {
+ mStyleContext->mComputingStruct = mOuterSID;
+ }
+
+ };
+
+private:
+ // Used to check for undeclared dependencies.
+ // See AUTO_CHECK_DEPENDENCY in nsStyleContextInlines.h.
+ nsStyleStructID mComputingStruct;
+
+#define AUTO_CHECK_DEPENDENCY(gecko_, sid_) \
+ mozilla::GeckoStyleContext::AutoCheckDependency checkNesting_(gecko_, sid_)
+#else
+#define AUTO_CHECK_DEPENDENCY(gecko_, sid_)
+#endif
};
}
#endif // mozilla_GeckoStyleContext_h
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -85,17 +85,16 @@ nsStyleContext::nsStyleContext(nsStyleCo
nsIAtom* aPseudoTag,
CSSPseudoElementType aPseudoType)
: mParent(aParent)
, mPseudoTag(aPseudoTag)
, mBits(((uint64_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT)
, mRefCnt(0)
#ifdef DEBUG
, mFrameRefCnt(0)
- , mComputingStruct(nsStyleStructID_None)
#endif
{}
void
nsStyleContext::FinishConstruction()
{
// 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.
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -414,45 +414,16 @@ protected:
#include "nsStyleStructList.h"
#undef STYLE_STRUCT
default:
MOZ_ASSERT_UNREACHABLE("unexpected nsStyleStructID value");
return nullptr;
}
}
-#ifdef DEBUG
- struct AutoCheckDependency {
-
- nsStyleContext* mStyleContext;
- nsStyleStructID mOuterSID;
-
- AutoCheckDependency(nsStyleContext* aContext, nsStyleStructID aInnerSID)
- : mStyleContext(aContext)
- {
- mOuterSID = aContext->mComputingStruct;
- MOZ_ASSERT(mOuterSID == nsStyleStructID_None ||
- DependencyAllowed(mOuterSID, aInnerSID),
- "Undeclared dependency, see generate-stylestructlist.py");
- aContext->mComputingStruct = aInnerSID;
- }
-
- ~AutoCheckDependency()
- {
- mStyleContext->mComputingStruct = mOuterSID;
- }
-
- };
-
-#define AUTO_CHECK_DEPENDENCY(sid_) \
- AutoCheckDependency checkNesting_(this, sid_)
-#else
-#define AUTO_CHECK_DEPENDENCY(sid_)
-#endif
-
// Helper functions for GetStyle* and PeekStyle*
#define STYLE_STRUCT_INHERITED(name_, checkdata_cb_) \
template<bool aComputeData> \
const nsStyle##name_ * DoGetStyle##name_();
#define STYLE_STRUCT_RESET(name_, checkdata_cb_) \
template<bool aComputeData> \
const nsStyle##name_ * DoGetStyle##name_();
@@ -480,18 +451,16 @@ protected:
uint64_t mBits;
uint32_t mRefCnt;
#ifdef DEBUG
uint32_t mFrameRefCnt; // number of frames that use this
// as their style context
- nsStyleStructID mComputingStruct;
-
static bool DependencyAllowed(nsStyleStructID aOuterSID,
nsStyleStructID aInnerSID)
{
return !!(sDependencyTable[aOuterSID] &
nsCachedStyleData::GetBitForSID(aInnerSID));
}
static const uint32_t sDependencyTable[];
--- a/layout/style/nsStyleContextInlines.h
+++ b/layout/style/nsStyleContextInlines.h
@@ -67,17 +67,17 @@ const nsStyle##name_ * nsStyleContext::D
if (cachedData) /* Have it cached already, yay */ \
return cachedData; \
if (!aComputeData) { \
/* We always cache inherited structs on the context when we */\
/* compute them. */ \
return nullptr; \
} \
/* Have the rulenode deal */ \
- AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
+ AUTO_CHECK_DEPENDENCY(gecko, eStyleStruct_##name_); \
const nsStyle##name_ * newData = \
gecko->RuleNode()-> \
GetStyle##name_<aComputeData>(this->AsGecko(), mBits); \
/* always cache inherited data on the style context; the rule */\
/* node set the bit in mBits for us if needed. */ \
gecko->mCachedInheritedData \
.mStyleStructs[eStyleStruct_##name_] = \
const_cast<nsStyle##name_ *>(newData); \
@@ -137,17 +137,17 @@ const nsStyle##name_ * nsStyleContext::D
if (gecko->mCachedResetData) { \
const nsStyle##name_ * cachedData = \
static_cast<nsStyle##name_*>( \
gecko->mCachedResetData->mStyleStructs[eStyleStruct_##name_]); \
if (cachedData) /* Have it cached already, yay */ \
return cachedData; \
} \
/* Have the rulenode deal */ \
- AUTO_CHECK_DEPENDENCY(eStyleStruct_##name_); \
+ AUTO_CHECK_DEPENDENCY(gecko, eStyleStruct_##name_); \
return gecko->RuleNode()->GetStyle##name_<aComputeData>(this->AsGecko()); \
} \
auto servo = AsServo(); \
const bool needToCompute = !(mBits & NS_STYLE_INHERIT_BIT(name_)); \
if (!aComputeData && needToCompute) { \
return nullptr; \
} \
const nsStyle##name_* data = \