Commit Graph

429 Commits

Author SHA1 Message Date
Boris Chiou
61c4d08674 Bug 1108055 - Part 4: Add ComputedTiming mochitests. r=birtles
Add test_animation-computed-timing.html in css-animations and
css-transitions.

--HG--
extra : rebase_source : 7bfee6909c7d929399cbdb2a2c462000b6215228
2015-11-02 00:37:00 +01:00
Boris Chiou
2c0d38d0d8 Bug 1108055 - Part 3: Implement GetComputedTiming method. r=birtles
Implement KeyframeEffectReadOnly::GetComputedTiming().

--HG--
extra : rebase_source : eae0dc0887bf559924ad96cead438d0e7eab9081
2015-10-23 00:48:00 +02:00
Boris Chiou
b2d9321540 Bug 1108055 - Part 2: Refine ComputedTiming. r=birtles
Do some minor revisions in struct ComputedTiming.
1. Use Nullable<double> mProgress, so remove the static const kNullProgress.
   The generated ComputedTimingProperties dictionary uses "Nullable" variable,
   so we replace the origin type in ComputedTiming to make it more consistent
   with that in ComputedTimingProperties dictionary.
2. Use scoped enums for AnimationPhase.

--HG--
extra : rebase_source : 31280c867a30e7bcdcfe831cbc72ca08c8ddc762
2015-10-19 00:38:00 +02:00
Boris Chiou
ba5bbe41ce Bug 1108055 - Part 1: Add ComputedTimingProperties dictionary. r=smaug
Add two dictionaries into AnimationEffectReadOnly.webidl:
1. AnimationEffectTimingProperties
2. ComputedTimingProperties
And then re-generate this class.

--HG--
extra : rebase_source : 81b2a3c08453cabcb2ac1334e6d4bde2c1bafeea
2015-10-13 22:17:00 +02:00
Brian Birtles
67a7daaa2f Bug 1216846 - Don't update hold time when completing a pause if it is already set; r=heycam
The Animation.pause() method operates asynchronously since, if the animation is
currently running on the compositor, we should wait for the animation to stop
on the compositor before establishing the pause time. Otherwise, if the
compositor is ahead of the main thread and we use the main thread's notion of
the current time to establish the pause time, the animation will jump backwards
when we take it off the compositor.

This pause time is represented using the "hold time".

However, when we have a finished animation, its current time is not advancing
but rather its current time is fixed to its end time. This too is represented
using the hold time. As a result, if we pause a finished animation we should
not update its hold time (by calculating the current time from the start time)
but just continue to use the existing hold time. This is true of any other
situation where we might have set the hold time before or during pausing.
2015-11-02 08:33:58 +09:00
Cameron McCormack
bce3927621 Bug 1216872 - Make 100% Keyframe returned by getFrames() have easing:linear. r=birtles 2015-10-22 19:22:38 +11:00
Cameron McCormack
50e5a35995 Bug 1208951 - Part 11: Tests. r=birtles 2015-10-22 19:22:38 +11:00
Cameron McCormack
44142b120c Bug 1208951 - Part 10: Make GetFrames aware of initial/final zero-length segments and discontinuities between segments. r=birtles 2015-10-22 19:22:38 +11:00
Cameron McCormack
235db06383 Bug 1208951 - Part 9: Implement KeyframeEffectReadOnly constructor. r=bzbarsky r=birtles 2015-10-22 19:22:38 +11:00
Cameron McCormack
50c4eb3b78 Bug 1208951 - Part 2: Use a comparator object instead of operator< on KeyframeValueEntry. r=birtles 2015-10-22 19:22:37 +11:00
Cameron McCormack
b746909966 Bug 1208951 - Part 1: Split half of KeyframeValueEntry into a base class. r=birtles
In a subsequent patch, we will have another struct like
KeyframeValueEntry, but storing an StyleAnimationValue and an
ComputingTimingFunction object (not a pointer).  So we split
KeyframeValueEntry into two, retaining the KeyframeValueEntry name for
the base class and naming the current one KeyframeStringValueEntry.
2015-10-22 19:22:37 +11:00
Brian Birtles
b4f581b39f Bug 1194639 part 8 - Report changes from calling pause() to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
b860019be5 Bug 1194639 part 7 - Report changes from calling play() to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
dc867a5d59 Bug 1194639 part 6 - Report changes from calling finish() to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
ea0acf6dda Bug 1194639 part 5 - Report changes from calling reverse() to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
1dac94b623 Bug 1194639 part 4 - Report changes to currentTime to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
66cb8a4081 Bug 1194639 part 3 - Report changes to startTime to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
eab83a05b4 Bug 1194639 part 2 - Report changes to playbackRate to animation mutation observers; r=heycam 2015-10-22 15:16:18 +09:00
Brian Birtles
5d800ef88f Bug 1194639 part 1 - Add AutoMutationBatchForAnimation; r=heycam 2015-10-22 15:16:18 +09:00
Nathan Froyd
01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Brian Birtles
6b03b4a52f Bug 1208938 part 3 - Update pending finishing handling; r=heycam
Animation::Tick contains special handling to cope with pending ready times
that are in the future. This was originally introduced to cope with the
situation where we are called multiple times per refresh-driver tick.

