Граф коммитов

446 Коммитов

Автор SHA1 Сообщение Дата
Brian Birtles 7f2f1073ca Bug 927349 part 7 - Factor out AnimationTimeline::GetRefreshDriver into a separate method; r=jwatt
This is in preparation for adding AnimationTimeline::FastForward in the next
patch which will reuse this code.
2014-12-18 08:42:41 +09:00
Brian Birtles c93cabd2c1 Bug 927349 part 6 - Rename AnimationPlayer::ResolveStartTime to AnimationPlayer::StartNow; r=jwatt
ResolveStartTime is a bit hard to understand. Eventually, once we implement
SetStartTime, we can probably remove this method altogether and just use that.
This renaming moves us closer to that direction.

This patch also adjusts a comment about the preconditions for calling StartNow.
This is because in a subsequent patch in this series we will update the
assertion at the beginning of StartNow to simply check that the player is
pending.
2014-12-18 08:42:41 +09:00
Brian Birtles 9fdafb68a4 Bug 927349 part 5 - Cancel players that are no longer used; r=jwatt
This patch adds a means of terminating an animation so that is has no effect.
The procedure is defined by Web Animations:

  http://w3c.github.io/web-animations/#cancelling-a-player-section

We don't implement all of this, however, since we don't currently support the
finished promise or custom effects.

In a later bug we will expose this as the cancel() method on AnimationPlayer.

We call this method for terminated animations in nsAnimationManager and
nsTransitionManager to ensure they get removed from the pending player tracker
and so that, for example, the ready promise of CSS Animation player objects is
rejected when the corresponding item is removed from animation-name.
2014-12-18 08:42:41 +09:00
Brian Birtles c91b2dea43 Bug 927349 part 4 - Make the ready Promise be created lazily; r=heycam
In Bug 1104435 we made the initial ready promise be created lazily. This patch
takes this a step further and makes sure we don't create the promise at all
unless it is explicitly requested.
2014-12-18 08:42:41 +09:00
Brian Birtles e7e0331a96 Bug 927349 part 3 - Cancel a pending play when pause is called; r=jwatt
This patch updates the pause procedure for AnimationPlayer so that if there is
a pending play it will be cancelled.

At the same it removes the existing check for a redundant call to Pause when we
are already paused. This check is not necessary since if we are already paused
the method will have no effect anyway.

Finally, this patch updates the comment about going to the pending state while
pausing since this will happen in bug 1109390.
2014-12-18 08:42:41 +09:00
Brian Birtles 97da0a29b5 Bug 927349 part 2 - Add AnimationPlayer::mIsPending and return "pending" from AnimationPlayer::PlayState(); r=jwatt
This patch adds a member for tracking if a player is currently pending or not
and uses this to return the "pending" state from PlayState(). We don't currently
set mIsPending to true yet, however.

Additionally, this patch updates AnimationPlayer::ComposeStyle to set
aNeedsRefreshes to true when the player is pending. This is used by the
appropriate animation/transition manager to determine if it should continue to
observe the refresh driver or not.
2014-12-18 08:42:41 +09:00
Brian Birtles 1c721ff76d Bug 927349 part 1 - Add PendingPlayerTracker; r=jwatt
This patch adds a hashtable to nsDocument that stores all the animation players
that are currently waiting to start. In the future it may also be used to store
players that are waiting to pause which is why the methods are called
AddPlayPending/RemovePlayPending instead of just AddPlayer/RemovePlayer.
2014-12-18 08:42:41 +09:00
Brian Birtles 11e4d27c81 Bug 1104435 part 9 - Make getting AnimationPlayer.ready flush for CSS Animation players; r=heycam 2014-12-18 08:42:41 +09:00
Brian Birtles fdda18cad2 Bug 1104435 part 8 - Add tests for AnimationPlayer.ready; r=heycam 2014-12-18 08:42:40 +09:00
Brian Birtles 28dc20551a Bug 1104435 part 7 - Update AnimationPlayer tests to wait on ready promise; r=heycam
AnimationPlayer.ready will currently always be resolved but by updating these
tests to wait on it anyway they should continue to work once we introduce the
delayed animation start behavior.
2014-12-18 08:42:40 +09:00
Brian Birtles e510de8cf2 Bug 1104435 part 6 - Use step_func inside Promise callbacks; r=heycam
Since bug 1104433, step_func now passes on the return value of its callback.
That means we can use it directly as a Promise callback function in Promise
chains where the return value of the function is another Promise.

This patch updates existing tests to eliminate the awkward handling we had
around wrapping some parts of Promise callbacks in step() but leaving the return
statement outside it.
2014-12-18 08:42:40 +09:00
Brian Birtles e6c6f40af3 Bug 1104435 part 5 - Factor out common animation test methods into testcommon.js; r=heycam
This patch moves commonly used addDiv and waitForFrame test methods to
a separate testcommon.js support file.

It also takes advantage of the updates to testharness.js from bug 1104433 to
rework addDiv such that it automatically removes the created div at the end of
the test.
2014-12-18 08:42:40 +09:00
Brian Birtles d5194f5c02 Bug 1104435 part 4 - Create and resolve new ready promises on play(); r=heycam
Every time we call play() (and in future pause()) we should create a new Promise
object and then fulfill it when we complete the play() operation.

