Bug 572200, part 1: Make rule nodes know whether they're used directly by a style context. r=bzbarsky

This commit is contained in:
L. David Baron 2012-11-07 11:55:53 -08:00
parent 7c9e487c8c
commit 4555f7cb1b
3 changed files with 16 additions and 2 deletions

View File

@ -646,6 +646,18 @@ public:
return (mDependentBits & NS_RULE_NODE_IS_IMPORTANT) != 0;
}
/**
* Has this rule node at some time in its lifetime been the mRuleNode
* of some style context (as opposed to only being the ancestor of
* some style context's mRuleNode)?
*/
void SetUsedDirectly() {
mDependentBits |= NS_RULE_NODE_USED_DIRECTLY;
}
bool IsUsedDirectly() const {
return (mDependentBits & NS_RULE_NODE_USED_DIRECTLY) != 0;
}
// NOTE: Does not |AddRef|.
nsIStyleRule* GetRule() const { return mRule; }
// NOTE: Does not |AddRef|.

View File

@ -65,14 +65,15 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
#endif
}
mRuleNode->AddRef();
mRuleNode->SetUsedDirectly(); // before ApplyStyleFixups()!
ApplyStyleFixups();
#define eStyleStruct_LastItem (nsStyleStructID_Length - 1)
NS_ASSERTION(NS_STYLE_INHERIT_MASK & NS_STYLE_INHERIT_BIT(LastItem),
"NS_STYLE_INHERIT_MASK must be bigger, and other bits shifted");
#undef eStyleStruct_LastItem
mRuleNode->AddRef();
}
nsStyleContext::~nsStyleContext()

View File

@ -60,6 +60,7 @@ struct nsCSSValueList;
// Additional bits for nsRuleNode's mDependentBits:
#define NS_RULE_NODE_GC_MARK 0x02000000
#define NS_RULE_NODE_USED_DIRECTLY 0x04000000
#define NS_RULE_NODE_IS_IMPORTANT 0x08000000
#define NS_RULE_NODE_LEVEL_MASK 0xf0000000
#define NS_RULE_NODE_LEVEL_SHIFT 28