| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 SVGElement* svgParent = toSVGElement(parent); | 127 SVGElement* svgParent = toSVGElement(parent); |
| 128 // Replace 'inherit' by its computed property value. | 128 // Replace 'inherit' by its computed property value. |
| 129 String value = computeCSSPropertyValue( | 129 String value = computeCSSPropertyValue( |
| 130 svgParent, cssPropertyID(attributeName().localName())); | 130 svgParent, cssPropertyID(attributeName().localName())); |
| 131 return m_animator.createPropertyForAnimation(value); | 131 return m_animator.createPropertyForAnimation(value); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void SVGAnimateElement::calculateAnimatedValue(float percentage, | 134 void SVGAnimateElement::calculateAnimatedValue(float percentage, |
| 135 unsigned repeatCount, | 135 unsigned repeatCount, |
| 136 SVGSMILElement* resultElement) { | 136 SVGSMILElement* resultElement) { |
| 137 ASSERT(resultElement); | 137 DCHECK(resultElement); |
| 138 SVGElement* targetElement = this->targetElement(); | 138 DCHECK(targetElement()); |
| 139 if (!targetElement || !isSVGAnimateElement(*resultElement)) | 139 if (!isSVGAnimateElement(*resultElement)) |
| 140 return; | 140 return; |
| 141 | 141 |
| 142 ASSERT(percentage >= 0 && percentage <= 1); | 142 ASSERT(percentage >= 0 && percentage <= 1); |
| 143 ASSERT(animatedPropertyType() != AnimatedTransformList || | 143 ASSERT(animatedPropertyType() != AnimatedTransformList || |
| 144 isSVGAnimateTransformElement(*this)); | 144 isSVGAnimateTransformElement(*this)); |
| 145 ASSERT(animatedPropertyType() != AnimatedUnknown); | 145 ASSERT(animatedPropertyType() != AnimatedUnknown); |
| 146 ASSERT(m_fromProperty); | 146 ASSERT(m_fromProperty); |
| 147 ASSERT(m_fromProperty->type() == animatedPropertyType()); | 147 ASSERT(m_fromProperty->type() == animatedPropertyType()); |
| 148 ASSERT(m_toProperty); | 148 ASSERT(m_toProperty); |
| 149 | 149 |
| 150 SVGAnimateElement* resultAnimationElement = | 150 SVGAnimateElement* resultAnimationElement = |
| 151 toSVGAnimateElement(resultElement); | 151 toSVGAnimateElement(resultElement); |
| 152 ASSERT(resultAnimationElement->m_animatedProperty); | 152 ASSERT(resultAnimationElement->m_animatedProperty); |
| 153 ASSERT(resultAnimationElement->animatedPropertyType() == | 153 ASSERT(resultAnimationElement->animatedPropertyType() == |
| 154 animatedPropertyType()); | 154 animatedPropertyType()); |
| 155 | 155 |
| 156 if (isSVGSetElement(*this)) | 156 if (isSVGSetElement(*this)) |
| 157 percentage = 1; | 157 percentage = 1; |
| 158 | 158 |
| 159 if (getCalcMode() == CalcModeDiscrete) | 159 if (getCalcMode() == CalcModeDiscrete) |
| 160 percentage = percentage < 0.5 ? 0 : 1; | 160 percentage = percentage < 0.5 ? 0 : 1; |
| 161 | 161 |
| 162 // Target element might have changed. | 162 // Target element might have changed. |
| 163 SVGElement* targetElement = this->targetElement(); |
| 163 m_animator.setContextElement(targetElement); | 164 m_animator.setContextElement(targetElement); |
| 164 | 165 |
| 165 // Values-animation accumulates using the last values entry corresponding to | 166 // Values-animation accumulates using the last values entry corresponding to |
| 166 // the end of duration time. | 167 // the end of duration time. |
| 167 SVGPropertyBase* animatedValue = resultAnimationElement->m_animatedProperty; | 168 SVGPropertyBase* animatedValue = resultAnimationElement->m_animatedProperty; |
| 168 SVGPropertyBase* toAtEndOfDurationValue = | 169 SVGPropertyBase* toAtEndOfDurationValue = |
| 169 m_toAtEndOfDurationProperty ? m_toAtEndOfDurationProperty : m_toProperty; | 170 m_toAtEndOfDurationProperty ? m_toAtEndOfDurationProperty : m_toProperty; |
| 170 SVGPropertyBase* fromValue = | 171 SVGPropertyBase* fromValue = |
| 171 getAnimationMode() == ToAnimation ? animatedValue : m_fromProperty.get(); | 172 getAnimationMode() == ToAnimation ? animatedValue : m_fromProperty.get(); |
| 172 SVGPropertyBase* toValue = m_toProperty; | 173 SVGPropertyBase* toValue = m_toProperty; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 184 const String& toAtEndOfDurationString) { | 185 const String& toAtEndOfDurationString) { |
| 185 if (toAtEndOfDurationString.isEmpty()) | 186 if (toAtEndOfDurationString.isEmpty()) |
| 186 return false; | 187 return false; |
| 187 m_toAtEndOfDurationProperty = | 188 m_toAtEndOfDurationProperty = |
| 188 m_animator.createPropertyForAnimation(toAtEndOfDurationString); | 189 m_animator.createPropertyForAnimation(toAtEndOfDurationString); |
| 189 return true; | 190 return true; |
| 190 } | 191 } |
| 191 | 192 |
| 192 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, | 193 bool SVGAnimateElement::calculateFromAndToValues(const String& fromString, |
| 193 const String& toString) { | 194 const String& toString) { |
| 194 SVGElement* targetElement = this->targetElement(); | 195 DCHECK(targetElement()); |
| 195 if (!targetElement) | |
| 196 return false; | |
| 197 | |
| 198 m_fromProperty = m_animator.createPropertyForAnimation(fromString); | 196 m_fromProperty = m_animator.createPropertyForAnimation(fromString); |
| 199 m_fromPropertyValueType = propertyValueType(attributeName(), fromString); | 197 m_fromPropertyValueType = propertyValueType(attributeName(), fromString); |
| 200 m_toProperty = m_animator.createPropertyForAnimation(toString); | 198 m_toProperty = m_animator.createPropertyForAnimation(toString); |
| 201 m_toPropertyValueType = propertyValueType(attributeName(), toString); | 199 m_toPropertyValueType = propertyValueType(attributeName(), toString); |
| 202 return true; | 200 return true; |
| 203 } | 201 } |
| 204 | 202 |
| 205 bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, | 203 bool SVGAnimateElement::calculateFromAndByValues(const String& fromString, |
| 206 const String& byString) { | 204 const String& byString) { |
| 207 SVGElement* targetElement = this->targetElement(); | 205 DCHECK(targetElement()); |
| 208 if (!targetElement) | |
| 209 return false; | |
| 210 | 206 |
| 211 if (getAnimationMode() == ByAnimation && !isAdditive()) | 207 if (getAnimationMode() == ByAnimation && !isAdditive()) |
| 212 return false; | 208 return false; |
| 213 | 209 |
| 214 // from-by animation may only be used with attributes that support addition | 210 // from-by animation may only be used with attributes that support addition |
| 215 // (e.g. most numeric attributes). | 211 // (e.g. most numeric attributes). |
| 216 if (getAnimationMode() == FromByAnimation && | 212 if (getAnimationMode() == FromByAnimation && |
| 217 !animatedPropertyTypeSupportsAddition()) | 213 !animatedPropertyTypeSupportsAddition()) |
| 218 return false; | 214 return false; |
| 219 | 215 |
| 220 DCHECK(!isSVGSetElement(*this)); | 216 DCHECK(!isSVGSetElement(*this)); |
| 221 | 217 |
| 222 m_fromProperty = m_animator.createPropertyForAnimation(fromString); | 218 m_fromProperty = m_animator.createPropertyForAnimation(fromString); |
| 223 m_fromPropertyValueType = propertyValueType(attributeName(), fromString); | 219 m_fromPropertyValueType = propertyValueType(attributeName(), fromString); |
| 224 m_toProperty = m_animator.createPropertyForAnimation(byString); | 220 m_toProperty = m_animator.createPropertyForAnimation(byString); |
| 225 m_toPropertyValueType = propertyValueType(attributeName(), byString); | 221 m_toPropertyValueType = propertyValueType(attributeName(), byString); |
| 226 m_toProperty->add(m_fromProperty, targetElement); | 222 m_toProperty->add(m_fromProperty, targetElement()); |
| 227 return true; | 223 return true; |
| 228 } | 224 } |
| 229 | 225 |
| 230 void SVGAnimateElement::resetAnimatedType() { | 226 void SVGAnimateElement::resetAnimatedType() { |
| 231 SVGElement* targetElement = this->targetElement(); | 227 SVGElement* targetElement = this->targetElement(); |
| 232 const QualifiedName& attributeName = this->attributeName(); | 228 const QualifiedName& attributeName = this->attributeName(); |
| 233 | 229 |
| 234 m_animator.reset(targetElement); | 230 m_animator.reset(targetElement); |
| 235 | 231 |
| 236 ShouldApplyAnimationType shouldApply = | 232 ShouldApplyAnimationType shouldApply = |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 getAnimationMode() == FromByAnimation) { | 348 getAnimationMode() == FromByAnimation) { |
| 353 if (!animatedPropertyTypeSupportsAddition()) | 349 if (!animatedPropertyTypeSupportsAddition()) |
| 354 return false; | 350 return false; |
| 355 } | 351 } |
| 356 | 352 |
| 357 return SVGAnimationElement::isAdditive(); | 353 return SVGAnimationElement::isAdditive(); |
| 358 } | 354 } |
| 359 | 355 |
| 360 float SVGAnimateElement::calculateDistance(const String& fromString, | 356 float SVGAnimateElement::calculateDistance(const String& fromString, |
| 361 const String& toString) { | 357 const String& toString) { |
| 358 DCHECK(targetElement()); |
| 362 // FIXME: A return value of float is not enough to support paced animations on | 359 // FIXME: A return value of float is not enough to support paced animations on |
| 363 // lists. | 360 // lists. |
| 364 SVGElement* targetElement = this->targetElement(); | |
| 365 if (!targetElement) | |
| 366 return -1; | |
| 367 SVGPropertyBase* fromValue = | 361 SVGPropertyBase* fromValue = |
| 368 m_animator.createPropertyForAnimation(fromString); | 362 m_animator.createPropertyForAnimation(fromString); |
| 369 SVGPropertyBase* toValue = m_animator.createPropertyForAnimation(toString); | 363 SVGPropertyBase* toValue = m_animator.createPropertyForAnimation(toString); |
| 370 return fromValue->calculateDistance(toValue, targetElement); | 364 return fromValue->calculateDistance(toValue, targetElement()); |
| 371 } | 365 } |
| 372 | 366 |
| 373 void SVGAnimateElement::setTargetElement(SVGElement* target) { | 367 void SVGAnimateElement::setTargetElement(SVGElement* target) { |
| 374 SVGAnimationElement::setTargetElement(target); | 368 SVGAnimationElement::setTargetElement(target); |
| 375 resetAnimatedPropertyType(); | 369 resetAnimatedPropertyType(); |
| 376 } | 370 } |
| 377 | 371 |
| 378 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { | 372 void SVGAnimateElement::setAttributeName(const QualifiedName& attributeName) { |
| 379 SVGAnimationElement::setAttributeName(attributeName); | 373 SVGAnimationElement::setAttributeName(attributeName); |
| 380 resetAnimatedPropertyType(); | 374 resetAnimatedPropertyType(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 391 DEFINE_TRACE(SVGAnimateElement) { | 385 DEFINE_TRACE(SVGAnimateElement) { |
| 392 visitor->trace(m_fromProperty); | 386 visitor->trace(m_fromProperty); |
| 393 visitor->trace(m_toProperty); | 387 visitor->trace(m_toProperty); |
| 394 visitor->trace(m_toAtEndOfDurationProperty); | 388 visitor->trace(m_toAtEndOfDurationProperty); |
| 395 visitor->trace(m_animatedProperty); | 389 visitor->trace(m_animatedProperty); |
| 396 visitor->trace(m_animator); | 390 visitor->trace(m_animator); |
| 397 SVGAnimationElement::trace(visitor); | 391 SVGAnimationElement::trace(visitor); |
| 398 } | 392 } |
| 399 | 393 |
| 400 } // namespace blink | 394 } // namespace blink |
| OLD | NEW |