Commit Graph

369 Commits

Author SHA1 Message Date
Brian Birtles
735ff9144b Bug 1188251 part 11 - Add RestyleType::Layer; r=dholbert
We currently have a series of methods that clobber various bits of animation
state to force animations on layers to be updated. This aligns closely with
the restyle code introduced in this patch series.

By re-using RequestRestyle when updating animations on layers, not only should
we be able to simplify the code somewhat but, in future, we should also be able
to have Animation objects use the same mechanism to update layers during
a regular tick.

For example, currently we have a bug where when an animation starts after
a delay with the same value as the backwards fill then we don't send the
animation to the compositor right away (see
https://dxr.mozilla.org/mozilla-central/rev/d6ea652c579992daa9041cc9718bb7c6abefbc91/layout/style/test/test_animations_omta.html#287).
By adding this Restyle::Layer value we should be able to fix that in future.
2015-08-18 16:11:55 +09:00
Brian Birtles
0959beed1d Bug 1188251 part 9 - Request restyles from Animation::Tick; r=dholbert
In preparation for ultimately being able to run animations without a manager,
this patch moves the request restyle code from FlushAnimations to
Animation::Tick. (Ultimately most of this functionality should move to the
KeyframeEffect but for now Animation is fine.)
2015-08-18 16:11:55 +09:00
Brian Birtles
3801a43ea4 Bug 1188251 part 8 - Remove call to Animation::Tick from CheckAnimationRule; r=dholbert
We want to move the newly-introduced RequestRestyle call from FlushAnimations
to Animation::Tick. However, nsAnimationManager::CheckAnimationRule calls
Animation::Tick so this would cause us to start posting animation restyles
within a restyle.

Typically, Animations have an effect (currently there is only one type of
effect: KeyframeEffectReadOnly) and when there is any change in timing they
pass it down to their effect. However, the Animation is dependent on the
duration of the effect for determining if it is "finished" or not. As a result,
when an effect's timing changes, the owning Animation needs to know.

(The way this *should* work is that effects should tell their animation or
trigger some chain of events that causes animation's to update themselves.
However, the current implementation of effects is fairly primitive and does
not do this or even have a reference to the owning Animation. When we
implement the script API for updating the timing properties of effects we will
have to fix this but for now it is up to code in layout/style to update the
Animation when it touches the corresponding effect's timing.)

nsAnimationManager::CheckAnimationRule currently does this by calling
Animation::Tick() which ensures the Animation's finished state is updated
accordingly.

Ultimately we want to ensure that Animation::Tick is called exactly once per
frame (and at the appropriate point in that frame) so we'd like to remove this
call from CheckAnimationRule.

This patch achieves that by:

* Making Animation::SetEffect update the animation's timing - this is necessary
  for animations that are created by CheckAnimationRule and will be
  necessary when once we make Animation.effect writeable from script anyway.

* Calling Animation::SetEffect even for the case when we are updating the
  existing effect.

Another side-effect of calling Animation::Tick within
nsAnimationManager::CheckAnimationRule is that CSSAnimation::Tick queues
events. There are some tests (e.g. layout/style/test/test_animations.html) that
assume that animationstart events are dispatched immediately when new
animations are created. That will change with bug 1134163 but for now we
should maintain this existing behavior since changing this might introduce
compatibility issues that are best dealt with as a separate bug rather than
blocking this refactoring. To that end, this patch also explicitly queues
animationstart events for newly-created animations.
2015-08-17 13:59:45 +09:00
Brian Birtles
3181a27423 Bug 1181392 part 10 - Remove KeyframeEffect::IsFinishedTransition; r=dbaron 2015-08-07 12:29:36 +09:00
Brian Birtles
4c037e0122 Bug 1181392 part 3 - Remove use of IsFinishedTransition in KeyframeEffectReadOnly; r=dbaron
KeyframeEffectReadOnly uses IsFinishedTransition to exclude finished transitions
from certain tests. This check, however, is redundant in each case.
This is because any effect marked as IsFinishedTransition will have the
following properties:
- owning animation's PlayState() == Finished or Idle
- animation phase = after or null
- progress = null (this is because transitions don't fill forwards)
2015-08-07 12:29:35 +09:00
Brian Birtles
c74fcc3c54 Bug 1181392 part 2 - Remove use of IsFinishedTransition from Animation::ComposeStyle; r=dbaron
Animation::ComposeStyle uses IsFinishedTransition to skip doing work for
transitions that have run their course. We can, however, generalize this to
cover all animations that are not currently contributing to the animated
style--that is animations that are not "in effect".

We need to add this check *after* we update aNeedsRefreshes since an animation
that is not "in effect" because it has a delay and no backwards fill (in this
case it will have a play state of "running") still needs refreshes.
2015-08-07 12:29:35 +09:00
Brian Birtles
c9bbacc6bb Bug 1181392 part 1 - Remove use of IsFinishedTransition from Animation::CanThrottle; r=dbaron
Previously we used IsFinishedTransition so that if the only animations present
are finished transitions we could throttle the tick. In fact, this probably
shouldn't even be necessary since we shouldn't be calling CanThrottle if
AnimationCollection::mNeedsRefreshes is false. However, so long as we're
performing this test it turns out we can generalize this further and throttle
ticks for all finished animations that are not newly finished, regardless of
whether they are running on the compositor or not (although this method won't
be called unless the animation property could be run on the compositor anyway).

This method is somewhat confusing. For one, it is not strictly limited to
animations that are running on the compositor. It appears to only return true
when the animation is running on the compositor but the mIsRunningOnCompositor
flag doesn't get cleared when the animation finishes (bug 1151694). As a result
this method also deals with animations that are now running on the main thread.
This patch makes us deal with such animations more consistently.

This patch also reworks this method so that it's hopefully a little easier to
follow and a little more consistent since I spent several hours trying to
understand the different combinations of inputs this method could take and what
question it was trying to answer.
2015-08-07 12:29:35 +09:00
Brian Birtles
e4cb3c7353 Bug 1180125 part 2 - Move AnimationCommon classes out of CSS namespace; r=dbaron
The long-term plan is to drop the mozilla::css namespace altogether. Before we
go to much further with refactoring code in AnimationCommon, we should drop
usage of the mozilla::css namespace. Specifically, this patch moves the
CommonAnimationManager and AnimValuesStyleRule classes to the mozilla namespace.
2015-07-29 10:57:39 +09:00
Brian Birtles
4b7b196882 Bug 1180125 part 1 - Queue and dispatch CSS animation events as a separate step; r=dbaron
This patch prepares the way for script-generated events by making
event dispatch a separate process that happens after sampling animations.
This will allow us to sample animations from their associated timeline
(removing the need for a further manager to tracker script-generated
animations).

Furthermore, once we sample animations from timelines the order in which they
are sampled is likely to be more or less random so by making event dispatch at
separate step, we have an opportunity to sort the events and dispatch in
a consistent and sensible order. It also ensures that event callbacks will
not be run until all animations (including transitions) have been updated
ensuring they see a consistent view of timing properties.

This patch only affects event handling for CSS animations. Transitions will
be dealt with in a subsequent patch.
2015-07-29 10:57:39 +09:00
Hiroyuki Ikezoe
8e84ad1433 Bug 1178664 - Part 4 -Implement Animation.oncancel event. r=bbirtles, r=smaug 2015-07-30 23:26:00 +02:00
Hiroyuki Ikezoe
df3f6a345b Bug 1178664 - Part 3 - Implement Animation.onfinish event. r=bbirtles, r=smaug 2015-07-30 23:25:00 +02:00
Hiroyuki Ikezoe
4b19a7af6c Bug 1178664 - Part 1 - Make Animation interface EventTarget inheritance. r=smaug 2015-07-30 23:23:00 +02:00
Hiroyuki Ikezoe
2a1d28c96d Bug 1178665 - Part 3: Make finish notifications asynchronously in most cases. r=bbirtles, r=smaug 2015-07-29 23:21:00 +02:00
Hiroyuki Ikezoe
a264b3d06d Bug 1178665 - Part 2 - Adapt to latest Animation.finish procedure changes. r=bbirtles
ee99cc4db5
2015-07-14 21:45:00 +02:00
Carsten "Tomcat" Book
0aead8cf1c Backed out changeset 79bcd4f744c0 (bug 1180125) 2015-07-29 17:32:24 +02:00
Carsten "Tomcat" Book
8a8dda54b2 Backed out changeset a4fb4e4b1c8b (bug 1180125) 2015-07-29 17:32:19 +02:00
Brian Birtles
010c24e700 Bug 1180125 part 2 - Move AnimationCommon classes out of CSS namespace; r=dbaron
The long-term plan is to drop the mozilla::css namespace altogether. Before we
go to much further with refactoring code in AnimationCommon, we should drop
usage of the mozilla::css namespace. Specifically, this patch moves the
CommonAnimationManager and AnimValuesStyleRule classes to the mozilla namespace.
2015-07-29 10:57:39 +09:00
Brian Birtles
d78ef3ed78 Bug 1180125 part 1 - Queue and dispatch CSS animation events as a separate step; r=dbaron
This patch prepares the way for script-generated events by making
event dispatch a separate process that happens after sampling animations.
This will allow us to sample animations from their associated timeline
(removing the need for a further manager to tracker script-generated
animations).

Furthermore, once we sample animations from timelines the order in which they
are sampled is likely to be more or less random so by making event dispatch at
separate step, we have an opportunity to sort the events and dispatch in
a consistent and sensible order. It also ensures that event callbacks will
not be run until all animations (including transitions) have been updated
ensuring they see a consistent view of timing properties.

This patch only affects event handling for CSS animations. Transitions will
be dealt with in a subsequent patch.
2015-07-29 10:57:39 +09:00
Hiroyuki Ikezoe
b42820456a Bug 1186684 - Remove unused ErrorResult in Animation::SetPlaybackRate/SilentlySetPlaybackRate. r=bbirtles 2015-07-23 02:55:00 -04:00
Brian Birtles
8ea5b02209 Bug 1182981 part 2 - Use nsTHashtable::Iterator in AnimationTimeline; r=njn 2015-07-21 10:47:23 +09:00
Brian Birtles
9a4df31364 Bug 1182981 part 1 - Use nsTHashtable::Iterator in PendingAnimationTracker; r=njn 2015-07-21 10:47:13 +09:00
Brian Birtles
dc0e1274e7 Bug 1168759 - Disable test_deferred_start.html on B2G debug emulator; r=ryanvm 2015-07-21 10:47:02 +09:00
Birunthan Mohanathas
e52329c788 Bug 1182996 - Fix and add missing namespace comments. rs=ehsan
The bulk of this commit was generated by running:

  run-clang-tidy.py \
    -checks='-*,llvm-namespace-comment' \
    -header-filter=^/.../mozilla-central/.* \
    -fix
2015-07-13 08:25:42 -07:00
Hiroyuki Ikezoe
b1c987adff Bug 1182931 - Expose assert_unreached in subwindows. r=bbirtles 2015-07-12 17:04:00 +02:00
Ehsan Akhgari
988febd399 Bug 1113086 follow-up: Add a forward declaration to fix build bustage 2015-07-10 20:49:32 -04:00
Carsten "Tomcat" Book
0eeb1ca3f5 Backed out changeset 91846db1056c (bug 1113086) 2015-07-11 14:13:36 +02:00
Ehsan Akhgari
00054da590 Bug 1113086 follow-up: Add a forward declaration to fix build bustage 2015-07-10 21:09:08 -04:00
Hiroyuki Ikezoe
07d5954a67 Bug 1150808 - Implement Animation.reverse(). r=smaug r=birtles 2015-07-09 22:54:00 +02:00
Hiroyuki Ikezoe
59df058305 Bug 1181905 - Animation::IsPlaying should check playbackRate != 0 to stop playing on compositor animation. r=bbirtles 2015-07-09 20:54:00 +02:00
Brian Birtles
df99d6e31d Bug 1150810 part 16 - Add tests for AnimationTimeline.getAnimations(); r=jwatt 2015-06-15 11:05:43 +09:00
Brian Birtles
728332e869 Bug 1150810 part 15 - Add a comment about need to store more than just relevant animations; r=jwatt
We'll likely address this as part of bug 1151731 when we sample animations from
their timeline.
2015-06-15 11:05:43 +09:00
Brian Birtles
b3b286bc91 Bug 1150810 part 14 - Don't return animations targetting pseudo-elements; r=jwatt 2015-06-15 11:05:43 +09:00
Brian Birtles
8e773aba10 Bug 1150810 part 13 - Sort the result of AnimationTimeline::GetAnimations; r=jwatt 2015-06-15 11:05:43 +09:00
Brian Birtles
1044b8c708 Bug 1150810 part 12 - Flush styles in AnimationTimeline::GetAnimations(); r=jwatt 2015-06-15 11:05:43 +09:00
Brian Birtles
b6e612666f Bug 1150810 part 11 - Add some assertions to AnimationTimeline::GetAnimations; r=jwatt 2015-06-15 11:05:43 +09:00
Brian Birtles
f967d3dad9 Bug 1150810 part 10 - Add AnimationTimeline::GetAnimations; r=jwatt; r=smaug
This patch also removes the (commented-out) play() method from the
AnimationTimeline.webidl since it has been removed from the spec.
2015-06-15 11:05:43 +09:00
Brian Birtles
b28f292a64 Bug 1150810 part 9 - Add relevant animations to timeline; r=jwatt
We only store relevant animations on the timeline. Relevant animations are
any animations that are running or yet to run ("current animations") or
which have finished but are still applying a fill mode ("in effect animations").

AnimationTimeline.getAnimations() only ever returns relevant animations so
this is the minimum set we need to keep track of. Keeping track of any more
than this would prevent us from garbage-collecting any no longer relevant
animations since we keep a strong reference to this animations.

The reason we keep a strong reference is that if an animation is attached to
a timeline, even if there are no references to it from script or markup it
needs to be kept alive in order to dispatch events or resolve promises. An
irrelevant animation however is not going to do either of these things without
outside intervention so we don't need to keep it alive.
2015-06-15 11:05:43 +09:00
Brian Birtles
986793f780 Bug 1150810 part 8 - Add AnimationTimeline::AddAnimations/RemoveAnimations; r=jwatt 2015-04-28 16:41:09 +09:00
Brian Birtles
12879b1348 Bug 1150810 part 7 - Add Animation::SetTimeline; r=jwatt 2015-04-28 17:21:58 +09:00
Brian Birtles
ad5ac012b2 Bug 1150810 part 6 - Rename Timeline() to GetTimeline(); r=smaug
This is in anticipation of adding Animation::SetTimeline(). Once we set the
timeline out of band, there's a chance that getting it could return null so
this patch makes the WebIDL and method name reflect that.
2015-04-28 16:25:07 +09:00
Brian Birtles
d3efa42100 Bug 1150810 part 5 - Handle Timeline() returning null; r=jwatt 2015-04-28 12:49:12 +09:00
Brian Birtles
cd630f438e Bug 1150810 part 4 - Store global on Animation; r=smaug, jwatt
The connection between an Animation and an AnimationTimeline is optional. That
is, it is possible to have an Animation without an AnimationTimeline. Until now
we have often just assumed the timeline will be set but eventually we need to
support the possibility of the timeline being null. Indeed, later in this patch
series we will set the timeline out-of-band (i.e. not in the constructor) using
SetTimeline which opens up the possibility that timeline will be null for
a period of time.

This patch paves the way for having an optional timeline by storing the global
used for, e.g. creating promises, on the Animation object itself.
2015-04-28 15:48:35 +09:00
Brian Birtles
70ca5ce014 Bug 1150810 part 3 - Make IsPossiblyOrphanedPendingAnimation return true when there is no rendered doc; r=jwatt
This appears to be an existing bug.
2015-04-28 15:47:45 +09:00
Brian Birtles
128bbb53ef Bug 1150810 part 2 - Replace references to DocumentTimeline with AnimationTimeline; r=jwatt
This is needed not only for supporting other kinds of timelines, but also for
when we come to implement SetTimeline(AnimationTimeline* aTimeline).
2015-04-28 11:29:13 +09:00
Brian Birtles
3b62eec6f6 Bug 1150810 part 1 - Move DocumentTimeline methods up to AnimationTimeline; r=jwatt
This is not strictly necessary yet but we will want to implement methods
like GetAnimations() on the base class, AnimationTimeline, so we may as well do
that now rather than adding that code to DocumentTimeline and moving it later.
2015-04-28 11:17:10 +09:00
Brian Birtles
a44ee78b26 Bug 1171817 part 14 - Add AnimationPtrComparator class; r=dbaron
Having created composite ordering methods for the different kinds of animations
this patch adds a Comparator class so that they can be used to sort an
array of such animations.

This patch uses this Comparator object to sort the results returned by
Element.getAnimations. For this case, the order in which we create animations
and transitions happens to almost perfectly correspond with the composite
ordering defined so that no sorting is necessary.

One exception is that some -moz-* transitions may be created after transitions
that they should sort before when sorting by transition property. In this
case the sorting added in this patch should ensure they are returned in the
correct sequence.

Unfortunately, we can't easily test this since the test files we have are
intended to be cross-browser (where -moz-* properties won't be supported).

Once we implement AnimationTimeline.getAnimations (bug 1150810) we'll have
a better opportunity to test this sorting. For now, the added tests in this
patch just serve as a regression test that the sorting hasn't upset the
already correct order (and an interop test in future once we move them to
web-platform-tests).
2015-06-09 11:13:54 +09:00
Brian Birtles
83a5e09a6a Bug 1171817 part 9 - Add override of HasLowerCompositeOrderThan for CSS animations; r=dbaron
This patch also extends the tests for Element.getAnimations(). It doesn't
actually exercise the code added (it's not actually called yet since it doesn't
need to be for Element.getAnimations) but simply provides a useful regression
and interop test.
2015-06-09 11:13:54 +09:00
Brian Birtles
0e6a90b51b Bug 1171817 part 8 - Override sequence numbers for CSS animations; r=dbaron
This patch re-uses Animation::mSequenceNum to store the index of CSS animations
within their corresponding animation-name property. When the animation is
removed from an animation-name property it reverts to using the default
animation composite order.

This patch also updates Animation::DoCancel to call UpdateTiming instead of
UpdateEffect. This is because UpdateTiming is responsible for updating the
sequence number (when custom composite order is not in effect). When we remove
an animation from animation-name it will be cancelled and at that point we
expect its sequence number to be cleared which will only happen if
UpdateTiming gets called.
2015-06-09 11:13:54 +09:00
Brian Birtles
e1086a0caf Bug 1171817 part 7 - Add Animation::IsUsingCustomCompositeOrder; r=dbaron
Add a virtual method we can use to determine when an animation is having its
sequence number set by some other mechanism than the general logic
defined for animations.

This allows CSS animations and transitions to re-use the sequence number for
their own purposes. Typically what will happen is something like this:

1. A CSSAnimation is created corresponding to an item in the animation-name
   property.

   At this point CSSAnimation::IsUsingCustomCompositeOrder() will return true
   and nsAnimationManager will set the sequence number based on the position of
   the animation in animation-name.

2. If at a later point the animation is removed from the animation-name but kept
   alive by script, CSSAnimation::CancelFromStyle will be called which will
   clear the custom sequence number (i.e. set it to kUnsequenced) and also
   update the CSSAnimation's state such as
   CSSAnimation::IsUsingCustomCompositeOrder() returns false.

3. Then, then the CSSAnimation next transitions out of the idle state it will
   have its sequence number set just like any other Animation and be ordered
   like any other Animation (since we can no longer use animation-name to
   determine its composite order).

This behavior is added in subsequent patches in this series (and likewise for
CSS transitions too).
2015-06-09 11:13:54 +09:00
Brian Birtles
140b2f4296 Bug 1171817 part 6 - Add Animation::HasLowerCompositeOrderThan; r=dbaron
This patch introduces a method that will be used for sorting animations based on
their composite order. The method is based on the API for Comparator objects (as
used by nsTArray and co.) which have a LessThan method. (For the
Comparator::Equals method we can used pointer equality since no two independent
objects should have equal composite order.)
2015-06-09 11:13:53 +09:00