This patch adds that step. This allows us to tweak test cases that currently
expect animations to start immediately so that by waiting on this promise they
will continue to work when we introduce the delayed start behavior in bug
927349.

We should also resolve the ready promise when we are in the pending state and
pause() is called. However, since we currently never enter the pending state we
don't need to add this just yet.
2014-12-18 08:42:40 +09:00
Brian Birtles 5834996813 Bug 1104435 part 3 - Add AnimationPlayer.ready promise; r=smaug
This patch simply adds the ready promise to AnimationPlayer. Creating new
promises and resolving them is added in a subsequent patch.
2014-12-18 08:42:40 +09:00
Brian Birtles 93e0028762 Bug 1104435 part 2 - Make AnimationPlayer derive from nsISupports; r=smaug
Web Animations defines the AnimationPlayer.ready Promise as type
Promise<AnimationPlayer>. This promise resolves to the AnimationPlayer object on
which it is defined. However, in order to be able to pass AnimationPlayer as
a resolution value it needs to implement nsISupports.

This patch makes AnimationPlayer derive from nsISupports.
2014-12-18 08:42:40 +09:00
Brian Birtles 4d0e7f2cd7 Bug 1104435 part 1 - Make AnimationTimeline::GetParentObject return an nsIGlobalObject; r=smaug
In order to create a Promise object for AnimationPlayer.ready, we need an
nsIGlobalObject. Currently we can access this through the following chain:

  AnimationPlayer -> AnimationTimeline -> Document -> nsIGlobalObject

Come bug 1096776 (Support AnimationPlayers without a timeline or with an
inactive timeline) we will no longer be able to rely on having an
AnimationTimeline so we will probably have to store the corresponding window
object on the AnimationPlayer. For now, however, we can look up the timeline as
above.

This patch makes this a little more straightforward by changing the return type
and value of AnimationTimeline::GetParentObject to return the nsIGlobalObject of
the document with which it is associated.
2014-12-18 08:42:40 +09:00
Daniel Holbert 22ecaed796 Bug 1107351: Simplify logic in AnimationPlayer::GetCurrentTime(). r=birtles 2014-12-04 12:13:38 -08:00
Brian Birtles 3410496562 Bug 1104427 part 3 - Make resolving the start time a separate method in AnimationPlayer; r=dholbert
In preparation for deferring the start of animations in bug 927349, this patch
makes the code that resolves the start time a separate method. In this patch we
call the method immediately from AnimationPlayer::DoPlay. However, in the future
this will be called at a later point when the first frame of the animation has
been rendered.
2014-12-04 08:28:38 -08:00
Brian Birtles ba8d2e5233 Bug 1104427 part 2 - Encapsulate AnimationPlayer::mStartTime; r=dholbert
Now that there is a public accessor for mStartTime, we can make it a protected
member of AnimationPlayer. The only time mStartTime is ever set is when playing
the animation so we can replace external modifications to mStartTime with calls
to Play(). This simplifies implementing deferred starting of animations
in bug 927349 by isolating the deferred playback logic to AnimationPlayer.

Note that even when we call PauseFromStyle immediately afterwards we still need
to call PlayFromStyle (or Play) first in order to resolve the time at which the
player should be paused. A newly created player doesn't have a current time so
if we were simply to call pause it wouldn't pause at the start of the animation
as we might expect. The call to Play(FromStyle) will cause the current time to
become zero and then we pause at that time.
2014-12-04 08:28:38 -08:00
Brian Birtles fd2b033a29 Bug 1104427 part 1 - Rename GetStartTime to GetStartTimeAsDouble; r=bholley
In forthcoming patches we will encapsulate AnimationPlayer::mStartTime so we can
ensure that related state is updated appropriately. We would like to expose
mStartTime via GetStartTime() but currently a method of that name returns the
start time as a double.

This patch applies the pattern used for currentTime to startTime; specifically,
GetCurrentTime() returns the TimeDuration (since that's what C++ callers should
use) while GetCurrentTimeAsDouble() returns a double.

At the same time, this patch also removes the [Pure] extended attribute from
startTime in the WebIDL definition since subsequent patches either in this bug
or in bug 927349 will mean that startTime can be updated out-of-band.
Specifically, we will implement deferred playback of animation such that the
startTime remains null until we've finished rendering the first frame of the
animation.
2014-12-04 08:28:38 -08:00
Brian Birtles 3148509768 Bug 1104424 - Rework pausing in AnimationPlayer to remove mIsPaused; r=dholbert
This patch reworks AnimationPlayer to represent the paused state by a null start
time. This brings it into line with recent changes in the Web Animations spec
and removes the need for the mIsPaused member variable.

The idea is that in order for a player to play, it needs a start time and
an active timeline. The processing is roughly:
* If it is seeked to a particular time (through setting the currentTime or
  calling pause() or finish()) but has no start time, it is paused.
* Otherwise, if it has no active timeline or no start time, it is idle.

