Skip to content

Optimize Animation::iterate() into Animation::iterate_by() - #400

Merged
Loirooriol merged 1 commit into
servo:mainfrom
Loirooriol:optimize-animation-iterate
Jun 26, 2026
Merged

Loirooriol merged 1 commit into
servo:mainfrom
Loirooriol:optimize-animation-iterate

Conversation

@Loirooriol

@Loirooriol Loirooriol commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

This method was performing a single iteration. But most callers want to perform multiple iterations, so they were calling it in a loop.

So this patch replaces iterate() with iterate_by(), which takes the desired number of iterations as a parameter, and returns the actual number of iterations that were performed.

Servo PR: servo/servo#45978

Comment thread style/servo/animation.rs Resolved
This method was performing a single iteration. But most callers want to
perform multiple iterations, so they were calling it in a loop.

So this patch replaces `iterate()` with `iterate_by()`, which takes the
desired number of iterations as a parameter, and returns the actual
number of iterations that were performed.

Signed-off-by: Oriol Brufau <[email protected]>
@Loirooriol
Loirooriol force-pushed the optimize-animation-iterate branch from 8e49442 to 323937f Compare June 25, 2026 19:07
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jun 25, 2026
@Loirooriol
Loirooriol marked this pull request as ready for review June 25, 2026 20:09
@Loirooriol
Loirooriol requested a review from mrobinson June 25, 2026 20:09

@yezhizhen yezhizhen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice.

Comment thread style/servo/animation.rs
self.iterate();
progress -= 1.;
}
progress -= self.iterate_by(progress);

@yezhizhen yezhizhen Jun 26, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The progress we pass to iterate_by can actually be negative.

The behaviour actually does not change. But was there always a bug here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I'm following, what do you think should happen if progress is negative?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nvm. I think it is correct. We will set the self.state = Paused(progress); one line below.

Comment thread style/servo/animation.rs Resolved
@Loirooriol
Loirooriol added this pull request to the merge queue Jun 26, 2026
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jun 26, 2026
Merged via the queue into servo:main with commit e7a7e34 Jun 26, 2026
5 checks passed
@Loirooriol
Loirooriol deleted the optimize-animation-iterate branch June 26, 2026 08:12
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jun 26, 2026
…servo#45978)

Bump Stylo to servo/stylo#400

Testing: Not needed, no change in behavior

Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jun 26, 2026
…servo#45978)

Bump Stylo to servo/stylo#400

Testing: Not needed, no change in behavior

Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Jun 26, 2026
…servo#45978)

Bump Stylo to servo/stylo#400

Testing: Not needed, no change in behavior

Signed-off-by: Oriol Brufau <[email protected]>
servo-wpt-sync pushed a commit to servo/wpt that referenced this pull request Jun 26, 2026
…web-platform-tests#45978)

Bump Stylo to servo/stylo#400

Testing: Not needed, no change in behavior

Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit that referenced this pull request Jul 1, 2026
This method was performing a single iteration. But most callers want to
perform multiple iterations, so they were calling it in a loop.

So this patch replaces `iterate()` with `iterate_by()`, which takes the
desired number of iterations as a parameter, and returns the actual
number of iterations that were performed.

Servo PR: servo/servo#45978

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

This method was performing a single iteration. But most callers want to
perform multiple iterations, so they were calling it in a loop.

So this patch replaces `iterate()` with `iterate_by()`, which takes the
desired number of iterations as a parameter, and returns the actual
number of iterations that were performed.

Imports servo/stylo#400

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

This method was performing a single iteration. But most callers want to
perform multiple iterations, so they were calling it in a loop.

So this patch replaces `iterate()` with `iterate_by()`, which takes the
desired number of iterations as a parameter, and returns the actual
number of iterations that were performed.

Imports servo#400

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

This method was performing a single iteration. But most callers want to
perform multiple iterations, so they were calling it in a loop.

So this patch replaces `iterate()` with `iterate_by()`, which takes the
desired number of iterations as a parameter, and returns the actual
number of iterations that were performed.

Imports servo/stylo#400

Differential Revision: https://phabricator.services.mozilla.com/D310919
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