As of bug 1195180, Animation::Tick should no longer be called multiple
times per refresh driver tick. It would seem, therefore, that we no longer
need to check for a future time. However, since introducing this check, the
vsync refresh driver timer has been added which means that we can still have
a recorded time from TimeStamp::Now that is ahead of the vsync time used to
update the refresh driver. In that case, however, rather than waiting for the
next tick, we should simply clamp that pending ready time to the refresh driver
time and finish pending immediately.

This patch also updates one of the tests for reversing. With this updated
behavior we can sometimes arrive at a situation where when an Animation starts
and its ready promise resolves, its currentTime is still 0. If we call
reverse() at this point on an animation with an infinite active duration it
should throw an InvalidStateError. To avoid this situation, this test makes
sure we wait an extra frame before calling reverse().
2015-10-07 14:30:28 +09:00
Brian Birtles
0ea5e5c7c8 Bug 1208938 part 2 - Remove Animation::HasEndEventToQueue; r=heycam 2015-10-07 14:30:28 +09:00
Brian Birtles
9590e60a48 Bug 1208938 part 1 - Rename AnimationCollection::mNeedsRefreshes to mStyleChanging; r=heycam
This patch renames AnimationCollection::mNeedsRefreshes to indicate that it
no longer has any relationship to whether or not we observe the refresh driver.
2015-09-17 15:43:15 +09:00
Brian Birtles
ad657213b1 Bug 1208385 part 2 - Remove stored parent time from KeyframeEffectReadOnly and get the time directly from the owning animation; r=heycam 2015-10-07 14:30:28 +09:00
Brian Birtles
d89f0d836b Bug 1208385 part 1 - Store a pointer to the owning animation on each KeyframeEffect; r=heycam
We need to do this so effects can query their owning animation for the current
time and avoid falling out of sync. Furthermore, this pointer is needed
for a number of other bugs (e.g. bug 1166500 comment 12, or bug 1190235)
anyway.
2015-10-07 14:30:27 +09:00
Brian Birtles
08a8534ec0 Bug 1208385 part 0 - Fix up some references to Web Animations spec; r=heycam 2015-10-07 14:30:27 +09:00
Ryan VanderMeulen
5c1905cbf4 Bug 1209519 - Undef GetCurrentTime in DocumentTimeline.h to fix --disable-accessibility bustage. r=birtles
--HG--
extra : rebase_source : cec795042cf8b6e47209395ff18925d3d9e8d03c
2015-09-29 10:04:30 -04:00
Brian Birtles
9621365cd2 Bug 1208929 - Turn on -Wshadow for dom/animation; r=glandium
This patch also shuffles the order of LOCAL_INCLUDES and FINAL_LIBRARY to match
what most other moz.build files seem to do.
2015-09-29 13:22:24 +09:00
Cameron McCormack
260625c5e6 Bug 1198708 - Part 7: Tests. r=birtles 2015-09-29 12:20:14 +10:00
Cameron McCormack
c2e4c54592 Bug 1198708 - Part 6: Implement KeyframeEffectReadOnly.getFrames(). r=birtles,bzbarsky
Since getFrames() must gather all properties set at a given keyframe
offset time for a given easing function, we need to provide a total
ordering for ComputedTimingFunction objects.  Until the spec defines how
to do this, we sort first by NS_STYLE_TRANSITION_TIMING_FUNCTION_*
value, then second by the four values in a cubic-bezier() function (in
order) or the integer and optional keyword in a steps() function.