By removing the mIsPaused flag the number of possible permutations of states is
reduced so the model is easier to reason about (see:
http://lists.w3.org/Archives/Public/public-fx/2014OctDec/0026.html).

This patch replaces the mIsPaused flag with checks for mStartTime.IsNull()
according to the rules outlined above.
2014-12-04 08:28:37 -08:00
Brian Birtles f38c5b5e70 Bug 1083670 - Move API tests for CSS Animations and CSS Transitions into separate directories; r=dbaron
--HG--
rename : dom/animation/test/css-integration/test_animation-effect-name.html => dom/animation/test/css-animations/test_animation-effect-name.html
rename : dom/animation/test/css-integration/test_animation-pausing.html => dom/animation/test/css-animations/test_animation-pausing.html
rename : dom/animation/test/css-integration/test_animation-player-playstate.html => dom/animation/test/css-animations/test_animation-player-playstate.html
rename : dom/animation/test/css-integration/test_animation-target.html => dom/animation/test/css-animations/test_animation-target.html
rename : dom/animation/test/css-integration/test_animations-dynamic-changes.html => dom/animation/test/css-animations/test_animations-dynamic-changes.html
rename : dom/animation/test/css-integration/test_element-get-animation-players.html => dom/animation/test/css-animations/test_element-get-animation-players.html
rename : dom/animation/test/css-integration/test_animation-effect-name.html => dom/animation/test/css-transitions/test_animation-effect-name.html
rename : dom/animation/test/css-integration/test_animation-pausing.html => dom/animation/test/css-transitions/test_animation-pausing.html
rename : dom/animation/test/css-integration/test_animation-target.html => dom/animation/test/css-transitions/test_animation-target.html
rename : dom/animation/test/css-integration/test_element-get-animation-players.html => dom/animation/test/css-transitions/test_element-get-animation-players.html
2014-11-17 13:46:01 +09:00
Brian Birtles aa575c832b Bug 1081007 - Fix relationship between Play/PlayFromJS/PlayFromStyle etc.; r=dholbert
The existing relationship between the particular versions of
AnimationPlayer::Play* (particularly in the CSSAnimationPlayer) subclass are
confusing because, for example, CSSAnimationPlayer::PlayFromStyle needs to be
careful to *not* call Play on CSSAnimationPlayer, but only on the parent
object (since otherwise we reset the sticky pause behavior).

This patch reworks this relationship by adding a protected DoPlay method that
performs the common pausing behavior. Play/PlayFromJS/PlayFromStyle then add
flushing, sticky pausing etc. as necessary.

This patch also removes the UpdateFlags enum and parameters previously used to
control whether we forced an update to style. This is no longer necessary since
we no longer call 'Play' from style. Instead we make Play always post restyles.

If we come across a case where we want to call Play and *not* post restyles, we
can re-add the flags then.

Roughly the same arrangement is true for Pause except that we don't currently
flush styles for CSS animations in PauseFromJS since it currently won't make any
observable difference.
2014-11-17 13:46:01 +09:00
Brian Birtles 48893c4454 Bug 1073336 part 15 - Switch AnimationPlayer to using less aggressive update mechanism; r=dbaron 2014-11-17 13:46:00 +09:00
Brian Birtles 49dee50d8c Bug 1073336 part 13 - Add AnimationPlayer::PostUpdate; r=dbaron
Adds a method for notifying the collection of changes to one of its players.
2014-11-17 13:45:59 +09:00
Brian Birtles d855c6692f Bug 1073336 part 12 - Add AnimationPlayer::GetCollection(); r=dbaron
This patch adds a method to animation players that looks up the
AnimationPlayerCollection to which the player belongs.
2014-11-17 13:45:59 +09:00
Brian Birtles bb9a6c6bf6 Bug 1073336 part 10 - Add AnimationPlayer::GetAnimationManager(); r=dbaron
This patch introduces an abstract method to AnimationPlayer to fetch the manager
object associated with the player. This method is implemented separate by
CSSAnimationPlayer and CSSTransitionPlayer to return the nsAnimationManager or
nsTransitionManager accordingly.
2014-11-17 13:45:58 +09:00
Brian Birtles 9f8acdf64c Bug 1073336 part 9 - Add protected AnimationPlayer::GetPresContext(); r=dbaron
This patch adds a further getter to find the pres context associated with an
animation player's target element, if any.
2014-11-17 13:45:58 +09:00
Brian Birtles dc613405f6 Bug 1073336 part 8 - Add protected AnimationPlayer::GetRenderedDocument(); r=dbaron
In order for AnimationPlayer objects to be able to notify their
collection/manager, the can either store an extra pointer member, or they can
navigate to the collection as follows:

  player->source(animation)->target(element)->document
    ->presShell->presContext->manager->collection

This patch adds a getter for the first part of this journey up to the document.
2014-11-17 13:45:58 +09:00
Brian Birtles 9efcdfde21 Bug 1073336 part 7 - Move style flushing to CSSAnimationPlayer and CSSTransitionPlayer; r=dbaron
Previously AnimationPlayer::Play() and AnimationPlayer::PlayState() would flush
styles as part of their operation. This, however, is only needed when the player
corresponds to a CSS Animation or CSS Transition. Now that we have concrete
subclasses for each of these cases we can move style flushing to the subclasses
and remove it from the base class (which is expected to be shared with
animations that are not dependent on style).
2014-11-17 13:45:58 +09:00
Brian Birtles 5f35f63800 Bug 1073336 part 6 - Add CSSTransitionPlayer; r=dbaron
In order to be able to find the collection a player belongs to from its source
content, we first need to be able to determine which manager--the animation
manager or transition manager--to look up.

We eventually plan to push transition event dispatch down to a CSS
transitions-specific subclass of AnimationPlayer, so this seems like a suitable
point to introduce this class.

Using this subclass we can define a virtual GetManager method that will
return the appropriate animation/transition manager for the player.
2014-11-17 13:45:57 +09:00
Brian Birtles e6792d259c Bug 1078122 part 9 - Move queuing of CSS animation events to CSSAnimationPlayer; r=dholbert
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.
2014-10-20 13:55:47 +09:00
Brian Birtles 789072d059 Bug 1078122 part 8 - Use the new GetTarget overload in AnimationPlayer; r=dholbert 2014-10-20 13:55:47 +09:00
Brian Birtles 5c994b7aac Bug 1078122 part 7 - Add method to Animation to get the target element and pseudo; r=dholbert 2014-10-20 13:55:47 +09:00
Brian Birtles 63eb4db9c0 Bug 1078122 part 6 - Store the previous finished state; r=dholbert
AnimationPlayer::CanThrottle determines if an animation player has just finished
by inspecting the value of mLastNotification. This is problematic for two
reasons:

1. mLastNotification is intended to be used for events (as the XXX comment
   notes)
2. mLastNotification is specific to CSS Animations and should be moved to
   CSSAnimationPlayer.

To address this, this patch adds an extra member mIsPreviousStateFinished. The
Web Animations spec already defines animation players as having such a member:

  http://w3c.github.io/web-animations/#previous-finished-state

We set it to true when we calculate the style for an animation that has
finished. This differs slightly from the code it is replacing as explained
below.

In the case of CSS Animations we perform the following sequence of steps on each
sample.

  1. EnsureStyleRuleFor (calls CanThrottle, and maybe ComposeStyle)
  2. GetEventsForCurrentTime

In the existing code, we update mLastNotification in (2) which happens on every
sample, even throttled samples.

In this patch, however, we update mIsPreviousStateFinished in (1) during the
ComposeStyle step which only happens for unthrottled samples. So, as of this
patch, in CanThrottle, we ask "have we newly entered the finished state since
the last *unthrottled* sample?", whereas previously we simply looked for
a change since the last sample, throttled or not. However, if the answer to the
question is "yes", then we'll run an unthrottled sample and update
mIsPreviousStateFinished so these should be functionally equivalent.

Another subtle difference is that this patch looks at the player's finished
state rather than the animation phase of its source content, and these will
produce different results in the case where the player is paused. However, since
paused animations are not run on the compositor, this should not matter.

In the case of CSS Transitions, AnimationPlayer::CanThrottle() is not currently
used and so mIsPreviousStateFinished is irrelevant.

Ultimately, both the existing and the new code is somewhat fragile but hopefully
this will be addressed by:
* Replacing mIsPreviousStateFinished with inspecting whether the finished
  promise is settled (bug 1074630),
* Merging more of the code in nsAnimationManager and nsTransitionManager and
  applying a unified approach to sampling that better accommodates these
  considerations.
2014-10-20 13:55:47 +09:00
Brian Birtles c1d26b86ba Bug 1078122 part 5 - Move CSSAnimationPlayer to nsAnimationManager; r=dholbert
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.
2014-10-20 13:55:46 +09:00
Brian Birtles 0898410bf5 Bug 1078122 part 4 - Make the mSource and mTimeline members of AnimationPlayer protected; r=dholbert 2014-10-20 13:55:46 +09:00
Brian Birtles b986ff9440 Bug 1078122 part 3 - Move animation value building down to the Animation objects; r=dholbert
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.
2014-10-20 13:55:46 +09:00
Brian Birtles 0decc8d175 Bug 1078122 part 2 - Encapsulate mIsRunningOnCompositor in AnimationPlayer; r=dholbert 2014-10-20 13:55:46 +09:00
Brian Birtles 95887412b4 Bug 1078122 part 1 - Move checks for animation throttling to AnimationPlayer; r=dholbert
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).
2014-10-20 13:55:45 +09:00
Brian Birtles 07c1c4a9cc Bug 1078119 - Rename AnimationTimeline/AnimationPlayer GetCurrentTimeDuration; r=bz
This patch performs the following renaming:

  AnimationPlayer::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationPlayer::GetCurrentTimeDuration -> GetCurrentTime
  AnimationTimeline::GetCurrentTime -> GetCurrentTimeAsDouble
  AnimationTimeline::GetCurrentTimeDuration -> GetCurrentTime
2014-10-20 13:55:45 +09:00
David Zbarsky 5f09ff6dc7 Bug 1037321 - Implement playState on AnimationPlayer; r=birtles, r=bz 2014-10-20 13:55:45 +09:00
Brian Birtles 6ab3c04168 Bug 1070745 part 9 - Tests for play/pause behavior; r=dholbert 2014-10-20 13:55:45 +09:00
Brian Birtles 81c9d5cfcb Bug 1070745 part 8 - Use play/pause from nsAnimationManager; r=dholbert
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).
2014-10-20 13:55:44 +09:00
Brian Birtles 3b9fd1bf92 Bug 1070745 part 7 - Add style flush at the beginning of Play(); r=dholbert
For players running CSS animations and CSS transitions we should perform a style
flush before running play() so that we are operating on the most up-to-date
state of animation-play-state.

For transitions, which don't have a play-state property, we will still need to
run this style flush before running play() to get the right finishing behavior
if transition-duration has changed. We haven't implemented finishing yet (that's
bug 1074630) but I've kept the flush for both cases now since I'm afraid we'll
forget it later.

Also, since we don't have a subclass of AnimationPlayer for transitions yet I've
put the style flush in the base class. In future, when we add
CSSTransitionPlayer we can move the flush to only those players that need up to
date style information.
2014-10-20 13:55:44 +09:00
Brian Birtles b4a6bc854c Bug 1070745 part 6 - Add means of marking a CSSAnimationPlayer as being paused by style; r=dholbert
When an animation player is paused by script this overrides whatever
animation-play-state is set by style. The logic for producing the correct
override behavior will be added to nsAnimationManager but first we need
to record in the player where it was paused.
2014-10-20 13:55:44 +09:00
David Zbarsky f9a448224d Bug 1070745 part 5 - Add CSSAnimationPlayer subclass; r=dholbert
This patch introduces a CSSAnimationPlayer subclass of AnimationPlayer. This is
because when we have an animation player running a CSS animation it has some
special behavior not needed in the general case such as:

