void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* element, double timelineCurrentTime) { ActiveAnimations* activeAnimations = element ? element->activeAnimations() : 0; AnimationStack* animationStack = activeAnimations ? &activeAnimations->defaultStack() : 0; HashMap<CSSPropertyID, RefPtr<Interpolation> > activeInterpolationsForTransitions; if (update->newTransitions().isEmpty() && update->cancelledTransitions().isEmpty()) { activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); } else { Vector<RawPtr<InertAnimation> > newTransitions; for (CSSAnimationUpdate::NewTransitionMap::const_iterator iter = update->newTransitions().begin(); iter != update->newTransitions().end(); ++iter) newTransitions.append(iter->value.animation.get()); HashSet<RawPtr<const AnimationPlayer> > cancelledAnimationPlayers; if (!update->cancelledTransitions().isEmpty()) { ASSERT(activeAnimations); const TransitionMap& transitionMap = activeAnimations->cssAnimations().m_transitions; for (HashSet<CSSPropertyID>::iterator iter = update->cancelledTransitions().begin(); iter != update->cancelledTransitions().end(); ++iter) { ASSERT(transitionMap.contains(*iter)); cancelledAnimationPlayers.add(transitionMap.get(*iter).player.get()); } } activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::TransitionPriority, timelineCurrentTime); } // Properties being animated by animations don't get values from transitions applied. if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpolationsForTransitions.isEmpty()) { for (HashMap<CSSPropertyID, RefPtr<Interpolation> >::const_iterator iter = update->activeInterpolationsForAnimations().begin(); iter != update->activeInterpolationsForAnimations().end(); ++iter) activeInterpolationsForTransitions.remove(iter->key); } update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTransitions); }
void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate* update, const Element* animatingElement, double timelineCurrentTime) { ActiveAnimations* activeAnimations = animatingElement ? animatingElement->activeAnimations() : nullptr; AnimationStack* animationStack = activeAnimations ? &activeAnimations->defaultStack() : nullptr; WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation>> activeInterpolationsForTransitions; if (update->newTransitions().isEmpty() && update->cancelledTransitions().isEmpty()) { activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime); } else { WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newTransitions; for (const auto& entry : update->newTransitions()) newTransitions.append(entry.value.animation.get()); WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAnimationPlayers; if (!update->cancelledTransitions().isEmpty()) { ASSERT(activeAnimations); const TransitionMap& transitionMap = activeAnimations->cssAnimations().m_transitions; for (CSSPropertyID id : update->cancelledTransitions()) { ASSERT(transitionMap.contains(id)); cancelledAnimationPlayers.add(transitionMap.get(id).player.get()); } } activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::TransitionPriority, timelineCurrentTime); } // Properties being animated by animations don't get values from transitions applied. if (!update->activeInterpolationsForAnimations().isEmpty() && !activeInterpolationsForTransitions.isEmpty()) { for (const auto& entry : update->activeInterpolationsForAnimations()) activeInterpolationsForTransitions.remove(entry.key); } update->adoptActiveInterpolationsForTransitions(activeInterpolationsForTransitions); }
void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const Element* element, const RenderStyle& style) { if (!element) return; ActiveAnimations* activeAnimations = element->activeAnimations(); const TransitionMap* activeTransitions = activeAnimations ? &activeAnimations->cssAnimations().m_transitions : 0; const CSSTransitionData* transitionData = style.transitions(); #if ENABLE(ASSERT) // In debug builds we verify that it would have been safe to avoid populating and testing listedProperties if the style recalc is due to animation. const bool animationStyleRecalc = false; #else // In release builds we avoid the cost of checking for new and interrupted transitions if the style recalc is due to animation. const bool animationStyleRecalc = activeAnimations && activeAnimations->isAnimationStyleChange(); #endif BitArray<numCSSProperties> listedProperties; bool anyTransitionHadTransitionAll = false; const RenderObject* renderer = element->renderer(); if (!animationStyleRecalc && style.display() != NONE && renderer && renderer->style() && transitionData) { const RenderStyle& oldStyle = *renderer->style(); for (size_t i = 0; i < transitionData->propertyList().size(); ++i) { const CSSTransitionData::TransitionProperty& transitionProperty = transitionData->propertyList()[i]; CSSTransitionData::TransitionPropertyType mode = transitionProperty.propertyType; CSSPropertyID property = transitionProperty.propertyId; if (mode == CSSTransitionData::TransitionNone || mode == CSSTransitionData::TransitionUnknown) continue; bool animateAll = mode == CSSTransitionData::TransitionAll; ASSERT(animateAll || mode == CSSTransitionData::TransitionSingleProperty); if (animateAll) anyTransitionHadTransitionAll = true; const StylePropertyShorthand& propertyList = animateAll ? CSSAnimations::animatableProperties() : shorthandForProperty(property); // If not a shorthand we only execute one iteration of this loop, and refer to the property directly. for (unsigned j = 0; !j || j < propertyList.length(); ++j) { CSSPropertyID id = propertyList.length() ? propertyList.properties()[j] : property; CSSPropertyID eventId = id; if (!animateAll) { id = propertyForAnimation(id); if (CSSPropertyMetadata::isAnimatableProperty(id)) listedProperties.set(id); else continue; } if (!update->activeInterpolationsForAnimations().contains(id) && (!activeAnimations || !activeAnimations->cssAnimations().m_previousActiveInterpolationsForAnimations.contains(id))) { calculateTransitionUpdateForProperty(id, eventId, *transitionData, i, oldStyle, style, activeTransitions, update, element); } } } } if (activeTransitions) { for (TransitionMap::const_iterator iter = activeTransitions->begin(); iter != activeTransitions->end(); ++iter) { const AnimationPlayer& player = *iter->value.player; CSSPropertyID id = iter->key; if (player.finishedInternal() || (!anyTransitionHadTransitionAll && !animationStyleRecalc && !listedProperties.get(id))) { // TODO: Figure out why this fails on Chrome OS login page. crbug.com/365507 // ASSERT(player.finishedInternal() || !(activeAnimations && activeAnimations->isAnimationStyleChange())); update->cancelTransition(id); } } } }