Bug 1087536 patch 1 - Record the transition manager's cover rule as in the eTransitionSheet level of the cascade so that ResolveStyleWithReplacement replaces it correctly. r=birtles

Without this patch, patch 3 will cause bugs where we'll never remove the
cover rule we create during the process of starting a transition.  This
won't actually be problematic during the transition, since the
transition will overwrite it, but once the transition completes, the
cover rule will still be around, and we'll be stuck with the
pre-transition value instead of the post-transition value.

It's possible it also fixes existing bugs prior to the patch series in
this bug.
This commit is contained in:
L. David Baron 2014-11-17 11:39:14 -08:00
parent 6514be6291
commit 79ff09761b
2 changed files with 18 additions and 3 deletions

View File

@ -1282,9 +1282,13 @@ nsStyleSet::ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
ruleWalker.SetCurrentNode(aBaseContext->RuleNode());
// FIXME: Perhaps this should be passed in, but it probably doesn't
// matter.
ruleWalker.SetLevel(eDocSheet, false, false);
// This needs to be the transition sheet because that is the highest
// level of the cascade, and thus the only thing that makes sense if
// we are ever going to call ResolveStyleWithReplacement on the
// resulting context. It's also the right thing for the one case (the
// transition manager's cover rule) where we put the result of this
// function in the style context tree.
ruleWalker.SetLevel(eTransitionSheet, false, false);
for (int32_t i = 0; i < aRules.Count(); i++) {
ruleWalker.ForwardOnPossiblyCSSRule(aRules.ObjectAt(i));
}

View File

@ -115,6 +115,17 @@ class nsStyleSet
// Get a style context that represents aBaseContext, but as though
// it additionally matched the rules in the aRules array (in that
// order, as more specific than any other rules).
//
// One of the following must hold:
// 1. The resulting style context must be used only on a temporary
// basis, and it must never be put into the style context tree
// (and, in particular, we must never call
// ResolveStyleWithReplacement with it as the old context, which
// might happen if it is put in the style context tree), or
// 2. The additional rules must be appropriate for the transitions
// level of the cascade, which is the highest level of the cascade.
// (This is the case for one current caller, the cover rule used
// for CSS transitions.)
already_AddRefed<nsStyleContext>
ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
const nsCOMArray<nsIStyleRule> &aRules);