Make author !important rules override CSS animations. (Bug 783714) r=bzbarsky

This was resolved at the CSS Working Group meeting on 2012-08-15.
This commit is contained in:
L. David Baron 2012-08-29 18:27:01 -07:00
parent ab82605a1f
commit f0cb06f18c
2 changed files with 29 additions and 18 deletions

View File

@ -446,9 +446,7 @@ IsMoreSpecificThanAnimation(nsRuleNode *aRuleNode)
{
return !aRuleNode->IsRoot() &&
(aRuleNode->GetLevel() == nsStyleSet::eTransitionSheet ||
(aRuleNode->IsImportantRule() &&
(aRuleNode->GetLevel() == nsStyleSet::eAgentSheet ||
aRuleNode->GetLevel() == nsStyleSet::eUserSheet)));
aRuleNode->IsImportantRule());
}
static nsIStyleRule*
@ -718,17 +716,17 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
{
// Cascading order:
// [least important]
// 1. UA normal rules = Agent normal
// 2. User normal rules = User normal
// 3. Presentation hints = PresHint normal
// 4. Author normal rules = Document normal
// 5. Override normal rules = Override normal
// 6. Author !important rules = Document !important
// 7. Override !important rules = Override !important
// -. animation rules = Animation normal
// 8. User !important rules = User !important
// 9. UA !important rules = Agent !important
// -. transition rules = Transition normal
// - UA normal rules = Agent normal
// - User normal rules = User normal
// - Presentation hints = PresHint normal
// - Author normal rules = Document normal
// - Override normal rules = Override normal
// - animation rules = Animation normal
// - Author !important rules = Document !important
// - Override !important rules = Override !important
// - User !important rules = User !important
// - UA !important rules = Agent !important
// - transition rules = Transition normal
// [most important]
// Save off the last rule before we start walking our agent sheets;
@ -778,6 +776,10 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
nsRuleNode* lastOvrRN = aRuleWalker->CurrentNode();
bool haveImportantOverrideRules = !aRuleWalker->GetCheckForImportantRules();
// This needs to match IsMoreSpecificThanAnimation() above.
aRuleWalker->SetLevel(eAnimationSheet, false, false);
(*aCollectorFunc)(mRuleProcessors[eAnimationSheet], aData);
if (haveImportantDocRules) {
aRuleWalker->SetLevel(eDocSheet, true, false);
AddImportantRules(lastDocRN, lastPresHintRN, aRuleWalker); // doc
@ -798,10 +800,6 @@ nsStyleSet::FileRules(nsIStyleRuleProcessor::EnumFunc aCollectorFunc,
}
#endif
// This needs to match IsMoreSpecificThanAnimation() above.
aRuleWalker->SetLevel(eAnimationSheet, false, false);
(*aCollectorFunc)(mRuleProcessors[eAnimationSheet], aData);
#ifdef DEBUG
AssertNoCSSRules(lastPresHintRN, lastUserRN);
#endif

View File

@ -60,6 +60,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=435442
100% { padding-bottom: 20px; animation-timing-function: ease-out }
}
@keyframes always_fifty {
from, to { margin-left: 50px }
}
#withbefore::before, #withafter::after {
content: "";
animation: anim2 1s linear alternate infinite;
@ -1316,6 +1320,15 @@ is(cs.marginTop, "40px",
"rest of animation should still work when UA !important present at 200ms");
done_div();
// Test that author !important rules override animations, but
// that animations override regular author rules.
new_div("animation: always_fifty 1s linear infinite; margin-left: 200px");
is(cs.marginLeft, "50px", "animations override regular author rules");
done_div();
new_div("animation: always_fifty 1s linear infinite; margin-left: 200px ! important;");
is(cs.marginLeft, "200px", "important author rules override animations");
done_div();
// Test interaction of animations and restyling (Bug 686656).
// This test depends on kf3 getting its 0% and 100% values from the
// rules below it in the cascade; we're checking that the animation