Commit Graph

178 Commits

Author SHA1 Message Date
Brian Birtles
eee37dc2bd 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
a66a1ea7b5 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
cbee07055c Bug 1040543 part 6 - Rename mAnimations to mPlayers and likewise for similar local variables; r=bz
Now that we have both AnimationPlayer and Animation in use we need to clarify
which object we are referring to. This patch renames a number of member and
local variables to better reflect whether they point to an AnimationPlayer or an
Animation.

This patch is mostly renaming only with one exception. Since we are touching
a number of local variables used in loops (for looping over the array of
animation players) we take the opportunity to replace a number of instances of
uint32_t with size_t since that is the preferred type for array indices now.
2014-08-10 17:06:48 +10:00
Brian Birtles
9403f55c91 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
fd89e49012 Bug 1040543 part 4 - Create Animation objects and set on AnimationPlayer; r=bz 2014-08-10 17:06:47 +10:00
Brian Birtles
f5e61ac556 Bug 1040543 part 2 - Rename ElementAnimationCollection to AnimationPlayerCollection; r=bz 2014-08-10 17:06:46 +10:00
Brian Birtles
b1759d304e 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
L. David Baron
e86e9d1a9b Bug 996796 patch 25 - Remove the old (now-unused) miniflush code (preserving one of the header comments). r=heycam 2014-08-06 22:58:44 -07:00
L. David Baron
0876ad393b Bug 996796 patch 23 - Make transition manager ignore StyleContextChanged notifications during an animation-only style update. r=heycam
This will be necessary when we use the restyle tracker for the
animation-only style flush.
2014-08-06 22:58:44 -07:00
L. David Baron
89ead0b4bb Bug 996796 patch 3 - Move the knowledge of when we last updated main-thread-suppressed animation styles into the restyle manager rather than have two separate but always equal timestamps for animations and transitions. r=birtles 2014-07-24 21:35:34 -07:00
Brian Birtles
8c171ff8b2 Bug 1036287 part 6 - Add a GetComputedTiming shortcut that uses the current animation timeline time; r=dholbert
This patch introduces a method GetComputedTiming that calls GetComputedTimingAt
supplying the current time of the animation's timeline.

We still keep the GetComputedTimingAt static method since it is used for
off-main thread animation. Furthermore, we keep the second argument to
GetComputedTiming--the animation's timing properties--since on some occasions we
want to override those properties (ElementPropertyTransition::ValuePortionFor
does this). We could also add another overload that also supplies the
animation's timing properties but that can happen as a separate step.
2014-07-16 09:02:33 +09:00
Brian Birtles
cb1c2b8db6 Bug 1036287 part 4 - Make GetLocalTime(At) get the current time automatically from the timeline; r=dholbert
This patch changes ElementAnimation::GetLocalTimeAt so that instead of taking
the current time as input, it uses the animation's mTimeline member to look up
the current time of the associated timeline. As a result of this, it is possible
to remove a few instances of querying the refresh driver for the current time.
Further instances are removed in subsequent patches.

Furthermore, in order to keep the use of time sources consistent, the mStartTime
of new transitions and animations is initialized with the current time from the
animation's timeline rather than with the latest refresh driver tick.
Since this time could, in future, be null, GetLocalTime(At) is updated to check
for a null start time.

GetLocalTimeAt is also renamed to GetLocalTime in the process.
2014-07-16 09:02:32 +09:00
Brian Birtles
00b3f67470 Bug 1036287 part 3 - Make GetLocalTimeAt return a nullable time duration; r=dholbert
Once we support arbitrary timelines which can return null current time values,
the local time of an animation can also become null so this patch updates
ElementAnimation::GetLocalTimeAt to return a Nullable<TimeDuration>.
Doing this also allows us to pass the result of GetLocalTimeAt directly to
GetComputedTimingAt.
2014-07-16 09:02:32 +09:00
Brian Birtles
928bc914e9 Bug 1032573 part 2 - Add a timeline member to ElementAnimations; r=dbaron
When we expose ElementAnimation objects to script they need to have a parent
object so they can be associated with a Window.

This patch adds a pointer from an ElementAnimation to its AnimationTimeline.
2014-07-16 09:02:30 +09:00
Brian Birtles
aa6189d49d Bug 1010067 - Whitespace fix to nsTransitionManager::FlushTransitions. No review.
This change was suggested in bug 1010067 comment 22 but somehow ended up in the
wrong patch when pushing.
2014-07-03 09:04:35 +09:00
Brian Birtles
5b2fa4efcf Bug 1010067 part 8 - Rename ElementData methods and members in CommonAnimationManager to ElementCollection; r=dbaron 2014-06-27 08:57:13 +09:00
Brian Birtles
eaac41e0ed Bug 1010067 part 7 - Rename instances of ElementAnimationCollection; r=dbaron 2014-06-27 08:57:13 +09:00
Brian Birtles
9e4d81e4f0 Bug 1010067 part 6 - Rename mozilla::css::CommonElementAnimationData to mozilla::ElementAnimationCollection; r=dbaron 2014-06-27 08:57:12 +09:00
Brian Birtles
0771a7d9a4 Bug 1010067 part 4 - Rename nsTransition to mozilla::StyleTransition; r=dbaron 2014-06-27 08:57:12 +09:00
Brian Birtles
8f71c54c7e Bug 1029370 part 2 - Make nsTransitionManager::FlushTransitions reuse GetComputedTimingAt; r=dholbert
This patch removes some redundant calculation of timing phases in
FlushTransitions by calling GetComputedTiming and using the definitions there.
2014-06-25 09:42:19 +09:00
Brian Birtles
2b0a950785 Bug 1010067 part 2 - Rename nsStyleAnimation.{h,cpp} to StyleAnimationValue.{h,cpp}; r=dbaron
--HG--
rename : layout/style/nsStyleAnimation.cpp => layout/style/StyleAnimationValue.cpp
rename : layout/style/nsStyleAnimation.h => layout/style/StyleAnimationValue.h
2014-06-24 15:29:54 +09:00
Brian Birtles
7621375179 Bug 1010067 part 1 - Rename nsStyleAnimation::Value to mozilla::StyleAnimationValue; r=dbaron
This patch also moves the static methods defined on nsStyleAnimation so that
they are part of StyleAnimationValue class.

Renaming nsStyleAnimation.h to StyleAnimationValue.h is performed in a separate
patch to simplify the diff (since some tools may not handle file renames
elegantly).
2014-06-24 15:29:54 +09:00
Brian Birtles
e16787cc55 Bug 1026302 part 5 - Make a common property dtor for CommonElementAnimationData; r=dbaron
This patch takes the two static methods ElementAnimationsPropertyDtor and
ElementTransitionsPropertyDtor and replaces them with a class static on
CommonElementAnimationData.
2014-06-24 15:29:53 +09:00
Brian Birtles
37a0234ba2 Bug 1026302 part 2 - Move PostRestyleForAnimation to CommonElementAnimationData; r=dbaron
This patch moves PostRestyleForAnimation from ElementAnimations to the base
class CommonElementAnimationData and makes use of it within nsTransitionManager.
2014-06-23 14:10:19 +09:00
Brian Birtles
f5f2dd7e5b Bug 1026302 part 1 - Move IsForElement and PseudoElement from ElementAnimations to CommonElementAnimationData; r=dbaron
IsForElement and PseudoElement are currently only defined on ElementAnimations
but could be used for transitions. This patch moves these methods to the common
base class CommonElementAnimationData and also makes use of PseudoElement within
nsTransitionManager.
2014-06-23 14:10:18 +09:00
Brian Birtles
96ea9a8d85 Backing out bug 1026302 for build bustage changesets 3e719e2cc1bd and 7a2b642bf77a 2014-06-23 11:26:59 +09:00
Brian Birtles
d95a8b7c55 Bug 1026302 part 2 - Move PostRestyleForAnimation to CommonElementAnimationData; r=dbaron
This patch moves PostRestyleForAnimation from ElementAnimations to the base
class CommonElementAnimationData and makes use of it within nsTransitionManager.
2014-06-23 10:48:01 +09:00
Brian Birtles
e1a2c170b9 Bug 1026302 part 1 - Move IsForElement and PseudoElement from ElementAnimations to CommonElementAnimationData; r=dbaron
IsForElement and PseudoElement are currently only defined on ElementAnimations
but could be used for transitions. This patch moves these methods to the common
base class CommonElementAnimationData and also makes use of PseudoElement within
nsTransitionManager.
2014-06-23 10:48:01 +09:00
Brian Birtles
7bcfb501cb Bug 1025709 part 12 - Remove ElementTransitions; r=heycam
This patch replaces all references to ElementTransitions (now that it is empty)
with references to the base class, CommonElementAnimationData. It also takes the
opportunity to tidy up some of the call sites in nsLayoutUtils since they no
longer need to differentiate between animations and transitions.
2014-06-20 12:39:26 +09:00
Brian Birtles
530d14feb3 Bug 1025709 part 11 - Make ElementPropertyTransition::ValuePortionFor reuse GetComputedTimingAt; r=heycam
In order to remove redundant code and generally make transitions less special,
this patch reworks ValuePortionFor to reuse the existing code for calculation
the fractional distance of within the animation interval.
2014-06-20 12:39:26 +09:00
Brian Birtles
5aba002a6b Bug 1025709 part 8 - Move CanPerformOnCompositorThread from ElementAnimations/ElementTransitions to the base class; r=heycam 2014-06-20 12:39:25 +09:00
Brian Birtles
04b8371079 Bug 1025709 part 7 - Move HasAnimationOfProperty from ElementAnimations/ElementTransitions to base class; r=heycam
This patch moves HasAnimationOfProperty to CommonElementAnimationData. It also
takes the chance to start removing some redundancy from nsLayoutUtils
/ ActiveLayerTracker. Some of this should never have been added in the first
place and some could have been removed earlier on but while we're fixing up
HasAnimationOfProperty it seems like an appropriate time to fix up its call
sites too.

