Bug 1216842 - Part 10: Remove the limit of the computed timing progress. r=birtles

Now we produce computed timing progress outside [0,1] range.
We use the last segment to calculate animation values if the value is greater than 1.
We use the first segment to calculate animation values if the value is lesser than 0.
This commit is contained in:
Hiroyuki Ikezoe 2016-02-18 14:20:00 +01:00
parent deebc5f2f0
commit 71fe2ff072
9 changed files with 215 additions and 18 deletions

View File

@ -490,11 +490,6 @@ KeyframeEffectReadOnly::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
return;
}
MOZ_ASSERT(!computedTiming.mProgress.IsNull() &&
0.0 <= computedTiming.mProgress.Value() &&
computedTiming.mProgress.Value() <= 1.0,
"iteration progress should be in [0-1]");
for (size_t propIdx = 0, propEnd = mProperties.Length();
propIdx != propEnd; ++propIdx)
{
@ -532,16 +527,12 @@ KeyframeEffectReadOnly::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
*segmentEnd = segment + prop.mSegments.Length();
while (segment->mToKey < computedTiming.mProgress.Value()) {
MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
++segment;
if (segment == segmentEnd) {
MOZ_ASSERT_UNREACHABLE("incorrect iteration progress");
break; // in order to continue in outer loop (just below)
if ((segment+1) == segmentEnd) {
break;
}
++segment;
MOZ_ASSERT(segment->mFromKey == (segment-1)->mToKey, "incorrect keys");
}
if (segment == segmentEnd) {
continue;
}
MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
MOZ_ASSERT(segment >= prop.mSegments.Elements() &&
size_t(segment - prop.mSegments.Elements()) <

View File

@ -0,0 +1,35 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>Bug 1216842: effect-level easing function produces negative values (compositor thread)</title>
<style>
#target {
width: 100px; height: 100px;
background: blue;
}
</style>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ opacity: [0, 1] },
{
fill: "forwards",
/* The function produces negative values in (0, 0.766312060) */
easing: "cubic-bezier(0,-0.5,1,-0.5)",
duration: 100,
iterations: 0.75 /* To finish in the extraporation range */
}
);
var animation = new Animation(effect, document.timeline);
animation.play();
animation.finished.then(function() {
document.documentElement.className = "";
});
</script>
</html>

View File

@ -0,0 +1,35 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>Bug 1216842: effect-level easing function produces values greater than 1 (compositor thread)</title>
<style>
#target {
width: 100px; height: 100px;
background: blue;
}
</style>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ opacity: [0, 1] },
{
fill: "forwards",
/* The function produces values greater than 1 in (0.23368794, 1) */
easing: "cubic-bezier(0,1.5,1,1.5)",
duration: 100,
iterations: 0.25 /* To finish in the extraporation range */
}
);
var animation = new Animation(effect, document.timeline);
animation.play();
animation.finished.then(function() {
document.documentElement.className = "";
});
</script>
</html>

View File

@ -0,0 +1,27 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>Bug 1216842: effect-level easing function produces values greater than 1 (main-thread)</title>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ color: ["red", "blue"] },
{
fill: "forwards",
/* The function produces values greater than 1 in (0.23368794, 1) */
easing: "cubic-bezier(0,1.5,1,1.5)",
duration: 100
}
);
var animation = new Animation(effect, document.timeline);
animation.pause();
animation.currentTime = 250;
document.documentElement.className = "";
</script>
</html>

View File

@ -0,0 +1,27 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>Bug 1216842: effect-level easing function produces negative values (main-thread)</title>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ color: ["red", "blue"] },
{
fill: "forwards",
/* The function produces negative values in (0, 0.766312060) */
easing: "cubic-bezier(0,-0.5,1,-0.5)",
duration: 100
}
);
var animation = new Animation(effect, document.timeline);
animation.pause();
animation.currentTime = 250;
document.documentElement.className = "";
</script>
</html>

View File

@ -0,0 +1,38 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>
Bug 1216842: effect-level easing function produces negative values passed
to step-end function (compositor thread)
</title>
<style>
#target {
width: 100px; height: 100px;
background: blue;
}
</style>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ opacity: [0, 1], easing: "step-end" },
{
fill: "forwards",
/* The function produces negative values in (0, 0.766312060) */
easing: "cubic-bezier(0,-0.5,1,-0.5)",
duration: 100,
iterations: 0.75 /* To finish in the extraporation range */
}
);
var animation = new Animation(effect, document.timeline);
animation.play();
animation.finished.then(function() {
document.documentElement.className = "";
});
</script>
</html>

View File

@ -0,0 +1,38 @@
<!doctype html>
<html class="reftest-wait">
<head>
<title>
Bug 1216842: effect-level easing function produces values greater than 1
which are passed to step-end function (compositor thread)
</title>
<style>
#target {
width: 100px; height: 100px;
background: blue;
}
</style>
</head>
<body>
<div id="target"></div>
</body>
<script>
var target = document.getElementById("target");
var effect =
new KeyframeEffectReadOnly(
target,
{ opacity: [0, 1], easing: "step-end" },
{
fill: "forwards",
/* The function produces values greater than 1 in (0.23368794, 1) */
easing: "cubic-bezier(0,1.5,1,1.5)",
duration: 100,
iterations: 0.25 /* To finish in the extraporation range */
}
);
var animation = new Animation(effect, document.timeline);
animation.play();
animation.finished.then(function() {
document.documentElement.className = "";
});
</script>
</html>

View File

@ -1,2 +1,8 @@
load 1239889-1.html
load 1244595-1.html
load 1216842-1.html
load 1216842-2.html
load 1216842-3.html
load 1216842-4.html
load 1216842-5.html
load 1216842-6.html

View File

@ -604,14 +604,14 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
dom::KeyframeEffectReadOnly::GetComputedTimingAt(
Nullable<TimeDuration>(elapsedDuration), timing);
MOZ_ASSERT(!computedTiming.mProgress.IsNull() &&
0.0 <= computedTiming.mProgress.Value() &&
computedTiming.mProgress.Value() <= 1.0,
"iteration progress should be in [0-1]");
MOZ_ASSERT(!computedTiming.mProgress.IsNull(),
"iteration progress should not be null");
int segmentIndex = 0;
uint32_t segmentIndex = 0;
size_t segmentSize = animation.segments().Length();
AnimationSegment* segment = animation.segments().Elements();
while (segment->endPortion() < computedTiming.mProgress.Value()) {
while (segment->endPortion() < computedTiming.mProgress.Value() &&
segmentIndex < segmentSize - 1) {
++segment;
++segmentIndex;
}