Cache important rule the first time the rule is matched so we don't rely on the declaration for it past that point. (Bug 522595) r=bzbarsky

This commit is contained in:
L. David Baron 2009-12-11 08:13:19 -08:00
parent 4ee286e827
commit cec495c863

View File

@ -1409,23 +1409,16 @@ nsCSSDeclaration* CSSStyleRuleImpl::GetDeclaration(void) const
nsIStyleRule* CSSStyleRuleImpl::GetImportantRule(void)
{
if (!mDeclaration->HasImportantData()) {
NS_ASSERTION(!mImportantRule, "immutable, so should be no important rule");
return nsnull;
}
if (!mImportantRule) {
mImportantRule = new CSSImportantRule(mDeclaration);
if (!mImportantRule)
return nsnull;
NS_ADDREF(mImportantRule);
}
return mImportantRule;
}
/* virtual */ void
CSSStyleRuleImpl::RuleMatched()
{
if (mDeclaration->HasImportantData() && !mImportantRule) {
mImportantRule = new CSSImportantRule(mDeclaration);
NS_IF_ADDREF(mImportantRule);
}
}
NS_IMETHODIMP