本文整理汇总了C++中Animation::CancelFromStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ Animation::CancelFromStyle方法的具体用法?C++ Animation::CancelFromStyle怎么用?C++ Animation::CancelFromStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Animation
的用法示例。
在下文中一共展示了Animation::CancelFromStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mb
//.........这里部分代码省略.........
nsRefPtr<CSSAnimation> oldAnim;
size_t oldIdx = collection->mAnimations.Length();
while (oldIdx-- != 0) {
CSSAnimation* a = collection->mAnimations[oldIdx]->AsCSSAnimation();
MOZ_ASSERT(a, "All animations in the CSS Animation collection should"
" be CSSAnimation objects");
if (a->Name() == newAnim->Name()) {
oldAnim = a;
break;
}
}
if (!oldAnim) {
continue;
}
bool animationChanged = false;
// Update the old from the new so we can keep the original object
// identity (and any expando properties attached to it).
if (oldAnim->GetEffect() && newAnim->GetEffect()) {
KeyframeEffectReadOnly* oldEffect = oldAnim->GetEffect();
KeyframeEffectReadOnly* newEffect = newAnim->GetEffect();
animationChanged =
oldEffect->Timing() != newEffect->Timing() ||
oldEffect->Properties() != newEffect->Properties();
oldEffect->Timing() = newEffect->Timing();
oldEffect->Properties() = newEffect->Properties();
}
// Reset compositor state so animation will be re-synchronized.
oldAnim->ClearIsRunningOnCompositor();
// Handle changes in play state. If the animation is idle, however,
// changes to animation-play-state should *not* restart it.
if (oldAnim->PlayState() != AnimationPlayState::Idle) {
// CSSAnimation takes care of override behavior so that,
// for example, if the author has called pause(), that will
// override the animation-play-state.
// (We should check newAnim->IsStylePaused() but that requires
// downcasting to CSSAnimation and we happen to know that
// newAnim will only ever be paused by calling PauseFromStyle
// making IsPausedOrPausing synonymous in this case.)
if (!oldAnim->IsStylePaused() && newAnim->IsPausedOrPausing()) {
oldAnim->PauseFromStyle();
animationChanged = true;
} else if (oldAnim->IsStylePaused() &&
!newAnim->IsPausedOrPausing()) {
oldAnim->PlayFromStyle();
animationChanged = true;
}
}
if (animationChanged) {
nsNodeUtils::AnimationChanged(oldAnim);
}
// Replace new animation with the (updated) old one and remove the
// old one from the array so we don't try to match it any more.
//
// Although we're doing this while iterating this is safe because
// we're not changing the length of newAnimations and we've finished
// iterating over the list of old iterations.
newAnim->CancelFromStyle();
newAnim = nullptr;
newAnimations.ReplaceElementAt(newIdx, oldAnim);
collection->mAnimations.RemoveElementAt(oldIdx);
// We've touched the old animation's timing properties, so this
// could update the old animation's relevance.
oldAnim->UpdateRelevance();
}
}
} else {
collection =
GetAnimations(aElement, aStyleContext->GetPseudoType(), true);
}
collection->mAnimations.SwapElements(newAnimations);
collection->mNeedsRefreshes = true;
collection->Tick();
// Cancel removed animations
for (size_t newAnimIdx = newAnimations.Length(); newAnimIdx-- != 0; ) {
newAnimations[newAnimIdx]->CancelFromStyle();
}
UpdateCascadeResults(aStyleContext, collection);
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
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
// nsPresShell::FlushPendingNotifications.
if (!mPendingEvents.IsEmpty()) {
mPresContext->Document()->SetNeedStyleFlush();
}
return GetAnimationRule(aElement, aStyleContext->GetPseudoType());
}
示例2: mb
//.........这里部分代码省略.........
newAnim->AsCSSAnimation()->QueueEvents();
continue;
}
bool animationChanged = false;
// Update the old from the new so we can keep the original object
// identity (and any expando properties attached to it).
if (oldAnim->GetEffect() && newAnim->GetEffect()) {
KeyframeEffectReadOnly* oldEffect = oldAnim->GetEffect();
KeyframeEffectReadOnly* newEffect = newAnim->GetEffect();
animationChanged =
oldEffect->Timing() != newEffect->Timing() ||
oldEffect->Properties() != newEffect->Properties();
oldEffect->SetTiming(newEffect->Timing());
// To preserve the mIsRunningOnCompositor value on each property,
// we copy it from the old effect to the new effect since, in the
// following step, we will completely clobber the properties on the
// old effect with the values on the new effect.
CopyIsRunningOnCompositor(*oldEffect, *newEffect);
oldEffect->Properties() = newEffect->Properties();
}
// Handle changes in play state. If the animation is idle, however,
// changes to animation-play-state should *not* restart it.
if (oldAnim->PlayState() != AnimationPlayState::Idle) {
// CSSAnimation takes care of override behavior so that,
// for example, if the author has called pause(), that will
// override the animation-play-state.
// (We should check newAnim->IsStylePaused() but that requires
// downcasting to CSSAnimation and we happen to know that
// newAnim will only ever be paused by calling PauseFromStyle
// making IsPausedOrPausing synonymous in this case.)
if (!oldAnim->IsStylePaused() && newAnim->IsPausedOrPausing()) {
oldAnim->PauseFromStyle();
animationChanged = true;
} else if (oldAnim->IsStylePaused() &&
!newAnim->IsPausedOrPausing()) {
oldAnim->PlayFromStyle();
animationChanged = true;
}
}
oldAnim->CopyAnimationIndex(*newAnim->AsCSSAnimation());
// Updating the effect timing above might already have caused the
// animation to become irrelevant so only add a changed record if
// the animation is still relevant.
if (animationChanged && oldAnim->IsRelevant()) {
nsNodeUtils::AnimationChanged(oldAnim);
}
// Replace new animation with the (updated) old one and remove the
// old one from the array so we don't try to match it any more.
//
// Although we're doing this while iterating this is safe because
// we're not changing the length of newAnimations and we've finished
// iterating over the list of old iterations.
newAnim->CancelFromStyle();
newAnim = nullptr;
newAnimations.ReplaceElementAt(newIdx, oldAnim);
collection->mAnimations.RemoveElementAt(oldIdx);
}
}
} else {
collection = GetAnimationCollection(aElement,
aStyleContext->GetPseudoType(),
true /* aCreateIfNeeded */);
for (Animation* animation : newAnimations) {
// FIXME: Bug 1134163 - As above, we have shouldn't actually need to
// queue events here. (But we do for now since some tests expect
// animationstart events to be dispatched immediately.)
animation->AsCSSAnimation()->QueueEvents();
}
}
collection->mAnimations.SwapElements(newAnimations);
collection->mStyleChanging = true;
// Cancel removed animations
for (size_t newAnimIdx = newAnimations.Length(); newAnimIdx-- != 0; ) {
newAnimations[newAnimIdx]->CancelFromStyle();
}
EffectCompositor::UpdateCascadeResults(aElement,
aStyleContext->GetPseudoType(),
aStyleContext);
TimeStamp refreshTime = mPresContext->RefreshDriver()->MostRecentRefresh();
collection->EnsureStyleRuleFor(refreshTime);
// We don't actually dispatch the pending events now. We'll either
// dispatch them the next time we get a refresh driver notification
// or the next time somebody calls
// nsPresShell::FlushPendingNotifications.
if (mEventDispatcher.HasQueuedEvents()) {
mPresContext->Document()->SetNeedStyleFlush();
}
return GetAnimationRule(aElement, aStyleContext->GetPseudoType());
}