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::addWebAnimationsPendingSVGElement(SVGElement& elemen
t) |
| 63 { |
| 64 ASSERT(RuntimeEnabledFeatures::webAnimationsSVGEnabled()); |
| 65 m_webAnimationsPendingSVGElements.add(&element); |
| 66 } |
| 67 |
57 void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourc
eContainer* resource) | 68 void SVGDocumentExtensions::addResource(const AtomicString& id, LayoutSVGResourc
eContainer* resource) |
58 { | 69 { |
59 ASSERT(resource); | 70 ASSERT(resource); |
60 | 71 |
61 if (id.isEmpty()) | 72 if (id.isEmpty()) |
62 return; | 73 return; |
63 | 74 |
64 // Replaces resource if already present, to handle potential id changes | 75 // Replaces resource if already present, to handle potential id changes |
65 m_resources.set(id, resource); | 76 m_resources.set(id, resource); |
66 } | 77 } |
67 | 78 |
68 void SVGDocumentExtensions::removeResource(const AtomicString& id) | 79 void SVGDocumentExtensions::removeResource(const AtomicString& id) |
69 { | 80 { |
70 if (id.isEmpty()) | 81 if (id.isEmpty()) |
71 return; | 82 return; |
72 | 83 |
73 m_resources.remove(id); | 84 m_resources.remove(id); |
74 } | 85 } |
75 | 86 |
76 LayoutSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicStri
ng& id) const | 87 LayoutSVGResourceContainer* SVGDocumentExtensions::resourceById(const AtomicStri
ng& id) const |
77 { | 88 { |
78 if (id.isEmpty()) | 89 if (id.isEmpty()) |
79 return nullptr; | 90 return nullptr; |
80 | 91 |
81 return m_resources.get(id); | 92 return m_resources.get(id); |
82 } | 93 } |
83 | 94 |
84 void SVGDocumentExtensions::serviceOnAnimationFrame(Document& document, double m
onotonicAnimationStartTime) | 95 void SVGDocumentExtensions::serviceOnAnimationFrame(Document& document, double m
onotonicAnimationStartTime) |
85 { | 96 { |
86 if (!document.svgExtensions() || !RuntimeEnabledFeatures::smilEnabled()) | 97 if (!document.svgExtensions()) |
87 return; | 98 return; |
88 document.accessSVGExtensions().serviceAnimations(monotonicAnimationStartTime
); | 99 document.accessSVGExtensions().serviceAnimations(monotonicAnimationStartTime
); |
89 } | 100 } |
90 | 101 |
91 void SVGDocumentExtensions::serviceAnimations(double monotonicAnimationStartTime
) | 102 void SVGDocumentExtensions::serviceAnimations(double monotonicAnimationStartTime
) |
92 { | 103 { |
93 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; | 104 if (RuntimeEnabledFeatures::smilEnabled()) { |
94 copyToVector(m_timeContainers, timeContainers); | 105 WillBeHeapVector<RefPtrWillBeMember<SVGSVGElement>> timeContainers; |
95 for (const auto& container : timeContainers) | 106 copyToVector(m_timeContainers, timeContainers); |
96 container->timeContainer()->serviceAnimations(monotonicAnimationStartTim
e); | 107 for (const auto& container : timeContainers) |
| 108 container->timeContainer()->serviceAnimations(monotonicAnimationStar
tTime); |
| 109 } |
| 110 |
| 111 SVGElementSet webAnimationsPendingSVGElements; |
| 112 webAnimationsPendingSVGElements.swap(m_webAnimationsPendingSVGElements); |
| 113 |
| 114 // 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. |
| 115 for (auto& svgElement : webAnimationsPendingSVGElements) { |
| 116 ActiveInterpolationsMap activeInterpolationsMap = AnimationStack::active
Interpolations( |
| 117 &svgElement->elementAnimations()->animationStack(), nullptr, nullptr
, KeyframeEffect::DefaultPriority); |
| 118 for (auto& entry : activeInterpolationsMap) { |
| 119 if (!entry.key.isSVGAttribute()) |
| 120 continue; |
| 121 const QualifiedName& attribute = entry.key.svgAttribute(); |
| 122 const Interpolation& interpolation = *entry.value.first(); |
| 123 if (interpolation.isInvalidatableInterpolation()) { |
| 124 InterpolationEnvironment environment(*svgElement, svgElement->pr
opertyFromAttribute(attribute)->baseValueBase()); |
| 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_webAnimationsPendingSVGElements.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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 { | 386 { |
350 ASSERT(m_document); | 387 ASSERT(m_document); |
351 return rootElement(*m_document); | 388 return rootElement(*m_document); |
352 } | 389 } |
353 | 390 |
354 DEFINE_TRACE(SVGDocumentExtensions) | 391 DEFINE_TRACE(SVGDocumentExtensions) |
355 { | 392 { |
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); |
| 396 visitor->trace(m_webAnimationsPendingSVGElements); |
359 visitor->trace(m_relativeLengthSVGRoots); | 397 visitor->trace(m_relativeLengthSVGRoots); |
360 visitor->trace(m_pendingResources); | 398 visitor->trace(m_pendingResources); |
361 visitor->trace(m_pendingResourcesForRemoval); | 399 visitor->trace(m_pendingResourcesForRemoval); |
362 #endif | 400 #endif |
363 } | 401 } |
364 | 402 |
365 } | 403 } |
OLD | NEW |