Bug 1089417 patch 1 - Add assertions that rule processors are valid before we access them. r=heycam

This was just something that seemed worth asserting in the process of
debugging, since I wanted to see if it was the problem.
This commit is contained in:
L. David Baron 2014-12-05 15:50:00 -08:00
parent 76319d4f5b
commit 35d9fb6ba2

View File

@ -975,6 +975,8 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
PROFILER_LABEL("nsStyleSet", "FileRules", PROFILER_LABEL("nsStyleSet", "FileRules",
js::ProfileEntry::Category::CSS); js::ProfileEntry::Category::CSS);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
// Cascading order: // Cascading order:
// [least important] // [least important]
// - UA normal rules = Agent normal // - UA normal rules = Agent normal
@ -1164,6 +1166,8 @@ nsStyleSet::WalkRuleProcessors(nsIStyleRuleProcessor::EnumFunc aFunc,
ElementDependentRuleProcessorData* aData, ElementDependentRuleProcessorData* aData,
bool aWalkAllXBLStylesheets) bool aWalkAllXBLStylesheets)
{ {
NS_ASSERTION(mBatching == 0, "rule processors out of date");
if (mRuleProcessors[eAgentSheet]) if (mRuleProcessors[eAgentSheet])
(*aFunc)(mRuleProcessors[eAgentSheet], aData); (*aFunc)(mRuleProcessors[eAgentSheet], aData);
@ -1368,6 +1372,8 @@ nsStyleSet::RuleNodeWithReplacement(Element* aElement,
nsCSSPseudoElements::Type aPseudoType, nsCSSPseudoElements::Type aPseudoType,
nsRestyleHint aReplacements) nsRestyleHint aReplacements)
{ {
NS_ASSERTION(mBatching == 0, "rule processors out of date");
NS_ABORT_IF_FALSE(!(aReplacements & ~(eRestyle_CSSTransitions | NS_ABORT_IF_FALSE(!(aReplacements & ~(eRestyle_CSSTransitions |
eRestyle_CSSAnimations | eRestyle_CSSAnimations |
eRestyle_SVGAttrAnimations | eRestyle_SVGAttrAnimations |
@ -1882,6 +1888,7 @@ nsStyleSet::AppendFontFaceRules(nsPresContext* aPresContext,
nsTArray<nsFontFaceRuleContainer>& aArray) nsTArray<nsFontFaceRuleContainer>& aArray)
{ {
NS_ENSURE_FALSE(mInShutdown, false); NS_ENSURE_FALSE(mInShutdown, false);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) { for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
if (gCSSSheetTypes[i] == eScopedDocSheet) if (gCSSSheetTypes[i] == eScopedDocSheet)
@ -1899,6 +1906,7 @@ nsStyleSet::KeyframesRuleForName(nsPresContext* aPresContext,
const nsString& aName) const nsString& aName)
{ {
NS_ENSURE_FALSE(mInShutdown, nullptr); NS_ENSURE_FALSE(mInShutdown, nullptr);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) { for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
if (gCSSSheetTypes[i] == eScopedDocSheet) if (gCSSSheetTypes[i] == eScopedDocSheet)
@ -1920,6 +1928,7 @@ nsStyleSet::CounterStyleRuleForName(nsPresContext* aPresContext,
const nsAString& aName) const nsAString& aName)
{ {
NS_ENSURE_FALSE(mInShutdown, nullptr); NS_ENSURE_FALSE(mInShutdown, nullptr);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) { for (uint32_t i = ArrayLength(gCSSSheetTypes); i-- != 0; ) {
if (gCSSSheetTypes[i] == eScopedDocSheet) if (gCSSSheetTypes[i] == eScopedDocSheet)
@ -1941,6 +1950,7 @@ nsStyleSet::AppendFontFeatureValuesRules(nsPresContext* aPresContext,
nsTArray<nsCSSFontFeatureValuesRule*>& aArray) nsTArray<nsCSSFontFeatureValuesRule*>& aArray)
{ {
NS_ENSURE_FALSE(mInShutdown, false); NS_ENSURE_FALSE(mInShutdown, false);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) { for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*> nsCSSRuleProcessor *ruleProc = static_cast<nsCSSRuleProcessor*>
@ -1993,6 +2003,7 @@ nsStyleSet::AppendPageRules(nsPresContext* aPresContext,
nsTArray<nsCSSPageRule*>& aArray) nsTArray<nsCSSPageRule*>& aArray)
{ {
NS_ENSURE_FALSE(mInShutdown, false); NS_ENSURE_FALSE(mInShutdown, false);
NS_ASSERTION(mBatching == 0, "rule processors out of date");
for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) { for (uint32_t i = 0; i < ArrayLength(gCSSSheetTypes); ++i) {
if (gCSSSheetTypes[i] == eScopedDocSheet) if (gCSSSheetTypes[i] == eScopedDocSheet)
@ -2342,6 +2353,8 @@ nsStyleSet::HasAttributeDependentStyle(nsPresContext* aPresContext,
bool bool
nsStyleSet::MediumFeaturesChanged(nsPresContext* aPresContext) nsStyleSet::MediumFeaturesChanged(nsPresContext* aPresContext)
{ {
NS_ASSERTION(mBatching == 0, "rule processors out of date");
// We can't use WalkRuleProcessors without a content node. // We can't use WalkRuleProcessors without a content node.
bool stylesChanged = false; bool stylesChanged = false;
for (uint32_t i = 0; i < ArrayLength(mRuleProcessors); ++i) { for (uint32_t i = 0; i < ArrayLength(mRuleProcessors); ++i) {