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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Inc. All rights reserved.
3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2007 Rob Buis <buis@kde.org> 4 * Copyright (C) 2007 Rob Buis <buis@kde.org>
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to 17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 */ 20 */
21 21
22 #include "config.h" 22 #include "config.h"
23 #include "core/svg/SVGDocumentExtensions.h" 23 #include "core/svg/SVGDocumentExtensions.h"
24 24
25 #include "core/animation/AnimationStack.h"
26 #include "core/animation/ElementAnimations.h"
27 #include "core/animation/InterpolationEnvironment.h"
28 #include "core/animation/InvalidatableInterpolation.h"
29 #include "core/animation/SVGInterpolation.h"
25 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
26 #include "core/inspector/ConsoleMessage.h" 31 #include "core/inspector/ConsoleMessage.h"
27 #include "core/layout/svg/SVGResourcesCache.h" 32 #include "core/layout/svg/SVGResourcesCache.h"
28 #include "core/svg/SVGSVGElement.h" 33 #include "core/svg/SVGSVGElement.h"
29 #include "core/svg/animation/SMILTimeContainer.h" 34 #include "core/svg/animation/SMILTimeContainer.h"
30 #include "wtf/TemporaryChange.h" 35 #include "wtf/TemporaryChange.h"
31 #include "wtf/text/AtomicString.h" 36 #include "wtf/text/AtomicString.h"
32 37
33 namespace blink { 38 namespace blink {
34 39
(...skipping 12 matching lines...) Expand all
47 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement* element) 52 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement* element)
48 { 53 {
49 m_timeContainers.add(element); 54 m_timeContainers.add(element);
50 } 55 }
51 56
52 void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element) 57 void SVGDocumentExtensions::removeTimeContainer(SVGSVGElement* element)
53 { 58 {
54 m_timeContainers.remove(element); 59 m_timeContainers.remove(element);
55 } 60 }
56 61
62 void SVGDocumentExtensions::addPendingWebAnimatedSVGElement(SVGElement& element)
63 {
64 m_webAnimatedSVGElements.add(&element);
65 }
66
57 void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourc eContainer* resource) 67 void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourc eContainer* resource)
58 { 68 {
59 ASSERT(resource); 69 ASSERT(resource);
60 70
61 if (id.isEmpty()) 71 if (id.isEmpty())
62 return; 72 return;
63 73
64 // Replaces resource if already present, to handle potential id changes 74 // Replaces resource if already present, to handle potential id changes
65 m_resources.set(id, resource); 75 m_resources.set(id, resource);
66 } 76 }
67 77
68 void SVGDocumentExtensions::removeResource(const AtomicString& id) 78 void SVGDocumentExtensions::removeResource(const AtomicString& id)
69 { 79 {
70 if (id.isEmpty()) 80 if (id.isEmpty())
71 return; 81 return;
72 82
73 m_resources.remove(id); 83 m_resources.remove(id);
74 } 84 }
75 85
76 LayoutSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicStri ng& id) const 86 LayoutSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicStri ng& id) const
77 { 87 {
78 if (id.isEmpty()) 88 if (id.isEmpty())
79 return nullptr; 89 return nullptr;
80 90
81 return m_resources.get(id); 91 return m_resources.get(id);
82 } 92 }
83 93
84 void SVGDocumentExtensions::serviceOnAnimationFrame(Document& document, double m onotonicAnimationStartTime) 94 void SVGDocumentExtensions::serviceOnAnimationFrame(Document& document, double m onotonicAnimationStartTime)
85 { 95 {
86 if (!document.svgExtensions() || !RuntimeEnabledFeatures::smilEnabled()) 96 if (!document.svgExtensions())
87 return; 97 return;
88 document.accessSVGExtensions().serviceAnimations(monotonicAnimationStartTime ); 98 document.accessSVGExtensions().serviceAnimations(monotonicAnimationStartTime );
89 } 99 }
90 100
91 void SVGDocumentExtensions::serviceAnimations(double monotonicAnimationStartTime ) 101 void SVGDocumentExtensions::serviceAnimations(double monotonicAnimationStartTime )
92 { 102 {
93 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; 103 if (RuntimeEnabledFeatures::smilEnabled()) {
94 copyToVector(m_timeContainers, timeContainers); 104 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers;
95 for (const auto& container : timeContainers) 105 copyToVector(m_timeContainers, timeContainers);
96 container->timeContainer()->serviceAnimations(monotonicAnimationStartTim e); 106 for (const auto& container : timeContainers)
107 container->timeContainer()->serviceAnimations(monotonicAnimationStar tTime);
108 }
109
110 // TODO(alancutter): Make SVG animation effect application a separate docume nt lifecycle phase from servicing animations to be responsive to Javascript mani pulation of exposed animation objects.
111 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.
112 ActiveInterpolationsMap activeInterpolationsMap = AnimationStack::active Interpolations(&svgElement->elementAnimations()->animationStack(), nullptr, null ptr, 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.
113 for (auto& entry : activeInterpolationsMap) {
114 if (!entry.key.isSVGAttribute())
115 continue;
116 const QualifiedName& attribute = entry.key.svgAttribute();
117 const Interpolation& interpolation = *entry.value.first();
118 if (interpolation.isInvalidatableInterpolation()) {
119 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> propertyBase = svgEl ement->propertyFromAttribute(attribute);
120 InterpolationEnvironment environment(*svgElement, *propertyBase) ;
121 InvalidatableInterpolation::applyStack(entry.value, environment) ;
122 } else {
123 // TODO(alancutter): Remove this old code path once animations h ave completely migrated to InterpolationTypes.
124 toSVGInterpolation(interpolation).apply(*svgElement);
125 }
126 }
127 }
128 m_webAnimatedSVGElements.clear();
97 } 129 }
98 130
99 void SVGDocumentExtensions::startAnimations() 131 void SVGDocumentExtensions::startAnimations()
100 { 132 {
101 // FIXME: Eventually every "Time Container" will need a way to latch on to s ome global timer 133 // FIXME: Eventually every "Time Container" will need a way to latch on to s ome global timer
102 // starting animations for a document will do this "latching" 134 // starting animations for a document will do this "latching"
103 // FIXME: We hold a ref pointers to prevent a shadow tree from getting remov ed out from underneath us. 135 // FIXME: We hold a ref pointers to prevent a shadow tree from getting remov ed out from underneath us.
104 // In the future we should refactor the use-element to avoid this. See https ://webkit.org/b/53704 136 // In the future we should refactor the use-element to avoid this. See https ://webkit.org/b/53704
105 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; 137 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers;
106 copyToVector(m_timeContainers, timeContainers); 138 copyToVector(m_timeContainers, timeContainers);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 #if ENABLE(OILPAN) 388 #if ENABLE(OILPAN)
357 visitor->trace(m_document); 389 visitor->trace(m_document);
358 visitor->trace(m_timeContainers); 390 visitor->trace(m_timeContainers);
359 visitor->trace(m_relativeLengthSVGRoots); 391 visitor->trace(m_relativeLengthSVGRoots);
360 visitor->trace(m_pendingResources); 392 visitor->trace(m_pendingResources);
361 visitor->trace(m_pendingResourcesForRemoval); 393 visitor->trace(m_pendingResourcesForRemoval);
362 #endif 394 #endif
363 } 395 }
364 396
365 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698