This patch moves the code for queuing CSS animation events from
nsAnimationManager to CSSAnimationPlayer. In doing so, it also moves the
mLastNotification member and associated enum values.
This patch takes the CSSAnimationPlayer object, currently defined in
dom/animation/AnimationPlayer.{cpp,h}, and moves it to
layout/style/nsAnimationManager.{cpp,h} where the rest of the CSS
Animations-specific code lives.
At the same time it extends the scope of the mozilla namespace block in
nsAnimationManager.h to also include the AnimationEventInfo and EventArray types
since these classes, which don't have an ns* prefix, probably should be in the
mozilla namespace anyway.
This patch extracts the logic for calculating animation styles from
AnimationPlayerCollection and puts the bulk of it into the Animation objects.
Some of the initial logic surrounding the animation player state (e.g. is it
paused or not, etc.) is put into AnimationPlayer.
In future we may shift this logic even further down to the AnimationEffect
objects but currently we don't create such objects unless necessary.
This patch moves code from AnimationPlayerCollection to AnimationPlayer.
However, there is one subtle change in logic involved. Previously, we would test
if the player had finished by getting the computed time of its source content
and checking if it was in the after phase or not. In this patch, however, we
simply check the play state to see if it is finished or not.
These two approaches differ in the case where an animation is paused after it
has finished. The animation phase approach will indicate the player has
finished, but the play state approach will indicate the player has paused (since
the "paused" state trumps the "finished" state). This, however, should not
produce any observable effect because when an animation is paused
mIsRunningOnCompositor will be false (we don't put paused animations on the
compositor).
This patch uses the PlayFromStyle/PauseFromStyle methods on CSSAnimationPlayer
to perform play/pause control. (This allows us to encapsulate mHoldTime and
mPaused. We will encapsulate mStartTime etc. in subsequent bugs.
The override behavior of play()/pause() with regard to animation-play-state is:
* pause()/play() override the current animation-play-state
* pause() causes the player to remain paused until play() is called regardless
of changes to animation-play-state
(* Calling play() will override the animation-play-state but won't "stick". i.e.
subsequently setting animation-play-state: paused will pause the animation.)
These different permutations are tested in the next patch in this series.
This interaction will probably become more complicated once we introduce
finishing behavior (since we might not want animations to restart when
setting animation-play-state: running).
We only need to store if an animation is paused or not, hence a bool is
sufficient. Furthermore, the convenience of using the same type as the specified
style of animation-play-state will disappear once pausing behavior is wrapped up
behind Play() and Pause() methods.
We use new_div, check_events etc. in a number of animation-related mochitests
and with this bug we'll want to use them in a few more. This patch factors them
out into animation_utils.js and tidies them up a little.
scroll-behavior-5.html - Element.ScrollLeft and Element.ScrollTop scroll-behavior tests
- Set Element.ScrollLeft and Element.ScrollTop, for <div> tag with
no 'scroll-behavior' attribute. Expected to be instantaneous.
- Set Element.ScrollLeft and Element.ScrollTop, for <div> tag with
'scroll-behavior: auto'. Expected to be instantaneous.
- Set Element.ScrollLeft and Element.ScrollTop, for <div> tag with
'scroll-behavior: instant'. Expected to be instantaneous.
- Set Element.ScrollLeft and Element.ScrollTop, for <div> tag with
'scroll-behavior: smooth'. Expected to be smooth.
scroll-behavior-4.html - Anchor Link Scrolling
- Navigate to Anchor, for <div> tag with no ‘scroll-behavior’ attribute.
Expected to be instantaneous.
- Navigate to Anchor, for <div> tag with ‘scroll-behavior: auto’.
Expected to be instantaneous.
- Navigate to Anchor, for <div> tag with ‘scroll-behavior: instant’.
Expected to be instantaneous.
- Navigate to Anchor, for <div> tag with ‘scroll-behavior: smooth’.
Expected to be smooth.
- When an anchor link is clicked, the SCROLL_SMOOTH_AUTO flag is now set by
PresShell::GoToAnchor when calling PresShell::ScrollContentIntoView.
- Added an arguement, aAnimateScroll, to PresShell:GoToAnchor to indicate that
the scroll may be animated. This will only be set to true when an anchor
link is clicked. Opening a page with an anchor link will not trigger
such animations.
scroll-behavior-1.html - Viewport Scrolling, expected to be smooth:
- DOM Method not specifying scroll-behavior, for <body> tag with 'scroll-behavior: smooth’
scroll-behavior-2.html - Div Scrolling, expected to be smooth:
- DOM Method not specifying scroll-behavior, for <div> tag with 'scroll-behavior: smooth’
- DOM Method specifying ‘auto’ scroll-behavior, for <div> tag with ‘scroll-behavior: smooth’
- DOM Method specifying 'smooth’ scroll-behavior, for <div> tag with ‘scroll-behavior: smooth’
- DOM Method specifying ‘smooth’ scroll-behavior, for <div> tag with ‘scroll-behavior: instant’
- DOM Method specifying ‘smooth’ scroll-behavior, for <div> tag with ‘scroll-behavior: auto’
- DOM Method specifying ‘smooth’ scroll-behavior, for <div> tag with no scroll-behavior attribute.
scroll-behavior-3.html - Div Scrolling, expected to be instant:
- DOM Method not specifying scroll-behavior, for <div> tag with ‘scroll-behavior: instant’
- DOM Method not specifying scroll-behavior, for <div> tag with ‘scroll-behavior: auto’
- DOM Method not specifying scroll-behavior, for <div> tag with no scroll-behavior attribute.
- DOM Method specifying ‘instant’ scroll-behavior, for <div> tag with ‘scroll-behavior: smooth’
- DOM Method specifying ‘instant’ scroll-behavior, for <div> tag with ‘scroll-behavior: instant’
- DOM Method specifying ‘instant’ scroll-behavior, for <div> tag with ‘scroll-behavior: auto’
- DOM Method specifying ‘instant’ scroll-behavior, for <div> tag with no scroll-behavior attribute.
- DOM Method specifying ‘auto’ scroll-behavior, for <div> tag with ‘scroll-behavior: instant’
- DOM Method specifying ‘auto’ scroll-behavior, for <div> tag with ‘scroll-behavior: auto’
- DOM Method specifying ‘auto’ scroll-behavior, for <div> tag with no scroll-behavior attribute.
- Added SCROLL_SMOOTH_AUTO flag to nsIPresShell to enable selection of
scroll behavior through CSS.
- Updated Element and Window scrolling DOM methods to enable smooth scrolling
set through the scroll-behavior CSS property.
- Keyboard, scroll bar, mousewheel, and any other events that scroll smoothly
with the general.smoothScroll preference enabled will now scroll instantly
if the scroll frame has "scroll-behavior: instant" applied through CSS.
- Implemented boilerplate to add the scroll-behavior CSS property.
- Added layout.css.scroll-behavior.property-enabled preference to
allow the scroll-behavior CSS property to be enabled independently
of the CSSOM-View DOM scrolling api extensions for smooth scrolling.