Bug 1341985 - Call UpdateAnimations even if the element has no computed values. r?heycam,birtles
MozReview-Commit-ID: 2dgAF7WOWxr
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -425,22 +425,21 @@ Gecko_StyleAnimationsEquals(RawGeckoStyl
RawGeckoStyleAnimationListBorrowed aB)
{
return *aA == *aB;
}
void
Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull,
- ServoComputedValuesBorrowed aComputedValues,
+ ServoComputedValuesBorrowedOrNull aComputedValues,
ServoComputedValuesBorrowedOrNull aParentComputedValues)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aElement);
- MOZ_ASSERT(aComputedValues);
nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
if (!presContext) {
return;
}
if (presContext->IsDynamic() && aElement->IsInComposedDoc()) {
presContext->AnimationManager()->
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -179,17 +179,17 @@ Gecko_GetHTMLPresentationAttrDeclaration
RawServoDeclarationBlockStrong
Gecko_GetAnimationRule(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTag,
mozilla::EffectCompositor::CascadeLevel aCascadeLevel);
bool Gecko_StyleAnimationsEquals(RawGeckoStyleAnimationListBorrowed,
RawGeckoStyleAnimationListBorrowed);
void Gecko_UpdateAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull,
- ServoComputedValuesBorrowed aComputedValues,
+ ServoComputedValuesBorrowedOrNull aComputedValues,
ServoComputedValuesBorrowedOrNull aParentComputedValues);
bool Gecko_ElementHasCSSAnimations(RawGeckoElementBorrowed aElement,
nsIAtom* aPseudoTagOrNull);
// Atoms.
nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
void Gecko_AddRefAtom(nsIAtom* aAtom);
void Gecko_ReleaseAtom(nsIAtom* aAtom);
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -1059,22 +1059,27 @@ nsAnimationManager::UpdateAnimations(
"Should not update animations for print or print preview");
MOZ_ASSERT(aElement->IsInComposedDoc(),
"Should not update animations that are not attached to the "
"document tree");
CSSPseudoElementType pseudoType =
nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
CSSEnabledState::eForAllContent);
+ if (!aComputedValues) {
+ // If we are in a display:none subtree we will have no computed values.
+ // Since CSS animations should not run in display:none subtrees we should
+ // stop (actually, destroy) any animations on this element here.
+ StopAnimationsForElement(aElement, pseudoType);
+ return;
+ }
+
NonOwningAnimationTarget target(aElement, pseudoType);
ServoCSSAnimationBuilder builder(aComputedValues, aParentComputedValues);
- // Currently we don't seem to call this UpdateAnimations for elements in
- // display:none subtree. We will call this function for such elements with
- // null computed values in bug 1341985.
const nsStyleDisplay *disp = Servo_GetStyleDisplay(aComputedValues);
DoUpdateAnimations(target, *disp, builder);
}
template<class BuilderType>
void
nsAnimationManager::DoUpdateAnimations(
const NonOwningAnimationTarget& aTarget,