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 * |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (RuntimeEnabledFeatures::smilEnabled()) { | 92 if (RuntimeEnabledFeatures::smilEnabled()) { |
93 HeapVector<Member<SVGSVGElement>> timeContainers; | 93 HeapVector<Member<SVGSVGElement>> timeContainers; |
94 copyToVector(m_timeContainers, timeContainers); | 94 copyToVector(m_timeContainers, timeContainers); |
95 for (const auto& container : timeContainers) | 95 for (const auto& container : timeContainers) |
96 container->timeContainer()->serviceAnimations(); | 96 container->timeContainer()->serviceAnimations(); |
97 } | 97 } |
98 | 98 |
99 SVGElementSet webAnimationsPendingSVGElements; | 99 SVGElementSet webAnimationsPendingSVGElements; |
100 webAnimationsPendingSVGElements.swap(m_webAnimationsPendingSVGElements); | 100 webAnimationsPendingSVGElements.swap(m_webAnimationsPendingSVGElements); |
101 | 101 |
102 // TODO(alancutter): Make SVG animation effect application a separate document
lifecycle phase from servicing animations to be responsive to Javascript manipu
lation of exposed animation objects. | 102 // TODO(alancutter): Make SVG animation effect application a separate document |
| 103 // lifecycle phase from servicing animations to be responsive to Javascript |
| 104 // manipulation of exposed animation objects. |
103 for (auto& svgElement : webAnimationsPendingSVGElements) | 105 for (auto& svgElement : webAnimationsPendingSVGElements) |
104 svgElement->applyActiveWebAnimations(); | 106 svgElement->applyActiveWebAnimations(); |
105 | 107 |
106 ASSERT(m_webAnimationsPendingSVGElements.isEmpty()); | 108 ASSERT(m_webAnimationsPendingSVGElements.isEmpty()); |
107 } | 109 } |
108 | 110 |
109 void SVGDocumentExtensions::startAnimations() { | 111 void SVGDocumentExtensions::startAnimations() { |
110 // FIXME: Eventually every "Time Container" will need a way to latch on to som
e global timer | 112 // FIXME: Eventually every "Time Container" will need a way to latch on to |
111 // starting animations for a document will do this "latching" | 113 // some global timer starting animations for a document will do this |
112 // FIXME: We hold a ref pointers to prevent a shadow tree from getting removed
out from underneath us. | 114 // "latching" |
113 // In the future we should refactor the use-element to avoid this. See https:/
/webkit.org/b/53704 | 115 // FIXME: We hold a ref pointers to prevent a shadow tree from getting removed |
| 116 // out from underneath us. In the future we should refactor the use-element |
| 117 // to avoid this. See https://webkit.org/b/53704 |
114 HeapVector<Member<SVGSVGElement>> timeContainers; | 118 HeapVector<Member<SVGSVGElement>> timeContainers; |
115 copyToVector(m_timeContainers, timeContainers); | 119 copyToVector(m_timeContainers, timeContainers); |
116 for (const auto& container : timeContainers) { | 120 for (const auto& container : timeContainers) { |
117 SMILTimeContainer* timeContainer = container->timeContainer(); | 121 SMILTimeContainer* timeContainer = container->timeContainer(); |
118 if (!timeContainer->isStarted()) | 122 if (!timeContainer->isStarted()) |
119 timeContainer->start(); | 123 timeContainer->start(); |
120 } | 124 } |
121 } | 125 } |
122 | 126 |
123 void SVGDocumentExtensions::pauseAnimations() { | 127 void SVGDocumentExtensions::pauseAnimations() { |
124 for (SVGSVGElement* element : m_timeContainers) | 128 for (SVGSVGElement* element : m_timeContainers) |
125 element->pauseAnimations(); | 129 element->pauseAnimations(); |
126 } | 130 } |
127 | 131 |
128 void SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements() { | 132 void SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements() { |
129 HeapVector<Member<SVGSVGElement>> timeContainers; | 133 HeapVector<Member<SVGSVGElement>> timeContainers; |
130 copyToVector(m_timeContainers, timeContainers); | 134 copyToVector(m_timeContainers, timeContainers); |
131 for (const auto& container : timeContainers) { | 135 for (const auto& container : timeContainers) { |
132 SVGSVGElement* outerSVG = container.get(); | 136 SVGSVGElement* outerSVG = container.get(); |
133 if (!outerSVG->isOutermostSVGSVGElement()) | 137 if (!outerSVG->isOutermostSVGSVGElement()) |
134 continue; | 138 continue; |
135 | 139 |
136 // don't dispatch the load event document is not wellformed (for XML/standal
one svg) | 140 // Don't dispatch the load event document is not wellformed (for |
| 141 // XML/standalone svg). |
137 if (outerSVG->document().wellFormed() || | 142 if (outerSVG->document().wellFormed() || |
138 !outerSVG->document().isSVGDocument()) | 143 !outerSVG->document().isSVGDocument()) |
139 outerSVG->sendSVGLoadEventIfPossible(); | 144 outerSVG->sendSVGLoadEventIfPossible(); |
140 } | 145 } |
141 } | 146 } |
142 | 147 |
143 void SVGDocumentExtensions::reportError(const String& message) { | 148 void SVGDocumentExtensions::reportError(const String& message) { |
144 ConsoleMessage* consoleMessage = ConsoleMessage::create( | 149 ConsoleMessage* consoleMessage = ConsoleMessage::create( |
145 RenderingMessageSource, ErrorMessageLevel, "Error: " + message); | 150 RenderingMessageSource, ErrorMessageLevel, "Error: " + message); |
146 m_document->addConsoleMessage(consoleMessage); | 151 m_document->addConsoleMessage(consoleMessage); |
(...skipping 17 matching lines...) Expand all Loading... |
164 } | 169 } |
165 | 170 |
166 bool SVGDocumentExtensions::hasPendingResource(const AtomicString& id) const { | 171 bool SVGDocumentExtensions::hasPendingResource(const AtomicString& id) const { |
167 if (id.isEmpty()) | 172 if (id.isEmpty()) |
168 return false; | 173 return false; |
169 | 174 |
170 return m_pendingResources.contains(id); | 175 return m_pendingResources.contains(id); |
171 } | 176 } |
172 | 177 |
173 bool SVGDocumentExtensions::isElementPendingResources(Element* element) const { | 178 bool SVGDocumentExtensions::isElementPendingResources(Element* element) const { |
174 // This algorithm takes time proportional to the number of pending resources a
nd need not. | 179 // This algorithm takes time proportional to the number of pending resources |
175 // If performance becomes an issue we can keep a counted set of elements and a
nswer the question efficiently. | 180 // and need not. If performance becomes an issue we can keep a counted set of |
| 181 // elements and answer the question efficiently. |
176 | 182 |
177 ASSERT(element); | 183 ASSERT(element); |
178 | 184 |
179 for (const auto& entry : m_pendingResources) { | 185 for (const auto& entry : m_pendingResources) { |
180 SVGPendingElements* elements = entry.value.get(); | 186 SVGPendingElements* elements = entry.value.get(); |
181 ASSERT(elements); | 187 ASSERT(elements); |
182 | 188 |
183 if (elements->contains(element)) | 189 if (elements->contains(element)) |
184 return true; | 190 return true; |
185 } | 191 } |
(...skipping 29 matching lines...) Expand all Loading... |
215 ASSERT(elements); | 221 ASSERT(elements); |
216 ASSERT(!elements->isEmpty()); | 222 ASSERT(!elements->isEmpty()); |
217 | 223 |
218 elements->remove(element); | 224 elements->remove(element); |
219 if (elements->isEmpty()) | 225 if (elements->isEmpty()) |
220 toBeRemoved.append(entry.key); | 226 toBeRemoved.append(entry.key); |
221 } | 227 } |
222 | 228 |
223 clearHasPendingResourcesIfPossible(element); | 229 clearHasPendingResourcesIfPossible(element); |
224 | 230 |
225 // We use the removePendingResource function here because it deals with set
lifetime correctly. | 231 // We use the removePendingResource function here because it deals with set |
| 232 // lifetime correctly. |
226 for (const AtomicString& id : toBeRemoved) | 233 for (const AtomicString& id : toBeRemoved) |
227 removePendingResource(id); | 234 removePendingResource(id); |
228 } | 235 } |
229 | 236 |
230 // Remove the element from pending resources that were scheduled for removal. | 237 // Remove the element from pending resources that were scheduled for removal. |
231 if (!m_pendingResourcesForRemoval.isEmpty()) { | 238 if (!m_pendingResourcesForRemoval.isEmpty()) { |
232 Vector<AtomicString> toBeRemoved; | 239 Vector<AtomicString> toBeRemoved; |
233 for (const auto& entry : m_pendingResourcesForRemoval) { | 240 for (const auto& entry : m_pendingResourcesForRemoval) { |
234 SVGPendingElements* elements = entry.value.get(); | 241 SVGPendingElements* elements = entry.value.get(); |
235 ASSERT(elements); | 242 ASSERT(elements); |
236 ASSERT(!elements->isEmpty()); | 243 ASSERT(!elements->isEmpty()); |
237 | 244 |
238 elements->remove(element); | 245 elements->remove(element); |
239 if (elements->isEmpty()) | 246 if (elements->isEmpty()) |
240 toBeRemoved.append(entry.key); | 247 toBeRemoved.append(entry.key); |
241 } | 248 } |
242 | 249 |
243 // We use the removePendingResourceForRemoval function here because it deals
with set lifetime correctly. | 250 // We use the removePendingResourceForRemoval function here because it deals |
| 251 // with set lifetime correctly. |
244 for (const AtomicString& id : toBeRemoved) | 252 for (const AtomicString& id : toBeRemoved) |
245 removePendingResourceForRemoval(id); | 253 removePendingResourceForRemoval(id); |
246 } | 254 } |
247 } | 255 } |
248 | 256 |
249 SVGDocumentExtensions::SVGPendingElements* | 257 SVGDocumentExtensions::SVGPendingElements* |
250 SVGDocumentExtensions::removePendingResource(const AtomicString& id) { | 258 SVGDocumentExtensions::removePendingResource(const AtomicString& id) { |
251 ASSERT(m_pendingResources.contains(id)); | 259 ASSERT(m_pendingResources.contains(id)); |
252 return m_pendingResources.take(id); | 260 return m_pendingResources.take(id); |
253 } | 261 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 DEFINE_TRACE(SVGDocumentExtensions) { | 358 DEFINE_TRACE(SVGDocumentExtensions) { |
351 visitor->trace(m_document); | 359 visitor->trace(m_document); |
352 visitor->trace(m_timeContainers); | 360 visitor->trace(m_timeContainers); |
353 visitor->trace(m_webAnimationsPendingSVGElements); | 361 visitor->trace(m_webAnimationsPendingSVGElements); |
354 visitor->trace(m_relativeLengthSVGRoots); | 362 visitor->trace(m_relativeLengthSVGRoots); |
355 visitor->trace(m_pendingResources); | 363 visitor->trace(m_pendingResources); |
356 visitor->trace(m_pendingResourcesForRemoval); | 364 visitor->trace(m_pendingResourcesForRemoval); |
357 } | 365 } |
358 | 366 |
359 } // namespace blink | 367 } // namespace blink |
OLD | NEW |