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.
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).
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.
Bug 1004871 part 4 - Move FillsForwards/FillsBackwards to AnimationTiming; r=dholbert

This patch moves the FillsForwards/FillsBackwards methods previously defined on
ElementAnimations to the structure contain the fill mode: AnimationTiming. It
also changes GetPositionInIteration to use these methods.
Bug 1004871 part 5 - Add ComputedTiming data structure; r=dholbert

This patch adds a ComputedTiming struct for storing the results of calculating
the timing properties of an animation at a given sample time.
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.
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.
Bug 1004871 part 8 - Simplify ElementAnimations::GetEventsAt; r=dholbert

This patch shuffles the code in ElementAnimations::GetEventsAt to make it easier
to follow.

It also removes a check for whether or not the animation is paused.
Previously we would not dispatch events if the animation was paused and in its
active phase (but we would if the animation had finished). There doesn't seem to
be any reason for this. If the animation was paused between the last sample and
the current sample and the boundary of an iteration also occurred in that time
then I expect we should dispatch that event. Removing this check for the pause
state does not cause any tests fail.

Separating out the event logic here makes it clear that we do not dispatch start
events in the situation where one sample falls before the active interval and
one sample falls after it (filed as bug 1004361). This patch adds a comment to
this effect.
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.
Bug 1004871 part 10 - Stop passing a fill mode of "both" to GetComputedTimingAt for throttled samples; r=dholbert

This was only needed when we were inspecting the returned time fraction but now
that we inspect the phase it's not necessary to force the fill mode to "both".
Bug 1004871 part 11 - Move ElementAnimation members closer together for readability and packing; r=dholbert

Also shuffle the initialization of members in
nsAnimationManager::BuildAnimations to roughly match the order in which they
are declared (with the exception that mPlayState needs to be set before calling
IsPaused() which is used to set mPauseStart).
Bug 1015803 - Align Layers' Animation.numIterations with AnimationTiming.mIterationCount; r=dholbert

In the IPC Animation struct used in layers code we have a member called
'numIterations' where 'iterate forever' is represented by -1.

In layout/style however we have an AnimationTiming struct with an
mIterationCount member where 'iterate forever' is represented by
NS_IEEEPositiveInfinity().

This patch renames 'numIterations' to 'iterationCount' and uses infinity to
represent 'iterate forever'.
Bug 1004361 - Dispatch animationstart events as well when skipping entire animation intervals; r=dholbert