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

96 Коммитов

Автор SHA1 Сообщение Дата
Jonathan Watt 9d8a4a932c Bug 1073379, part 4 - Rework the CSS animations event dispatch code to handle startTime shifting the animations back in time. r=dholbert 2015-02-13 15:58:33 +00: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
David Zbarsky 7e217619a6 Bug 1085769: Merge ContentOrAncestorHasAnimation/Transition r=birtles 2014-11-19 21:48:42 -05:00
David Zbarsky 8498454656 Bug 1085769: Merge RulesMatching, GetAnimationPlayers, and GetAnimationRule r=birtles 2014-11-19 21:48:41 -05: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 9acbbb6122 Bug 1073336 part 11 - Move GetAnimationPlayers to base CommonAnimationManager class; r=dbaron
nsAnimationManager provides GetAnimationPlayers while nsTransitionManager
provides GetElementTransitions. Both perform the same function, namely, fetching
(and optionally creating if it does not exist) the AnimationPlayerCollection for
the specified element/pseudo. Furthermore, both take the same arguments.

This patch aligns the method names and makes this a virtual method on the base
class CommonAnimationManager so that it can be used generically from a pointer
to a CommonAnimationManager.
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 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 6435d45744 Bug 1073336 part 1 - Move CheckNeedsRefreshes to CommonAnimationManager; r=dbaron
In order to add AnimationPlayerCollection::NotifyPlayerUpdated, collections
need a way of updating their managers to inform them that their mNeedsRefreshes
flag has changed and hence the manager may need to resume observing the refresh
driver.

Currently, only nsAnimationManager makes use of mNeedsRefreshes and provides
a CheckNeedsRefresh method. In order to allow AnimationPlayerCollection to
operate independently of the type of manager it is attached to (and because
there's a lot of similar code here that we eventually want to move to a common
manager anyway), this patch moves CheckNeedsRefreshes and associated
machinery to CommonAnimationManager.
2014-11-17 13:45:56 +09:00
L. David Baron e60f613f42 Bug 1087541 - Make RuleNodeWithReplacement handle animations and transitions like RulesMatching codepath does. r=birtles
I originally wrote this to see if it would fix bug 1086937, but it
didn't.

