Closed Bug 1150807 Opened 10 years ago Closed 10 years ago

Implement Animation.cancel()

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla40
Tracking Status
firefox40 --- fixed

People

(Reporter: birtles, Assigned: birtles)

References

Details

Attachments

(5 files, 1 obsolete file)

No description provided.
Assignee: nobody → bbirtles
Status: NEW → ASSIGNED
Attached patch WIP patch (obsolete) — Splinter Review
This patch is still missing a few tests (as listed at the end of css-animations/test_animation-cancel.html). Currently one of the tests in css-animations/test_animation-playstate.html is failing because it's checking that after we set the currentTime while idle we transition to the paused state. By the letter of the spec we should actually start playing from currentTime (i.e. transition to the running state) but I'm not sure if that's actually the desired behaviour in this case or if we should update the spec. It seems like it makes more sense only to update the start time if it's already set.
(In reply to Brian Birtles (:birtles) from comment #2) > Currently one of the tests in css-animations/test_animation-playstate.html > is failing because it's checking that after we set the currentTime while > idle we transition to the paused state. By the letter of the spec we should > actually start playing from currentTime (i.e. transition to the running > state) but I'm not sure if that's actually the desired behaviour in this > case or if we should update the spec. It seems like it makes more sense only > to update the start time if it's already set. I'm going to change the spec: https://lists.w3.org/Archives/Public/public-fx/2015AprJun/0027.html
The main problem I'm facing now is what to call the different Cancel methods. For each of these Animation methods we have four different ways of calling them: a. Call from script -- needs to reset a bunch of state in style so that we retrigger layer transactions etc. b. Call from script on a CSS animation/transition -- needs to reset state in style AND needs to flush style before doing anything c. Call from style -- doesn't need to reset any of that state (since we're in style already) but *may* need to behave differently (specifically for pausing/playing we behave differently when being called from style) d. Call from elsewhere in Gecko -- needs to reset a bunch of state in style Typically we've named these as follows: a. XXXFromJS() b. XXXFromJS() (but on the CSSAnimation/CSSTransition-specific override) c. XXXFromStyle() d. XXX() I wonder about (d). I wonder if XXX() should just do the operation but not reset state in style and make that the responsibility of the caller. Currently there *are* no other callers in Gecko at the moment other than style. It might be that in bug 1151731 we find a better way of expressing this so I'll just leave it as-is for now.
The reasoning for this change is described here: https://lists.w3.org/Archives/Public/public-fx/2015AprJun/0027.html Furthermore, subsequent tests introduced in this bug for the animation playState depend on this change.
Attachment #8596439 - Flags: review?(jwatt)
This patch makes Cancel() call PostUpdate which clobbers certain state in style so that animated style is correctly flushed when an animation is cancelled. The main difficulty with this is that we *don't* want to call this when we're cancelling an animation as a result of a style update or else we'll trigger needless work. The pattern elsewhere has been to define a *FromStyle() method for this case (e.g. CSSAnimation::PlayFromStyle, PauseFromStyle). This isn't ideal because there's always the danger we will forget to call the appropriate *FromStyle method. It is, however, consistent. Hopefully in bug 1151731 we'll find a better way of expressing this.
Attachment #8596442 - Flags: review?(jwatt)
This isn't spec'ed anywhere (since the whole Web Animations API <-> CSS interaction isn't spec'ed yet) but it seems that changing animation-play-state should not restart an idle animation. If an author calls Cancel() on an animation then that animation should continue to be idle until they call Play()/Pause() from the API. Cancelling an animation and hanging on to it is a purely API-only feature and hence it's reasonable that restoring it from this state is also an API-only feature. One can imagine use-cases such as polyfilling where script wants to remove any CSS Animations/Transitions run by the browser and replace them with something else entirely. In that case, the script can call Cancel() on the animation and be sure that the animation is going to stay out of the way even if something else tweaks the animation-play-state.
Attachment #8596444 - Flags: review?(jwatt)
Attachment #8596445 - Flags: review?(jwatt)
Attachment #8595193 - Attachment is obsolete: true
Attachment #8596439 - Flags: review?(jwatt) → review+
Attachment #8596442 - Flags: review?(jwatt) → review+
Attachment #8596444 - Flags: review?(jwatt) → review+
Attachment #8596441 - Flags: review?(bugs) → review+
Attachment #8596445 - Flags: review?(jwatt) → review+
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: