Commit Graph

112 Commits

Author SHA1 Message Date
Brian Birtles
a920efd572 Back out parts 22-29 from bug 927349 for causing intermittent test failure in css-animations/test_animation-pausing.html on 10.8 2014-12-26 11:54:43 +09:00
Brian Birtles
f7d63236d2 Bug 927349 part 29 - Disable failing browser_555547.js on Windows opt - pushed again without backing out parts 22-29 at the same time; r=me
In https://hg.mozilla.org/integration/mozilla-inbound/rev/3ab2ff9b9f94
I accidentally pushed part 29 along with a backout for parts 22-29. This patch
reverts that change.

If this changset causes problems, the following changesets should be backed out:

https://hg.mozilla.org/integration/mozilla-inbound/rev/477f46897b0b
https://hg.mozilla.org/integration/mozilla-inbound/rev/6c345954bce5
https://hg.mozilla.org/integration/mozilla-inbound/rev/642e400b22a9
https://hg.mozilla.org/integration/mozilla-inbound/rev/9bdf7c2279fa
https://hg.mozilla.org/integration/mozilla-inbound/rev/79cac8c71159
https://hg.mozilla.org/integration/mozilla-inbound/rev/cfe757e478d5
https://hg.mozilla.org/integration/mozilla-inbound/rev/eaf834051cbd
2014-12-26 08:49:20 +09:00
Brian Birtles
ee653f7631 Bug 927349 part 29 - Disable failing browser_555547.js on Windows opt; r=me (as discussed with jwatt) 2014-12-25 16:31:55 +09:00
Brian Birtles
825410b2e4 Bug 927349 part 26 - Add a test for compositor animations with a delay; r=nical
This patch adds a test that we correctly incorporate the delay when setting
a layer animation's initialCurrentTime.

The notion of 'current time' on layer animations differs from that on main
thread animations in that it does not incorporate the animation delay.
Instead, we wait until an animation's delay has complete before putting it
on the layer and then it we add without delay.

For animations that are still waiting to start we need to factor this delay into
the initialCurrentTime stored on the layer animation so that when we update
the animation's start time it represents the time *after* the delay has
finished. Previously we failed to do this but no tests failed since all existing
tests for delay rely on DOMWindowUtils.advanceTimeAndRefresh which avoids this
particular code path (since we don't add pending animations to layers while
the refresh driver is under test control).

This patch adds a test for animation delay that does not rely on
DOMWindowUtils.advanceTimeAndRefresh which has been confirmed to fail if we
don't incorporate the delay in our calculation of initialCurrentTime.
2014-12-25 16:28:25 +09:00
Brian Birtles
4afa75dffb Bug 927349 part 25 - Test cancelling of players; r=heycam 2014-12-25 16:28:24 +09:00
Brian Birtles
effd1cb201 Bug 927349 part 24 - Add a test that empty animations still start; r=heycam 2014-12-25 16:28:24 +09:00
Brian Birtles
319654e355 Bug 927349 part 23 - Wait on player.ready on test_running_on_compositor.html; r=jwatt 2014-12-25 16:28:24 +09:00
Brian Birtles
5a254139d4 Bug 927349 part 22 - Make AnimationPlayer wait for animations to be rendered before starting; r=jwatt
This patch (finally!) introduces the delayed start behavior. It updates
AnimationPlayer::DoPlay to put animations in the PendingPlayerTracker from
where they are triggered.

This patch also updates nsTransitionManager to set the animation's source
before calling Play as otherwise the AnimationPlayer won't be able to access
the pending player tracker (which it locates by navigating AnimationPlayer ->
Animation (source content) -> target element -> composed doc -> pending player
tracker). In future, when we support setting the AnimationPlayer.source property
we will make this more robust so that the order in which these steps are
performed doesn't matter.

