Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Unified Diff: third_party/WebKit/Source/core/svg/SVGDocumentExtensions.cpp

Issue 1420553004: SVG Web Animations: Add compositing pipeline for SVGInterpolationTypes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_svgValueInterpolationType
Patch Set: Review changes Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..027a89bd1bdf6037ab2e7be7cbe88d42a6ad153e 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);
dstockwell 2015/10/28 03:39:38 ASSERT runtime enabled feature?
alancutter (OOO until 2018) 2015/10/29 04:56:51 Done.
+}
+
void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourceContainer* resource)
{
ASSERT(resource);
@@ -83,17 +93,44 @@ 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);
+ }
+
+ SVGElementSet webAnimatedSVGElements;
+ webAnimatedSVGElements.swap(m_webAnimatedSVGElements);
+
+ // 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 : webAnimatedSVGElements) {
+ ActiveInterpolationsMap activeInterpolationsMap = AnimationStack::activeInterpolations(
+ &svgElement->elementAnimations()->animationStack(), nullptr, nullptr, KeyframeEffect::DefaultPriority);
+ 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);
+ }
+ }
+ }
+
+ ASSERT(m_webAnimatedSVGElements.isEmpty());
}
void SVGDocumentExtensions::startAnimations()

Powered by Google App Engine
This is Rietveld 408576698