void KeyframeEffect::applyEffects() { ASSERT(isInEffect()); ASSERT(animation()); if (!m_target || !m_model) return; // Cancel composited animation of transform if a motion path has been introduced on the element. if (m_target->computedStyle() && m_target->computedStyle()->hasMotionPath() && animation()->hasActiveAnimationsOnCompositor() && animation()->affects(*m_target, CSSPropertyTransform)) { animation()->cancelAnimationOnCompositor(); } double iteration = currentIteration(); ASSERT(iteration >= 0); OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullptr; // FIXME: Handle iteration values which overflow int. m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDuration(), interpolations); if (m_sampledEffect) { m_sampledEffect->setInterpolations(interpolations.release()); } else if (interpolations && !interpolations->isEmpty()) { OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interpolations.release()); m_sampledEffect = sampledEffect.get(); ensureAnimationStack(m_target).add(sampledEffect.release()); } else { return; } m_target->setNeedsAnimationStyleRecalc(); if (m_target->isSVGElement()) m_sampledEffect->applySVGUpdate(toSVGElement(*m_target)); }
PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> CSSAnimations::calculateUpdate(const Element* animatingElement, Element& element, const RenderStyle& style, RenderStyle* parentStyle, StyleResolver* resolver) { OwnPtrWillBeRawPtr<CSSAnimationUpdate> update = adoptPtrWillBeNoop(new CSSAnimationUpdate()); calculateAnimationUpdate(update.get(), animatingElement, element, style, parentStyle, resolver); calculateAnimationActiveInterpolations(update.get(), animatingElement, element.document().timeline().currentTimeInternal()); calculateTransitionUpdate(update.get(), animatingElement, style); calculateTransitionActiveInterpolations(update.get(), animatingElement, element.document().timeline().currentTimeInternal()); return update->isEmpty() ? nullptr : update.release(); }
void RuleSet::compactPendingRules(PendingRuleMap& pendingMap, CompactRuleMap& compactMap) { for (auto& item : pendingMap) { OwnPtrWillBeRawPtr<WillBeHeapLinkedStack<RuleData>> pendingRules = item.value.release(); CompactRuleMap::ValueType* compactRules = compactMap.add(item.key, nullptr).storedValue; WillBeHeapTerminatedArrayBuilder<RuleData> builder(compactRules->value.release()); builder.grow(pendingRules->size()); while (!pendingRules->isEmpty()) { builder.append(pendingRules->peek()); pendingRules->pop(); } compactRules->value = builder.release(); } }
void Animation::applyEffects() { ASSERT(isInEffect()); ASSERT(player()); if (!m_target || !m_effect) return; double iteration = currentIteration(); ASSERT(iteration >= 0); // FIXME: Handle iteration values which overflow int. OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > interpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), iterationDuration()); if (m_sampledEffect) { m_sampledEffect->setInterpolations(interpolations.release()); } else if (!interpolations->isEmpty()) { OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interpolations.release()); m_sampledEffect = sampledEffect.get(); ensureAnimationStack(m_target).add(sampledEffect.release()); } else { return; } m_target->setNeedsAnimationStyleRecalc(); }