Also, since HasAnimationOrTransition actually returns an object, not a bool, we
this patch renames it to GetAnimationsOrTransitions.
2014-06-20 12:39:25 +09:00
Brian Birtles
af843d9fd9 Bug 1025709 part 5 - Replace aIsThrottled bool value with an enum; r=heycam 2014-06-20 12:39:25 +09:00
Brian Birtles
ae594f7975 Bug 1025709 part 4 - Move EnsureStyleRuleFor from ElementTransitions and ElementAnimations to CommonElementAnimationData; r=heycam
Both ElementAnimations and ElementTransitions have an EnsureStyleRuleFor method.
The ElementAnimations version is a more general of the ElementTransitions one
with the exception that the ElementTransitions version checks for finished
transitions. This patch moves the code from ElementAnimations to
CommonElementAnimationData with one minor change: adding the checks for finished
transitions. The ElementTransitions version is removed.

Since the ElementAnimations version contains a second parameter, aIsThrottled,
callers of ElementTransitions must include this extra parameter. In
a subsequent patch we add an enum for this parameter to make call sites easier
to read.

The ElementAnimations version also sets the mNeedsRefreshes member so at the
same time we move mNeedsRefreshes to CommonElementAnimationData. Furthermore,
since the ElementAnimations version which we have adopted returns early if
mNeedsRefreshes is false, this patch ensures that when we call
EnsureStyleRuleFor from ElementTransitions::WalkTransitionRule, we set
mNeedsRefreshes to true first.

Another difference to account for is that the ElementTransitions version of
EnsureStyleRuleFor *always* sets mStyleRule (even if it doesn't add anything to
it) where as the ElementAnimations version only creates the rule when necessary
so we need to add a check to ElementTransitions::WalkTransitionRule that
mStyleRule is actually set before using it.
2014-06-20 12:39:24 +09:00
Brian Birtles
6607a15a60 Bug 1025709 part 2 - Add IsFinished() to ElementAnimation; r=heycam
One of the main differences in handling a list of transitions vs a list of
regular animations is that when we are dealing with a list of transitions we
need to check for transitions that have finished and are about to be discarded
but need to be retained temporarily to provide correct triggering of subsequent
transitions. Such transitions are marked as "removed sentinels" and are ignored
for most operations.

This patch moves the methods for setting and checking such transitions to the
base class ElementAnimation so that we can treat animations and transitions
alike without having to downcast or do obscure checks for mStartTime.IsNull()
(which equates to checking if the animation is a "removed sentinel" but is not
particularly clear).

In the process, this patch renames said methods to Is/SetFinishedTransition
since hopefully that is a little easier to understand at a glance.
2014-06-20 12:39:24 +09:00
Brian Birtles
292c410c9e Bug 1025709 part 1 - Move mDelay to AnimationTiming; r=heycam
This patch is the first part in preparing the way to merge ElementTransitions
with CommonElementAnimationData (which we'll eventually rename to something
nicer).

