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 16 matching lines...) Expand all Loading... |
27 #include "core/css/StylePropertySet.h" | 27 #include "core/css/StylePropertySet.h" |
28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
29 #include "core/dom/QualifiedName.h" | 29 #include "core/dom/QualifiedName.h" |
30 #include "core/dom/StyleChangeReason.h" | 30 #include "core/dom/StyleChangeReason.h" |
31 #include "core/svg/properties/SVGProperty.h" | 31 #include "core/svg/properties/SVGProperty.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
| 37 bool isTargetAttributeCSSProperty(SVGElement& targetElement, |
| 38 const QualifiedName& attributeName) { |
| 39 return SVGElement::isAnimatableCSSProperty(attributeName) || |
| 40 targetElement.isPresentationAttribute(attributeName); |
| 41 } |
| 42 |
37 String computeCSSPropertyValue(SVGElement* element, CSSPropertyID id) { | 43 String computeCSSPropertyValue(SVGElement* element, CSSPropertyID id) { |
38 DCHECK(element); | 44 DCHECK(element); |
39 // TODO(fs): StyleEngine doesn't support document without a frame. | 45 // TODO(fs): StyleEngine doesn't support document without a frame. |
40 // Refer to comment in Element::computedStyle. | 46 // Refer to comment in Element::computedStyle. |
41 DCHECK(element->inActiveDocument()); | 47 DCHECK(element->inActiveDocument()); |
42 | 48 |
43 // Don't include any properties resulting from CSS Transitions/Animations or | 49 // Don't include any properties resulting from CSS Transitions/Animations or |
44 // SMIL animations, as we want to retrieve the "base value". | 50 // SMIL animations, as we want to retrieve the "base value". |
45 element->setUseOverrideComputedStyle(true); | 51 element->setUseOverrideComputedStyle(true); |
46 String value = | 52 String value = |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 SVGAnimateElement::ShouldApplyAnimationType | 141 SVGAnimateElement::ShouldApplyAnimationType |
136 SVGAnimateElement::shouldApplyAnimation(SVGElement* targetElement, | 142 SVGAnimateElement::shouldApplyAnimation(SVGElement* targetElement, |
137 const QualifiedName& attributeName) { | 143 const QualifiedName& attributeName) { |
138 if (!hasValidAttributeType() || attributeName == anyQName() || | 144 if (!hasValidAttributeType() || attributeName == anyQName() || |
139 !targetElement || !targetElement->inActiveDocument() || | 145 !targetElement || !targetElement->inActiveDocument() || |
140 !targetElement->parentNode()) | 146 !targetElement->parentNode()) |
141 return DontApplyAnimation; | 147 return DontApplyAnimation; |
142 | 148 |
143 // Always animate CSS properties using the ApplyCSSAnimation code path, | 149 // Always animate CSS properties using the ApplyCSSAnimation code path, |
144 // regardless of the attributeType value. | 150 // regardless of the attributeType value. |
145 if (isTargetAttributeCSSProperty(targetElement, attributeName)) { | 151 if (isTargetAttributeCSSProperty(*targetElement, attributeName)) { |
146 if (targetElement->isPresentationAttributeWithSVGDOM(attributeName)) | 152 if (targetElement->isPresentationAttributeWithSVGDOM(attributeName)) |
147 return ApplyXMLandCSSAnimation; | 153 return ApplyXMLandCSSAnimation; |
148 | 154 |
149 return ApplyCSSAnimation; | 155 return ApplyCSSAnimation; |
150 } | 156 } |
151 // If attributeType="CSS" and attributeName doesn't point to a CSS property, | 157 // If attributeType="CSS" and attributeName doesn't point to a CSS property, |
152 // ignore the animation. | 158 // ignore the animation. |
153 if (getAttributeType() == AttributeTypeCSS) | 159 if (getAttributeType() == AttributeTypeCSS) |
154 return DontApplyAnimation; | 160 return DontApplyAnimation; |
155 | 161 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 if (shouldApply == ApplyXMLAnimation || | 286 if (shouldApply == ApplyXMLAnimation || |
281 shouldApply == ApplyXMLandCSSAnimation) { | 287 shouldApply == ApplyXMLandCSSAnimation) { |
282 // SVG DOM animVal animation code-path. | 288 // SVG DOM animVal animation code-path. |
283 m_animatedProperty = m_animator.createAnimatedValue(); | 289 m_animatedProperty = m_animator.createAnimatedValue(); |
284 targetElement->setAnimatedAttribute(attributeName, m_animatedProperty); | 290 targetElement->setAnimatedAttribute(attributeName, m_animatedProperty); |
285 return; | 291 return; |
286 } | 292 } |
287 DCHECK_EQ(shouldApply, ApplyCSSAnimation); | 293 DCHECK_EQ(shouldApply, ApplyCSSAnimation); |
288 | 294 |
289 // CSS properties animation code-path. | 295 // CSS properties animation code-path. |
290 DCHECK(isTargetAttributeCSSProperty(targetElement, attributeName)); | 296 DCHECK(isTargetAttributeCSSProperty(*targetElement, attributeName)); |
291 String baseValue = computeCSSPropertyValue( | 297 String baseValue = computeCSSPropertyValue( |
292 targetElement, cssPropertyID(attributeName.localName())); | 298 targetElement, cssPropertyID(attributeName.localName())); |
293 m_animatedProperty = m_animator.createPropertyForAnimation(baseValue); | 299 m_animatedProperty = m_animator.createPropertyForAnimation(baseValue); |
294 } | 300 } |
295 | 301 |
296 void SVGAnimateElement::clearAnimatedType() { | 302 void SVGAnimateElement::clearAnimatedType() { |
297 if (!m_animatedProperty) | 303 if (!m_animatedProperty) |
298 return; | 304 return; |
299 | 305 |
300 // The animated property lock is held for the "result animation" (see | 306 // The animated property lock is held for the "result animation" (see |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 m_attributeType = AttributeTypeXML; | 433 m_attributeType = AttributeTypeXML; |
428 else | 434 else |
429 m_attributeType = AttributeTypeAuto; | 435 m_attributeType = AttributeTypeAuto; |
430 checkInvalidCSSAttributeType(); | 436 checkInvalidCSSAttributeType(); |
431 } | 437 } |
432 | 438 |
433 void SVGAnimateElement::checkInvalidCSSAttributeType() { | 439 void SVGAnimateElement::checkInvalidCSSAttributeType() { |
434 bool hasInvalidCSSAttributeType = | 440 bool hasInvalidCSSAttributeType = |
435 targetElement() && hasValidAttributeName() && | 441 targetElement() && hasValidAttributeName() && |
436 getAttributeType() == AttributeTypeCSS && | 442 getAttributeType() == AttributeTypeCSS && |
437 !isTargetAttributeCSSProperty(targetElement(), attributeName()); | 443 !isTargetAttributeCSSProperty(*targetElement(), attributeName()); |
438 | 444 |
439 if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) { | 445 if (hasInvalidCSSAttributeType != m_hasInvalidCSSAttributeType) { |
440 if (hasInvalidCSSAttributeType) | 446 if (hasInvalidCSSAttributeType) |
441 unscheduleIfScheduled(); | 447 unscheduleIfScheduled(); |
442 | 448 |
443 m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType; | 449 m_hasInvalidCSSAttributeType = hasInvalidCSSAttributeType; |
444 | 450 |
445 if (!hasInvalidCSSAttributeType) | 451 if (!hasInvalidCSSAttributeType) |
446 schedule(); | 452 schedule(); |
447 } | 453 } |
(...skipping 14 matching lines...) Expand all Loading... |
462 DEFINE_TRACE(SVGAnimateElement) { | 468 DEFINE_TRACE(SVGAnimateElement) { |
463 visitor->trace(m_fromProperty); | 469 visitor->trace(m_fromProperty); |
464 visitor->trace(m_toProperty); | 470 visitor->trace(m_toProperty); |
465 visitor->trace(m_toAtEndOfDurationProperty); | 471 visitor->trace(m_toAtEndOfDurationProperty); |
466 visitor->trace(m_animatedProperty); | 472 visitor->trace(m_animatedProperty); |
467 visitor->trace(m_animator); | 473 visitor->trace(m_animator); |
468 SVGAnimationElement::trace(visitor); | 474 SVGAnimationElement::trace(visitor); |
469 } | 475 } |
470 | 476 |
471 } // namespace blink | 477 } // namespace blink |
OLD | NEW |