Chromium Code Reviews| Index: third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp |
| diff --git a/third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp b/third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp |
| index e3a6fb5560101aaf7b26b4fc20d123c8d68ccb68..055f098d010923961cae73e2b90f9a3a5213056a 100644 |
| --- a/third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp |
| +++ b/third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp |
| @@ -22,6 +22,11 @@ |
| #include "config.h" |
| #include "core/svg/SVGDocumentExtensions.h" |
| +#include "core/animation/AnimationStack.h" |
| +#include "core/animation/ElementAnimations.h" |
| +#include "core/animation/InterpolationEnvironment.h" |
| +#include "core/animation/InvalidatableInterpolation.h" |
| +#include "core/animation/SVGInterpolation.h" |
| #include "core/dom/Document.h" |
| #include "core/inspector/ConsoleMessage.h" |
| #include "core/layout/svg/SVGResourcesCache.h" |
| @@ -54,6 +59,11 @@ void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element) |
| m_timeContainers.remove(element); |
| } |
| +void SVGDocumentExtensions::addPendingWebAnimatedSVGElement(SVGElement& element) |
| +{ |
| + m_webAnimatedSVGElements.add(&element); |
| +} |
| + |
| void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourceContainer* resource) |
| { |
| ASSERT(resource); |
| @@ -83,17 +93,39 @@ LayoutSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicStri |
| void SVGDocumentExtensions::serviceOnAnimationFrame(Document& document, double monotonicAnimationStartTime) |
| { |
| - if (!document.svgExtensions() || !RuntimeEnabledFeatures::smilEnabled()) |
| + if (!document.svgExtensions()) |
| return; |
| document.accessSVGExtensions().serviceAnimations(monotonicAnimationStartTime); |
| } |
| void SVGDocumentExtensions::serviceAnimations(double monotonicAnimationStartTime) |
| { |
| - WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; |
| - copyToVector(m_timeContainers, timeContainers); |
| - for (const auto& container : timeContainers) |
| - container->timeContainer()->serviceAnimations(monotonicAnimationStartTime); |
| + if (RuntimeEnabledFeatures::smilEnabled()) { |
| + WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; |
| + copyToVector(m_timeContainers, timeContainers); |
| + for (const auto& container : timeContainers) |
| + container->timeContainer()->serviceAnimations(monotonicAnimationStartTime); |
| + } |
| + |
| + // TODO(alancutter): Make SVG animation effect application a separate document lifecycle phase from servicing animations to be responsive to Javascript manipulation of exposed animation objects. |
| + for (auto& svgElement : m_webAnimatedSVGElements) { |
|
pdr.
2015/10/21 00:47:37
I'm a little worried about this for loop modifying
alancutter (OOO until 2018)
2015/10/21 04:20:42
Good idea, done.
|
| + ActiveInterpolationsMap activeInterpolationsMap = AnimationStack::activeInterpolations(&svgElement->elementAnimations()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority, 0); |
|
pdr.
2015/10/21 00:47:37
We don't have a line limit but 200+ can be hard to
alancutter (OOO until 2018)
2015/10/21 04:20:42
Done.
|
| + for (auto& entry : activeInterpolationsMap) { |
| + if (!entry.key.isSVGAttribute()) |
| + continue; |
| + const QualifiedName& attribute = entry.key.svgAttribute(); |
| + const Interpolation& interpolation = *entry.value.first(); |
| + if (interpolation.isInvalidatableInterpolation()) { |
| + RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> propertyBase = svgElement->propertyFromAttribute(attribute); |
| + InterpolationEnvironment environment(*svgElement, *propertyBase); |
| + InvalidatableInterpolation::applyStack(entry.value, environment); |
| + } else { |
| + // TODO(alancutter): Remove this old code path once animations have completely migrated to InterpolationTypes. |
| + toSVGInterpolation(interpolation).apply(*svgElement); |
| + } |
| + } |
| + } |
| + m_webAnimatedSVGElements.clear(); |
| } |
| void SVGDocumentExtensions::startAnimations() |