Here we move mTiming from CommonElementAnimationData to the AnimationTiming
struct. While this is not strictly necessary in order to do the later
refactoring it makes it simpler since it:

- Divides time calculation into calculation based on dynamic play state (the
  responsibility of animation players in Web Animations terms) and static
  author-specified timing parameters (a property of animations in Web Animations
  terms).
- In future we will probably put animations on the compositor during their
  delay phase so we will want the delay to be present in the AnimationTiming
  struct then.
- Makes AnimationTiming line up with the dictionary of the same name in Web
  Animations.
2014-06-20 12:39:23 +09:00
William Chen
4ea70e9814 Bug 1022741 - Use CrossShadowCurrentDoc() in Element::UpdateState. r=smaug 2014-06-10 14:41:31 -07:00
Brian Birtles
f22f27e127 Bug 1004871 part 2 - Add AnimationTiming struct, to encapsulate animation timing parameters; r=dholbert
Introduces a struct to store timing parameters for passing to
GetPositionInIteration. In future this struct is expected to be expanded to
include other timing parameters as well (based roughly on Web Animations'
"Timing" interface, hence the name AnimationTiming).
2014-05-28 16:51:49 +09:00
Brian Birtles
c5f689a020 Bug 1004383 part 4 - Move mAnimations to CommonElementAnimationData; r=dbaron
As a result, transitions are now stored using a pointer to the base class,
mozilla::ElementAnimation. We downcast to a transition only when necessary. No
error-checking of the result of AsTransition is performed since we only ever
call it on the mAnimations member of ElementTransitions.
2014-05-15 08:38:37 +09:00
Brian Birtles
e3859b3244 Bug 1004383 part 1 - Put StyleAnimation on the heap; r=dbaron
This patch takes StyleAnimation and makes it ref-counted heap object. This
should allow us to store StyleAnimation and its subclasses (transitions only
currently) in a consistent fashion (an array of base-class pointers).
Furthermore, this will be helpful if we want these things to be pointed to
from Javascript objects that may, for example, preserve their lifetime beyond
that of the element that currently owns them.

This patch also introduces a typedef for an array of refptrs to StyleAnimation
objects (and similarly for the subclass ElementPropertyTransition) to simplify
the code somewhat.
2014-05-15 08:38:37 +09:00
Benoit Jacob
2e1ef0025a Bug 1004098 - Make nsTArray use size_t in its interface (32bitness is fine as an internal detail) - r=froydnj, sr=bsmedberg 2014-05-08 21:03:35 -04:00
Cameron McCormack
dfc3049e3e Bug 992333 - Skip custom properties when looking for properties to transition. r=dbaron 2014-04-13 11:44:31 +10:00
Brian Birtles
e60cc1f28c Bug 880596 part 4 - Reuse ElementAnimation::HasAnimationOfProperty; r=dbaron
Now that ElementTransitionProperty inherits from ElementAnimation,
ElementTransitions::HasAnimationOfProperty can re-use
ElementAnimation::HasAnimationOfProperty in its definition of
ElementTransitions::HasAnimationOfProperty.

Similarly, in nsDisplayList::AddAnimationsAndTransitionsToLayer we can use this
method rather than drilling down to the appropriate segment by hand.
2014-04-03 14:57:27 +09:00
Brian Birtles
165671f347 Bug 880596 part 3 - Remove ElementPropertyTransition::IsRunningAt and mIsRunningOnCompositor; r=dbaron
Both ElementPropertyTransition and ElementAnimation specify an IsRunningAt
method which have the same purpose but with two subtle differences:

a) ElementPropertyTransition::IsRunningAt checks if the transition is a removed
sentinel and if so returns false. This patch adds a check for a null start time
to IsRunningAt since I think in future we will want to allow null times in
various places to represent, for example, animations that are not connected to
a timeline. (However, ultimately we will probably not allow start times on
*animations* to be null, only on their associated player.)

Should we later use a different mechanism for marking sentinel transitions (e.g.
a boolean flag) this method should still be correct as it checks if aTime is
inside the transition interval before returning true.

