Skip to content

Always use progress=1.0 for 0 duration animation values - #403

Merged
mrobinson merged 1 commit into
servo:mainfrom
mrobinson:one-progress-for-zero-duration-animations
Jun 27, 2026
Merged

mrobinson merged 1 commit into
servo:mainfrom
mrobinson:one-progress-for-zero-duration-animations

Conversation

@mrobinson

@mrobinson mrobinson commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Servo PR: servo/servo#46016

Comment thread style/servo/animation.rs Outdated
let progress = if self.property_animation.duration == 0.0 {
1.0
} else {
(time - self.start_time) / (self.property_animation.duration)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While at it, unnecessary parentheses:

Suggested change
(time - self.start_time) / (self.property_animation.duration)
(time - self.start_time) / self.property_animation.duration

@mrobinson
mrobinson force-pushed the one-progress-for-zero-duration-animations branch 2 times, most recently from 9a38345 to 07895b9 Compare June 26, 2026 19:00
@mrobinson
mrobinson marked this pull request as ready for review June 26, 2026 19:04
Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson
mrobinson force-pushed the one-progress-for-zero-duration-animations branch from 07895b9 to 7ecccbf Compare June 27, 2026 09:30
@mrobinson
mrobinson added this pull request to the merge queue Jun 27, 2026
Merged via the queue into servo:main with commit 44bdcc6 Jun 27, 2026
5 checks passed
@mrobinson
mrobinson deleted the one-progress-for-zero-duration-animations branch June 27, 2026 12:48
pull Bot pushed a commit to Haofei/servo that referenced this pull request Jun 27, 2026
…#46016)

This commits makes two changes to prevent animations from producing
invalid color values (defense in depth):

1. Update Stylo to a version that fixing an issue with interpolation of
   values in interrupted transitions that are reversing[^1].
2. Prevents the creation of WebRender color values with alpha that is
   out of range.

[^1]: https://www.w3.org/TR/css-transitions-1/#reversing

Stylo PR: servo/stylo#403
Testing: This change adds a WPT crash test.
Fixes: servo#45945
Loirooriol pushed a commit that referenced this pull request Jul 1, 2026
Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Servo PR: servo/servo#46016

Signed-off-by: Martin Robinson <[email protected]>
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jul 7, 2026
…. r=firefox-style-system-reviewers,emilio

Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Imports servo/stylo#403

Differential Revision: https://phabricator.services.mozilla.com/D310924
github-actions Bot pushed a commit to longvatrong111/stylo that referenced this pull request Jul 8, 2026
…. r=firefox-style-system-reviewers,emilio

Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Imports servo#403

Differential Revision: https://phabricator.services.mozilla.com/D310924
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…. r=firefox-style-system-reviewers,emilio

Transitions can sometimes have 0 duration when the transition reversing
shortening factor is also calculated to be 0. When that happens, we
should always use 1.0 for the progress when calculating the value for
the transition. This avoid division by zero.

Imports servo/stylo#403

Differential Revision: https://phabricator.services.mozilla.com/D310924
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants