Bug 1274944 - Part 4: Implement mutation observer for setting spacing. r=birtles

MozReview-Commit-ID: LmCO9QyQbBU

--HG--
extra : rebase_source : f078d871b6c5fab565a3ab03fdbf4ac3452704e6
This commit is contained in:
Boris Chiou 2016-09-05 12:00:12 +08:00
parent 7d2125257c
commit c15da6fa38
2 changed files with 71 additions and 0 deletions

View File

@ -168,6 +168,10 @@ KeyframeEffect::SetSpacing(JSContext* aCx,
KeyframeUtils::ApplyDistributeSpacing(mKeyframes);
}
if (mAnimation && mAnimation->IsRelevant()) {
nsNodeUtils::AnimationChanged(mAnimation);
}
if (mTarget) {
RefPtr<nsStyleContext> styleContext = GetTargetStyleContext();
if (styleContext) {

View File

@ -1896,6 +1896,73 @@ addAsyncAnimTest("set_effect_with_previous_animation",
yield await_frame();
});
addAsyncAnimTest("set_spacing",
{ observe: div, subtree: true }, function*() {
var anim = div.animate([ { marginLeft: "0px" },
{ marginLeft: "-20px" },
{ marginLeft: "100px" },
{ marginLeft: "50px" } ],
{ duration: 100 * MS_PER_SEC });
yield await_frame();
assert_records([{ added: [anim], changed: [], removed: [] }],
"records after animation is added");
anim.effect.spacing = "paced(margin-left)";
yield await_frame();
assert_records([{ added: [], changed: [anim], removed: [] }],
"records after animation is changed");
anim.cancel();
yield await_frame();
assert_records([{ added: [], changed: [], removed: [anim] }],
"records after animation end");
});
addAsyncAnimTest("set_spacing_on_a_non-animatable_property",
{ observe: div, subtree: true }, function*() {
var anim = div.animate([ { marginLeft: "0px" },
{ marginLeft: "-20px" },
{ marginLeft: "100px" },
{ marginLeft: "50px" } ],
{ duration: 100 * MS_PER_SEC,
spacing: "paced(margin-left)" });
yield await_frame();
assert_records([{ added: [anim], changed: [], removed: [] }],
"records after animation is added");
anim.effect.spacing = "paced(animation-duration)";
yield await_frame();
assert_records([{ added: [], changed: [anim], removed: [] }],
"records after setting a non-animatable paced property");
anim.cancel();
yield await_frame();
assert_records([{ added: [], changed: [], removed: [anim] }],
"records after animation end");
});
addAsyncAnimTest("set_the_same_spacing",
{ observe: div, subtree: true }, function*() {
var anim = div.animate([ { marginLeft: "0px" },
{ marginLeft: "-20px" },
{ marginLeft: "100px" },
{ marginLeft: "50px" } ],
{ duration: 100 * MS_PER_SEC,
spacing: "paced(margin-left)" });
yield await_frame();
assert_records([{ added: [anim], changed: [], removed: [] }],
"records after animation is added");
anim.effect.spacing = "paced(margin-left)";
yield await_frame();
assert_records([], "no record after setting the same spacing");
anim.cancel();
yield await_frame();
assert_records([{ added: [], changed: [], removed: [anim] }],
"records after animation end");
});
// Run the tests.
SimpleTest.requestLongerTimeout(2);
SimpleTest.waitForExplicitFinish();