Because we don't support automatic spacing of keyframes yet,
ComputedKeyFrame.computedOffset is always the same as Keyframe.offset.

Another assumption made is that the value of easing for a Keyframe
object at 100% should be the same as the value from the previous
Keyframe for the same property.  An alternative would be to leave off
easing from that Keyframe, which would need the default value for that
IDL dictionary member removed (otherwise it would always be set to
"linear").
2015-09-29 12:20:14 +10:00
Cameron McCormack
45eb434b3e Bug 1198708 - Part 5: Add method to serialize a ComputedTimingFunction. r=birtles 2015-09-29 12:20:14 +10:00
Cameron McCormack
9293060eef Bug 1198708 - Part 1: Store exact timing-function type on nsTimingFunction and ComputedTimingFunction. r=birtles
Since Keyframe.easing should reflect the {transition,animation}-timing-
function value relevant to each keyframe, we'll need to store on
nsTimingFunction the specific timing function value that was used, and
copy it down into ComputedTimingFunction for
KeyframeEffectReadOnly.getFrames() to access.  This includes storing
whether the optional start/end keyword in a steps() function was
specified.
2015-09-29 12:20:13 +10:00
Brian Birtles
16b5c82dc9 Bug 1207951 - Fix buggy logic in ComposeStyle; r=heycam 2015-09-28 12:38:41 +09:00
Brian Birtles
820618158a Bug 1195180 part 9 - Add test for seeking finished -> paused; r=heycam
This patch adds a test that even when we seek from being irrelevant to another
state where we no longer need ticks that we still spin the refresh driver
in order to queue and dispatch an animationstart event.
2015-09-28 12:38:41 +09:00
Brian Birtles
36c16f7957 Bug 1195180 part 8 - Tick animations from their timeline; r=heycam 2015-09-28 12:38:41 +09:00
Brian Birtles
68cafe83b4 Bug 1195180 part 7 - Store animations in an array; r=heycam
Currently AnimationTimeline stores animations in a hashmap which means that
when we go to iterate over those animations to tick them we will visit them
in an order that is non-deterministic.

Although many of the observable effects of ticking an animation (e.g. CSS
animation/transition events, mutation observer events) are later sorted so that
the result does not depend on the order in which animations are ticked, this is
not true for in all cases. In particular, the order in which Animation.finished
promises are resolved will vary depending on the order in which animations are
ticked. Likewise, for Animation finish events.

Furthermore, it seems generally desirable to have a deterministic order for
visiting animations in order to aid reproducing bugs.

To achieve this, this patch switches the storage of animations in
AnimationTimeline to use an array instead. However, when adding animations
we need to determine if the animation to add already exists. To this end we
also maintain a hashmap of the animations so we can quickly determine if
the animation to add is a duplicate or not.
2015-09-28 12:38:41 +09:00
Brian Birtles
ae189d2746 Bug 1195180 part 6 - Lazily remove animations from timelines; r=heycam
Now that DocumentTimeline observes the refresh driver we can use regular
ticks to remove unnecessary animations.

We do this because in a subsequent patch, in order to provide deterministic
enumeration order when ticking animations, we will store animations in an array.
Removing an arbitrary element from an nsTArray is O(n) since we have to search
for the array index first, or O(log n) if we keep the array sorted. If we
destroy a subtree containing n animations, the operation effectively becomes
O(n^2), or, if we keep the array sorted, O(n log n). By destroying during a
tick when we are already iterating over the array, however, we will be able
to do this much more efficiently.

Whether an animation is newly associated with a timeline, or is disassociated
from a timeline, or if it merely has its timing updated, the behavior
implemented in this patch is to simply make sure we are observing the refresh
driver and deal with the animation on the next tick.

It might seem that we could be a lot more clever about this and, for example, if
an animation reports NeedsTicks() == false, not start observing the refresh
driver. There are various edge cases however that need to be taken into account.
For example, if a CSS animation is finished (IsRelevant() == false so that
animation will have been removed from the timeline), and paused
(NeedsTicks() == false), and we seek it back to the point where it is relevant
again, we actually need to observe the refresh driver so that it can dispatch an
animationstart event on the next tick. A test case in a subsequent patch tests
this specific situation.

We could possibly add logic to detect if we need to fire events on the next tick
but the complexity does not seem warranted given that even if we unnecessarily
start observing the refresh driver, we will stop watching it on the next tick.