b) ElementPropertyTransition::IsRunningAt returns false if the transition is in
the delay phase, that is, waiting to start. This patch changes this behavior so
that transitions are considered running even if they are in the delay phase.
This brings their behavior into line with animations and removes the need for
the ElementPropertyTransition::mIsRunningOnCompositor since it is only used to
determine when a transition in the delay phase has begun.

ElementAnimation::IsRunningAt also handles pause state and iterations but this
logic should still be correct for transitions which, in this area, only use
a subset of the functionality of animations since their pause state is always
playing and their iteration count is 1.
2014-04-03 14:57:27 +09:00
Brian Birtles
400ebf0c64 Bug 880596 part 2 - Make ElementPropertyTransition inherit from ElementAnimation; r=dbaron
As part of moving towards more shared data structures for animation, this patch
makes ElementPropertyTransition inherit from ElementAnimation. At the same time
we switch from storing the target property, start/end values, start time, delay,
and timing function on the transition to the corresponding location in
ElementAnimation.

Since nsDisplayList::AddAnimationsAndTransitionsToLayer was already doing this
conversion in order to create animations to pass to the compositor thread, we
can remove the conversion code from there and just use the ElementAnimation data
structures as-is.

A number of assertions are added to verify that transitions are set up as
expected (namely, they have only a single property-animation with a single
segment). As we move to more generic handling of animations and transitions
these assertions should disappear.
2014-04-03 14:57:27 +09:00
Brian Birtles
af4841c2d2 Bug 880596 part 1 - Separate delay from start time for transitions; r=dbaron
As a first step towards making CSS animations and CSS transitions use the same
data structures, this patch aligns their behavior with regards to start time and
delay handling.

Previously, ElementAnimation objects maintained separate mStartTime and mDelay
members whilst ElementPropertyTransition objects maintained a single mStartTime
property that incorporated the delay. This patch adds an mDelay member to
ElementPropertyTransition and stores the delay and start time separately.
Calculations involving ElementPropertyTransition::mStartTime are adjusted to
incorporate mDelay.
2014-04-03 14:57:27 +09:00
Masayuki Nakano
abfbab58dd Bug 983049 part.5 Rename nsEventDispatcher to mozilla::EventDispatcher r=smaug
--HG--
rename : dom/events/nsEventDispatcher.cpp => dom/events/EventDispatcher.cpp
rename : dom/events/nsEventDispatcher.h => dom/events/EventDispatcher.h
2014-03-18 13:48:21 +09:00
L. David Baron
5edf98e9eb Bug 978712 - Prevent non-running transitions and animations (animations or transitions during their delay period, and animations after they finish) from repeatedly poking layer activity because we think we can run them on the compositor. r=heycam
This changes the behavior of the CanPerformOnCompositorThread methods of
both ElementAnimations and ElementTransitions to check that the
respective animations or transitions are actually running.  This is ok
because:
 - The main caller is nsLayoutUtils::HasAnimationsForCompositor, and all
   of its callers pretty clearly want the more restricted behavior (they're
   concerned with layer activity)
 - The only other callers of these functions are
   nsAnimationManager::FlushAnimations and
   nsTransitionManager::FlushTransitions (determining when to do
   throttling), nsAnimationManager::GetAnimationsForCompositor (whose
   only caller,
   nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer, also checks
   IsRunningAt).  I think these also all want or are fine with having
   the IsRunningAt check.

As to the actual changes:
 - In the animation manager, I think it's a mistake that
   ElementAnimation::IsRunningAt didn't already check
   mIterationDuration, since we throw out animations with a bad
   iteration-duration in ElementAnimations::EnsureStyleRuleFor.  So this
   makes that change as well.
 - In the transition manager, IsRunningAt already checks
   !IsRemovedSentinel().

I've confirmed in gdb on a device that this fixes the repeated
nsIFrame::SchedulePaint calls that were the symptom of this bug.

I believe this patch also makes it so that a short animation of a
property that can't be animated on the compositor doesn't prevent the
entire duration of the animation of a property that can from being
throttled (having the main thread style updates suppressed).
2014-03-06 22:08:57 -08:00
Masayuki Nakano
fb3875cd82 Bug 969219 Simplify constructor of InternalTransitionEvent r=smaug 2014-02-11 14:35:25 +09:00
Nicholas Cameron
baad7aecad Bug 914847. Mini-flush for animations. r=dbaron 2013-10-22 14:14:41 +02:00