Note that this conflicts a bit with the patch in bug 1085769; whoever
lands second will have some merging (though it shouldn't be difficult).

The updating of the style rule is needed as part of the animation-only
style update, but it shouldn't be in the general restyling code, so it
has moved there.
2014-11-11 15:42:57 -08: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 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
David Zbarsky fd4c921077 Bug 1067701 - Implement Animation.target; r=birtles, r=bz 2014-10-02 15:14:15 +09: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
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
Ehsan Akhgari 5833657423 Bug 1055519 - Fix some more bad implicit constructors in layout and widget; r=roc 2014-08-20 00:58:22 -04:00
Brian Birtles d3002fb8dd Bug 1040543 part 2 - Rename ElementAnimationCollection to AnimationPlayerCollection; r=bz 2014-08-10 17:06:46 +10:00
L. David Baron 57a0eac1db 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
Brian Birtles f7c2a452ed 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 9454e09015 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 25fb32b91e 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 d8a8a8df73 Bug 1010067 part 6 - Rename mozilla::css::CommonElementAnimationData to mozilla::ElementAnimationCollection; r=dbaron 2014-06-27 08:57:12 +09:00
Brian Birtles 45a81560cb Bug 1010067 part 3 - Rename nsAnimation to mozilla::StyleAnimation; r=dbaron 2014-06-27 08:57:11 +09:00
Jan Beich 2e22bb3467 Bug 1029927 - Unbreak non-SPS build after bug 1026302. r=birtles 2014-06-24 18:13:00 +02:00
Brian Birtles d30c6f0f93 Bug 1026302 part 4 - Remove ElementAnimations; r=dbaron
This patch removes ElementAnimations and replaces all references to
ElementAnimations with references to CommonElementAnimationData.

We don't bother to rename variables like 'ea' or methods like
GetElementAnimations to correspond with the data type
(CommonElementAnimationData) since CommonElementAnimationData will soon be
renamed in bug 1010067 and we'll rename these things then.

The ElementAnimationsPropertyDtor function is renamed and merged in a subsequent
patch in this series.
2014-06-24 15:29:53 +09:00
Brian Birtles 4f5c10b649 Bug 1026302 part 3 - Move GetEventsAt to nsAnimationManager; r=dbaron
In order to unify ElementAnimations with CommonElementAnimationData we need to
find another home for GetEventsAt which is specific to queueing CSS Animation
events. For now nsAnimationManager seems an appropriate place and corresponds
more closely to the arrangement for transitions (where nsTransitionManager is
responsible for queueing the events by iterating over the list of animations).

In future we may reintroduce a subclass of animation specific to CSS Animations
that does this event queueing but for now nsAnimationManager seems to be a
suitable place.

This patch simply moves the code and replaces references to "mAnimation" with
"eEA->mAnimation". There are no functional changes.
2014-06-24 15:29:53 +09:00
Brian Birtles fd31104744 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 69e56c645b 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 516d813bbb Backing out bug 1026302 for build bustage changesets 3e719e2cc1bd and 7a2b642bf77a 2014-06-23 11:26:59 +09:00
Brian Birtles d01a278fc3 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 00e736ff46 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
Jan Beich e8a0a3bf5b Bug 1028036 - Unbreak clang build on BSD after bug 1025709, using the proper namespace declaration. r=birtles 2014-06-22 22:23:59 +02:00
Brian Birtles a722f517b1 Bug 1025709 part 9 - Move heavy lifting of GetAnimationsForCompositor from ElementAnimations/ElementTransitions to base class; r=heycam
This patch still leaves ElementAnimations|
ElementTransitions::GetAnimationsForCompositor as shortcuts
for the method now defined on CommonElementAnimationData.
2014-06-20 12:39:25 +09:00
Brian Birtles 67a80bcb08 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 f4c56d0897 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 e8729cc7fd Bug 1025709 part 6 - Reuse nsAnimationManager::EnsureStyleRuleFor; r=heycam
In a number of places in nsAnimationManager we have the following sequence of
calls:

  CommonElementAnimationData::EnsureStyleRuleFor
  ElementAnimations::GetEventsAt
  nsAnimationManager::CheckNeedsRefresh

nsAnimationManager::EnsureStyleRuleFor already does exactly that so we should
just reuse it.

At the same time we rename EnsureStyleRuleFor to UpdateStyleAndEvents since
that's a bit more accurate. It's also confusing to have two methods of the same
name (but on different objects) that don't exactly correspond in terms of
the scope of what they do.
2014-06-20 12:39:25 +09:00
Brian Birtles 0833cb3100 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 7265fd639b Bug 1004871 part 9 - Move ElementAnimations::GetPositionInIteration to ElementAnimation::GetComputedTimingAt; r=dholbert
This patch simply moves the code from ElementAnimations to ElementAnimation so
that it can later be used in transitions code and so we can later move
EnsureStyleRuleFor to ElementAnimation.
2014-05-28 16:51:50 +09:00
Brian Birtles 3ce242ee48 Bug 1004871 part 7 - Remove event queueing from GetPositionInIteration and do it in GetEventsAt; r=dholbert
This patch simply shifts the event-related code from GetPositionInIteration to
GetEventsAt. Although there are simplifications that could be done to
GetEventsAt, they are deferred to a subsequent patch so as not to obscure the
translation of code from one function to another.

As a result of moving event-related handling from GetPositionInIteration it no
longer needs to support different main-thread vs compositor modes.
2014-05-28 16:51:49 +09:00
Brian Birtles efbd693128 Bug 1004871 part 6 - Make GetPositionInIteration return a ComputedTiming object; r=dholbert
This patch makes ElementAnimations::GetPositionInIteration return
a ComputedTiming object instead of just a time portion (time fraction).

Since the ComputedTiming object includes phase information, we can fix those
parts of EnsureStyleRule and GetEventsAt that were temporarily using the time
portion to guess if the animation might have finished or not.
2014-05-28 16:51:49 +09:00
Brian Birtles 25641302e6 Bug 1004871 part 3 - Replace parameters to GetPositionInIteration with an AnimationTiming object; r=dholbert
This patch makes use of the AnimationTiming struct introduced in the previous
patch to simplify calls to ElementAnimations::GetPositionInIteration.
2014-05-28 16:51:49 +09:00
Brian Birtles b4d589de64 Bug 1004871 part 1 - Factor event queuing out of EnsureStyleRuleFor; r=dholbert
This patch moves event queuing out of EnsureStyleRuleFor into a separate method.
This is a preparatory step towards making GetPositionInIteration into a more
generic method for calculating the current time fraction.

In order to achieve this, GetPositionInIteration needs to be able to calculate
the correct time portion for times outside the range [0, 1] even when it is not
passed a ElementAnimation object. Specifically, it needs the fill mode of the
animation to be passed in.

(Rather than using FillForwards/FillBackwards this patch just compares the
NS_STYLE_ANIMATION_FILL_MODE_* values directly but FillForwards/FillBackwards
are restored in a subsequent patch when they are added to the struct used to
lump the timing parameters together.)

There are a number of places where positionInIteration is used to determine if
the current sample occurs in the active phase or after. This is sub-optimal but
is fixed in a subsequent patch in this series.

The actual work of removing event queuing from GetPositionInIteration is
deferred to a subsequent patch in order to keep the changes as small as
possible. This patch simply makes separate calls to GetPositionInIteration for
interpolating and for event queuing.
2014-05-28 16:51:48 +09:00
Brian Birtles 9c7f65de0d 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 92e305760e Bug 1004383 part 2 - Rename StyleAnimation to ElementAnimation; r=dholbert
We currently have mozilla::StyleAnimation as well as nsStyleAnimation. This
patch renames StyleAnimation back to ElementAnimation.

Although ElementAnimation is very similar to ElementAnimations, in the near
future we expect to retire ElementAnimations and replace it with a common
AnimationSet-like structure that is covers the features of ElementAnimations and
ElementTransitions.
2014-05-15 08:38:37 +09:00
Brian Birtles 7595a03399 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
Brian Birtles 016517a8be Bug 880596 part 8 - Rename ElementAnimation to StyleAnimation; r=dbaron
We need a basic representation of animations from which we can derive subclasses
to represent specific cases such as transitions. For now we will retrofit
ElementAnimation for that purpose hence renaming it to StyleAnimation.

This patch removes the "using namespace mozilla::layers" line from
AnimationCommon.cpp since the unified build system concatenates several files
together before compiling making using declarations like this leak into other
files potentially creating ambiguities. Previously, when we were calling
ElementAnimation, 'Animation', there were ambiguities between
mozilla::layers::Animation and this new 'Animation' class. In general, it is
probably a good idea to limit the scope of these using declarations so I've kept
that change.
2014-04-03 14:57:28 +09:00
Brian Birtles 70cf5d9db3 Bug 880596 part 7 - Move ElementAnimation to AnimationCommon; r=dbaron
This patch relocates ElementAnimation from nsAnimationManager.{h,cpp} to
AnimationCommon.{h,cpp} and in the process moves it into the mozilla::css
namespace.
2014-04-03 14:57:28 +09:00
Brian Birtles 32b1480e8c Bug 880596 part 5 - Make ElementAnimation::HasAnimationOfProperty no longer virtual; r=dbaron
ElementAnimation::HasAnimationOfProperty doesn't seem to be overridden anywhere.
I suspect it was a copy-paste mistake because the methods of the same name on
ElementAnimations, ElementTransitions, and CommonElementAnimationData are
virtual.
2014-04-03 14:57:28 +09:00
Brian Birtles 0717077492 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 843cf9276a Bug 975261 part 5 - Fix OMTA animations with backwards fill; r=dzbarsky
When we have a backwards fill and we sample at *exactly* the start of the
animation on the next refresh driver tick, when we get to
RestyleManager::ComputeStyleChangeFor (or more specifically
ElementRestyler::CaptureChange) we notice that the style hasn't changed (since
the first frame of the animation produces the same value as the backwards fill)
and end up with an empty change list. As a result we never schedule a view
manager flush and rebuild the layer. Hence, the animation never gets sent to the
compositor thread. On the next tick we're already throttling the main thread.

This patch fixes this by applying the same approach as is used for transitions,
that is, explicitly marking which animations are running on the compositor
thread so we know if we need to trigger a layer transaction or not. This should
not only be more robust than the previous code but also facilitate aligning
animations and transitions code (bug 880596).
2014-03-22 05:59:58 +08:00