-
Notifications
You must be signed in to change notification settings - Fork 57
Rework ElementAnimationSet::start_transition_if_applicable to be more like the specification
#145
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
Conversation
nicoburns
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be rebased on top of the latest main
230370b to
ed063e7
Compare
7f43b7b to
090b1fe
Compare
80fa179 to
560638c
Compare
|
What should I rebase on now? I got many conflicts when rebasing on main. |
|
I force-pushed the main branch to sync changes from upstream, which is not ideal for PRs. With your branch at 08279e1, you should be able to do Where 7ee9643 is the nearest common ancestor of your branch and https://github.com/servo/stylo/commits/2025-03-11/ |
172dac0 to
28fc84e
Compare
|
Somehow I cannot compile anymore.. I just fetched the latest Servo main branch. I am on the latest Servo main branch. |
@yezhizhen You upgraded to the latest Stylo branch a little too quickly! CI is still running on the corresponding Servo PR (servo/servo#35990). Your code should compile again once that merges. Until then you can run against the |
|
Haha thanks Nico! I will get back tomorrow then :) |
4a2dd8c to
4ef8b50
Compare
|
I still cannot compile locally, with latest pulled repo I made some adjustments to Cargo.toml in Servo. It starts to compile, but has following errors now: EDIT: Seems to work now after servo/servo#36011 |
current.servo+stylo.main.branch.mp4after.apply.fix.mp4 |
|
@yezhizhen Thanks! I'll take a look at this today. |
|
Okay. I've spent some time looking more closely at this change and I think it's a good start! Apologies for the current mess, but I think this is a good opportunity to actually implement the specification in the order it is written.
|
Thanks for the suggestions! When I opened this PR I try to work around original code without altering it too much. It is nice we can do this now :) |
|
@mrobinson I just restructured the code completely to follow exact same order as spec is written in. And my newly added wpt-tests and other manual tests are still passing. EDIT: Latest test result: https://github.com/yezhizhen/servo/actions/runs/14153448812 |
ecdab05 to
e46917b
Compare
|
@yezhizhen I've pushed a couple commits onto your branch with some minor changes. Please take a look. Do these seeem okay to you? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrobinson LGTM mostly, but Condition 3 of step 1 is not checked in your latest commit.
I also have some other questions below :)
| match ignore_transitions { | ||
| IgnoreTransitions::Canceled => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel a bit clumsy, as this check is done in each iteration despite the static execution path. And we need to introduce a extra enum.
Does compiler optimize it away? Would it still be better, if we just create two functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that two functions would lead to a good deal of code repetition, so a single function makes more sense to me. This kind of check should be very cheap. Another option here could be using bitflags.
| &self, | ||
| context: &mut StyleContext<Self>, | ||
| old_styles: &ElementStyles, | ||
| old_styles: &mut ElementStyles, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not mutated tho. Would it be better to just remove mut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's correct, but these changes are unrelated so should be posted in another PR.
style/animation.rs
Outdated
| if !has_running_transition && (transitionable && from != to) && (duration + delay > 0.0) { | ||
| // > 3. the element does not have a completed transition for the property or the end value | ||
| // > of the completed transition is different from the after-change style for the property | ||
| let mut start_new_transition = !has_completed_transition; | ||
| if has_completed_transition { | ||
| let completed_transition = old_transition.as_ref().unwrap(); | ||
| start_new_transition = completed_transition.property_animation.to != to; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition 3 also needs to be checked in step 1.
Right now it is removed in your latest commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I've added this back.
|
https://github.com/yezhizhen/servo/actions/runs/14217536133 @mrobinson The latest try run in Servo PR for this Stylo PR is successful. |
| &self, | ||
| context: &mut StyleContext<Self>, | ||
| old_styles: &ElementStyles, | ||
| old_styles: &mut ElementStyles, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that's correct, but these changes are unrelated so should be posted in another PR.
| match ignore_transitions { | ||
| IgnoreTransitions::Canceled => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that two functions would lead to a good deal of code repetition, so a single function makes more sense to me. This kind of check should be very cheap. Another option here could be using bitflags.
style/animation.rs
Outdated
| if !has_running_transition && (transitionable && from != to) && (duration + delay > 0.0) { | ||
| // > 3. the element does not have a completed transition for the property or the end value | ||
| // > of the completed transition is different from the after-change style for the property | ||
| let mut start_new_transition = !has_completed_transition; | ||
| if has_completed_transition { | ||
| let completed_transition = old_transition.as_ref().unwrap(); | ||
| start_new_transition = completed_transition.property_animation.to != to; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I've added this back.
|
@yezhizhen Sorry, for some reason my comment on the unresolved conversation was left in a draft state. You can find it above now. |
|
If this looks okay to you, I will squash the changes and land the PR. |
|
@mrobinson LGTM. Please land :) For the Servo PR, I believe that I need to rebase and revert |
33247f9 to
f51e372
Compare
…re like the specification This improves the behavior of transition toggling, cancellation, and delay. In particular, there are many improvements with how transitions are started when replacing an existing one. Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Euclid Ye <[email protected]> Signed-off-by: Martin Robinson <[email protected]>
f51e372 to
ea495b1
Compare
ElementAnimationSet::start_transition_if_applicable to be more like the specification
mrobinson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the long process to review this!
|
I'm going to land this one event though the Servo PR isn't approved yet as it shouldn't cause any issues in Servo except another test will start passing. |
Should be fine as |
More details in Stylo PR: servo/stylo#145 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes - fixes #35833 - fixes #35982 <!-- Either: --> - [x] There are new passing test: `css/css-logical/animation-004.html: Transitions from physical to logical update when the direction is changed` Created new test files as well: 1. `css-transitions/transition-remove-and-change-immediate.html` 2. `css-transitions/transition-zero-duration-with-delay.html` 3. `css-transitions/transitioncancel-003.html` <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> cc @Asun0204 @xiaochengh @stevennovaryo Signed-off-by: Euclid Ye <[email protected]>
More details in Stylo PR: servo/stylo#145 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes - fixes servo#35833 - fixes servo#35982 <!-- Either: --> - [x] There are new passing test: `css/css-logical/animation-004.html: Transitions from physical to logical update when the direction is changed` Created new test files as well: 1. `css-transitions/transition-remove-and-change-immediate.html` 2. `css-transitions/transition-zero-duration-with-delay.html` 3. `css-transitions/transitioncancel-003.html` <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> cc @Asun0204 @xiaochengh @stevennovaryo Signed-off-by: Euclid Ye <[email protected]>
This improves the behavior of transition toggling, cancellation, and
delay. In particular, there are many improvements with how transitions
are started when replacing an existing one.
Servo PR: servo/servo#35978
Co-authored-by: Martin Robinson [email protected]
Signed-off-by: Euclid Ye [email protected]
Signed-off-by: Martin Robinson [email protected]