* Flushing style before performing certain operations to ensure we are using
  the latest information.
* Dispatching CSS Animation events when we start/end.
* Storing extra state with regards to "how" the animation was paused.
  This is because, for example, if an animation is paused by script this
  overrides specified style.
2014-10-20 13:55:44 +09:00
David Zbarsky 225e200eaa Bug 1070745 part 4 - Add AnimationPlayer::Play and AnimationPlayer::Pause; r=dholbert
This patch introduces the basic implementation of play() and pause().

There are a lot of gaps still because we don't yet:
* Support the pending state (to be covered in bug 927349)
* Support finishing behavior (to be covered in bug 1074630)
* Have a good way of updating animation state outside of style resolution (bug
  1073336)

Also, we don't call these methods from CSS yet because the interaction between
play()/pause() and animation-play-state requires storing some extra state which
we introduce in subsequent patches in this series.

This patch introduces, temporarily, an update flag to indicate whether
play()/pause() operations need to post a restyle event. When these methods are
triggered by processing restyles we don't want to post another (unnecessary)
restyle event. In bug 1073336 we will remove the need for this.
2014-10-20 13:55:43 +09:00
David Zbarsky 7e543c4444 Bug 1070745 part 3 - Convert AnimationPlayer mPlayState to an mPaused bool; r=birtles
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.
2014-10-20 13:55:43 +09:00
Brian Birtles 311c41828e Bug 1070745 part 2 - Update AnimationPlayer IDL to enable play() and pause(); r=bz
We map play()/pause() to PlayFromJS/PauseFromJS internally so that internal
users don't accidentally call Play()/Pause() which flush style.
2014-10-20 13:55:43 +09:00
Peter Van der Beken dcda2ba9bb Bug 1078744 - Replace SetIsDOMBinding with SetIsNonDOMBinding, remove nsWrapperCache::SetIsDOMBinding. r=bz.
--HG--
extra : rebase_source : 89c476cd9436530b2df5acc903909e34188417a0
2014-10-07 11:44:49 +02:00
David Zbarsky fd4c921077 Bug 1067701 - Implement Animation.target; r=birtles, r=bz 2014-10-02 15:14:15 +09:00
Brian Birtles 1a844b4526 Bug 1074054 part 2 - Make Element::GetAnimationPlayers return in-effect animations too; r=dbaron
This patch makes Element::GetAnimationPlayers return not only current animations
but also animations that have finished but are filling forwards. This brings the
implementation into line with recent changes to the Web Animations spec and
allows querying all the animations that are currently affecting an element or
which are scheduled to do so in the future.
2014-10-02 15:14:14 +09:00
Brian Birtles add5d0af0e Bug 1074054 part 1 - Add Animation::IsInEffect; r=dbaron
This patch adds a utility method to return if an animation is "in effect" or not
as defined by Web Animations:

  http://w3c.github.io/web-animations/#in-effect

