void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const Element* animatingElement, const ComputedStyle& style) { if (!animatingElement) return; if (animatingElement->document().printing() || animatingElement->document().wasPrinting()) return; ElementAnimations* elementAnimations = animatingElement->elementAnimations(); const TransitionMap* activeTransitions = elementAnimations ? &elementAnimations->cssAnimations().m_transitions : nullptr; 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 = elementAnimations && elementAnimations->isAnimationStyleChange(); #endif BitArray<numCSSProperties> listedProperties; bool anyTransitionHadTransitionAll = false; const LayoutObject* layoutObject = animatingElement->layoutObject(); if (!animationStyleRecalc && style.display() != NONE && layoutObject && layoutObject->style() && transitionData) { const ComputedStyle& oldStyle = *layoutObject->style(); for (size_t i = 0; i < transitionData->propertyList().size(); ++i) { const CSSTransitionData::TransitionProperty& transitionProperty = transitionData->propertyList()[i]; if (transitionProperty.propertyType != CSSTransitionData::TransitionKnownProperty) continue; CSSPropertyID property = resolveCSSPropertyID(transitionProperty.unresolvedProperty); bool animateAll = property == CSSPropertyAll; if (animateAll) anyTransitionHadTransitionAll = true; const StylePropertyShorthand& propertyList = animateAll ? CSSAnimations::propertiesForTransitionAll() : 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; ASSERT(id >= firstCSSProperty); if (!animateAll) { if (CSSPropertyMetadata::isInterpolableProperty(id)) listedProperties.set(id - firstCSSProperty); else continue; } // FIXME: We should transition if an !important property changes even when an animation is running, // but this is a bit hard to do with the current applyMatchedProperties system. PropertyHandle property = PropertyHandle(id); if (!update.activeInterpolationsForAnimations().contains(property) && (!elementAnimations || !elementAnimations->cssAnimations().m_previousActiveInterpolationsForAnimations.contains(property))) { calculateTransitionUpdateForProperty(id, *transitionData, i, oldStyle, style, activeTransitions, update, animatingElement); } } } } if (activeTransitions) { for (const auto& entry : *activeTransitions) { CSSPropertyID id = entry.key; if (!anyTransitionHadTransitionAll && !animationStyleRecalc && !listedProperties.get(id - firstCSSProperty)) { // TODO: Figure out why this fails on Chrome OS login page. crbug.com/365507 // ASSERT(animation.playStateInternal() == Animation::Finished || !(elementAnimations && elementAnimations->isAnimationStyleChange())); update.cancelTransition(id); } else if (entry.value.animation->finishedInternal()) { update.finishTransition(id); } } } }
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); } } } }