2010-07-01 05:54:29 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2009-10-08 07:22:42 +04:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-10-08 07:22:42 +04:00
|
|
|
|
|
|
|
/* Code to start and animate CSS transitions. */
|
|
|
|
|
|
|
|
#include "nsTransitionManager.h"
|
2012-12-12 01:12:43 +04:00
|
|
|
#include "nsAnimationManager.h"
|
2015-06-30 04:00:39 +03:00
|
|
|
#include "mozilla/dom/CSSTransitionBinding.h"
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsStyleContext.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2009-10-08 07:22:42 +04:00
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "nsRefreshDriver.h"
|
|
|
|
#include "nsRuleProcessorData.h"
|
|
|
|
#include "nsRuleWalker.h"
|
|
|
|
#include "nsCSSPropertySet.h"
|
2014-03-18 08:48:21 +04:00
|
|
|
#include "mozilla/EventDispatcher.h"
|
2014-06-24 10:29:54 +04:00
|
|
|
#include "mozilla/StyleAnimationValue.h"
|
2015-04-28 05:29:13 +03:00
|
|
|
#include "mozilla/dom/DocumentTimeline.h"
|
2010-05-14 21:04:51 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-07-31 21:28:22 +04:00
|
|
|
#include "nsIFrame.h"
|
2012-12-12 01:12:43 +04:00
|
|
|
#include "Layers.h"
|
|
|
|
#include "FrameLayerBuilder.h"
|
2015-04-14 03:13:27 +03:00
|
|
|
#include "nsCSSProps.h"
|
2012-12-12 01:12:43 +04:00
|
|
|
#include "nsDisplayList.h"
|
2013-01-09 08:37:29 +04:00
|
|
|
#include "nsStyleChangeList.h"
|
2013-08-20 02:55:18 +04:00
|
|
|
#include "nsStyleSet.h"
|
|
|
|
#include "RestyleManager.h"
|
2015-03-14 08:34:40 +03:00
|
|
|
#include "nsDOMMutationObserver.h"
|
2009-10-08 07:22:42 +04:00
|
|
|
|
|
|
|
using mozilla::TimeStamp;
|
|
|
|
using mozilla::TimeDuration;
|
2015-04-21 04:22:09 +03:00
|
|
|
using mozilla::dom::Animation;
|
2015-04-30 16:06:43 +03:00
|
|
|
using mozilla::dom::KeyframeEffectReadOnly;
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2012-12-12 01:12:43 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::css;
|
2010-05-14 21:04:51 +04:00
|
|
|
|
2010-11-10 18:49:53 +03:00
|
|
|
double
|
2014-07-16 04:02:32 +04:00
|
|
|
ElementPropertyTransition::CurrentValuePortion() const
|
2010-11-10 18:49:53 +03:00
|
|
|
{
|
2015-05-13 07:57:35 +03:00
|
|
|
// It would be easy enough to handle finished transitions by using a
|
|
|
|
// progress of 1 but currently we should not be called for finished
|
2014-06-20 07:39:26 +04:00
|
|
|
// transitions.
|
2014-08-10 11:06:52 +04:00
|
|
|
MOZ_ASSERT(!IsFinishedTransition(),
|
2014-06-20 07:39:26 +04:00
|
|
|
"Getting the value portion of a finished transition");
|
2014-08-10 11:06:52 +04:00
|
|
|
MOZ_ASSERT(!GetLocalTime().IsNull(),
|
2014-07-16 04:02:32 +04:00
|
|
|
"Getting the value portion of an animation that's not being "
|
|
|
|
"sampled");
|
2014-06-20 07:39:26 +04:00
|
|
|
|
2014-07-16 04:02:33 +04:00
|
|
|
// Transitions use a fill mode of 'backwards' so GetComputedTiming will
|
2015-05-13 07:57:35 +03:00
|
|
|
// never return a null time progress due to being *before* the animation
|
2014-06-20 07:39:26 +04:00
|
|
|
// interval. However, it might be possible that we're behind on flushing
|
|
|
|
// causing us to get called *after* the animation interval. So, just in
|
2015-05-13 07:57:35 +03:00
|
|
|
// case, we override the fill mode to 'both' to ensure the progress
|
2014-06-20 07:39:26 +04:00
|
|
|
// is never null.
|
2014-08-10 11:06:52 +04:00
|
|
|
AnimationTiming timingToUse = mTiming;
|
2014-06-20 07:39:26 +04:00
|
|
|
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
|
2014-08-10 11:06:52 +04:00
|
|
|
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
|
2014-06-20 07:39:26 +04:00
|
|
|
|
2015-05-13 07:57:35 +03:00
|
|
|
MOZ_ASSERT(computedTiming.mProgress != ComputedTiming::kNullProgress,
|
|
|
|
"Got a null progress for a fill mode of 'both'");
|
2014-08-10 11:06:52 +04:00
|
|
|
MOZ_ASSERT(mProperties.Length() == 1,
|
2014-04-03 09:57:27 +04:00
|
|
|
"Should have one animation property for a transition");
|
2014-08-10 11:06:52 +04:00
|
|
|
MOZ_ASSERT(mProperties[0].mSegments.Length() == 1,
|
2014-04-03 09:57:27 +04:00
|
|
|
"Animation property should have one segment for a transition");
|
2014-08-10 11:06:52 +04:00
|
|
|
return mProperties[0].mSegments[0].mTimingFunction
|
2015-05-13 07:57:35 +03:00
|
|
|
.GetValue(computedTiming.mProgress);
|
2010-11-10 18:49:53 +03:00
|
|
|
}
|
|
|
|
|
2015-07-29 04:57:39 +03:00
|
|
|
////////////////////////// CSSTransition ////////////////////////////
|
2014-11-17 07:45:58 +03:00
|
|
|
|
2015-06-30 04:00:39 +03:00
|
|
|
JSObject*
|
|
|
|
CSSTransition::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|
|
|
{
|
|
|
|
return dom::CSSTransitionBinding::Wrap(aCx, this, aGivenProto);
|
|
|
|
}
|
|
|
|
|
2015-07-01 09:19:04 +03:00
|
|
|
void
|
|
|
|
CSSTransition::GetTransitionProperty(nsString& aRetVal) const
|
|
|
|
{
|
|
|
|
// Once we make the effect property settable (bug 1049975) we will need
|
|
|
|
// to store the transition property on the CSSTransition itself but for
|
|
|
|
// now we can just query the effect.
|
|
|
|
MOZ_ASSERT(mEffect && mEffect->AsTransition(),
|
|
|
|
"Transitions should have a transition effect");
|
|
|
|
nsCSSProperty prop = mEffect->AsTransition()->TransitionProperty();
|
|
|
|
aRetVal = NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(prop));
|
|
|
|
}
|
|
|
|
|
2015-06-30 04:00:39 +03:00
|
|
|
AnimationPlayState
|
2015-04-21 04:22:10 +03:00
|
|
|
CSSTransition::PlayStateFromJS() const
|
2014-11-17 07:45:58 +03:00
|
|
|
{
|
|
|
|
FlushStyle();
|
2015-04-21 04:22:09 +03:00
|
|
|
return Animation::PlayStateFromJS();
|
2014-11-17 07:45:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-19 08:00:48 +03:00
|
|
|
CSSTransition::PlayFromJS(ErrorResult& aRv)
|
2014-11-17 07:45:58 +03:00
|
|
|
{
|
|
|
|
FlushStyle();
|
2015-05-19 08:00:48 +03:00
|
|
|
Animation::PlayFromJS(aRv);
|
2014-11-17 07:45:58 +03:00
|
|
|
}
|
|
|
|
|
2014-11-17 07:45:58 +03:00
|
|
|
CommonAnimationManager*
|
2015-04-21 04:22:10 +03:00
|
|
|
CSSTransition::GetAnimationManager() const
|
2014-11-17 07:45:58 +03:00
|
|
|
{
|
|
|
|
nsPresContext* context = GetPresContext();
|
|
|
|
if (!context) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return context->TransitionManager();
|
|
|
|
}
|
|
|
|
|
2015-06-09 05:13:54 +03:00
|
|
|
nsCSSProperty
|
|
|
|
CSSTransition::TransitionProperty() const
|
|
|
|
{
|
|
|
|
// FIXME: Once we support replacing/removing the effect (bug 1049975)
|
|
|
|
// we'll need to store the original transition property so we keep
|
|
|
|
// returning the same value in that case.
|
|
|
|
dom::KeyframeEffectReadOnly* effect = GetEffect();
|
|
|
|
MOZ_ASSERT(effect && effect->AsTransition(),
|
|
|
|
"Transition should have a transition effect");
|
|
|
|
return effect->AsTransition()->TransitionProperty();
|
|
|
|
}
|
|
|
|
|
2015-06-09 05:13:54 +03:00
|
|
|
bool
|
|
|
|
CSSTransition::HasLowerCompositeOrderThan(const Animation& aOther) const
|
|
|
|
{
|
|
|
|
// 0. Object-equality case
|
|
|
|
if (&aOther == this) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1. Transitions sort lowest
|
|
|
|
const CSSTransition* otherTransition = aOther.AsCSSTransition();
|
|
|
|
if (!otherTransition) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2. CSS transitions that correspond to a transition-property property sort
|
|
|
|
// lower than CSS transitions owned by script.
|
|
|
|
if (!IsUsingCustomCompositeOrder()) {
|
|
|
|
return !aOther.IsUsingCustomCompositeOrder() ?
|
|
|
|
Animation::HasLowerCompositeOrderThan(aOther) :
|
|
|
|
false;
|
|
|
|
}
|
|
|
|
if (!aOther.IsUsingCustomCompositeOrder()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3. Sort by document order
|
2015-06-09 05:13:54 +03:00
|
|
|
MOZ_ASSERT(mOwningElement.IsSet() && otherTransition->OwningElement().IsSet(),
|
|
|
|
"Transitions using custom composite order should have an owning "
|
|
|
|
"element");
|
|
|
|
if (!mOwningElement.Equals(otherTransition->OwningElement())) {
|
|
|
|
return mOwningElement.LessThan(otherTransition->OwningElement());
|
2015-06-09 05:13:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// 4. (Same element and pseudo): Sort by transition generation
|
|
|
|
if (mSequenceNum != otherTransition->mSequenceNum) {
|
|
|
|
return mSequenceNum < otherTransition->mSequenceNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 5. (Same transition generation): Sort by transition property
|
|
|
|
return nsCSSProps::GetStringValue(TransitionProperty()) <
|
|
|
|
nsCSSProps::GetStringValue(otherTransition->TransitionProperty());
|
|
|
|
}
|
|
|
|
|
2015-07-29 04:57:39 +03:00
|
|
|
////////////////////////// nsTransitionManager ////////////////////////////
|
|
|
|
|
2015-07-29 04:57:40 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION(nsTransitionManager, mEventDispatcher)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTransitionManager)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTransitionManager)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTransitionManager)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIStyleRuleProcessor)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2015-02-17 01:15:02 +03:00
|
|
|
void
|
2010-05-14 21:04:51 +04:00
|
|
|
nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
2009-10-08 07:22:42 +04:00
|
|
|
nsStyleContext *aOldStyleContext,
|
2015-02-17 01:15:02 +03:00
|
|
|
nsRefPtr<nsStyleContext>* aNewStyleContext /* inout */)
|
2009-10-08 07:22:42 +04:00
|
|
|
{
|
2015-02-17 01:15:02 +03:00
|
|
|
nsStyleContext* newStyleContext = *aNewStyleContext;
|
|
|
|
|
|
|
|
NS_PRECONDITION(aOldStyleContext->GetPseudo() == newStyleContext->GetPseudo(),
|
2009-10-08 07:22:42 +04:00
|
|
|
"pseudo type mismatch");
|
|
|
|
|
2014-08-07 09:58:44 +04:00
|
|
|
if (mInAnimationOnlyStyleUpdate) {
|
|
|
|
// If we're doing an animation-only style update, return, since the
|
|
|
|
// purpose of an animation-only style update is to update only the
|
|
|
|
// animation styles so that we don't consider style changes
|
|
|
|
// resulting from changes in the animation time for starting a
|
|
|
|
// transition.
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2014-08-07 09:58:44 +04:00
|
|
|
}
|
|
|
|
|
2013-05-29 10:36:39 +04:00
|
|
|
if (!mPresContext->IsDynamic()) {
|
|
|
|
// For print or print preview, ignore transitions.
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2013-05-29 10:36:39 +04:00
|
|
|
}
|
|
|
|
|
2014-08-14 02:39:02 +04:00
|
|
|
if (aOldStyleContext->HasPseudoElementData() !=
|
2015-02-17 01:15:02 +03:00
|
|
|
newStyleContext->HasPseudoElementData()) {
|
2014-08-14 02:39:02 +04:00
|
|
|
// If the old style context and new style context differ in terms of
|
|
|
|
// whether they're inside ::first-letter, ::first-line, or similar,
|
|
|
|
// bail. We can't hit this codepath for normal style changes
|
|
|
|
// involving moving frames around the boundaries of these
|
|
|
|
// pseudo-elements since we don't call StyleContextChanged from
|
|
|
|
// ReparentStyleContext. However, we can hit this codepath during
|
|
|
|
// the handling of transitions that start across reframes.
|
|
|
|
//
|
|
|
|
// While there isn't an easy *perfect* way to handle this case, err
|
|
|
|
// on the side of missing some transitions that we ought to have
|
|
|
|
// rather than having bogus transitions that we shouldn't.
|
|
|
|
//
|
|
|
|
// We could consider changing this handling, although it's worth
|
|
|
|
// thinking about whether the code below could do anything weird in
|
|
|
|
// this case.
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2014-08-14 02:39:02 +04:00
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// NOTE: Things in this function (and ConsiderStartingTransition)
|
|
|
|
// should never call PeekStyleData because we don't preserve gotten
|
|
|
|
// structs across reframes.
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
// Return sooner (before the startedAny check below) for the most
|
2009-12-22 00:46:25 +03:00
|
|
|
// common case: no transitions specified or running.
|
2015-02-17 01:15:02 +03:00
|
|
|
const nsStyleDisplay *disp = newStyleContext->StyleDisplay();
|
|
|
|
nsCSSPseudoElements::Type pseudoType = newStyleContext->GetPseudoType();
|
2010-07-01 05:54:29 +04:00
|
|
|
if (pseudoType != nsCSSPseudoElements::ePseudo_NotPseudoElement) {
|
|
|
|
if (pseudoType != nsCSSPseudoElements::ePseudo_before &&
|
|
|
|
pseudoType != nsCSSPseudoElements::ePseudo_after) {
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2010-07-01 05:54:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION((pseudoType == nsCSSPseudoElements::ePseudo_before &&
|
2015-03-03 14:09:00 +03:00
|
|
|
aElement->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore) ||
|
2010-07-01 05:54:29 +04:00
|
|
|
(pseudoType == nsCSSPseudoElements::ePseudo_after &&
|
2015-03-03 14:09:00 +03:00
|
|
|
aElement->NodeInfo()->NameAtom() == nsGkAtoms::mozgeneratedcontentafter),
|
2010-07-01 05:54:29 +04:00
|
|
|
"Unexpected aElement coming through");
|
|
|
|
|
|
|
|
// Else the element we want to use from now on is the element the
|
|
|
|
// :before or :after is attached to.
|
|
|
|
aElement = aElement->GetParent()->AsElement();
|
|
|
|
}
|
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* collection = GetAnimations(aElement, pseudoType, false);
|
2014-06-27 03:57:13 +04:00
|
|
|
if (!collection &&
|
2009-12-22 00:46:25 +03:00
|
|
|
disp->mTransitionPropertyCount == 1 &&
|
2015-02-19 03:49:51 +03:00
|
|
|
disp->mTransitions[0].GetCombinedDuration() <= 0.0f) {
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2012-07-31 21:28:21 +04:00
|
|
|
}
|
2012-07-30 22:36:12 +04:00
|
|
|
|
2015-02-17 01:15:03 +03:00
|
|
|
if (collection &&
|
|
|
|
collection->mCheckGeneration ==
|
|
|
|
mPresContext->RestyleManager()->GetAnimationGeneration()) {
|
|
|
|
// When we start a new transition, we immediately post a restyle.
|
|
|
|
// If the animation generation on the collection is current, that
|
|
|
|
// means *this* is that restyle, since we bump the animation
|
|
|
|
// generation on the restyle manager whenever there's a real style
|
|
|
|
// change (i.e., one where mInAnimationOnlyStyleUpdate isn't true,
|
|
|
|
// which causes us to return above). Thus we shouldn't do anything.
|
|
|
|
return;
|
|
|
|
}
|
2015-02-17 01:15:02 +03:00
|
|
|
if (newStyleContext->GetParent() &&
|
|
|
|
newStyleContext->GetParent()->HasPseudoElementData()) {
|
2009-10-08 07:22:42 +04:00
|
|
|
// Ignore transitions on things that inherit properties from
|
|
|
|
// pseudo-elements.
|
2009-10-16 04:23:19 +04:00
|
|
|
// FIXME (Bug 522599): Add tests for this.
|
2015-02-17 01:15:02 +03:00
|
|
|
return;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
|
2013-05-22 14:31:03 +04:00
|
|
|
NS_WARN_IF_FALSE(!nsLayoutUtils::AreAsyncAnimationsEnabled() ||
|
2014-07-25 08:35:34 +04:00
|
|
|
mPresContext->RestyleManager()->
|
|
|
|
ThrottledAnimationStyleIsUpToDate(),
|
2012-12-12 01:12:43 +04:00
|
|
|
"throttled animations not up to date");
|
|
|
|
|
2015-02-17 01:15:02 +03:00
|
|
|
// Compute what the css-transitions spec calls the "after-change
|
|
|
|
// style", which is the new style without any data from transitions,
|
|
|
|
// but still inheriting from data that contains transitions that are
|
|
|
|
// not stopping or starting right now.
|
|
|
|
nsRefPtr<nsStyleContext> afterChangeStyle;
|
|
|
|
if (collection) {
|
|
|
|
nsStyleSet* styleSet = mPresContext->StyleSet();
|
|
|
|
afterChangeStyle =
|
2015-02-17 01:15:02 +03:00
|
|
|
styleSet->ResolveStyleWithoutAnimation(aElement, newStyleContext,
|
2015-02-17 01:15:02 +03:00
|
|
|
eRestyle_CSSTransitions);
|
|
|
|
} else {
|
2015-02-17 01:15:02 +03:00
|
|
|
afterChangeStyle = newStyleContext;
|
2015-02-17 01:15:02 +03:00
|
|
|
}
|
|
|
|
|
2015-03-14 08:34:40 +03:00
|
|
|
nsAutoAnimationMutationBatch mb(aElement);
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
// Per http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html
|
|
|
|
// I'll consider only the transitions from the number of items in
|
|
|
|
// 'transition-property' on down, and later ones will override earlier
|
|
|
|
// ones (tracked using |whichStarted|).
|
2011-09-29 10:19:26 +04:00
|
|
|
bool startedAny = false;
|
2009-10-08 07:22:42 +04:00
|
|
|
nsCSSPropertySet whichStarted;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = disp->mTransitionPropertyCount; i-- != 0; ) {
|
2014-06-27 03:57:12 +04:00
|
|
|
const StyleTransition& t = disp->mTransitions[i];
|
2015-02-19 03:49:51 +03:00
|
|
|
// Check the combined duration (combination of delay and duration)
|
|
|
|
// first, since it defaults to zero, which means we can ignore the
|
|
|
|
// transition.
|
|
|
|
if (t.GetCombinedDuration() > 0.0f) {
|
2009-10-08 07:22:42 +04:00
|
|
|
// We might have something to transition. See if any of the
|
|
|
|
// properties in question changed and are animatable.
|
2009-12-11 19:13:19 +03:00
|
|
|
// FIXME: Would be good to find a way to share code between this
|
|
|
|
// interpretation of transition-property and the one below.
|
2009-10-08 07:22:42 +04:00
|
|
|
nsCSSProperty property = t.GetProperty();
|
|
|
|
if (property == eCSSPropertyExtra_no_properties ||
|
2014-04-13 05:44:31 +04:00
|
|
|
property == eCSSPropertyExtra_variable ||
|
2009-10-08 07:22:42 +04:00
|
|
|
property == eCSSProperty_UNKNOWN) {
|
|
|
|
// Nothing to do, but need to exclude this from cases below.
|
|
|
|
} else if (property == eCSSPropertyExtra_all_properties) {
|
2012-07-31 21:28:21 +04:00
|
|
|
for (nsCSSProperty p = nsCSSProperty(0);
|
2009-10-08 07:22:42 +04:00
|
|
|
p < eCSSProperty_COUNT_no_shorthands;
|
|
|
|
p = nsCSSProperty(p + 1)) {
|
2014-06-27 03:57:13 +04:00
|
|
|
ConsiderStartingTransition(p, t, aElement, collection,
|
2015-02-17 01:15:02 +03:00
|
|
|
aOldStyleContext, afterChangeStyle,
|
2009-10-08 07:22:42 +04:00
|
|
|
&startedAny, &whichStarted);
|
|
|
|
}
|
|
|
|
} else if (nsCSSProps::IsShorthand(property)) {
|
2015-01-17 07:55:07 +03:00
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
|
|
|
|
subprop, property, nsCSSProps::eEnabledForAllContent) {
|
2014-06-27 03:57:13 +04:00
|
|
|
ConsiderStartingTransition(*subprop, t, aElement, collection,
|
2015-02-17 01:15:02 +03:00
|
|
|
aOldStyleContext, afterChangeStyle,
|
2009-10-08 07:22:42 +04:00
|
|
|
&startedAny, &whichStarted);
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-27 03:57:13 +04:00
|
|
|
ConsiderStartingTransition(property, t, aElement, collection,
|
2015-02-17 01:15:02 +03:00
|
|
|
aOldStyleContext, afterChangeStyle,
|
2009-10-08 07:22:42 +04:00
|
|
|
&startedAny, &whichStarted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-11 19:13:19 +03:00
|
|
|
// Stop any transitions for properties that are no longer in
|
2015-02-17 01:15:04 +03:00
|
|
|
// 'transition-property', including finished transitions.
|
|
|
|
// Also stop any transitions (and remove any finished transitions)
|
|
|
|
// for properties that just changed (and are still in the set of
|
|
|
|
// properties to transition), but for which we didn't just start the
|
|
|
|
// transition. This can happen delay and duration are both zero, or
|
|
|
|
// because the new value is not interpolable.
|
Bug 1144410 - Remove finished transitions when a frame transitions away from being display:none. r=birtles
Since bug 960465 patch 14, we've retained finished transitions in order
to handle the issues described in
https://lists.w3.org/Archives/Public/www-style/2015Jan/0444.html . The
code that did this made the assumption that the transition manager is
notified of the full sequence of style changes that happen to an
element. However, when an element becomes part of a display:none
subtree and then later becomes displayed again, the transition manager
is not notified of a style change when it becomes displayed again (when
we do not have the old style context).
This patch introduces code to prune the finished transitions when that
happens.
This really fixes only part of the set of problems described in bug
1158431, which also affect running transitions. However, it's the part
of that set that was a regression from bug 960465, which introduced the
retention of finished transitions, and which makes these issues
substantially easier to hit.
I'd like to fix this part quickly because it's a regression and we
should backport the fix.
Without the patch, I confirmed that the following two tests fail:
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity after starting second transition - got 0, expected 1
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity during second transition - got 0, expected 0.5
With the patch, all the added tests pass.
--HG--
extra : transplant_source : %B4%A5%5Ck%E1%B7%F5Et%CF%9B%9F%40%97c%C5NM%D3%A8
2015-04-27 05:20:19 +03:00
|
|
|
// Note that we also do the latter set of work in
|
|
|
|
// nsTransitionManager::PruneCompletedTransitions.
|
2014-06-27 03:57:13 +04:00
|
|
|
if (collection) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool checkProperties =
|
2009-12-22 00:46:25 +03:00
|
|
|
disp->mTransitions[0].GetProperty() != eCSSPropertyExtra_all_properties;
|
2009-12-11 19:13:19 +03:00
|
|
|
nsCSSPropertySet allTransitionProperties;
|
2009-12-22 00:46:25 +03:00
|
|
|
if (checkProperties) {
|
2012-08-22 19:56:38 +04:00
|
|
|
for (uint32_t i = disp->mTransitionPropertyCount; i-- != 0; ) {
|
2014-06-27 03:57:12 +04:00
|
|
|
const StyleTransition& t = disp->mTransitions[i];
|
2009-12-22 00:46:25 +03:00
|
|
|
// FIXME: Would be good to find a way to share code between this
|
|
|
|
// interpretation of transition-property and the one above.
|
|
|
|
nsCSSProperty property = t.GetProperty();
|
|
|
|
if (property == eCSSPropertyExtra_no_properties ||
|
2014-04-13 05:44:31 +04:00
|
|
|
property == eCSSPropertyExtra_variable ||
|
2009-12-22 00:46:25 +03:00
|
|
|
property == eCSSProperty_UNKNOWN) {
|
|
|
|
// Nothing to do, but need to exclude this from cases below.
|
|
|
|
} else if (property == eCSSPropertyExtra_all_properties) {
|
2012-07-31 21:28:21 +04:00
|
|
|
for (nsCSSProperty p = nsCSSProperty(0);
|
2009-12-22 00:46:25 +03:00
|
|
|
p < eCSSProperty_COUNT_no_shorthands;
|
|
|
|
p = nsCSSProperty(p + 1)) {
|
|
|
|
allTransitionProperties.AddProperty(p);
|
|
|
|
}
|
|
|
|
} else if (nsCSSProps::IsShorthand(property)) {
|
2015-01-17 07:55:07 +03:00
|
|
|
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(
|
|
|
|
subprop, property, nsCSSProps::eEnabledForAllContent) {
|
2009-12-22 00:46:25 +03:00
|
|
|
allTransitionProperties.AddProperty(*subprop);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
allTransitionProperties.AddProperty(property);
|
2009-12-11 19:13:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationPtrArray& animations = collection->mAnimations;
|
|
|
|
size_t i = animations.Length();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(i != 0, "empty transitions list?");
|
2014-06-24 10:29:54 +04:00
|
|
|
StyleAnimationValue currentValue;
|
2009-12-11 19:13:19 +03:00
|
|
|
do {
|
|
|
|
--i;
|
2015-04-21 04:22:10 +03:00
|
|
|
Animation* anim = animations[i];
|
2015-04-30 16:06:43 +03:00
|
|
|
dom::KeyframeEffectReadOnly* effect = anim->GetEffect();
|
2015-04-15 02:48:21 +03:00
|
|
|
MOZ_ASSERT(effect && effect->Properties().Length() == 1,
|
2014-04-03 09:57:27 +04:00
|
|
|
"Should have one animation property for a transition");
|
2015-04-15 02:48:21 +03:00
|
|
|
MOZ_ASSERT(effect && effect->Properties()[0].mSegments.Length() == 1,
|
2014-04-03 09:57:27 +04:00
|
|
|
"Animation property should have one segment for a transition");
|
2015-04-15 02:48:21 +03:00
|
|
|
const AnimationProperty& prop = effect->Properties()[0];
|
2014-04-03 09:57:27 +04:00
|
|
|
const AnimationPropertySegment& segment = prop.mSegments[0];
|
2009-12-22 00:46:25 +03:00
|
|
|
// properties no longer in 'transition-property'
|
|
|
|
if ((checkProperties &&
|
2014-04-03 09:57:27 +04:00
|
|
|
!allTransitionProperties.HasProperty(prop.mProperty)) ||
|
2015-02-17 01:15:04 +03:00
|
|
|
// properties whose computed values changed but for which we
|
|
|
|
// did not start a new transition (because delay and
|
|
|
|
// duration are both zero, or because the new value is not
|
|
|
|
// interpolable); a new transition would have segment.mToValue
|
|
|
|
// matching currentValue
|
2015-02-17 01:15:02 +03:00
|
|
|
!ExtractComputedValueForTransition(prop.mProperty, afterChangeStyle,
|
2011-04-12 10:18:43 +04:00
|
|
|
currentValue) ||
|
2014-04-03 09:57:27 +04:00
|
|
|
currentValue != segment.mToValue) {
|
2009-12-22 00:46:25 +03:00
|
|
|
// stop the transition
|
2015-04-21 04:22:10 +03:00
|
|
|
if (!anim->GetEffect()->IsFinishedTransition()) {
|
2015-02-17 01:15:04 +03:00
|
|
|
collection->UpdateAnimationGeneration(mPresContext);
|
|
|
|
}
|
2015-07-09 02:05:16 +03:00
|
|
|
anim->CancelFromStyle();
|
2015-04-21 04:22:10 +03:00
|
|
|
animations.RemoveElementAt(i);
|
2009-12-11 19:13:19 +03:00
|
|
|
}
|
|
|
|
} while (i != 0);
|
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
if (animations.IsEmpty()) {
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->Destroy();
|
|
|
|
collection = nullptr;
|
2009-12-11 19:13:19 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 01:15:03 +03:00
|
|
|
MOZ_ASSERT(!startedAny || collection,
|
2015-02-10 01:34:50 +03:00
|
|
|
"must have element transitions if we started any transitions");
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2015-02-17 01:15:03 +03:00
|
|
|
if (collection) {
|
2015-03-20 07:10:00 +03:00
|
|
|
UpdateCascadeResultsWithTransitions(collection);
|
|
|
|
|
2015-02-17 01:15:03 +03:00
|
|
|
// Set the style rule refresh time to null so that EnsureStyleRuleFor
|
|
|
|
// creates a new style rule if we started *or* stopped transitions.
|
|
|
|
collection->mStyleRuleRefreshTime = TimeStamp();
|
2015-02-17 01:15:03 +03:00
|
|
|
collection->UpdateCheckGeneration(mPresContext);
|
2015-02-17 01:15:03 +03:00
|
|
|
collection->mNeedsRefreshes = true;
|
|
|
|
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
|
|
|
|
collection->EnsureStyleRuleFor(now, EnsureStyleRule_IsNotThrottled);
|
2015-02-17 01:15:03 +03:00
|
|
|
}
|
2013-06-18 06:18:55 +04:00
|
|
|
|
2015-02-17 01:15:03 +03:00
|
|
|
// We want to replace the new style context with the after-change style.
|
|
|
|
*aNewStyleContext = afterChangeStyle;
|
|
|
|
if (collection) {
|
|
|
|
// Since we have transition styles, we have to undo this replacement.
|
|
|
|
// The check of collection->mCheckGeneration against the restyle
|
|
|
|
// manager's GetAnimationGeneration() will ensure that we don't go
|
|
|
|
// through the rest of this function again when we do.
|
|
|
|
collection->PostRestyleForAnimation(mPresContext);
|
2015-02-17 01:15:03 +03:00
|
|
|
}
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-27 03:57:12 +04:00
|
|
|
nsTransitionManager::ConsiderStartingTransition(
|
|
|
|
nsCSSProperty aProperty,
|
|
|
|
const StyleTransition& aTransition,
|
|
|
|
dom::Element* aElement,
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection*& aElementTransitions,
|
2014-06-27 03:57:12 +04:00
|
|
|
nsStyleContext* aOldStyleContext,
|
|
|
|
nsStyleContext* aNewStyleContext,
|
|
|
|
bool* aStartedAny,
|
|
|
|
nsCSSPropertySet* aWhichStarted)
|
2009-10-08 07:22:42 +04:00
|
|
|
{
|
|
|
|
// IsShorthand itself will assert if aProperty is not a property.
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
|
|
|
|
"property out of range");
|
2012-12-12 01:12:43 +04:00
|
|
|
NS_ASSERTION(!aElementTransitions ||
|
|
|
|
aElementTransitions->mElement == aElement, "Element mismatch");
|
2009-10-08 07:22:42 +04:00
|
|
|
|
|
|
|
if (aWhichStarted->HasProperty(aProperty)) {
|
|
|
|
// A later item in transition-property already started a
|
|
|
|
// transition for this property, so we ignore this one.
|
|
|
|
// See comment above and
|
|
|
|
// http://lists.w3.org/Archives/Public/www-style/2009Aug/0109.html .
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsCSSProps::kAnimTypeTable[aProperty] == eStyleAnimType_None) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-10 04:34:22 +03:00
|
|
|
dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
2014-04-03 09:57:27 +04:00
|
|
|
|
2014-06-24 10:29:54 +04:00
|
|
|
StyleAnimationValue startValue, endValue, dummyValue;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveValues =
|
2011-04-12 10:18:43 +04:00
|
|
|
ExtractComputedValueForTransition(aProperty, aOldStyleContext,
|
2014-04-03 09:57:27 +04:00
|
|
|
startValue) &&
|
2011-04-12 10:18:43 +04:00
|
|
|
ExtractComputedValueForTransition(aProperty, aNewStyleContext,
|
2014-04-03 09:57:27 +04:00
|
|
|
endValue);
|
2012-07-31 21:28:22 +04:00
|
|
|
|
2014-04-03 09:57:27 +04:00
|
|
|
bool haveChange = startValue != endValue;
|
2014-05-15 03:38:37 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool shouldAnimate =
|
2011-01-15 06:57:53 +03:00
|
|
|
haveValues &&
|
2012-12-12 01:12:43 +04:00
|
|
|
haveChange &&
|
2009-10-08 07:22:42 +04:00
|
|
|
// Check that we can interpolate between these values
|
|
|
|
// (If this is ever a performance problem, we could add a
|
|
|
|
// CanInterpolate method, but it seems fine for now.)
|
2014-06-24 10:29:54 +04:00
|
|
|
StyleAnimationValue::Interpolate(aProperty, startValue, endValue,
|
|
|
|
0.5, dummyValue);
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2013-06-05 04:35:52 +04:00
|
|
|
bool haveCurrentTransition = false;
|
2014-05-09 05:03:35 +04:00
|
|
|
size_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
|
2013-06-05 04:35:52 +04:00
|
|
|
const ElementPropertyTransition *oldPT = nullptr;
|
2009-10-08 07:22:42 +04:00
|
|
|
if (aElementTransitions) {
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
|
|
|
for (size_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
|
2015-04-14 03:11:44 +03:00
|
|
|
const ElementPropertyTransition *iPt =
|
2015-04-21 04:22:10 +03:00
|
|
|
animations[i]->GetEffect()->AsTransition();
|
2015-04-14 03:11:44 +03:00
|
|
|
if (iPt->TransitionProperty() == aProperty) {
|
2013-06-05 04:35:52 +04:00
|
|
|
haveCurrentTransition = true;
|
2009-10-08 07:22:42 +04:00
|
|
|
currentIndex = i;
|
2015-04-14 03:11:44 +03:00
|
|
|
oldPT = iPt;
|
2009-10-08 07:22:42 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-05 04:35:52 +04:00
|
|
|
// If we got a style change that changed the value to the endpoint
|
|
|
|
// of the currently running transition, we don't want to interrupt
|
|
|
|
// its timing function.
|
|
|
|
// This needs to be before the !shouldAnimate && haveCurrentTransition
|
|
|
|
// case below because we might be close enough to the end of the
|
|
|
|
// transition that the current value rounds to the final value. In
|
|
|
|
// this case, we'll end up with shouldAnimate as false (because
|
|
|
|
// there's no value change), but we need to return early here rather
|
|
|
|
// than cancel the running transition because shouldAnimate is false!
|
2015-02-17 01:15:04 +03:00
|
|
|
//
|
|
|
|
// Likewise, if we got a style change that changed the value to the
|
|
|
|
// endpoint of our finished transition, we also don't want to start
|
|
|
|
// a new transition for the reasons described in
|
|
|
|
// https://lists.w3.org/Archives/Public/www-style/2015Jan/0444.html .
|
2014-08-10 11:06:52 +04:00
|
|
|
MOZ_ASSERT(!oldPT || oldPT->Properties()[0].mSegments.Length() == 1,
|
2014-04-03 09:57:27 +04:00
|
|
|
"Should have one animation property segment for a transition");
|
|
|
|
if (haveCurrentTransition && haveValues &&
|
2014-08-10 11:06:52 +04:00
|
|
|
oldPT->Properties()[0].mSegments[0].mToValue == endValue) {
|
2014-11-20 05:48:41 +03:00
|
|
|
// GetAnimationRule already called RestyleForAnimation.
|
2013-06-05 04:35:52 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
if (!shouldAnimate) {
|
2015-02-17 01:15:04 +03:00
|
|
|
if (haveCurrentTransition && !oldPT->IsFinishedTransition()) {
|
2013-06-12 09:43:17 +04:00
|
|
|
// We're in the middle of a transition, and just got a non-transition
|
|
|
|
// style change to something that we can't animate. This might happen
|
|
|
|
// because we got a non-transition style change changing to the current
|
|
|
|
// in-progress value (which is particularly easy to cause when we're
|
|
|
|
// currently in the 'transition-delay'). It also might happen because we
|
|
|
|
// just got a style change to a value that can't be interpolated.
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
2015-04-27 02:53:19 +03:00
|
|
|
animations[currentIndex]->CancelFromStyle();
|
2014-08-10 11:06:52 +04:00
|
|
|
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
2015-04-21 04:22:10 +03:00
|
|
|
animations.RemoveElementAt(currentIndex);
|
2012-12-12 01:12:43 +04:00
|
|
|
aElementTransitions->UpdateAnimationGeneration(mPresContext);
|
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
if (animations.IsEmpty()) {
|
2009-10-08 07:22:42 +04:00
|
|
|
aElementTransitions->Destroy();
|
|
|
|
// |aElementTransitions| is now a dangling pointer!
|
2012-07-30 18:20:58 +04:00
|
|
|
aElementTransitions = nullptr;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
2014-11-20 05:48:41 +03:00
|
|
|
// GetAnimationRule already called RestyleForAnimation.
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-10 18:49:53 +03:00
|
|
|
const nsTimingFunction &tf = aTransition.GetTimingFunction();
|
|
|
|
float delay = aTransition.GetDelay();
|
|
|
|
float duration = aTransition.GetDuration();
|
|
|
|
if (duration < 0.0) {
|
|
|
|
// The spec says a negative duration is treated as zero.
|
|
|
|
duration = 0.0;
|
|
|
|
}
|
2014-08-10 11:06:52 +04:00
|
|
|
|
|
|
|
StyleAnimationValue startForReversingTest = startValue;
|
|
|
|
double reversePortion = 1.0;
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2013-06-05 04:35:52 +04:00
|
|
|
// If the new transition reverses an existing one, we'll need to
|
|
|
|
// handle the timing differently.
|
2013-06-05 04:35:52 +04:00
|
|
|
if (haveCurrentTransition &&
|
2014-08-10 11:06:52 +04:00
|
|
|
!oldPT->IsFinishedTransition() &&
|
2014-04-03 09:57:27 +04:00
|
|
|
oldPT->mStartForReversingTest == endValue) {
|
2013-06-05 04:35:52 +04:00
|
|
|
// Compute the appropriate negative transition-delay such that right
|
|
|
|
// now we'd end up at the current position.
|
|
|
|
double valuePortion =
|
2014-07-16 04:02:32 +04:00
|
|
|
oldPT->CurrentValuePortion() * oldPT->mReversePortion +
|
2013-06-05 04:35:52 +04:00
|
|
|
(1.0 - oldPT->mReversePortion);
|
|
|
|
// A timing function with negative y1 (or y2!) might make
|
|
|
|
// valuePortion negative. In this case, we still want to apply our
|
|
|
|
// reversing logic based on relative distances, not make duration
|
|
|
|
// negative.
|
|
|
|
if (valuePortion < 0.0) {
|
|
|
|
valuePortion = -valuePortion;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
2013-06-05 04:35:52 +04:00
|
|
|
// A timing function with y2 (or y1!) greater than one might
|
|
|
|
// advance past its terminal value. It's probably a good idea to
|
|
|
|
// clamp valuePortion to be at most one to preserve the invariant
|
|
|
|
// that a transition will complete within at most its specified
|
|
|
|
// time.
|
|
|
|
if (valuePortion > 1.0) {
|
|
|
|
valuePortion = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Negative delays are essentially part of the transition
|
|
|
|
// function, so reduce them along with the duration, but don't
|
|
|
|
// reduce positive delays.
|
|
|
|
if (delay < 0.0f) {
|
|
|
|
delay *= valuePortion;
|
|
|
|
}
|
|
|
|
|
|
|
|
duration *= valuePortion;
|
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
startForReversingTest = oldPT->Properties()[0].mSegments[0].mToValue;
|
|
|
|
reversePortion = valuePortion;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
|
2014-08-10 11:06:50 +04:00
|
|
|
AnimationTiming timing;
|
|
|
|
timing.mIterationDuration = TimeDuration::FromMilliseconds(duration);
|
|
|
|
timing.mDelay = TimeDuration::FromMilliseconds(delay);
|
|
|
|
timing.mIterationCount = 1;
|
|
|
|
timing.mDirection = NS_STYLE_ANIMATION_DIRECTION_NORMAL;
|
|
|
|
timing.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BACKWARDS;
|
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
nsRefPtr<ElementPropertyTransition> pt =
|
2014-10-02 10:14:15 +04:00
|
|
|
new ElementPropertyTransition(aElement->OwnerDoc(), aElement,
|
|
|
|
aNewStyleContext->GetPseudoType(), timing);
|
2014-08-10 11:06:52 +04:00
|
|
|
pt->mStartForReversingTest = startForReversingTest;
|
|
|
|
pt->mReversePortion = reversePortion;
|
2014-08-10 11:06:47 +04:00
|
|
|
|
2014-08-10 11:06:52 +04:00
|
|
|
AnimationProperty& prop = *pt->Properties().AppendElement();
|
2014-04-03 09:57:27 +04:00
|
|
|
prop.mProperty = aProperty;
|
2015-03-20 07:10:00 +03:00
|
|
|
prop.mWinsInCascade = true;
|
2014-04-03 09:57:27 +04:00
|
|
|
|
|
|
|
AnimationPropertySegment& segment = *prop.mSegments.AppendElement();
|
|
|
|
segment.mFromValue = startValue;
|
|
|
|
segment.mToValue = endValue;
|
|
|
|
segment.mFromKey = 0;
|
|
|
|
segment.mToKey = 1;
|
|
|
|
segment.mTimingFunction.Init(tf);
|
|
|
|
|
2015-04-28 09:48:35 +03:00
|
|
|
nsRefPtr<CSSTransition> animation =
|
2015-04-28 11:21:58 +03:00
|
|
|
new CSSTransition(mPresContext->Document()->GetScopeObject());
|
2015-06-09 05:13:54 +03:00
|
|
|
animation->SetOwningElement(
|
|
|
|
OwningElementRef(*aElement, aNewStyleContext->GetPseudoType()));
|
2015-04-28 11:21:58 +03:00
|
|
|
animation->SetTimeline(timeline);
|
2015-06-09 05:13:54 +03:00
|
|
|
animation->SetCreationSequence(
|
|
|
|
mPresContext->RestyleManager()->GetAnimationGeneration());
|
2014-12-25 10:28:24 +03:00
|
|
|
// The order of the following two calls is important since PlayFromStyle
|
2015-04-21 04:22:10 +03:00
|
|
|
// will add the animation to the PendingAnimationTracker of its effect's
|
2015-04-21 04:22:09 +03:00
|
|
|
// document. When we come to make effect writeable (bug 1049975) we should
|
|
|
|
// remove this dependency.
|
2015-04-21 04:22:10 +03:00
|
|
|
animation->SetEffect(pt);
|
|
|
|
animation->PlayFromStyle();
|
2014-04-03 09:57:27 +04:00
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
if (!aElementTransitions) {
|
|
|
|
aElementTransitions =
|
2015-03-20 21:20:49 +03:00
|
|
|
GetAnimations(aElement, aNewStyleContext->GetPseudoType(), true);
|
2009-10-08 07:22:42 +04:00
|
|
|
if (!aElementTransitions) {
|
2014-06-20 07:39:26 +04:00
|
|
|
NS_WARNING("allocating CommonAnimationManager failed");
|
2009-10-08 07:22:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-07-31 21:28:21 +04:00
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationPtrArray& animations = aElementTransitions->mAnimations;
|
2009-10-08 07:22:42 +04:00
|
|
|
#ifdef DEBUG
|
2015-04-21 04:22:10 +03:00
|
|
|
for (size_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
i == currentIndex ||
|
2015-04-21 04:22:10 +03:00
|
|
|
(animations[i]->GetEffect() &&
|
|
|
|
animations[i]->GetEffect()->AsTransition()->TransitionProperty()
|
2015-04-14 03:11:44 +03:00
|
|
|
!= aProperty),
|
2015-02-10 01:34:50 +03:00
|
|
|
"duplicate transitions for property");
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
#endif
|
2013-06-05 04:35:52 +04:00
|
|
|
if (haveCurrentTransition) {
|
2015-04-27 02:53:19 +03:00
|
|
|
animations[currentIndex]->CancelFromStyle();
|
2015-02-19 03:52:36 +03:00
|
|
|
oldPT = nullptr; // Clear pointer so it doesn't dangle
|
2015-04-21 04:22:10 +03:00
|
|
|
animations[currentIndex] = animation;
|
2009-10-08 07:22:42 +04:00
|
|
|
} else {
|
2015-04-21 04:22:10 +03:00
|
|
|
if (!animations.AppendElement(animation)) {
|
2009-10-08 07:22:42 +04:00
|
|
|
NS_WARNING("out of memory");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-12-12 01:12:43 +04:00
|
|
|
aElementTransitions->UpdateAnimationGeneration(mPresContext);
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*aStartedAny = true;
|
2009-10-08 07:22:42 +04:00
|
|
|
aWhichStarted->AddProperty(aProperty);
|
|
|
|
}
|
|
|
|
|
Bug 1144410 - Remove finished transitions when a frame transitions away from being display:none. r=birtles
Since bug 960465 patch 14, we've retained finished transitions in order
to handle the issues described in
https://lists.w3.org/Archives/Public/www-style/2015Jan/0444.html . The
code that did this made the assumption that the transition manager is
notified of the full sequence of style changes that happen to an
element. However, when an element becomes part of a display:none
subtree and then later becomes displayed again, the transition manager
is not notified of a style change when it becomes displayed again (when
we do not have the old style context).
This patch introduces code to prune the finished transitions when that
happens.
This really fixes only part of the set of problems described in bug
1158431, which also affect running transitions. However, it's the part
of that set that was a regression from bug 960465, which introduced the
retention of finished transitions, and which makes these issues
substantially easier to hit.
I'd like to fix this part quickly because it's a regression and we
should backport the fix.
Without the patch, I confirmed that the following two tests fail:
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity after starting second transition - got 0, expected 1
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity during second transition - got 0, expected 0.5
With the patch, all the added tests pass.
--HG--
extra : transplant_source : %B4%A5%5Ck%E1%B7%F5Et%CF%9B%9F%40%97c%C5NM%D3%A8
2015-04-27 05:20:19 +03:00
|
|
|
void
|
|
|
|
nsTransitionManager::PruneCompletedTransitions(mozilla::dom::Element* aElement,
|
|
|
|
nsCSSPseudoElements::Type
|
|
|
|
aPseudoType,
|
|
|
|
nsStyleContext* aNewStyleContext)
|
|
|
|
{
|
|
|
|
AnimationCollection* collection = GetAnimations(aElement, aPseudoType, false);
|
|
|
|
if (!collection) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any finished transitions whose style doesn't match the new
|
|
|
|
// style.
|
|
|
|
// This is similar to some of the work that happens near the end of
|
|
|
|
// nsTransitionManager::StyleContextChanged.
|
|
|
|
// FIXME (bug 1158431): Really, we should also cancel running
|
|
|
|
// transitions whose destination doesn't match as well.
|
|
|
|
AnimationPtrArray& animations = collection->mAnimations;
|
|
|
|
size_t i = animations.Length();
|
|
|
|
MOZ_ASSERT(i != 0, "empty transitions list?");
|
|
|
|
do {
|
|
|
|
--i;
|
|
|
|
Animation* anim = animations[i];
|
2015-04-30 16:06:43 +03:00
|
|
|
dom::KeyframeEffectReadOnly* effect = anim->GetEffect();
|
Bug 1144410 - Remove finished transitions when a frame transitions away from being display:none. r=birtles
Since bug 960465 patch 14, we've retained finished transitions in order
to handle the issues described in
https://lists.w3.org/Archives/Public/www-style/2015Jan/0444.html . The
code that did this made the assumption that the transition manager is
notified of the full sequence of style changes that happen to an
element. However, when an element becomes part of a display:none
subtree and then later becomes displayed again, the transition manager
is not notified of a style change when it becomes displayed again (when
we do not have the old style context).
This patch introduces code to prune the finished transitions when that
happens.
This really fixes only part of the set of problems described in bug
1158431, which also affect running transitions. However, it's the part
of that set that was a regression from bug 960465, which introduced the
retention of finished transitions, and which makes these issues
substantially easier to hit.
I'd like to fix this part quickly because it's a regression and we
should backport the fix.
Without the patch, I confirmed that the following two tests fail:
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity after starting second transition - got 0, expected 1
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity during second transition - got 0, expected 0.5
With the patch, all the added tests pass.
--HG--
extra : transplant_source : %B4%A5%5Ck%E1%B7%F5Et%CF%9B%9F%40%97c%C5NM%D3%A8
2015-04-27 05:20:19 +03:00
|
|
|
|
|
|
|
if (!effect->IsFinishedTransition()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(effect && effect->Properties().Length() == 1,
|
|
|
|
"Should have one animation property for a transition");
|
|
|
|
MOZ_ASSERT(effect && effect->Properties()[0].mSegments.Length() == 1,
|
|
|
|
"Animation property should have one segment for a transition");
|
|
|
|
const AnimationProperty& prop = effect->Properties()[0];
|
|
|
|
const AnimationPropertySegment& segment = prop.mSegments[0];
|
|
|
|
|
|
|
|
// Since effect is a finished transition, we know it didn't
|
|
|
|
// influence style.
|
|
|
|
StyleAnimationValue currentValue;
|
|
|
|
if (!ExtractComputedValueForTransition(prop.mProperty, aNewStyleContext,
|
|
|
|
currentValue) ||
|
|
|
|
currentValue != segment.mToValue) {
|
2015-07-09 02:05:16 +03:00
|
|
|
anim->CancelFromStyle();
|
Bug 1144410 - Remove finished transitions when a frame transitions away from being display:none. r=birtles
Since bug 960465 patch 14, we've retained finished transitions in order
to handle the issues described in
https://lists.w3.org/Archives/Public/www-style/2015Jan/0444.html . The
code that did this made the assumption that the transition manager is
notified of the full sequence of style changes that happen to an
element. However, when an element becomes part of a display:none
subtree and then later becomes displayed again, the transition manager
is not notified of a style change when it becomes displayed again (when
we do not have the old style context).
This patch introduces code to prune the finished transitions when that
happens.
This really fixes only part of the set of problems described in bug
1158431, which also affect running transitions. However, it's the part
of that set that was a regression from bug 960465, which introduced the
retention of finished transitions, and which makes these issues
substantially easier to hit.
I'd like to fix this part quickly because it's a regression and we
should backport the fix.
Without the patch, I confirmed that the following two tests fail:
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity after starting second transition - got 0, expected 1
INFO TEST-UNEXPECTED-FAIL | layout/style/test/test_transitions_dynamic_changes.html | bug 1144410 test - opacity during second transition - got 0, expected 0.5
With the patch, all the added tests pass.
--HG--
extra : transplant_source : %B4%A5%5Ck%E1%B7%F5Et%CF%9B%9F%40%97c%C5NM%D3%A8
2015-04-27 05:20:19 +03:00
|
|
|
animations.RemoveElementAt(i);
|
|
|
|
}
|
|
|
|
} while (i != 0);
|
|
|
|
|
|
|
|
if (collection->mAnimations.IsEmpty()) {
|
|
|
|
collection->Destroy();
|
|
|
|
// |collection| is now a dangling pointer!
|
|
|
|
collection = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-20 07:10:00 +03:00
|
|
|
void
|
|
|
|
nsTransitionManager::UpdateCascadeResultsWithTransitions(
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* aTransitions)
|
2015-03-20 07:10:00 +03:00
|
|
|
{
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* animations = mPresContext->AnimationManager()->
|
2015-03-20 21:20:49 +03:00
|
|
|
GetAnimations(aTransitions->mElement,
|
|
|
|
aTransitions->PseudoElementType(), false);
|
2015-03-20 07:10:00 +03:00
|
|
|
UpdateCascadeResults(aTransitions, animations);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTransitionManager::UpdateCascadeResultsWithAnimations(
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* aAnimations)
|
2015-03-20 07:10:00 +03:00
|
|
|
{
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* transitions = mPresContext->TransitionManager()->
|
2015-03-20 21:20:49 +03:00
|
|
|
GetAnimations(aAnimations->mElement,
|
|
|
|
aAnimations->PseudoElementType(), false);
|
2015-03-20 07:10:00 +03:00
|
|
|
UpdateCascadeResults(transitions, aAnimations);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTransitionManager::UpdateCascadeResultsWithAnimationsToBeDestroyed(
|
2015-04-21 04:22:10 +03:00
|
|
|
const AnimationCollection* aAnimations)
|
2015-03-20 07:10:00 +03:00
|
|
|
{
|
|
|
|
// aAnimations is about to be destroyed. So get transitions from it,
|
|
|
|
// but then don't pass it to UpdateCascadeResults, since it has
|
|
|
|
// information that may now be incorrect.
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* transitions =
|
2015-03-20 07:10:00 +03:00
|
|
|
mPresContext->TransitionManager()->
|
2015-03-20 21:20:49 +03:00
|
|
|
GetAnimations(aAnimations->mElement,
|
|
|
|
aAnimations->PseudoElementType(), false);
|
2015-03-20 07:10:00 +03:00
|
|
|
UpdateCascadeResults(transitions, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-04-21 04:22:10 +03:00
|
|
|
nsTransitionManager::UpdateCascadeResults(AnimationCollection* aTransitions,
|
|
|
|
AnimationCollection* aAnimations)
|
2015-03-20 07:10:00 +03:00
|
|
|
{
|
|
|
|
if (!aTransitions) {
|
|
|
|
// Nothing to do.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCSSPropertySet propertiesUsed;
|
|
|
|
#ifdef DEBUG
|
|
|
|
nsCSSPropertySet propertiesWithTransitions;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// http://dev.w3.org/csswg/css-transitions/#application says that
|
|
|
|
// transitions do not apply when the same property has a CSS Animation
|
|
|
|
// on that element (even though animations are lower in the cascade).
|
2015-04-01 01:05:55 +03:00
|
|
|
if (aAnimations) {
|
|
|
|
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
|
|
|
|
// Passing EnsureStyleRule_IsThrottled is OK since we will
|
|
|
|
// unthrottle when animations are finishing.
|
|
|
|
aAnimations->EnsureStyleRuleFor(now, EnsureStyleRule_IsThrottled);
|
|
|
|
|
|
|
|
if (aAnimations->mStyleRule) {
|
|
|
|
aAnimations->mStyleRule->AddPropertiesToSet(propertiesUsed);
|
|
|
|
}
|
2015-03-20 07:10:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Since we should never have more than one transition for the same
|
|
|
|
// property, it doesn't matter what order we iterate the transitions.
|
|
|
|
// But let's go the same way as animations.
|
|
|
|
bool changed = false;
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationPtrArray& animations = aTransitions->mAnimations;
|
|
|
|
for (size_t animIdx = animations.Length(); animIdx-- != 0; ) {
|
|
|
|
MOZ_ASSERT(animations[animIdx]->GetEffect() &&
|
|
|
|
animations[animIdx]->GetEffect()->Properties().Length() == 1,
|
2015-03-20 07:10:00 +03:00
|
|
|
"Should have one animation property for a transition");
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationProperty& prop = animations[animIdx]->GetEffect()->Properties()[0];
|
2015-03-20 07:10:00 +03:00
|
|
|
bool newWinsInCascade = !propertiesUsed.HasProperty(prop.mProperty);
|
|
|
|
if (prop.mWinsInCascade != newWinsInCascade) {
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
prop.mWinsInCascade = newWinsInCascade;
|
|
|
|
// assert that we don't need to bother adding the transitioned
|
|
|
|
// properties into propertiesUsed
|
|
|
|
#ifdef DEBUG
|
|
|
|
MOZ_ASSERT(!propertiesWithTransitions.HasProperty(prop.mProperty),
|
|
|
|
"we're assuming we have only one transition per property");
|
|
|
|
propertiesWithTransitions.AddProperty(prop.mProperty);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
2015-04-01 01:05:54 +03:00
|
|
|
mPresContext->RestyleManager()->IncrementAnimationGeneration();
|
2015-03-20 07:10:00 +03:00
|
|
|
aTransitions->UpdateAnimationGeneration(mPresContext);
|
2015-04-01 01:05:54 +03:00
|
|
|
aTransitions->PostUpdateLayerAnimations();
|
2015-03-20 07:10:00 +03:00
|
|
|
|
|
|
|
// Invalidate our style rule.
|
|
|
|
aTransitions->mStyleRuleRefreshTime = TimeStamp();
|
|
|
|
aTransitions->mNeedsRefreshes = true;
|
2015-03-20 07:10:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
/*
|
|
|
|
* nsIStyleRuleProcessor implementation
|
|
|
|
*/
|
|
|
|
|
2011-12-09 09:01:52 +04:00
|
|
|
/* virtual */ size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
nsTransitionManager::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
2011-12-09 09:01:52 +04:00
|
|
|
{
|
|
|
|
return CommonAnimationManager::SizeOfExcludingThis(aMallocSizeOf);
|
2015-07-29 04:57:40 +03:00
|
|
|
|
|
|
|
// Measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - mEventDispatcher
|
2011-12-09 09:01:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
nsTransitionManager::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
2011-12-09 09:01:52 +04:00
|
|
|
{
|
2012-01-25 12:52:51 +04:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
2011-12-09 09:01:52 +04:00
|
|
|
}
|
|
|
|
|
2009-10-08 07:22:42 +04:00
|
|
|
/* virtual */ void
|
|
|
|
nsTransitionManager::WillRefresh(mozilla::TimeStamp aTime)
|
|
|
|
{
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(mPresContext,
|
|
|
|
"refresh driver should not notify additional observers "
|
|
|
|
"after pres context has been destroyed");
|
2010-09-15 23:40:11 +04:00
|
|
|
if (!mPresContext->GetPresShell()) {
|
|
|
|
// Someone might be keeping mPresContext alive past the point
|
|
|
|
// where it has been torn down; don't bother doing anything in
|
|
|
|
// this case. But do get rid of all our transitions so we stop
|
|
|
|
// triggering refreshes.
|
2014-06-27 03:57:13 +04:00
|
|
|
RemoveAllElementCollections();
|
2010-09-15 23:40:11 +04:00
|
|
|
return;
|
|
|
|
}
|
2009-12-23 22:10:31 +03:00
|
|
|
|
2012-12-12 01:12:43 +04:00
|
|
|
FlushTransitions(Can_Throttle);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
2014-06-25 04:42:19 +04:00
|
|
|
{
|
2014-06-27 03:57:13 +04:00
|
|
|
if (PR_CLIST_IS_EMPTY(&mElementCollections)) {
|
2012-12-12 01:12:43 +04:00
|
|
|
// no transitions, leave early
|
|
|
|
return;
|
|
|
|
}
|
2009-12-23 22:10:31 +03:00
|
|
|
|
2012-12-12 01:12:43 +04:00
|
|
|
TimeStamp now = mPresContext->RefreshDriver()->MostRecentRefresh();
|
|
|
|
bool didThrottle = false;
|
2012-12-23 08:52:13 +04:00
|
|
|
// Trim transitions that have completed, post restyle events for frames that
|
|
|
|
// are still transitioning, and start transitions with delays.
|
2009-10-08 07:22:42 +04:00
|
|
|
{
|
2014-06-27 03:57:13 +04:00
|
|
|
PRCList *next = PR_LIST_HEAD(&mElementCollections);
|
|
|
|
while (next != &mElementCollections) {
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection* collection = static_cast<AnimationCollection*>(next);
|
2009-10-08 07:22:42 +04:00
|
|
|
next = PR_NEXT_LINK(next);
|
|
|
|
|
2015-03-14 08:34:40 +03:00
|
|
|
nsAutoAnimationMutationBatch mb(collection->mElement);
|
|
|
|
|
2014-08-10 11:06:48 +04:00
|
|
|
collection->Tick();
|
2012-12-12 01:12:43 +04:00
|
|
|
bool canThrottleTick = aFlags == Can_Throttle &&
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->CanPerformOnCompositorThread(
|
2015-04-21 04:22:10 +03:00
|
|
|
AnimationCollection::CanAnimateFlags(0)) &&
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->CanThrottleAnimation(now);
|
2012-12-12 01:12:43 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(collection->mElement->GetCrossShadowCurrentDoc() ==
|
|
|
|
mPresContext->Document(),
|
|
|
|
"Element::UnbindFromTree should have "
|
|
|
|
"destroyed the element transitions object");
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
size_t i = collection->mAnimations.Length();
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(i != 0, "empty transitions list?");
|
2012-12-23 08:52:13 +04:00
|
|
|
bool transitionStartedOrEnded = false;
|
2009-10-08 07:22:42 +04:00
|
|
|
do {
|
|
|
|
--i;
|
2015-04-21 04:22:10 +03:00
|
|
|
Animation* anim = collection->mAnimations[i];
|
|
|
|
if (!anim->GetEffect()->IsFinishedTransition()) {
|
|
|
|
MOZ_ASSERT(anim->GetEffect(), "Transitions should have an effect");
|
2014-06-25 04:42:19 +04:00
|
|
|
ComputedTiming computedTiming =
|
2015-04-21 04:22:10 +03:00
|
|
|
anim->GetEffect()->GetComputedTiming();
|
2014-06-25 04:42:19 +04:00
|
|
|
if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) {
|
2015-07-29 18:31:59 +03:00
|
|
|
nsCSSProperty prop =
|
|
|
|
anim->GetEffect()->AsTransition()->TransitionProperty();
|
|
|
|
TimeDuration duration =
|
|
|
|
anim->GetEffect()->Timing().mIterationDuration;
|
2015-07-29 04:57:40 +03:00
|
|
|
mEventDispatcher.QueueEvent(
|
2015-07-29 18:31:59 +03:00
|
|
|
TransitionEventInfo(collection->mElement, prop,
|
2015-07-29 04:57:40 +03:00
|
|
|
duration, collection->PseudoElementType()));
|
2015-07-29 18:31:59 +03:00
|
|
|
|
2014-06-25 04:42:19 +04:00
|
|
|
// Leave this transition in the list for one more refresh
|
|
|
|
// cycle, since we haven't yet processed its style change, and
|
|
|
|
// if we also have (already, or will have from processing
|
|
|
|
// transitionend events or other refresh driver notifications)
|
|
|
|
// a non-animation style change that would affect it, we need
|
|
|
|
// to know not to start a new transition for the transition
|
|
|
|
// from the almost-completed value to the final value.
|
2015-04-21 04:22:10 +03:00
|
|
|
anim->GetEffect()->SetIsFinishedTransition(true);
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->UpdateAnimationGeneration(mPresContext);
|
2014-06-25 04:42:19 +04:00
|
|
|
transitionStartedOrEnded = true;
|
|
|
|
} else if ((computedTiming.mPhase ==
|
|
|
|
ComputedTiming::AnimationPhase_Active) &&
|
|
|
|
canThrottleTick &&
|
2015-04-21 04:22:10 +03:00
|
|
|
!anim->IsRunningOnCompositor()) {
|
2014-06-25 04:42:19 +04:00
|
|
|
// Start a transition with a delay where we should start the
|
|
|
|
// transition proper.
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->UpdateAnimationGeneration(mPresContext);
|
2014-06-25 04:42:19 +04:00
|
|
|
transitionStartedOrEnded = true;
|
2009-12-23 22:10:31 +03:00
|
|
|
}
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
} while (i != 0);
|
|
|
|
|
|
|
|
// We need to restyle even if the transition rule no longer
|
|
|
|
// applies (in which case we just made it not apply).
|
2014-07-03 04:04:35 +04:00
|
|
|
MOZ_ASSERT(collection->mElementProperty ==
|
|
|
|
nsGkAtoms::transitionsProperty ||
|
|
|
|
collection->mElementProperty ==
|
|
|
|
nsGkAtoms::transitionsOfBeforeProperty ||
|
|
|
|
collection->mElementProperty ==
|
|
|
|
nsGkAtoms::transitionsOfAfterProperty,
|
|
|
|
"Unexpected element property; might restyle too much");
|
2012-12-23 08:52:13 +04:00
|
|
|
if (!canThrottleTick || transitionStartedOrEnded) {
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->PostRestyleForAnimation(mPresContext);
|
2012-12-12 01:12:43 +04:00
|
|
|
} else {
|
|
|
|
didThrottle = true;
|
|
|
|
}
|
2009-10-08 07:22:42 +04:00
|
|
|
|
2015-04-21 04:22:10 +03:00
|
|
|
if (collection->mAnimations.IsEmpty()) {
|
2014-06-27 03:57:13 +04:00
|
|
|
collection->Destroy();
|
|
|
|
// |collection| is now a dangling pointer!
|
|
|
|
collection = nullptr;
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-12 01:12:43 +04:00
|
|
|
if (didThrottle) {
|
|
|
|
mPresContext->Document()->SetNeedStyleFlush();
|
|
|
|
}
|
|
|
|
|
2015-03-24 03:06:06 +03:00
|
|
|
MaybeStartOrStopObservingRefreshDriver();
|
2015-07-29 18:31:57 +03:00
|
|
|
|
2015-07-29 04:57:40 +03:00
|
|
|
mEventDispatcher.DispatchEvents(mPresContext);
|
2009-10-08 07:22:42 +04:00
|
|
|
}
|