This patch also updates a couple of tests to reflect the fact that
AnimationPlayer will now return the pending state.
2014-12-25 16:28:24 +09:00
Brian Birtles
df0ed85e37 Bug 927349 follow-up to (hopefully) fix breakage from GetCurrentTime on non-unified Windows build on a CLOSED TREE 2014-12-22 13:16:11 +09:00
Brian Birtles
311bcb5dde Bug 927349 part 21 - Factor out AnimationPlayer::UpdateSourceContent; r=jwatt
In the future we will want to specifically just update source content without
necessarily triggering any other actions that might take place on a tick (like
queuing events).
2014-12-22 09:35:42 +09:00
Brian Birtles
a8e1f5993f Bug 927349 part 19 - Don't add pending animations to layers when their refresh driver is under test control; r=jwatt 2014-12-22 09:35:42 +09:00
Brian Birtles
efbd8be28e Bug 927349 part 16 - Do a full reflow when we have pending animations; r=jwatt
We want to time animations from when their first frame is painted. However,
interruptible reflow complicates this since, for a given set of pending
animations, some may be painted whilst others are not. To simplify this we
simply force an uninterruptible reflow when we have animations that are
waiting to start.
2014-12-22 09:35:41 +09:00
Brian Birtles
8f67d51546 Bug 927349 part 15 - Schedule a paint when a new pending animation is added; r=jwatt
We would like to trigger animations from the point when the first frame of the
animation is painted. However, some animations will never trigger a paint (e.g.
animations with an empty keyframes rule). These animations should start start
however. To ensure this, whenever an animation is newly pending we schedule
a paint.
2014-12-22 09:35:41 +09:00
Brian Birtles
447dc9b5b0 Bug 927349 part 14 - Store reference to owning document on PendingPlayerTracker; r=jwatt
This patch adds a reference from PendingPlayerTracker back to the document
object that owns it. This is used in the next patch in this series to find the
document's root frame for scheduling a paint.
2014-12-22 09:35:41 +09:00
Brian Birtles
e1b048341b Bug 927349 part 9 - Add PendingPlayerTracker::StartPendingPlayers; r=jwatt 2014-12-22 09:35:41 +09:00
Brian Birtles
7491d80346 Bug 927349 part 8 - Fast-forward the timeline before resolving start times; r=jwatt
Normally animation players get times from their timeline which is based on the
refresh driver for their associated document. However, for animations that
we time from when their first frame has been rendered, we want to record the
actual time when painting finished as their start time. If we wait until the
next refresh driver tick then the delay between playing an animation and its
actual start will be too great.

In this patch, we introduce a mechanism for fast-forwarding a timeline to a
time between the current refresh driver time and the next refresh driver tick.
By adjusting the timeline rather than the player we maintain a consistent state
(in fact, if we just naively set the animation player start time to the
timestamp value we recorded when painting finished it will appear to start in
the future and the animation will temporarily jump from playing, to waiting to
start, then back to playing again on the next refresh driver tick).

To be completely consistent, however, when we fast-forward the timeline we
should tell all animation players listening to the timeline to mark their
target element as needing a style flush. Otherwise we may be able to observe an
inconsistency between some animation players' current time and the computed
style of their targets.

We don't, however, currently know which players are observing a given timeline.
We will likely introduce that in the near future (in order to implement
AnimationTimeline.getAnimationPlayers) and fix the inconsistency in timing then.
A test later in the patch series verifies this inconsistency so it is easy to
fix in future.

An alternative approach would be to simply record the time when animation should
start, send that time to the compositor but don't actually update the animation
start time on the main thread until the subsequent refresh driver tick. Such
an approach is complex as it introduces an additional state--"finished pending
but not yet started". We will attempt to switch to that approach in bug 1112480.
2014-12-22 09:35:41 +09:00
Brian Birtles
d603de6d36 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
eaf8eca4e5 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
10e4d7931c 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
0f4c322ad3 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
3a6cb969ee 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
e13569f368 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
0314261380 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
ff213fc773 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
2667ce66c5 Bug 1104435 part 8 - Add tests for AnimationPlayer.ready; r=heycam 2014-12-18 08:42:40 +09:00
Brian Birtles
0ccfb345fc 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
f8ae3984bc 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
e247b45dab 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
315ad16b5e 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
7ad2328010 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
533ba7ea02 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
3a1c92a1f8 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
cb7027688a Bug 1107351: Simplify logic in AnimationPlayer::GetCurrentTime(). r=birtles 2014-12-04 12:13:38 -08:00
Brian Birtles
8ca0dc9e19 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
1cc2e368cf 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
a77f99aea6 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
01618f35ef 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
ee7abcb854 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
36df4e1930 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
258fe87ae2 Bug 1073336 part 15 - Switch AnimationPlayer to using less aggressive update mechanism; r=dbaron 2014-11-17 13:46:00 +09:00
Brian Birtles
10f93ddcd9 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
0fdbb3e9cf 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
4decffbf8a 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
c7834a8d76 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
2ad427951a 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
b44c27da59 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
fa2ebddf91 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
f71c3c8dee 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
ce354c28fb Bug 1078122 part 8 - Use the new GetTarget overload in AnimationPlayer; r=dholbert 2014-10-20 13:55:47 +09:00
Brian Birtles
f9ea9d1df5 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