Bug 960465 patch 12 - Instead of using the full style covered by the cover rule as the parent style for descendents when we've tried starting transitions, use the after-change style. r=birtles

This switches to the new rules for how transitions start on descendants
when also starting on ancestors.
This commit is contained in:
L. David Baron 2015-02-17 11:15:03 +13:00
Родитель 38c8f0feac
Коммит fbd52317d1
2 изменённых файлов: 21 добавлений и 16 удалений

Просмотреть файл

@ -379,15 +379,20 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
// creates a new style rule if we started *or* stopped transitions. // creates a new style rule if we started *or* stopped transitions.
collection->mStyleRuleRefreshTime = TimeStamp(); collection->mStyleRuleRefreshTime = TimeStamp();
collection->UpdateCheckGeneration(mPresContext); collection->UpdateCheckGeneration(mPresContext);
collection->mNeedsRefreshes = true;
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
collection->EnsureStyleRuleFor(now, EnsureStyleRule_IsNotThrottled);
} }
// Replace the new style context by appending the cover rule. // We want to replace the new style context with the after-change style.
nsCOMArray<nsIStyleRule> rules; *aNewStyleContext = afterChangeStyle;
if (startedAny) { if (collection) {
rules.AppendObject(coverRule); // Since we have transition styles, we have to undo this replacement.
// The check of collection->mCheckGeneration against the restyle
// manager's GetAnimationGeneration() will ensure that we don't go
// through the rest of this function again when we do.
collection->PostRestyleForAnimation(mPresContext);
} }
*aNewStyleContext = mPresContext->StyleSet()->
ResolveStyleByAddingRules(*aNewStyleContext, rules);
} }
void void
@ -474,8 +479,6 @@ nsTransitionManager::ConsiderStartingTransition(
return; return;
} }
nsPresContext *presContext = aNewStyleContext->PresContext();
if (!shouldAnimate) { if (!shouldAnimate) {
if (haveCurrentTransition) { if (haveCurrentTransition) {
// We're in the middle of a transition, and just got a non-transition // We're in the middle of a transition, and just got a non-transition
@ -612,7 +615,6 @@ nsTransitionManager::ConsiderStartingTransition(
} }
} }
aElementTransitions->UpdateAnimationGeneration(mPresContext); aElementTransitions->UpdateAnimationGeneration(mPresContext);
aElementTransitions->PostRestyleForAnimation(presContext);
*aStartedAny = true; *aStartedAny = true;
aWhichStarted->AddProperty(aProperty); aWhichStarted->AddProperty(aProperty);

Просмотреть файл

@ -227,14 +227,13 @@ function make_reset_test(transition, description)
var reset_test = make_reset_test("4s margin-left ease-out 4s", "transition-delay reset to starting point"); var reset_test = make_reset_test("4s margin-left ease-out 4s", "transition-delay reset to starting point");
var reset_test_reference = make_reset_test("4s margin-left linear -3s", "reference for previous test (reset test)"); var reset_test_reference = make_reset_test("4s margin-left linear -3s", "reference for previous test (reset test)");
// Test that transitions on descendants do not trigger when the // Test that transitions on descendants start correctly when the
// inherited value is itself transitioning. In other words, when // inherited value is itself transitioning. In other words, when
// ancestor and descendant both have a transition for the same property, // ancestor and descendant both have a transition for the same property,
// and the descendant inherits the property from the ancestor, the // and the descendant inherits the property from the ancestor, the
// descendant's transition is ignored (as part of the idea of not // descendant's transition starts as specified, based on the concepts of
// starting transitions on changes that result from animation). // the before-change style, the after-change style, and the
// See http://lists.w3.org/Archives/Public/www-style/2009Jun/0121.html // after-transition style.
// and http://lists.w3.org/Archives/Public/www-style/2009Jul/0050.html
var descendant_tests = [ var descendant_tests = [
{ parent_transition: "", { parent_transition: "",
child_transition: "4s text-indent" }, child_transition: "4s text-indent" },
@ -642,6 +641,8 @@ function check_descendant_tests() {
values["letter-spacing"] = [ 10, 5 ]; values["letter-spacing"] = [ 10, 5 ];
var tf = timingFunctions["ease"]; var tf = timingFunctions["ease"];
var time = px_to_num(earlyrefcs.textIndent) / 125;
for (var i in descendant_tests) { for (var i in descendant_tests) {
var test = descendant_tests[i]; var test = descendant_tests[i];
@ -679,11 +680,13 @@ function check_descendant_tests() {
property + " on child)"); property + " on child)");
} }
if (property != "letter-spacing" && child_ti_duration == 0) { // Override the parent's transition with the child's as long
// as the child transition is still running.
if (property != "letter-spacing" && duration + delay > time) {
child_ti_duration = duration; child_ti_duration = duration;
child_ti_delay = delay; child_ti_delay = delay;
} }
if (property != "text-indent" && child_ls_duration == 0) { if (property != "text-indent" && duration + delay > time) {
child_ls_duration = duration; child_ls_duration = duration;
child_ls_delay = delay; child_ls_delay = delay;
} }