It also moves the utility method for querying if an animation is "current"
(IsCurrent) to the .cpp file since it is fairly long. (Bug 1046055 makes one of
the callers of IsCurrent inline-able which should offset any cost introduced by
this no longer being inline-able.)
2014-10-02 15:14:14 +09:00
Brian Birtles 86b19c0029 Bug 1046055 part 2 - Rename AnimationPlayer::IsCurrent to HasCurrentSource; r=dbaron
It's not the player that's "current" (a Web Animations term for an animation
that hasn't yet finished), but its source content, if any. This patch renames
the method on AnimationPlayer accordingly.

At the same time this patch moves the method to the header file since it's
quite simple and could possibly benefit from inlining.
2014-10-02 15:14:13 +09:00
Brian Birtles 1a49465f03 Bug 1073396 - Make Element.getAnimationPlayers flush style; r=dbaron 2014-10-02 15:14:13 +09:00
Ehsan Akhgari c78a04d048 Bug 1072299 - Build dom/animation in unified mode; r=baku
--HG--
extra : rebase_source : 2119739c119fddb1204f6941b19a9a3f68d49cf8
2014-09-25 10:11:43 -04:00
Brian Birtles 9f07908ee4 Bug 1039924 part 6 - Use StickyTimeDuration for timing calculations; r=dholbert
This patch takes the StickyTimeDuration defined in the previous patch and
uses it within the calculation of animation timing for parameters that are
expected to be +/- Forever.
2014-09-25 14:25:50 +09:00
Ehsan Akhgari 1b1d6ffebf Bug 1061023 - Fix more bad implicit constructors in DOM; r=baku
--HG--
extra : rebase_source : c80c5f9d7ae28286513cdb52ad76b46c240bdd5d
2014-09-01 18:26:43 -04:00
David Zbarsky 13da8bae55 Bug 1033114 Part 4: Make mStartTime a nullable TimeDuration r=birtles 2014-08-30 02:11:57 -04:00
David Zbarsky cbd65c781b Bug 1033114 Part 3: Make mStartTime a nullable TimeDuration r=birtles 2014-08-30 02:11:57 -04:00
David Zbarsky 846226f7fd Bug 1033114 Part 2: Rename mPauseStart to mHoldTime to match spec r=birtles 2014-08-30 02:11:56 -04:00
David Zbarsky 1f33b1a7b9 Bug 1033114 Part 1: Update AnimationPlayer to spec changes r=birtles, r=bz 2014-08-30 02:11:56 -04:00
Brian Birtles bf97de1a20 Bug 1045993 part 4 - Add tests for Animation.effect.name; r=dbaron 2014-08-22 13:42:48 +01:00
Brian Birtles 1d0abd4719 Bug 1045993 part 3 - Add AnimationEffect.name; r=dbaron, r=bz 2014-08-22 13:42:48 +01:00
Brian Birtles 058b40127c Bug 1045993 part 2 - Move the animation name from AnimationPlayer to Animation; r=dbaron
This patch stores the animation name on the Animation object rather than its
AnimationPlayer. This is because Animation objects don't have a reference to
their AnimationPlayer but their AnimationEffect needs access to the animation
name.

This patch also adds an accessor for AnimationPlayer to get the name from its
Animation (since players *do* have a reference to their source animation
content).
2014-08-22 13:42:48 +01:00
Brian Birtles 29081b3bb1 Bug 1045993 part 1 - Add AnimationEffect interface and Animation.effect member; r=dbaron, r=bz 2014-08-22 13:42:47 +01:00
Brian Birtles 85736e031c Bug 1045994 - Add a chrome-only property to AnimationPlayer to indicate if an animation is running on the compositor; r=dbaron, r=bz 2014-08-22 13:42:47 +01:00
Brian Birtles c9b30cafe3 Bug 1052147 - Initialize AnimationPlayer::mPlayState to running state; r=dbaron
The assertion in nsTimeStamp::operator >= occasionally fails due to a null RHS
timestamp when called from AnimationPlayer::GetCurrentTimeDuration, which, in
turn, is called from AnimationPlayer::SetSource.

The issue appears to be that we're not correctly initializing
AnimationPlayer.mPlayState. This value can be running (0) or paused (1) but we
only ever compare against the paused state (i.e. every other value is
effectively treated as running). If we don't initialize this we can end
up in the paused state but with mPauseStart not set to a valid (non-null)
TimeStamp. This creates an inconsistent state since we assume that when we're
paused mPauseStart is non-null, hence the assertion fails.

This gets tickled because, since bug 1040543, we call
AnimationPlayer::SetSource from nsAnimationManager::BuildAnimations *before* we
set mPlayState and mPauseStart.

This patch initializes mPlayState to the running state so we don't accidentally
end up in an inconsistent state.

It also removes some (now unnecessary) initialization of mPlayState and
mPauseStart from nsTransitionManager::ConsiderStartingTransition.

In future we could also consider reworking nsAnimationManager::BuildAnimations
so that we call SetSource on the new animation player *after* setting up its
play state. That may be more correct and would further avoid this problem but
may not be necessary since all that code is likely to change in the near future.
2014-08-13 18:21:45 +09:00
Brian Birtles 1e9fc689ae Bug 1040543 part 11 - Make ElementPropertyTransition inherit from Animation instead of AnimationPlayer; r=bz
This patch changes the inheritance of ElementPropertyTransition so that it is
a subclass of Animation not AnimationPlayer.

The only thing special about ElementPropertyTransition is it stores some extra
state for reversing transitions and an extra ValuePortionFor convenience method.
This reversing behavior is implemented by the transition manager by creating
a new AnimationPlayer (i.e. it is *not* a property of the AnimationPlayer). As
a result this extra state can be pushed down to Animation which simplifies the
code significantly.

In future if we implement KeyframeEffect as a separate object we may be able to
push transition-specific state down to KeyframeEffect instead.
2014-08-10 17:06:52 +10:00
Brian Birtles 264bff6b41 Bug 1040543 part 10 - Move mIsLastNotification from AnimationPlayer to Animation; r=bz
In this fourth step of dividing functionality between AnimationPlayer and
Animation, we move the mIsLastNotification and related methods/enums from
AnimationPlayer to Animation.

It is somewhat unclear where this belongs. This member is used to determine
which event to send for CSS Animations. The thinking behind moving this to
Animation is that if an animation that has already dispatched its animationstart
event was transferred to a new animation player with a similar current time then
I think it is expected that such an animation would *not* dispatch another
animationstart event. That suggests that event-state is a property of the
Animation not the AnimationPlayer.

Obviously, this needs to be defined somewhere (namely, the CSS Animations <->
Web Animations integration spec likely to become "CSS Animations Level 4"). Once
that behavior is agreed upon, if AnimationPlayer proves to be the more suitable
home for this member then it should be relatively straightforward to move the
member back at that time.
2014-08-10 17:06:51 +10:00
Brian Birtles 46562ab4f3 Bug 1040543 part 9 - Move IsFinishedTransition from AnimationPlayer to Animation; r=bz
As the third step in dividing functionality between AnimationPlayer and
Animation this patch moves the mIsFinishedTransition member and related methods
from AnimationPlayer to Animation.

At the same time we rename SetFinishedTransition to SetIsFinishedTransition.
2014-08-10 17:06:51 +10:00
Brian Birtles 2520d366a6 Bug 1040543 part 8 - Move timing parameters from AnimationPlayer to Animation; r=bz
As the second step in dividing functionality between AnimationPlayer and
Animation, this patch moves the AnimationTiming member from AnimationPlayer to
Animation.

Most of this patch is simply moving code around. However, one significant
functional difference is that Animation::GetLocalTime() uses the mParentTime
member which is set when the Animation is updated by the player it is attached
to.

Other less significant differences are:

* AnimationPlayer::GetLocalTime is renamed to GetCurrentTimeDuration
  In Web Animations, animation players have a (writeable) "current time" and
  animations have a (read-only) "local time".
  We would call the method simply "GetCurrentTime" (instead of
  "GetCurrentTimeDuration") but GetCurrentTime is the name of the method used in
  the content-facing API where it returns a double.

* "IsCurrent" is defined on both AnimationPlayer and Animation with the version
  in AnimationPlayer serving mostly as a convenience shortcut to the version on
  Animation.

* Animation::GetComputedTiming (previously on AnimationPlayer) now makes the
  timing parameter optional since most of the time it is not needed.
2014-08-10 17:06:50 +10:00
Brian Birtles 8088c0320d Bug 1040543 part 7 - Move keyframe properties from AnimationPlayer to Animation; r=bz
As the first step in dividing the functionality currently contained in
AnimationPlayer between AnimationPlayer and Animation this patch moves the set
of keyframe properties to the Animation.

These properties are returned from the Animation by a couple of Properties()
methods that provide direct access to the member variable. In future it is
anticipated that the non-const version will be replaced with an appropriate
setter function. This will likely happen when we implement a separate
KeyframeEffect object as defined by the Web Animations API.

With regards to error checking, nsAnimationManager checks the result of
AnimationPlayer::GetSource() and handles the case where it is nullptr.
nsTransitionManager, however, simply asserts that GetSource() is never null much
like it also asserts that there is only one property with one segment in the
animation. Eventually this code should be made more generic which will probably
happen in bug 999927.
2014-08-10 17:06:49 +10:00
Brian Birtles 249039905a Bug 1040543 part 5 - Pass down time from AnimationPlayer to Animation; r=bz
This patch makes AnimationPlayers pass their current time down to the Animation
they are playing.

Since all Animations need from their players is their time, this avoids adding
a pointer back to their AnimationPlayer.
2014-08-10 17:06:48 +10:00
Brian Birtles 8f9311bf63 Bug 1040543 part 4 - Create Animation objects and set on AnimationPlayer; r=bz 2014-08-10 17:06:47 +10:00
Brian Birtles 30c27e5573 Bug 1040543 part 3 - Add Animation interface; r=bz
This patch adds the Animation interface and adds a 'source' attribute to
AnimationPlayer that refers to this class.
2014-08-10 17:06:46 +10:00
Brian Birtles 0c90999575 Bug 1040543 part 1 - Move/Rename ElementAnimations to dom::AnimationPlayer; r=bz
This patch renames mozilla::ElementAnimations to mozilla::dom::AnimationPlayer
and moves the code from layout/style/AnimationCommon.cpp to
dom/animation/AnimationPlayer.cpp.

It also moves various helper classes needed by AnimationPlayer to
AnimationPlayer.cpp and moves them from the mozilla::css namespace to the
mozilla namespace.

Beyond that, there are no functional changes contained in this patch.

The renaming of various members and variables that used to refer to
ElementAnimation objects but now refer to AnimationPlayer objects--to give them
a more appropriate name--is performed in a subsequent patch.

--HG--
rename : layout/style/AnimationCommon.cpp => dom/animation/AnimationPlayer.cpp
rename : layout/style/AnimationCommon.h => dom/animation/AnimationPlayer.h
2014-08-10 17:06:44 +10:00
Ehsan Akhgari 444cd1c72e Bug 1050611 - Fix more bad implicit constructors in dom and docshell; r=smaug 2014-08-08 09:49:39 -04:00
Brian Birtles fb9a1a8fb3 Bug 1002332 - Make AnimationTimeline record the last refresh time and use that when there is no refresh driver; r=bz
A document that belongs to an iframe that is display:none as no associated pres
context from which to get a refresh driver. However, in this case
document.timeline.currentTime should still never go backwards (since document
timelines are supposed to be monotonically increasing).

This patch makes AnimationTimeline record the last value returned for the
current time so that if the document becomes display:none we can still return
the most recently used time.
2014-07-24 13:37:38 +09:00
Alexandre Poirot 7ea4dd517f Bug 1027242 - Blacklist mulet's failing tests + expose 'mulet' to ini files; fix previous bustage on a CLOSED TREE, r=ahal 2014-07-02 15:40:56 -07:00
Brian Birtles b846442afc Bug 1037316 part 2 - When updating animations, match existing animations one-by-one starting from the beginning of each list; r=dbaron
This patch changes the order in which we look for matches when updating existing
animations. Previously we would iterate through new animations in a forwards
direction but match old animations by going through the list of animations
backwards.

This patch makes us iterate through both lists in a backwards direction. That
means that if we have:

  animation: anim 100s

and later we make it

  animation: anim 100s, anim 100s

Then the new animation will be added to the *start* of the list, i.e. prepended,
and the resulting animation will not restart.
2014-07-23 10:51:12 +09:00
Brian Birtles 8e8054d839 Bug 1037316 part 1 - Return the same object when updating animations; r=dbaron
Previously when updating animations we'd generate a new list of animation
objects then try to match up animations from the existing list and copy across
state such as start times and notification flags. However, this means that from
the API we end up returning different objects.

This patch makes us maintain the same object identity when updating an existing
animation. It does this by looking for matching animations in both lists. If it
finds a match it copies the necessary information from the *new* animation to
the *existing* animation (but preserving the start time, last notification
etc.). Then, finally, it puts the *existing* animation in the list of *new*
animations and removes the corresponding *new* animation. The existing
animation is also removed from the list of existing animations so that it only
matches once.

The method used for matching is probably not intuitive but this is addressed in
a subsequent patch in this series.
2014-07-23 10:51:12 +09:00
Jonathan Griffin 1c5d8636ac Backed out changeset 64586374a208 on a CLOSED TREE 2014-07-22 18:29:57 -07:00
Alexandre Poirot 98afd25e0d Bug 1027242 - Blacklist mulet's failing tests + expose 'mulet' to ini files; fix previous bustage on a CLOSED TREE, r=ahal 2014-07-02 15:40:56 -07:00
Jonathan Griffin 38f79ff899 Backout 4f6d9db92389 for bustage on a CLOSED TREE 2014-07-22 17:55:50 -07:00
Mike Hommey bc5d6801bb Bug 1041860 - Avoid setting FINAL_LIBRARY to libraries that further use a FINAL_LIBRARY. r=mshal 2014-07-23 08:37:51 +09:00
Alexandre Poirot 37506aa45c Bug 1027242 - Blacklist mulet's failing tests + expose 'mulet' to ini files. r=ahal 2014-07-02 15:40:56 -07:00
Brian Birtles 223a177ee0 Bug 1033881 part 2 - Add tests to test_element-get-animation-players.html which checks for animation-name: missing; r=dbaron 2014-07-17 10:04:56 +09:00
Brian Birtles 9837c624e3 Bug 1032573 part 6 - Add tests for Element.getAnimationPlayers; r=dbaron 2014-07-16 09:02:31 +09:00
Brian Birtles 728dbd075d Bug 1032573 part 4 - Add AnimationTimeline::ToTimelineTime helper method; r=dbaron
This patch simply factors out the conversion from a TimeStamp value to
a nullable-double value relative to the start of the timeline. This is so that,
in a subsequent patch, this functionality can be reused by ElementAnimation
when it reports its start time (which is currently recorded as a TimeStamp).
2014-07-16 09:02:30 +09:00
Brian Birtles 7bb5ae0ed8 Bug 1032573 part 3 - Add AnimationTimeline::GetCurrentTimeStamp; r=dbaron
AnimationTimeline::GetCurrentTime returns the time value of the timeline as
a double. For internal calculations however it is more useful to get this as
a mozilla::TimeStamp.

This patch splits the calculation of the current time into two stages:
calculation as a timestamp then conversion to a double.
2014-07-16 09:02:30 +09:00
Benoit Jacob ec742680c8 Bug 1028588 - Fix dangerous public destructors in the rest of dom/ - r=ehsan 2014-06-23 15:56:07 -04:00
Brian Birtles 8e2dfae77b Bug 998246 part 5 - Add tests for AnimationTimeline; r=dholbert 2014-05-13 16:22:13 +09:00
Brian Birtles 3312bd13c9 Bug 998246 part 4 - Add currentTime member to AnimationTimeline; r=bz 2014-05-13 16:22:12 +09:00
Brian Birtles 09dc4937eb Bug 998246 part 2 - Add AnimationTimeline interface; r=bz, r=glandium 2014-05-13 16:22:12 +09:00