OLD | NEW |
---|---|
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 Loading... | |
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); | |
dstockwell
2015/10/28 03:39:38
ASSERT runtime enabled feature?
alancutter (OOO until 2018)
2015/10/29 04:56:51
Done.
| |
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 SVGElementSet webAnimatedSVGElements; | |
111 webAnimatedSVGElements.swap(m_webAnimatedSVGElements); | |
112 | |
113 // 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. | |
114 for (auto& svgElement : webAnimatedSVGElements) { | |
115 ActiveInterpolationsMap activeInterpolationsMap = AnimationStack::active Interpolations( | |
116 &svgElement->elementAnimations()->animationStack(), nullptr, nullptr , KeyframeEffect::DefaultPriority); | |
117 for (auto& entry : activeInterpolationsMap) { | |
118 if (!entry.key.isSVGAttribute()) | |
119 continue; | |
120 const QualifiedName& attribute = entry.key.svgAttribute(); | |
121 const Interpolation& interpolation = *entry.value.first(); | |
122 if (interpolation.isInvalidatableInterpolation()) { | |
123 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> propertyBase = svgEl ement->propertyFromAttribute(attribute); | |
124 InterpolationEnvironment environment(*svgElement, *propertyBase) ; | |
125 InvalidatableInterpolation::applyStack(entry.value, environment) ; | |
126 } else { | |
127 // TODO(alancutter): Remove this old code path once animations h ave completely migrated to InterpolationTypes. | |
128 toSVGInterpolation(interpolation).apply(*svgElement); | |
129 } | |
130 } | |
131 } | |
132 | |
133 ASSERT(m_webAnimatedSVGElements.isEmpty()); | |
97 } | 134 } |
98 | 135 |
99 void SVGDocumentExtensions::startAnimations() | 136 void SVGDocumentExtensions::startAnimations() |
100 { | 137 { |
101 // FIXME: Eventually every "Time Container" will need a way to latch on to s ome global timer | 138 // 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" | 139 // 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. | 140 // 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 | 141 // In the future we should refactor the use-element to avoid this. See https ://webkit.org/b/53704 |
105 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; | 142 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; |
106 copyToVector(m_timeContainers, timeContainers); | 143 copyToVector(m_timeContainers, timeContainers); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 #if ENABLE(OILPAN) | 393 #if ENABLE(OILPAN) |
357 visitor->trace(m_document); | 394 visitor->trace(m_document); |
358 visitor->trace(m_timeContainers); | 395 visitor->trace(m_timeContainers); |
359 visitor->trace(m_relativeLengthSVGRoots); | 396 visitor->trace(m_relativeLengthSVGRoots); |
360 visitor->trace(m_pendingResources); | 397 visitor->trace(m_pendingResources); |
361 visitor->trace(m_pendingResourcesForRemoval); | 398 visitor->trace(m_pendingResourcesForRemoval); |
362 #endif | 399 #endif |
363 } | 400 } |
364 | 401 |
365 } | 402 } |
OLD | NEW |