Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent cubic bezier from infinite-looping #476

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/timing-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@
return x;
}
var start = 0, end = 1;
while (1) {
while (start < end) {
var mid = (start + end) / 2;
function f(a, b, m) { return 3 * a * (1 - m) * (1 - m) * m + 3 * b * (1 - m) * m * m + m * m * m};
var xEst = f(a, c, mid);
if (Math.abs(x - xEst) < 0.0001) {
if (Math.abs(x - xEst) < 0.00001) {
return f(b, d, mid);
}
if (xEst < x) {
Expand All @@ -191,6 +191,7 @@
end = mid;
}
}
return f(b, d, mid);
}
}

Expand Down
23 changes: 20 additions & 3 deletions test/web-platform-tests-expectations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ module.exports = {
'test/web-platform-tests/web-animations/interfaces/Animation/constructor.html':
'KeyframeEffectReadOnly is not defined causing the test to timeout.',

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing.html':
'It seems to enter an infinite loop and halt the browser.',

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing-steps.html':
'It seems to enter an infinite loop and halt the browser.',
},
Expand Down Expand Up @@ -860,6 +857,26 @@ module.exports = {
'KeyframeEffectReadOnly is not defined',
},

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/effect-easing.html': {
'effect easing produces values greater than 1 with keyframe easing cubic-bezier(0, 0, 0, 0)':
'assert_approx_equals: The left of the animation should be approximately 102.40666638411385 at 250ms expected 102.40666638411385 +/- 0.01 but got 100',

'effect easing produces values greater than 1 with keyframe easing cubic-bezier(1, 1, 1, 1)':
'assert_approx_equals: The left of the animation should be approximately 102.40666638411385 at 250ms expected 102.40666638411385 +/- 0.01 but got 100',

'effect easing produces negative values 1 with keyframe easing cubic-bezier(0, 0, 0, 0)':
'assert_approx_equals: The left of the animation should be approximately -29.501119758965654 at 250ms expected -29.501119758965654 +/- 0.01 but got 0',

'effect easing produces negative values 1 with keyframe easing cubic-bezier(1, 1, 1, 1)':
'assert_approx_equals: The left of the animation should be approximately -29.501119758965654 at 250ms expected -29.501119758965654 +/- 0.01 but got 0',

'effect easing produces values greater than 1 with keyframe easing producing values greater than 1':
'assert_approx_equals: The left of the animation should be approximately 101.9006796334848 at 240ms expected 101.9006796334848 +/- 0.01 but got 100',

'effect easing produces negative values with keyframe easing producing negative values':
'assert_approx_equals: The left of the animation should be approximately -16.589193103032184 at 10ms expected -16.589193103032184 +/- 0.01 but got 0',
},

'test/web-platform-tests/web-animations/interfaces/KeyframeEffect/getComputedTiming.html': {
'getComputedTiming().activeDuration for a non-zero duration and default iteration count':
'KeyframeEffectReadOnly is not defined',
Expand Down