зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1010067 part 7 - Rename instances of ElementAnimationCollection; r=dbaron
This commit is contained in:
Родитель
d8a8a8df73
Коммит
19d210c918
|
@ -415,12 +415,12 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
|
|||
if (!content) {
|
||||
return;
|
||||
}
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* transitions =
|
||||
nsTransitionManager::GetAnimationsForCompositor(content, aProperty);
|
||||
ElementAnimationCollection* ea =
|
||||
ElementAnimationCollection* animations =
|
||||
nsAnimationManager::GetAnimationsForCompositor(content, aProperty);
|
||||
|
||||
if (!ea && !et) {
|
||||
if (!animations && !transitions) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -475,16 +475,16 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
|
|||
data = null_t();
|
||||
}
|
||||
|
||||
if (et) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, et->mAnimations,
|
||||
if (transitions) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, transitions->mAnimations,
|
||||
aLayer, data, pending);
|
||||
aLayer->SetAnimationGeneration(et->mAnimationGeneration);
|
||||
aLayer->SetAnimationGeneration(transitions->mAnimationGeneration);
|
||||
}
|
||||
|
||||
if (ea) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, ea->mAnimations,
|
||||
if (animations) {
|
||||
AddAnimationsForProperty(aFrame, aProperty, animations->mAnimations,
|
||||
aLayer, data, pending);
|
||||
aLayer->SetAnimationGeneration(ea->mAnimationGeneration);
|
||||
aLayer->SetAnimationGeneration(animations->mAnimationGeneration);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,15 +261,15 @@ GetAnimationsOrTransitionsForCompositor(nsIContent* aContent,
|
|||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty)
|
||||
{
|
||||
ElementAnimationCollection* animations =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(
|
||||
aContent->GetProperty(aAnimationProperty));
|
||||
if (animations) {
|
||||
bool propertyMatches = animations->HasAnimationOfProperty(aProperty);
|
||||
if (collection) {
|
||||
bool propertyMatches = collection->HasAnimationOfProperty(aProperty);
|
||||
if (propertyMatches &&
|
||||
animations->CanPerformOnCompositorThread(
|
||||
collection->CanPerformOnCompositorThread(
|
||||
ElementAnimationCollection::CanAnimate_AllowPartial)) {
|
||||
return animations;
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,13 +293,13 @@ GetAnimationsOrTransitions(nsIContent* aContent,
|
|||
nsIAtom* aAnimationProperty,
|
||||
nsCSSProperty aProperty)
|
||||
{
|
||||
ElementAnimationCollection* animations =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(aContent->GetProperty(
|
||||
aAnimationProperty));
|
||||
if (animations) {
|
||||
bool propertyMatches = animations->HasAnimationOfProperty(aProperty);
|
||||
if (collection) {
|
||||
bool propertyMatches = collection->HasAnimationOfProperty(aProperty);
|
||||
if (propertyMatches) {
|
||||
return animations;
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -327,10 +327,10 @@ nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent,
|
|||
|
||||
TimeStamp now = aPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
|
||||
ElementAnimationCollection* animations =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(
|
||||
aContent->GetProperty(aAnimationProperty));
|
||||
return (animations && animations->HasCurrentAnimationsAt(now));
|
||||
return (collection && collection->HasCurrentAnimationsAt(now));
|
||||
}
|
||||
|
||||
static gfxSize
|
||||
|
@ -391,14 +391,14 @@ GetMinAndMaxScaleForAnimationProperty(nsIContent* aContent,
|
|||
gfxSize& aMaxScale,
|
||||
gfxSize& aMinScale)
|
||||
{
|
||||
ElementAnimationCollection* animations =
|
||||
ElementAnimationCollection* collection =
|
||||
GetAnimationsOrTransitionsForCompositor(aContent, aAnimationProperty,
|
||||
eCSSProperty_transform);
|
||||
if (!animations)
|
||||
if (!collection)
|
||||
return;
|
||||
|
||||
for (uint32_t animIdx = animations->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mozilla::ElementAnimation* anim = animations->mAnimations[animIdx];
|
||||
for (uint32_t animIdx = collection->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
mozilla::ElementAnimation* anim = collection->mAnimations[animIdx];
|
||||
if (anim->IsFinishedTransition()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -84,19 +84,19 @@ CommonAnimationManager::GetAnimationsForCompositor(nsIContent* aContent,
|
|||
{
|
||||
if (!aContent->MayHaveAnimations())
|
||||
return nullptr;
|
||||
ElementAnimationCollection* animations =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(
|
||||
aContent->GetProperty(aElementProperty));
|
||||
if (!animations ||
|
||||
!animations->HasAnimationOfProperty(aProperty) ||
|
||||
!animations->CanPerformOnCompositorThread(
|
||||
if (!collection ||
|
||||
!collection->HasAnimationOfProperty(aProperty) ||
|
||||
!collection->CanPerformOnCompositorThread(
|
||||
ElementAnimationCollection::CanAnimate_AllowPartial)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This animation can be done on the compositor.
|
||||
// Mark the frame as active, in case we are able to throttle this animation.
|
||||
nsIFrame* frame = nsLayoutUtils::GetStyleFrame(animations->mElement);
|
||||
nsIFrame* frame = nsLayoutUtils::GetStyleFrame(collection->mElement);
|
||||
if (frame) {
|
||||
if (aProperty == eCSSProperty_opacity) {
|
||||
ActiveLayerTracker::NotifyAnimated(frame, eCSSProperty_opacity);
|
||||
|
@ -105,7 +105,7 @@ CommonAnimationManager::GetAnimationsForCompositor(nsIContent* aContent,
|
|||
}
|
||||
}
|
||||
|
||||
return animations;
|
||||
return collection;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -256,31 +256,31 @@ CommonAnimationManager::UpdateThrottledStyle(dom::Element* aElement,
|
|||
curRule.mLevel = ruleNode->GetLevel();
|
||||
|
||||
if (curRule.mLevel == nsStyleSet::eAnimationSheet) {
|
||||
ElementAnimationCollection* ea =
|
||||
ElementAnimationCollection* collection =
|
||||
mPresContext->AnimationManager()->GetElementAnimations(
|
||||
aElement,
|
||||
oldStyle->GetPseudoType(),
|
||||
false);
|
||||
NS_ASSERTION(ea,
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eAnimationSheet without animation on manager");
|
||||
|
||||
mPresContext->AnimationManager()->UpdateStyleAndEvents(
|
||||
ea, mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
collection, mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = ea->mStyleRule;
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else if (curRule.mLevel == nsStyleSet::eTransitionSheet) {
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* collection =
|
||||
mPresContext->TransitionManager()->GetElementTransitions(
|
||||
aElement,
|
||||
oldStyle->GetPseudoType(),
|
||||
false);
|
||||
NS_ASSERTION(et,
|
||||
NS_ASSERTION(collection,
|
||||
"Rule has level eTransitionSheet without transition on manager");
|
||||
|
||||
et->EnsureStyleRuleFor(
|
||||
collection->EnsureStyleRuleFor(
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
curRule.mRule = et->mStyleRule;
|
||||
curRule.mRule = collection->mStyleRule;
|
||||
} else {
|
||||
curRule.mRule = ruleNode->GetRule();
|
||||
}
|
||||
|
@ -584,8 +584,8 @@ ElementAnimation::ActiveDuration(const AnimationTiming& aTiming)
|
|||
bool
|
||||
ElementAnimationCollection::CanAnimatePropertyOnCompositor(
|
||||
const dom::Element *aElement,
|
||||
nsCSSProperty aProperty,
|
||||
CanAnimateFlags aFlags)
|
||||
nsCSSProperty aProperty,
|
||||
CanAnimateFlags aFlags)
|
||||
{
|
||||
bool shouldLog = nsLayoutUtils::IsAnimationLoggingEnabled();
|
||||
if (!gfxPlatform::OffMainThreadCompositingEnabled()) {
|
||||
|
@ -759,13 +759,13 @@ ElementAnimationCollection::LogAsyncAnimationFailure(nsCString& aMessage,
|
|||
ElementAnimationCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
|
||||
void *aPropertyValue, void *aData)
|
||||
{
|
||||
ElementAnimationCollection* data =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(aPropertyValue);
|
||||
#ifdef DEBUG
|
||||
NS_ABORT_IF_FALSE(!data->mCalledPropertyDtor, "can't call dtor twice");
|
||||
data->mCalledPropertyDtor = true;
|
||||
NS_ABORT_IF_FALSE(!collection->mCalledPropertyDtor, "can't call dtor twice");
|
||||
collection->mCalledPropertyDtor = true;
|
||||
#endif
|
||||
delete data;
|
||||
delete collection;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -119,11 +119,11 @@ class_::UpdateAllThrottledStylesInternal() \
|
|||
its descendants*/ \
|
||||
PRCList *next = PR_LIST_HEAD(&mElementData); \
|
||||
while (next != &mElementData) { \
|
||||
ElementAnimationCollection* ea = \
|
||||
ElementAnimationCollection* collection = \
|
||||
static_cast<ElementAnimationCollection*>(next); \
|
||||
next = PR_NEXT_LINK(next); \
|
||||
\
|
||||
if (ea->mFlushGeneration == now) { \
|
||||
if (collection->mFlushGeneration == now) { \
|
||||
/* this element has been ticked already */ \
|
||||
continue; \
|
||||
} \
|
||||
|
@ -131,7 +131,7 @@ class_::UpdateAllThrottledStylesInternal() \
|
|||
/* element is initialised to the starting element (i.e., one we know has
|
||||
an animation) and ends up with the root-most animated ancestor,
|
||||
that is, the element where we begin updates. */ \
|
||||
dom::Element* element = ea->mElement; \
|
||||
dom::Element* element = collection->mElement; \
|
||||
/* make a list of ancestors */ \
|
||||
nsTArray<dom::Element*> ancestors; \
|
||||
do { \
|
||||
|
|
|
@ -25,22 +25,23 @@ using namespace mozilla;
|
|||
using namespace mozilla::css;
|
||||
|
||||
void
|
||||
nsAnimationManager::UpdateStyleAndEvents(ElementAnimationCollection* aEA,
|
||||
nsAnimationManager::UpdateStyleAndEvents(ElementAnimationCollection*
|
||||
aCollection,
|
||||
TimeStamp aRefreshTime,
|
||||
EnsureStyleRuleFlags aFlags)
|
||||
{
|
||||
aEA->EnsureStyleRuleFor(aRefreshTime, aFlags);
|
||||
GetEventsAt(aEA, aRefreshTime, mPendingEvents);
|
||||
aCollection->EnsureStyleRuleFor(aRefreshTime, aFlags);
|
||||
GetEventsAt(aCollection, aRefreshTime, mPendingEvents);
|
||||
CheckNeedsRefresh();
|
||||
}
|
||||
|
||||
void
|
||||
nsAnimationManager::GetEventsAt(ElementAnimationCollection* aEA,
|
||||
nsAnimationManager::GetEventsAt(ElementAnimationCollection* aCollection,
|
||||
TimeStamp aRefreshTime,
|
||||
EventArray& aEventsToDispatch)
|
||||
{
|
||||
for (uint32_t animIdx = aEA->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
ElementAnimation* anim = aEA->mAnimations[animIdx];
|
||||
for (uint32_t animIdx = aCollection->mAnimations.Length(); animIdx-- != 0; ) {
|
||||
ElementAnimation* anim = aCollection->mAnimations[animIdx];
|
||||
|
||||
TimeDuration localTime = anim->GetLocalTimeAt(aRefreshTime);
|
||||
ComputedTiming computedTiming =
|
||||
|
@ -70,8 +71,8 @@ nsAnimationManager::GetEventsAt(ElementAnimationCollection* aEA,
|
|||
computedTiming.mCurrentIteration;
|
||||
TimeDuration elapsedTime =
|
||||
std::max(iterationStart, anim->InitialAdvance());
|
||||
AnimationEventInfo ei(aEA->mElement, anim->mName, message,
|
||||
elapsedTime, aEA->PseudoElement());
|
||||
AnimationEventInfo ei(aCollection->mElement, anim->mName, message,
|
||||
elapsedTime, aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
}
|
||||
break;
|
||||
|
@ -87,17 +88,19 @@ nsAnimationManager::GetEventsAt(ElementAnimationCollection* aEA,
|
|||
anim->mLastNotification = 0;
|
||||
TimeDuration elapsedTime =
|
||||
std::min(anim->InitialAdvance(), computedTiming.mActiveDuration);
|
||||
AnimationEventInfo ei(aEA->mElement, anim->mName, NS_ANIMATION_START,
|
||||
elapsedTime, aEA->PseudoElement());
|
||||
AnimationEventInfo ei(aCollection->mElement,
|
||||
anim->mName, NS_ANIMATION_START,
|
||||
elapsedTime, aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
}
|
||||
// Dispatch 'animationend' when needed.
|
||||
if (anim->mLastNotification !=
|
||||
ElementAnimation::LAST_NOTIFICATION_END) {
|
||||
anim->mLastNotification = ElementAnimation::LAST_NOTIFICATION_END;
|
||||
AnimationEventInfo ei(aEA->mElement, anim->mName, NS_ANIMATION_END,
|
||||
AnimationEventInfo ei(aCollection->mElement,
|
||||
anim->mName, NS_ANIMATION_END,
|
||||
computedTiming.mActiveDuration,
|
||||
aEA->PseudoElement());
|
||||
aCollection->PseudoElement());
|
||||
aEventsToDispatch.AppendElement(ei);
|
||||
}
|
||||
break;
|
||||
|
@ -128,28 +131,29 @@ nsAnimationManager::GetElementAnimations(dom::Element *aElement,
|
|||
"other than :before or :after");
|
||||
return nullptr;
|
||||
}
|
||||
ElementAnimationCollection *ea = static_cast<ElementAnimationCollection*>(
|
||||
aElement->GetProperty(propName));
|
||||
if (!ea && aCreateIfNeeded) {
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(aElement->GetProperty(propName));
|
||||
if (!collection && aCreateIfNeeded) {
|
||||
// FIXME: Consider arena-allocating?
|
||||
ea = new ElementAnimationCollection(aElement, propName, this,
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh());
|
||||
collection =
|
||||
new ElementAnimationCollection(aElement, propName, this,
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh());
|
||||
nsresult rv =
|
||||
aElement->SetProperty(propName, ea,
|
||||
aElement->SetProperty(propName, collection,
|
||||
&ElementAnimationCollection::PropertyDtor, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("SetProperty failed");
|
||||
delete ea;
|
||||
delete collection;
|
||||
return nullptr;
|
||||
}
|
||||
if (propName == nsGkAtoms::animationsProperty) {
|
||||
aElement->SetMayHaveAnimations();
|
||||
}
|
||||
|
||||
AddElementData(ea);
|
||||
AddElementData(collection);
|
||||
}
|
||||
|
||||
return ea;
|
||||
return collection;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
|
@ -227,10 +231,10 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
// Likewise, when we initially construct frames, we're not in a
|
||||
// style change, but also not in an animation restyle.
|
||||
|
||||
const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
|
||||
ElementAnimationCollection *ea =
|
||||
const nsStyleDisplay* disp = aStyleContext->StyleDisplay();
|
||||
ElementAnimationCollection* collection =
|
||||
GetElementAnimations(aElement, aStyleContext->GetPseudoType(), false);
|
||||
if (!ea &&
|
||||
if (!collection &&
|
||||
disp->mAnimationNameCount == 1 &&
|
||||
disp->mAnimations[0].GetName().IsEmpty()) {
|
||||
return nullptr;
|
||||
|
@ -241,18 +245,18 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
BuildAnimations(aStyleContext, newAnimations);
|
||||
|
||||
if (newAnimations.IsEmpty()) {
|
||||
if (ea) {
|
||||
ea->Destroy();
|
||||
if (collection) {
|
||||
collection->Destroy();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
|
||||
if (ea) {
|
||||
ea->mStyleRule = nullptr;
|
||||
ea->mStyleRuleRefreshTime = TimeStamp();
|
||||
ea->UpdateAnimationGeneration(mPresContext);
|
||||
if (collection) {
|
||||
collection->mStyleRule = nullptr;
|
||||
collection->mStyleRuleRefreshTime = TimeStamp();
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
|
||||
// Copy over the start times and (if still paused) pause starts
|
||||
// for each animation (matching on name only) that was also in the
|
||||
|
@ -264,7 +268,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
// In order to honor what the spec said, we'd copy more data over
|
||||
// (or potentially optimize BuildAnimations to avoid rebuilding it
|
||||
// in the first place).
|
||||
if (!ea->mAnimations.IsEmpty()) {
|
||||
if (!collection->mAnimations.IsEmpty()) {
|
||||
for (uint32_t newIdx = 0, newEnd = newAnimations.Length();
|
||||
newIdx != newEnd; ++newIdx) {
|
||||
nsRefPtr<ElementAnimation> newAnim = newAnimations[newIdx];
|
||||
|
@ -278,8 +282,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
// We'll use the last one since it's more likely to be the one
|
||||
// doing something.
|
||||
const ElementAnimation* oldAnim = nullptr;
|
||||
for (uint32_t oldIdx = ea->mAnimations.Length(); oldIdx-- != 0; ) {
|
||||
const ElementAnimation* a = ea->mAnimations[oldIdx];
|
||||
for (uint32_t oldIdx = collection->mAnimations.Length();
|
||||
oldIdx-- != 0; ) {
|
||||
const ElementAnimation* a = collection->mAnimations[oldIdx];
|
||||
if (a->mName == newAnim->mName) {
|
||||
oldAnim = a;
|
||||
break;
|
||||
|
@ -305,13 +310,14 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ea = GetElementAnimations(aElement, aStyleContext->GetPseudoType(),
|
||||
true);
|
||||
collection =
|
||||
GetElementAnimations(aElement, aStyleContext->GetPseudoType(), true);
|
||||
}
|
||||
ea->mAnimations.SwapElements(newAnimations);
|
||||
ea->mNeedsRefreshes = true;
|
||||
collection->mAnimations.SwapElements(newAnimations);
|
||||
collection->mNeedsRefreshes = true;
|
||||
|
||||
UpdateStyleAndEvents(ea, refreshTime, EnsureStyleRule_IsNotThrottled);
|
||||
UpdateStyleAndEvents(collection, refreshTime,
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
// We don't actually dispatch the mPendingEvents now. We'll either
|
||||
// dispatch them the next time we get a refresh driver notification
|
||||
// or the next time somebody calls
|
||||
|
@ -614,9 +620,9 @@ nsAnimationManager::GetAnimationRule(mozilla::dom::Element* aElement,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ElementAnimationCollection *ea =
|
||||
ElementAnimationCollection* collection =
|
||||
GetElementAnimations(aElement, aPseudoType, false);
|
||||
if (!ea) {
|
||||
if (!collection) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -625,19 +631,19 @@ nsAnimationManager::GetAnimationRule(mozilla::dom::Element* aElement,
|
|||
// During the non-animation part of processing restyles, we don't
|
||||
// add the animation rule.
|
||||
|
||||
if (ea->mStyleRule) {
|
||||
ea->PostRestyleForAnimation(mPresContext);
|
||||
if (collection->mStyleRule) {
|
||||
collection->PostRestyleForAnimation(mPresContext);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NS_WARN_IF_FALSE(!ea->mNeedsRefreshes ||
|
||||
ea->mStyleRuleRefreshTime ==
|
||||
NS_WARN_IF_FALSE(!collection->mNeedsRefreshes ||
|
||||
collection->mStyleRuleRefreshTime ==
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
"should already have refreshed style rule");
|
||||
|
||||
return ea->mStyleRule;
|
||||
return collection->mStyleRule;
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
|
@ -702,19 +708,19 @@ nsAnimationManager::FlushAnimations(FlushFlags aFlags)
|
|||
bool didThrottle = false;
|
||||
for (PRCList *l = PR_LIST_HEAD(&mElementData); l != &mElementData;
|
||||
l = PR_NEXT_LINK(l)) {
|
||||
ElementAnimationCollection *ea =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(l);
|
||||
bool canThrottleTick = aFlags == Can_Throttle &&
|
||||
ea->CanPerformOnCompositorThread(
|
||||
collection->CanPerformOnCompositorThread(
|
||||
ElementAnimationCollection::CanAnimateFlags(0)) &&
|
||||
ea->CanThrottleAnimation(now);
|
||||
collection->CanThrottleAnimation(now);
|
||||
|
||||
nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = ea->mStyleRule;
|
||||
UpdateStyleAndEvents(ea, now, canThrottleTick
|
||||
? EnsureStyleRule_IsThrottled
|
||||
: EnsureStyleRule_IsNotThrottled);
|
||||
if (oldStyleRule != ea->mStyleRule) {
|
||||
ea->PostRestyleForAnimation(mPresContext);
|
||||
nsRefPtr<css::AnimValuesStyleRule> oldStyleRule = collection->mStyleRule;
|
||||
UpdateStyleAndEvents(collection, now, canThrottleTick
|
||||
? EnsureStyleRule_IsThrottled
|
||||
: EnsureStyleRule_IsNotThrottled);
|
||||
if (oldStyleRule != collection->mStyleRule) {
|
||||
collection->PostRestyleForAnimation(mPresContext);
|
||||
} else {
|
||||
didThrottle = true;
|
||||
}
|
||||
|
@ -756,15 +762,17 @@ nsAnimationManager::UpdateThrottledStylesForSubtree(nsIContent* aContent,
|
|||
|
||||
nsRefPtr<nsStyleContext> newStyle;
|
||||
|
||||
ElementAnimationCollection* ea;
|
||||
ElementAnimationCollection* collection;
|
||||
if (element &&
|
||||
(ea = GetElementAnimations(element,
|
||||
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||
false))) {
|
||||
(collection =
|
||||
GetElementAnimations(element,
|
||||
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||
false))) {
|
||||
// re-resolve our style
|
||||
newStyle = UpdateThrottledStyle(element, aParentStyle, aChangeList);
|
||||
// remove the current transition from the working set
|
||||
ea->mFlushGeneration = mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
collection->mFlushGeneration =
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
} else {
|
||||
newStyle = ReparentContent(aContent, aParentStyle);
|
||||
}
|
||||
|
|
|
@ -85,15 +85,17 @@ nsTransitionManager::UpdateThrottledStylesForSubtree(nsIContent* aContent,
|
|||
|
||||
nsRefPtr<nsStyleContext> newStyle;
|
||||
|
||||
ElementAnimationCollection* et;
|
||||
ElementAnimationCollection* collection;
|
||||
if (element &&
|
||||
(et = GetElementTransitions(element,
|
||||
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||
false))) {
|
||||
(collection =
|
||||
GetElementTransitions(element,
|
||||
nsCSSPseudoElements::ePseudo_NotPseudoElement,
|
||||
false))) {
|
||||
// re-resolve our style
|
||||
newStyle = UpdateThrottledStyle(element, aParentStyle, aChangeList);
|
||||
// remove the current transition from the working set
|
||||
et->mFlushGeneration = mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
collection->mFlushGeneration =
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh();
|
||||
} else {
|
||||
newStyle = ReparentContent(aContent, aParentStyle);
|
||||
}
|
||||
|
@ -196,9 +198,9 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
aElement = aElement->GetParent()->AsElement();
|
||||
}
|
||||
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* collection =
|
||||
GetElementTransitions(aElement, pseudoType, false);
|
||||
if (!et &&
|
||||
if (!collection &&
|
||||
disp->mTransitionPropertyCount == 1 &&
|
||||
disp->mTransitions[0].GetDelay() == 0.0f &&
|
||||
disp->mTransitions[0].GetDuration() == 0.0f) {
|
||||
|
@ -246,18 +248,18 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
for (nsCSSProperty p = nsCSSProperty(0);
|
||||
p < eCSSProperty_COUNT_no_shorthands;
|
||||
p = nsCSSProperty(p + 1)) {
|
||||
ConsiderStartingTransition(p, t, aElement, et,
|
||||
ConsiderStartingTransition(p, t, aElement, collection,
|
||||
aOldStyleContext, aNewStyleContext,
|
||||
&startedAny, &whichStarted);
|
||||
}
|
||||
} else if (nsCSSProps::IsShorthand(property)) {
|
||||
CSSPROPS_FOR_SHORTHAND_SUBPROPERTIES(subprop, property) {
|
||||
ConsiderStartingTransition(*subprop, t, aElement, et,
|
||||
ConsiderStartingTransition(*subprop, t, aElement, collection,
|
||||
aOldStyleContext, aNewStyleContext,
|
||||
&startedAny, &whichStarted);
|
||||
}
|
||||
} else {
|
||||
ConsiderStartingTransition(property, t, aElement, et,
|
||||
ConsiderStartingTransition(property, t, aElement, collection,
|
||||
aOldStyleContext, aNewStyleContext,
|
||||
&startedAny, &whichStarted);
|
||||
}
|
||||
|
@ -269,7 +271,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
// Also stop any transitions for properties that just changed (and are
|
||||
// still in the set of properties to transition), but we didn't just
|
||||
// start the transition because delay and duration are both zero.
|
||||
if (et) {
|
||||
if (collection) {
|
||||
bool checkProperties =
|
||||
disp->mTransitions[0].GetProperty() != eCSSPropertyExtra_all_properties;
|
||||
nsCSSPropertySet allTransitionProperties;
|
||||
|
@ -299,7 +301,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
}
|
||||
}
|
||||
|
||||
ElementAnimationPtrArray& animations = et->mAnimations;
|
||||
ElementAnimationPtrArray& animations = collection->mAnimations;
|
||||
uint32_t i = animations.Length();
|
||||
NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
|
||||
StyleAnimationValue currentValue;
|
||||
|
@ -322,13 +324,13 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
currentValue != segment.mToValue) {
|
||||
// stop the transition
|
||||
animations.RemoveElementAt(i);
|
||||
et->UpdateAnimationGeneration(mPresContext);
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
}
|
||||
} while (i != 0);
|
||||
|
||||
if (animations.IsEmpty()) {
|
||||
et->Destroy();
|
||||
et = nullptr;
|
||||
collection->Destroy();
|
||||
collection = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,8 +338,8 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
NS_ABORT_IF_FALSE(et, "must have element transitions if we started "
|
||||
"any transitions");
|
||||
NS_ABORT_IF_FALSE(collection, "must have element transitions if we started "
|
||||
"any transitions");
|
||||
|
||||
// In the CSS working group discussion (2009 Jul 15 telecon,
|
||||
// http://www.w3.org/mid/4A5E1470.4030904@inkedblade.net ) of
|
||||
|
@ -356,7 +358,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
|
||||
nsRefPtr<css::AnimValuesStyleRule> coverRule = new css::AnimValuesStyleRule;
|
||||
|
||||
ElementAnimationPtrArray& animations = et->mAnimations;
|
||||
ElementAnimationPtrArray& animations = collection->mAnimations;
|
||||
for (uint32_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
|
||||
ElementAnimation* animation = animations[i];
|
||||
MOZ_ASSERT(animation->mProperties.Length() == 1,
|
||||
|
@ -370,7 +372,7 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
|
|||
}
|
||||
}
|
||||
|
||||
et->mStyleRule = nullptr;
|
||||
collection->mStyleRule = nullptr;
|
||||
|
||||
return coverRule.forget();
|
||||
}
|
||||
|
@ -590,9 +592,10 @@ nsTransitionManager::ConsiderStartingTransition(
|
|||
}
|
||||
|
||||
ElementAnimationCollection*
|
||||
nsTransitionManager::GetElementTransitions(dom::Element *aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType,
|
||||
bool aCreateIfNeeded)
|
||||
nsTransitionManager::GetElementTransitions(
|
||||
dom::Element *aElement,
|
||||
nsCSSPseudoElements::Type aPseudoType,
|
||||
bool aCreateIfNeeded)
|
||||
{
|
||||
if (!aCreateIfNeeded && PR_CLIST_IS_EMPTY(&mElementData)) {
|
||||
// Early return for the most common case.
|
||||
|
@ -612,28 +615,28 @@ nsTransitionManager::GetElementTransitions(dom::Element *aElement,
|
|||
"other than :before or :after");
|
||||
return nullptr;
|
||||
}
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(aElement->GetProperty(propName));
|
||||
if (!et && aCreateIfNeeded) {
|
||||
if (!collection && aCreateIfNeeded) {
|
||||
// FIXME: Consider arena-allocating?
|
||||
et = new ElementAnimationCollection(aElement, propName, this,
|
||||
collection = new ElementAnimationCollection(aElement, propName, this,
|
||||
mPresContext->RefreshDriver()->MostRecentRefresh());
|
||||
nsresult rv =
|
||||
aElement->SetProperty(propName, et,
|
||||
aElement->SetProperty(propName, collection,
|
||||
&ElementAnimationCollection::PropertyDtor, false);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("SetProperty failed");
|
||||
delete et;
|
||||
delete collection;
|
||||
return nullptr;
|
||||
}
|
||||
if (propName == nsGkAtoms::transitionsProperty) {
|
||||
aElement->SetMayHaveAnimations();
|
||||
}
|
||||
|
||||
AddElementData(et);
|
||||
AddElementData(collection);
|
||||
}
|
||||
|
||||
return et;
|
||||
return collection;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -641,12 +644,13 @@ nsTransitionManager::GetElementTransitions(dom::Element *aElement,
|
|||
*/
|
||||
|
||||
void
|
||||
nsTransitionManager::WalkTransitionRule(ElementDependentRuleProcessorData* aData,
|
||||
nsCSSPseudoElements::Type aPseudoType)
|
||||
nsTransitionManager::WalkTransitionRule(
|
||||
ElementDependentRuleProcessorData* aData,
|
||||
nsCSSPseudoElements::Type aPseudoType)
|
||||
{
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* collection =
|
||||
GetElementTransitions(aData->mElement, aPseudoType, false);
|
||||
if (!et) {
|
||||
if (!collection) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -664,17 +668,17 @@ nsTransitionManager::WalkTransitionRule(ElementDependentRuleProcessorData* aData
|
|||
|
||||
// We need to immediately restyle with animation
|
||||
// after doing this.
|
||||
et->PostRestyleForAnimation(mPresContext);
|
||||
collection->PostRestyleForAnimation(mPresContext);
|
||||
return;
|
||||
}
|
||||
|
||||
et->mNeedsRefreshes = true;
|
||||
et->EnsureStyleRuleFor(
|
||||
collection->mNeedsRefreshes = true;
|
||||
collection->EnsureStyleRuleFor(
|
||||
aData->mPresContext->RefreshDriver()->MostRecentRefresh(),
|
||||
EnsureStyleRule_IsNotThrottled);
|
||||
|
||||
if (et->mStyleRule) {
|
||||
aData->mRuleWalker->Forward(et->mStyleRule);
|
||||
if (collection->mStyleRule) {
|
||||
aData->mRuleWalker->Forward(collection->mStyleRule);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -783,26 +787,26 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
{
|
||||
PRCList *next = PR_LIST_HEAD(&mElementData);
|
||||
while (next != &mElementData) {
|
||||
ElementAnimationCollection* et =
|
||||
ElementAnimationCollection* collection =
|
||||
static_cast<ElementAnimationCollection*>(next);
|
||||
next = PR_NEXT_LINK(next);
|
||||
|
||||
bool canThrottleTick = aFlags == Can_Throttle &&
|
||||
et->CanPerformOnCompositorThread(
|
||||
collection->CanPerformOnCompositorThread(
|
||||
ElementAnimationCollection::CanAnimateFlags(0)) &&
|
||||
et->CanThrottleAnimation(now);
|
||||
collection->CanThrottleAnimation(now);
|
||||
|
||||
NS_ABORT_IF_FALSE(et->mElement->GetCrossShadowCurrentDoc() ==
|
||||
NS_ABORT_IF_FALSE(collection->mElement->GetCrossShadowCurrentDoc() ==
|
||||
mPresContext->Document(),
|
||||
"Element::UnbindFromTree should have "
|
||||
"destroyed the element transitions object");
|
||||
|
||||
uint32_t i = et->mAnimations.Length();
|
||||
uint32_t i = collection->mAnimations.Length();
|
||||
NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
|
||||
bool transitionStartedOrEnded = false;
|
||||
do {
|
||||
--i;
|
||||
ElementAnimation* anim = et->mAnimations[i];
|
||||
ElementAnimation* anim = collection->mAnimations[i];
|
||||
if (anim->IsFinishedTransition()) {
|
||||
// Actually remove transitions one throttle-able cycle after their
|
||||
// completion. We only clear on a throttle-able cycle because that
|
||||
|
@ -810,7 +814,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
// the transition. If the flush is not throttle-able, we might still
|
||||
// have new transitions left to process. See comment below.
|
||||
if (aFlags == Can_Throttle) {
|
||||
et->mAnimations.RemoveElementAt(i);
|
||||
collection->mAnimations.RemoveElementAt(i);
|
||||
}
|
||||
} else {
|
||||
TimeDuration localTime = anim->GetLocalTimeAt(now);
|
||||
|
@ -825,9 +829,9 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
prop = nsCSSProps::OtherNameFor(prop);
|
||||
}
|
||||
events.AppendElement(
|
||||
TransitionEventInfo(et->mElement, prop,
|
||||
TransitionEventInfo(collection->mElement, prop,
|
||||
anim->mTiming.mIterationDuration,
|
||||
et->PseudoElement()));
|
||||
collection->PseudoElement()));
|
||||
|
||||
// Leave this transition in the list for one more refresh
|
||||
// cycle, since we haven't yet processed its style change, and
|
||||
|
@ -837,7 +841,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
// to know not to start a new transition for the transition
|
||||
// from the almost-completed value to the final value.
|
||||
anim->SetFinishedTransition();
|
||||
et->UpdateAnimationGeneration(mPresContext);
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
transitionStartedOrEnded = true;
|
||||
} else if ((computedTiming.mPhase ==
|
||||
ComputedTiming::AnimationPhase_Active) &&
|
||||
|
@ -845,7 +849,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
!anim->mIsRunningOnCompositor) {
|
||||
// Start a transition with a delay where we should start the
|
||||
// transition proper.
|
||||
et->UpdateAnimationGeneration(mPresContext);
|
||||
collection->UpdateAnimationGeneration(mPresContext);
|
||||
transitionStartedOrEnded = true;
|
||||
}
|
||||
}
|
||||
|
@ -853,20 +857,22 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
|
|||
|
||||
// We need to restyle even if the transition rule no longer
|
||||
// applies (in which case we just made it not apply).
|
||||
NS_ASSERTION(et->mElementProperty == nsGkAtoms::transitionsProperty ||
|
||||
et->mElementProperty == nsGkAtoms::transitionsOfBeforeProperty ||
|
||||
et->mElementProperty == nsGkAtoms::transitionsOfAfterProperty,
|
||||
"Unexpected element property; might restyle too much");
|
||||
MOZ_ASSERT(
|
||||
collection->mElementProperty == nsGkAtoms::transitionsProperty ||
|
||||
collection->mElementProperty ==
|
||||
nsGkAtoms::transitionsOfBeforeProperty ||
|
||||
collection->mElementProperty == nsGkAtoms::transitionsOfAfterProperty,
|
||||
"Unexpected element property; might restyle too much");
|
||||
if (!canThrottleTick || transitionStartedOrEnded) {
|
||||
et->PostRestyleForAnimation(mPresContext);
|
||||
collection->PostRestyleForAnimation(mPresContext);
|
||||
} else {
|
||||
didThrottle = true;
|
||||
}
|
||||
|
||||
if (et->mAnimations.IsEmpty()) {
|
||||
et->Destroy();
|
||||
// |et| is now a dangling pointer!
|
||||
et = nullptr;
|
||||
if (collection->mAnimations.IsEmpty()) {
|
||||
collection->Destroy();
|
||||
// |collection| is now a dangling pointer!
|
||||
collection = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче