OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 DCHECK_EQ(shouldApply, ApplyCSSAnimation); | 199 DCHECK_EQ(shouldApply, ApplyCSSAnimation); |
200 | 200 |
201 // CSS properties animation code-path. | 201 // CSS properties animation code-path. |
202 String baseValue; | 202 String baseValue; |
203 DCHECK(isTargetAttributeCSSProperty(targetElement, attributeName)); | 203 DCHECK(isTargetAttributeCSSProperty(targetElement, attributeName)); |
204 computeCSSPropertyValue(targetElement, cssPropertyID(attributeName.localName ()), baseValue); | 204 computeCSSPropertyValue(targetElement, cssPropertyID(attributeName.localName ()), baseValue); |
205 | 205 |
206 m_animatedProperty = m_animator.constructFromString(baseValue); | 206 m_animatedProperty = m_animator.constructFromString(baseValue); |
207 } | 207 } |
208 | 208 |
209 static inline void applyCSSPropertyToTargetAndInstances(SVGElement* targetElemen t, const QualifiedName& attributeName, const String& valueAsString) | 209 static bool targetIsUsable(SVGElement* targetElement, const QualifiedName& attri bute) |
210 { | 210 { |
211 ASSERT(targetElement); | 211 return attribute != anyQName() |
212 if (attributeName == anyQName() || !targetElement->isConnected() || !targetE lement->parentNode()) | 212 && targetElement->isConnected() && targetElement->parentNode(); |
213 return; | |
214 | |
215 CSSPropertyID id = cssPropertyID(attributeName.localName()); | |
216 MutableStylePropertySet* propertySet = targetElement->ensureAnimatedSMILStyl eProperties(); | |
217 if (!propertySet->setProperty(id, valueAsString, false, 0)) | |
218 return; | |
219 | |
220 targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTra cing::create(StyleChangeReason::Animation)); | |
221 } | |
222 | |
223 static inline void removeCSSPropertyFromTargetAndInstances(SVGElement* targetEle ment, const QualifiedName& attributeName) | |
224 { | |
225 ASSERT(targetElement); | |
226 if (attributeName == anyQName() || !targetElement->isConnected() || !targetE lement->parentNode()) | |
227 return; | |
228 | |
229 CSSPropertyID id = cssPropertyID(attributeName.localName()); | |
230 targetElement->ensureAnimatedSMILStyleProperties()->removeProperty(id); | |
231 targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTra cing::create(StyleChangeReason::Animation)); | |
232 } | |
233 | |
234 static inline void notifyTargetAndInstancesAboutAnimValChange(SVGElement* target Element, const QualifiedName& attributeName) | |
235 { | |
236 ASSERT(targetElement); | |
237 if (attributeName == anyQName() || !targetElement->isConnected() || !targetE lement->parentNode()) | |
238 return; | |
239 | |
240 targetElement->invalidateAnimatedAttribute(attributeName); | |
241 } | 213 } |
242 | 214 |
243 void SVGAnimateElement::clearAnimatedType() | 215 void SVGAnimateElement::clearAnimatedType() |
244 { | 216 { |
245 if (!m_animatedProperty) | 217 if (!m_animatedProperty) |
246 return; | 218 return; |
247 | 219 |
248 // The animated property lock is held for the "result animation" (see SMILTi meContainer::updateAnimations()) | 220 // The animated property lock is held for the "result animation" (see SMILTi meContainer::updateAnimations()) |
249 // while we're processing an animation group. We will very likely crash late r if we clear the animated type | 221 // while we're processing an animation group. We will very likely crash late r if we clear the animated type |
250 // while the lock is held. See crbug.com/581546. | 222 // while the lock is held. See crbug.com/581546. |
251 DCHECK(!animatedTypeIsLocked()); | 223 DCHECK(!animatedTypeIsLocked()); |
252 | 224 |
253 SVGElement* targetElement = this->targetElement(); | 225 SVGElement* targetElement = this->targetElement(); |
254 if (!targetElement) { | 226 if (!targetElement) { |
255 m_animatedProperty.clear(); | 227 m_animatedProperty.clear(); |
256 return; | 228 return; |
257 } | 229 } |
258 | 230 |
259 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement, a ttributeName()); | 231 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement, a ttributeName()); |
260 if (shouldApply == ApplyXMLandCSSAnimation) { | 232 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingCSSPrope rty()) { |
261 removeCSSPropertyFromTargetAndInstances(targetElement, attributeName()); | |
262 } else if (m_animator.isAnimatingCSSProperty()) { | |
263 // CSS properties animation code-path. | 233 // CSS properties animation code-path. |
264 removeCSSPropertyFromTargetAndInstances(targetElement, attributeName()); | 234 if (targetIsUsable(targetElement, attributeName())) { |
265 m_animatedProperty.clear(); | 235 CSSPropertyID id = cssPropertyID(attributeName().localName()); |
266 m_animator.clear(); | 236 targetElement->ensureAnimatedSMILStyleProperties()->removeProperty(i d); |
267 return; | 237 targetElement->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReas onForTracing::create(StyleChangeReason::Animation)); |
238 } | |
268 } | 239 } |
269 | 240 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingSVGDom() ) { |
270 // SVG DOM animVal animation code-path. | 241 // SVG DOM animVal animation code-path. |
271 if (m_animatedProperty) { | |
272 m_animator.stopAnimValAnimation(); | 242 m_animator.stopAnimValAnimation(); |
273 notifyTargetAndInstancesAboutAnimValChange(targetElement, attributeName( )); | 243 if (targetIsUsable(targetElement, attributeName())) |
pdr.
2016/08/26 01:28:12
The attribute check is sort of unrelated to whethe
fs
2016/08/26 08:45:27
Well, we could make that "shouldApply != DontApply
| |
244 targetElement->invalidateAnimatedAttribute(attributeName()); | |
274 } | 245 } |
275 | 246 |
276 m_animatedProperty.clear(); | 247 m_animatedProperty.clear(); |
277 m_animator.clear(); | 248 m_animator.clear(); |
278 } | 249 } |
279 | 250 |
280 void SVGAnimateElement::applyResultsToTarget() | 251 void SVGAnimateElement::applyResultsToTarget() |
281 { | 252 { |
282 ASSERT(animatedPropertyType() != AnimatedTransformList || isSVGAnimateTransf ormElement(*this)); | 253 ASSERT(animatedPropertyType() != AnimatedTransformList || isSVGAnimateTransf ormElement(*this)); |
283 ASSERT(animatedPropertyType() != AnimatedUnknown); | 254 ASSERT(animatedPropertyType() != AnimatedUnknown); |
284 | 255 |
285 // Early exit if our animated type got destructed by a previous endedActiveI nterval(). | 256 // Early exit if our animated type got destructed by a previous endedActiveI nterval(). |
286 if (!m_animatedProperty) | 257 if (!m_animatedProperty) |
287 return; | 258 return; |
288 | 259 |
289 // We do update the style and the animation property independent of each oth er. | 260 // We do update the style and the animation property independent of each oth er. |
290 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement(), attributeName()); | 261 ShouldApplyAnimationType shouldApply = shouldApplyAnimation(targetElement(), attributeName()); |
291 if (shouldApply == ApplyXMLandCSSAnimation) { | 262 DCHECK(targetElement()); |
292 applyCSSPropertyToTargetAndInstances(targetElement(), attributeName(), m _animatedProperty->valueAsString()); | 263 if (!targetIsUsable(targetElement(), attributeName())) |
293 } else if (m_animator.isAnimatingCSSProperty()) { | 264 return; |
265 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingCSSPrope rty()) { | |
294 // CSS properties animation code-path. | 266 // CSS properties animation code-path. |
295 // Convert the result of the animation to a String and apply it as CSS p roperty on the target & all instances. | 267 // Convert the result of the animation to a String and apply it as CSS p roperty on the target. |
296 applyCSSPropertyToTargetAndInstances(targetElement(), attributeName(), m _animatedProperty->valueAsString()); | 268 CSSPropertyID id = cssPropertyID(attributeName().localName()); |
297 return; | 269 MutableStylePropertySet* propertySet = targetElement()->ensureAnimatedSM ILStyleProperties(); |
270 if (propertySet->setProperty(id, m_animatedProperty->valueAsString(), fa lse, 0)) | |
271 targetElement()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeRe asonForTracing::create(StyleChangeReason::Animation)); | |
298 } | 272 } |
299 | 273 if (shouldApply == ApplyXMLandCSSAnimation || m_animator.isAnimatingSVGDom() ) { |
300 // SVG DOM animVal animation code-path. | 274 // SVG DOM animVal animation code-path. |
301 // At this point the SVG DOM values are already changed, unlike for CSS. | 275 // At this point the SVG DOM values are already changed, unlike for CSS. |
302 // We only have to trigger update notifications here. | 276 // We only have to trigger update notifications here. |
303 notifyTargetAndInstancesAboutAnimValChange(targetElement(), attributeName()) ; | 277 targetElement()->invalidateAnimatedAttribute(attributeName()); |
278 } | |
304 } | 279 } |
305 | 280 |
306 bool SVGAnimateElement::animatedPropertyTypeSupportsAddition() | 281 bool SVGAnimateElement::animatedPropertyTypeSupportsAddition() |
307 { | 282 { |
308 // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndPropert ies. | 283 // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndPropert ies. |
309 switch (animatedPropertyType()) { | 284 switch (animatedPropertyType()) { |
310 case AnimatedBoolean: | 285 case AnimatedBoolean: |
311 case AnimatedEnumeration: | 286 case AnimatedEnumeration: |
312 case AnimatedPreserveAspectRatio: | 287 case AnimatedPreserveAspectRatio: |
313 case AnimatedString: | 288 case AnimatedString: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 { | 338 { |
364 visitor->trace(m_fromProperty); | 339 visitor->trace(m_fromProperty); |
365 visitor->trace(m_toProperty); | 340 visitor->trace(m_toProperty); |
366 visitor->trace(m_toAtEndOfDurationProperty); | 341 visitor->trace(m_toAtEndOfDurationProperty); |
367 visitor->trace(m_animatedProperty); | 342 visitor->trace(m_animatedProperty); |
368 visitor->trace(m_animator); | 343 visitor->trace(m_animator); |
369 SVGAnimationElement::trace(visitor); | 344 SVGAnimationElement::trace(visitor); |
370 } | 345 } |
371 | 346 |
372 } // namespace blink | 347 } // namespace blink |
OLD | NEW |