This patch removes some rather lengthy comments from
AnimationTiming::UpdateTiming. This is, in part, because of the behavior
described above that makes these comments no longer relevant. Other parts are
removed because the Web Animations specification has been updated such that a
timeline becoming inactive now pauses the animation[1] so that the issue
regarding detecting timelines becoming active/inactive no longer applies
since animations attached to an inactive timeline remain "relevant".

[1] https://w3c.github.io/web-animations/#responding-to-a-newly-inactive-timeline
2015-09-28 12:38:41 +09:00
Brian Birtles
4ba3abb7d3 Bug 1195180 part 5 - Synchronize refresh driver observing with presshell creation/teardown; r=heycam 2015-09-28 12:38:40 +09:00
Brian Birtles
615fb3a648 Bug 1195180 part 4 - Unregister from refresh observer when there are no animations needing ticks; r=heycam 2015-09-28 12:38:40 +09:00
Brian Birtles
5e9be9d40a Bug 1195180 part 3 - Add flag to record if DocumentTimeline is observing the refresh driver; r=heycam 2015-09-28 12:38:40 +09:00
Brian Birtles
a12e08d26e Bug 1195180 part 2 - Make DocumentTimeline inherit from nsARefreshObserver; r=heycam 2015-09-28 12:38:40 +09:00
Brian Birtles
534ef7e86c Bug 1195180 part 1 - Add Animation::NeedsTicks; r=heycam
Adds a method to determine if an animation requires refresh driver ticks.
We will use this function later to determine when it is safe to stop
observing the refresh driver.
2015-09-28 12:38:40 +09:00
Hiroyuki Ikezoe
2c827fa03a Bug 1151694 - Part 6 - A test case of Animation.isRunningOnCompositor for transition. r=bbirtles
--HG--
extra : rebase_source : f5f8b6641d16ff3330139fe5b496f9982e00f69f
2015-09-15 16:50:00 +02:00
Hiroyuki Ikezoe
b71bdc2f2a Bug 1151694 - Part 5 - Additional tests for Animation.IsRunningOnCompositor. r=bbirtles
--HG--
extra : rebase_source : 04a43de598784076de58b3520297602cfbd48223
2015-09-15 16:49:00 +02:00
Hiroyuki Ikezoe
d1899602ba Bug 1151694 - Part 4 - Able to use testcommon.js in the window which has no opener. r=bbirtles
--HG--
extra : rebase_source : abfc9c175114d35e328568e73227064b8895b78d
2015-09-10 19:17:00 +02:00
Hiroyuki Ikezoe
41ec8da9f3 Bug 1151694 - Part 3: Manage mIsRunningOnCompositor flags for each properties respectively. r=bbirtles
--HG--
extra : rebase_source : d189d779ef14e8ae5497b03b01e3d4d994803fe1
2015-09-16 16:05:00 +02:00
Brian Birtles
8bf9ca19e0 Bug 1183461 part 3 - Add Animation::AnimationTimeToTimeStamp; r=heycam
This patch adds a utility method to Animation which takes a time in the
same time space as "current time", i.e. "animation time" and convert it to
a TimeStamp. Subsequent patches in this series will use this method to
take the time when an event was scheduled to occur and convert it to a
TimeStamp so it can be compared with other event times. This allows us to
dispatch events in the order they would have fired given an infinitely
frequent sample rate.

--HG--
extra : rebase_source : 0b4f98b932bb2751bac24b4383fe20613176f0c4
2015-09-15 14:04:08 +09:00
Brian Birtles
d135283802 Bug 1183461 part 1 - Move InitialAdvance to CSSAnimation; r=heycam
Currently we define a helper method, InitialAdvance, on KeyframeEffectReadOnly.
However, this method is only used for filling out the elapsedTime member of
AnimationEvents (which are generated by CSS animations). This patch moves this
method to CSSAnimation since it is unneeded for other types of Animations.

--HG--
extra : rebase_source : 9ab3b81a8272c004aabf26fea557c9a2f5d76caf
2015-09-15 14:03:24 +09:00
Brian Birtles
c49da97499 Bug 1203009 part 6 - Add tests for new composite order; r=heycam 2015-09-15 13:58:17 +09:00
Brian Birtles
1bb17c4634 Bug 1203009 part 5 - Remove IsUsingCustomCompositeOrder; r=heycam 2015-09-15 13:32:12 +09:00