Commit Graph

155 Commits

Author SHA1 Message Date
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
Benoit Girard
8d1918abe4 Bug 936864 - Fix logic error in async animation code. r=roc 2013-11-13 17:21:39 -05:00
Robert O'Callahan
2709003286 Bug 911889. Part 2: Refactor MarkLayersActive code into its own class and be much more explicit about what it does. r=mattwoodrow
This also changes the functionality a little bit to track independent
per-property mutation counts and independent "content active" status.
2013-09-04 23:30:57 +12:00
Phil Ringnalda
98204c9e49 Back out 0a88dee3b92b:dc5cc7d7b84d (bug 911889) for beaucoup unexpected assertions
--HG--
extra : rebase_source : a2a13633b6028c99a3c732dbbafe8c800bc32071
2013-10-28 23:38:02 -07:00
Robert O'Callahan
58a3ced7c4 Bug 911889. Part 2: Refactor MarkLayersActive code into its own class and be much more explicit about what it does. r=mattwoodrow
This also changes the functionality a little bit to track independent
per-property mutation counts and independent "content active" status.

--HG--
extra : rebase_source : e69b8e7a95d36720bd38d74f0789ede603e58a09
2013-09-04 23:30:57 +12:00
Wes Kocher
e6b33b27c3 Backed out changeset 87ee0a1865e4 (bug 914847) 2013-10-22 16:55:14 -04:00
Nicholas Cameron
51bcfeb92d Bug 914847. Mini-flush for animations. r=dbaron 2013-10-22 14:14:41 +02:00
Markus Stange
14e4217296 Bug 929362 - When refusing compositor animation during BuildLayer, set a property on the frame that disables all async animations on it forever. r=roc
--HG--
extra : rebase_source : 98c9b690a4842c19314dd46f5e531601b77fe527
2013-10-22 12:30:45 +02:00
Masayuki Nakano
0f80cb30f7 Bug 920377 part.6 Get rid of nsTransitionEvent r=roc 2013-09-27 15:20:55 +09:00
Masayuki Nakano
ad647cc182 Bug 912956 part.17 mozilla/ContentEvents.h should be included directly r=roc 2013-09-25 20:21:20 +09:00
Ehsan Akhgari
86a457baf2 Bug 916610 - Minimize the #includes in layout/style; r=roc 2013-09-15 21:06:52 -04:00
L. David Baron
b71f20bcdf Bug 900783: Make HasAnimationOfProperty return false in the refresh driver tick in which the transition completes. r=nrc
I don't know of any observable bug that this fixes, but the code without
this fix seems incorrect; the "removed sentinel" concept generally
requires that callers enumerating transitions check that they're not
enumerating the sentinel.

This ensures that HasAnimationOfProperty switches from returning true to
false in the first refresh cycle after the end of the animation rather
than the second.

I originally wrote this in
https://bugzilla.mozilla.org/show_bug.cgi?id=876626#c13 but it turned
out not to be related to that bug.
2013-09-09 12:21:24 +02:00
Ehsan Akhgari
5fa9157954 Bug 906790 - Minimize layout/base #includes; r=roc 2013-08-19 18:55:18 -04:00
L. David Baron
c857e1a9dd Bug 898888: Transition manager should use SetStyleContext rather than SetStyleContextWithoutNotification. r=nrc
While debugging bug 858937 I noticed that the transition manager was
calling nsIFrame::SetStyleContextWithoutNotification rather than
nsIFrame::SetStyleContext.  SetStyleContextWithoutNotification should
only be used for things that aren't really style changes, but are
instead changes we make during frame construction before things are
really initialized.  Anything that's really a dynamic style change, as
these are, should use SetStyleContext.

I realize I said the opposite in bug 780692 comment 186, and bz said the
same in bug 780692 comment 204, which is why this is the state that it
is.
2013-07-30 17:36:08 -07:00
L. David Baron
a187fb3edb Bug 896138 patch 4: Move restyle management code from nsCSSFrameConstructor to RestyleManager. r=heycam
This moves restyling management out of nsCSSFrameConstructor (thus
reducing its size), and keeps the restyling code closer together.

This is the first of two big chunks of code moved in this patch series.
A later patch in this series will move related code from nsFrameManager
into the same destination file.
2013-07-20 12:14:25 -07:00
Nicholas Cameron
f00949e74d Bug 878142; be more precise about removing the animation manager from the refresh driver. r=dbaron 2013-06-25 20:58:46 +12:00
L. David Baron
5f034ee3ca Bug 858937 patch 2: Make off-main-thread CSS transitions/animations code that should be using nsLayoutUtils::GetStyleFrame do so. r=nrc
The fixes to the miniflush code
(nsTransitionManager::UpdateThrottledStyle and UpdateAllThrottledStyles)
fix the case where we constructed totally incorrect style contexts for
outer table frames (which have special style contexts inheriting from
the table frame) during the miniflush, leading to inconsistent style
data and other bad things, when we should have been touching the style
on the table frame instead.

The fixes to the other OMTA codepaths lead to layer tests being
performed on the same frame that the styles will be applied to, and
probably fix real bugs (which would occur when animating opacity or
transform on a table).
2013-06-24 22:32:10 -07:00
Phil Ringnalda
42e2a3397c Back out 2332bb3fe186:10f70b8b04fe (bug 858937) for warnings-as-errors bustage
CLOSED TREE
2013-06-24 23:42:05 -07:00
L. David Baron
53bb786d27 Bug 858937 patch 2: Make off-main-thread CSS transitions/animations code that should be using nsLayoutUtils::GetStyleFrame do so. r=nrc
The fixes to the miniflush code
(nsTransitionManager::UpdateThrottledStyle and UpdateAllThrottledStyles)
fix the case where we constructed totally incorrect style contexts for
outer table frames (which have special style contexts inheriting from
the table frame) during the miniflush, leading to inconsistent style
data and other bad things, when we should have been touching the style
on the table frame instead.

The fixes to the other OMTA codepaths lead to layer tests being
performed on the same frame that the styles will be applied to, and
probably fix real bugs (which would occur when animating opacity or
transform on a table).
2013-06-24 22:32:10 -07:00
Catalin Iacob
4f03e5bb1a Bug 798914 (part 5) - Use newly introduced mozilla::MallocSizeOf instead of nsMallocSizeOfFun. r=njn.
--HG--
extra : rebase_source : fc472490dd978d165f02f77ed37f07aed6e5bb61
2013-06-23 14:03:39 +02:00
Nicholas Cameron
34713ce671 Bug 849399. Invalidate existing style rule if we start a transition. r=dbaron 2013-06-18 14:18:55 +12:00
Ryan VanderMeulen
2dc37e4d26 Backed out changesets a06a3cca82e8 and 711d46a1f67e (bug 849399) for frequent Android reftest-2 failures. 2013-06-12 15:23:23 -04:00
Nicholas Cameron
c1be4ff1f3 Bug 880075. Move def of pts in one scope since it is no longer used in the if statement and add comment; r=dbaron 2013-06-12 17:43:17 +12:00
Nicholas Cameron
24e638c8c5 Bug 849399. Invalidate existing style rule if we start a transition. r=dbaron 2013-06-12 17:39:42 +12:00