Changeset 89187 in webkit
- Timestamp:
- Jun 17, 2011 10:30:53 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 19 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r89183 r89187 1 2011-06-17 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Rob Buis. 4 5 SVGAnimation should use direct unit animation for SVGAngle 6 https://bugs.webkit.org/show_bug.cgi?id=62807 7 8 Tests animation of SVGAngle with different units. 9 10 * svg/animations/script-tests/svgangle-animation-deg-to-grad.js: Added. 11 (sample1): 12 (sample2): 13 (sample3): 14 (executeTest): 15 * svg/animations/script-tests/svgangle-animation-deg-to-rad.js: Added. 16 (sample1): 17 (sample2): 18 (sample3): 19 (executeTest): 20 * svg/animations/script-tests/svgangle-animation-grad-to-deg.js: Added. 21 (sample1): 22 (sample2): 23 (sample3): 24 (executeTest): 25 * svg/animations/script-tests/svgangle-animation-grad-to-rad.js: Added. 26 (sample1): 27 (sample2): 28 (sample3): 29 (executeTest): 30 * svg/animations/script-tests/svgangle-animation-rad-to-deg.js: Added. 31 (sample1): 32 (sample2): 33 (sample3): 34 (executeTest): 35 * svg/animations/script-tests/svgangle-animation-rad-to-grad.js: Added. 36 (sample1): 37 (sample2): 38 (sample3): 39 (executeTest): 40 * svg/animations/svgangle-animation-deg-to-grad-expected.txt: Added. 41 * svg/animations/svgangle-animation-deg-to-grad.html: Added. 42 * svg/animations/svgangle-animation-deg-to-rad-expected.txt: Added. 43 * svg/animations/svgangle-animation-deg-to-rad.html: Added. 44 * svg/animations/svgangle-animation-grad-to-deg-expected.txt: Added. 45 * svg/animations/svgangle-animation-grad-to-deg.html: Added. 46 * svg/animations/svgangle-animation-grad-to-rad-expected.txt: Added. 47 * svg/animations/svgangle-animation-grad-to-rad.html: Added. 48 * svg/animations/svgangle-animation-rad-to-deg-expected.txt: Added. 49 * svg/animations/svgangle-animation-rad-to-deg.html: Added. 50 * svg/animations/svgangle-animation-rad-to-grad-expected.txt: Added. 51 * svg/animations/svgangle-animation-rad-to-grad.html: Added. 52 1 53 2011-06-17 Julien Chaffraix <jchaffraix@webkit.org> 2 54 -
trunk/Source/WebCore/CMakeLists.txt
r89186 r89187 1653 1653 svg/SVGAngle.cpp 1654 1654 svg/SVGAnimateColorElement.cpp 1655 svg/SVGAnimatedAngle.cpp 1655 1656 svg/SVGAnimatedLength.cpp 1656 1657 svg/SVGAnimateElement.cpp -
trunk/Source/WebCore/ChangeLog
r89186 r89187 1 2011-06-17 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Rob Buis. 4 5 SVGAnimation should use direct unit animation for SVGAngle 6 https://bugs.webkit.org/show_bug.cgi?id=62807 7 8 Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368 9 This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGAngle. We can animate the SVG primitive datatype SVGAngle 10 with different unit types now. 11 Removed number and unit parser from SVGAnimateElement. This is not needed anymore. 12 13 Tests: svg/animations/svgangle-animation-deg-to-grad.html 14 svg/animations/svgangle-animation-deg-to-rad.html 15 svg/animations/svgangle-animation-grad-to-deg.html 16 svg/animations/svgangle-animation-grad-to-rad.html 17 svg/animations/svgangle-animation-rad-to-deg.html 18 svg/animations/svgangle-animation-rad-to-grad.html 19 20 * CMakeLists.txt: Added SVGAnimatedAngle.cpp. 21 * GNUmakefile.list.am: Ditto. 22 * WebCore.gypi: Ditto. 23 * WebCore.pro: Ditto. 24 * WebCore.xcodeproj/project.pbxproj: Ditto. 25 * svg/SVGAllInOne.cpp: Ditto. 26 * svg/SVGAnimateElement.cpp: Make use of SVGAnimator for AnimatedAngle. 27 (WebCore::SVGAnimateElement::SVGAnimateElement): 28 (WebCore::SVGAnimateElement::determineAnimatedAttributeType): Ditto. 29 (WebCore::SVGAnimateElement::calculateAnimatedValue): Ditto. 30 (WebCore::SVGAnimateElement::calculateFromAndToValues): Ditto. 31 (WebCore::SVGAnimateElement::calculateFromAndByValues): Ditto. 32 (WebCore::SVGAnimateElement::resetToBaseValue): Ditto. 33 (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto. 34 (WebCore::SVGAnimateElement::calculateDistance): Ditto. 35 * svg/SVGAnimateElement.h: 36 * svg/SVGAnimatedAngle.cpp: Added. Added SVGAnimatedAngleAnimator for animation of SVGAngles. 37 (WebCore::SVGAnimatedAngleAnimator::SVGAnimatedAngleAnimator): 38 (WebCore::sharedSVGAngle): 39 (WebCore::SVGAnimatedAngleAnimator::constructFromString): 40 (WebCore::SVGAnimatedAngleAnimator::calculateFromAndToValues): 41 (WebCore::SVGAnimatedAngleAnimator::calculateFromAndByValues): 42 (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue): 43 (WebCore::SVGAnimatedAngleAnimator::calculateDistance): 44 * svg/SVGAnimatedAngle.h: 45 (WebCore::SVGAnimatedAngleAnimator::~SVGAnimatedAngleAnimator): 46 * svg/SVGAnimatedLength.cpp: 47 (WebCore::sharedSVGLength): Use an ExceptionCode for SVGLength::setValueAsString. 48 * svg/SVGAnimatedType.h: 49 (WebCore::SVGAnimatedType::create): 50 (WebCore::SVGAnimatedType::createAngle): 51 (WebCore::SVGAnimatedType::createLength): 52 (WebCore::SVGAnimatedType::~SVGAnimatedType): 53 (WebCore::SVGAnimatedType::angle): 54 (WebCore::SVGAnimatedType::valueAsString): 55 (WebCore::SVGAnimatedType::setValueAsString): 56 (WebCore::SVGAnimatedType::SVGAnimatedType): 57 * svg/SVGAnimatorFactory.h: 58 (WebCore::SVGAnimatorFactory::create): 59 * svg/SVGLength.cpp: 60 (WebCore::SVGLength::setValueAsString): Added an ExceptionCode for consistency reasons and as preparation for future error handling. 61 * svg/SVGLength.h: 62 * svg/SVGParserUtilities.cpp: 63 (WebCore::parseNumberFromString): Added number parser for String objects. 64 * svg/SVGParserUtilities.h: 65 1 66 2011-06-17 Anna Cavender <annacc@chromium.org> 2 67 -
trunk/Source/WebCore/GNUmakefile.list.am
r89146 r89187 3336 3336 Source/WebCore/svg/SVGAnimateColorElement.cpp \ 3337 3337 Source/WebCore/svg/SVGAnimateColorElement.h \ 3338 Source/WebCore/svg/SVGAnimatedAngle.cpp \ 3338 3339 Source/WebCore/svg/SVGAnimatedAngle.h \ 3339 3340 Source/WebCore/svg/SVGAnimatedBoolean.h \ -
trunk/Source/WebCore/WebCore.gypi
r89186 r89187 5705 5705 'svg/SVGAnimateColorElement.cpp', 5706 5706 'svg/SVGAnimateColorElement.h', 5707 'svg/SVGAnimatedAngle.cpp', 5707 5708 'svg/SVGAnimatedLength.cpp', 5708 5709 'svg/SVGAnimateElement.cpp', -
trunk/Source/WebCore/WebCore.pro
r89186 r89187 3293 3293 svg/SVGAngle.cpp \ 3294 3294 svg/SVGAnimateColorElement.cpp \ 3295 svg/SVGAnimatedAngle.cpp \ 3295 3296 svg/SVGAnimatedLength.cpp \ 3296 3297 svg/SVGAnimateElement.cpp \ -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r89186 r89187 937 937 4358E8851360A33B00E4748C /* SVGFEDropShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4358E8821360A33B00E4748C /* SVGFEDropShadowElement.cpp */; }; 938 938 4358E8861360A33B00E4748C /* SVGFEDropShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */; }; 939 4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */; }; 939 940 436708C112D9CA4B00044234 /* RenderSVGBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088212D9CA4A00044234 /* RenderSVGBlock.h */; }; 940 941 436708C312D9CA4B00044234 /* RenderSVGContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4367088412D9CA4A00044234 /* RenderSVGContainer.h */; }; … … 7369 7370 4358E8831360A33B00E4748C /* SVGFEDropShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFEDropShadowElement.h; sourceTree = "<group>"; }; 7370 7371 4358E8841360A33B00E4748C /* SVGFEDropShadowElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGFEDropShadowElement.idl; sourceTree = "<group>"; }; 7372 4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedAngle.cpp; sourceTree = "<group>"; }; 7371 7373 4367088112D9CA4A00044234 /* RenderSVGBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGBlock.cpp; sourceTree = "<group>"; }; 7372 7374 4367088212D9CA4A00044234 /* RenderSVGBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGBlock.h; sourceTree = "<group>"; }; … … 17337 17339 B22277E40D00BF1F0071B782 /* SVGAnimateColorElement.h */, 17338 17340 B22277E50D00BF1F0071B782 /* SVGAnimateColorElement.idl */, 17341 4362C7B813AC6F1A00344BEB /* SVGAnimatedAngle.cpp */, 17339 17342 087B84951272CEC700A14417 /* SVGAnimatedAngle.h */, 17340 17343 B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */, … … 25730 25733 B1AD4E7313A12A4600846B27 /* CueLoader.cpp in Sources */, 25731 25734 B1AD4E7B13A12A7200846B27 /* CueParser.cpp in Sources */, 25735 4362C7B913AC6F1A00344BEB /* SVGAnimatedAngle.cpp in Sources */, 25732 25736 ); 25733 25737 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/svg/SVGAllInOne.cpp
r88663 r89187 31 31 #include "SVGAngle.cpp" 32 32 #include "SVGAnimateColorElement.cpp" 33 #include "SVGAnimatedAngle.cpp" 33 34 #include "SVGAnimatedLength.cpp" 34 35 #include "SVGAnimateElement.cpp" -
trunk/Source/WebCore/svg/SVGAnimateElement.cpp
r88663 r89187 51 51 , m_fromNumber(0) 52 52 , m_toNumber(0) 53 , m_animatedNumber(numeric_limits< double>::infinity())53 , m_animatedNumber(numeric_limits<float>::infinity()) 54 54 , m_animatedPathPointer(0) 55 55 { … … 64 64 SVGAnimateElement::~SVGAnimateElement() 65 65 { 66 }67 68 static bool parseNumberValueAndUnit(const String& in, double& value, String& unit)69 {70 // FIXME: These are from top of my head, figure out all property types that can be animated as numbers.71 unsigned unitLength = 0;72 String parse = in.stripWhiteSpace();73 if (parse.endsWith("%"))74 unitLength = 1;75 else if (parse.endsWith("deg") || parse.endsWith("rad"))76 unitLength = 3;77 else if (parse.endsWith("grad"))78 unitLength = 4;79 String newUnit = parse.right(unitLength);80 String number = parse.left(parse.length() - unitLength);81 if ((!unit.isEmpty() && newUnit != unit) || number.isEmpty())82 return false;83 UChar last = number[number.length() - 1];84 if (last < '0' || last > '9')85 return false;86 unit = newUnit;87 bool ok;88 value = number.toDouble(&ok);89 return ok;90 66 } 91 67 … … 141 117 // support continuous animations. 142 118 switch (type) { 119 case AnimatedAngle: 120 return AnimatedAngle; 143 121 case AnimatedBoolean: 144 122 case AnimatedEnumeration: … … 152 130 case AnimatedLength: 153 131 return AnimatedLength; 154 case AnimatedAngle:155 132 case AnimatedInteger: 156 133 case AnimatedNumber: … … 202 179 String fromNumberString; 203 180 adjustForInheritance(targetElement, attributeName(), fromNumberString); 204 if (!parseNumber ValueAndUnit(fromNumberString, m_fromNumber, m_numberUnit))181 if (!parseNumberFromString(fromNumberString, m_fromNumber, false)) 205 182 return; 206 183 } … … 208 185 String toNumberString; 209 186 adjustForInheritance(targetElement, attributeName(), toNumberString); 210 if (!parseNumber ValueAndUnit(toNumberString, m_toNumber, m_numberUnit))187 if (!parseNumberFromString(toNumberString, m_toNumber, false)) 211 188 return; 212 189 } 213 190 214 doublenumber;191 float number; 215 192 if (calcMode() == CalcModeDiscrete) 216 193 number = isInFirstHalfOfAnimation ? m_fromNumber : m_toNumber; … … 310 287 return; 311 288 } 289 case AnimatedAngle: 312 290 case AnimatedLength: { 313 291 ASSERT(m_animator); … … 381 359 } 382 360 case AnimatedNumber: { 383 m_numberUnit = String(); 384 if (parseNumberValueAndUnit(toString, m_toNumber, m_numberUnit)) { 361 if (parseNumberFromString(toString, m_toNumber, false)) { 385 362 // For to-animations the from number is calculated later 386 if (animationMode() == ToAnimation || parseNumber ValueAndUnit(fromString, m_fromNumber, m_numberUnit))363 if (animationMode() == ToAnimation || parseNumberFromString(fromString, m_fromNumber, false)) 387 364 return true; 388 365 } … … 409 386 break; 410 387 } 411 case AnimatedLength: { 388 case AnimatedAngle: 389 case AnimatedLength: 412 390 ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString); 413 391 return true; 414 }415 392 default: 416 393 break; … … 450 427 return true; 451 428 } 452 case AnimatedLength: { 429 case AnimatedAngle: 430 case AnimatedLength: 453 431 ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString); 454 432 return true; 455 456 }457 433 default: 458 m_numberUnit = String();459 434 m_fromNumber = 0; 460 if (!fromString.isEmpty() && !parseNumber ValueAndUnit(fromString, m_fromNumber, m_numberUnit))435 if (!fromString.isEmpty() && !parseNumberFromString(fromString, m_fromNumber, false)) 461 436 return false; 462 if (!parseNumber ValueAndUnit(byString, m_toNumber, m_numberUnit))437 if (!parseNumberFromString(byString, m_toNumber, false)) 463 438 return false; 464 439 m_toNumber += m_fromNumber; … … 485 460 if (baseString.isEmpty()) { 486 461 m_animatedNumber = 0; 487 m_numberUnit = String();488 462 return; 489 463 } 490 if (parseNumber ValueAndUnit(baseString, m_animatedNumber, m_numberUnit))464 if (parseNumberFromString(baseString, m_animatedNumber, false)) 491 465 return; 492 466 break; … … 501 475 m_animatedPoints.clear(); 502 476 return; 477 case AnimatedAngle: 503 478 case AnimatedLength: { 504 m_animatedType = ensureAnimator()->constructFromString(baseString); 479 if (!m_animatedType) 480 m_animatedType = ensureAnimator()->constructFromString(baseString); 481 else 482 m_animatedType->setValueAsString(attributeName(), baseString); 505 483 return; 506 484 } … … 514 492 { 515 493 String valueToApply; 516 if (m_animatedAttributeType == AnimatedColor) 494 switch (m_animatedAttributeType) { 495 case AnimatedColor: 517 496 valueToApply = m_animatedColor.serialized(); 518 else if (m_animatedAttributeType == AnimatedNumber) 519 valueToApply = String::number(m_animatedNumber) + m_numberUnit; 520 else if (m_animatedAttributeType == AnimatedPath) { 497 break; 498 case AnimatedNumber: 499 valueToApply = String::number(m_animatedNumber); 500 break; 501 case AnimatedPath: { 521 502 if (!m_animatedPathPointer || m_animatedPathPointer->isEmpty()) 522 503 valueToApply = m_animatedString; … … 529 510 factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing); 530 511 } 531 } else if (m_animatedAttributeType == AnimatedPoints) 512 break; 513 } 514 case AnimatedPoints: 532 515 valueToApply = m_animatedPoints.isEmpty() ? m_animatedString : m_animatedPoints.valueAsString(); 533 else if (m_animatedAttributeType == AnimatedLength) 534 valueToApply = m_animatedType->length().valueAsString(); 535 else 516 break; 517 case AnimatedAngle: 518 case AnimatedLength: 519 valueToApply = m_animatedType->valueAsString(); 520 break; 521 default: 536 522 valueToApply = m_animatedString; 537 523 } 538 524 setTargetAttributeAnimatedValue(valueToApply); 539 525 } … … 546 532 m_animatedAttributeType = determineAnimatedAttributeType(targetElement); 547 533 if (m_animatedAttributeType == AnimatedNumber) { 548 double from; 549 double to; 550 String unit; 551 if (!parseNumberValueAndUnit(fromString, from, unit)) 534 float from; 535 float to; 536 if (!parseNumberFromString(fromString, from, false)) 552 537 return -1; 553 if (!parseNumber ValueAndUnit(toString, to, unit))538 if (!parseNumberFromString(toString, to, false)) 554 539 return -1; 555 return narrowPrecisionToFloat(fabs(to - from));540 return fabs(to - from); 556 541 } 557 542 if (m_animatedAttributeType == AnimatedColor) { … … 564 549 return ColorDistance(from, to).distance(); 565 550 } 566 if (m_animatedAttributeType == Animated Length)551 if (m_animatedAttributeType == AnimatedAngle || m_animatedAttributeType == AnimatedLength) 567 552 return ensureAnimator()->calculateDistance(this, fromString, toString); 568 553 return -1; -
trunk/Source/WebCore/svg/SVGAnimateElement.h
r88663 r89187 73 73 AnimatedPropertyValueType m_fromPropertyValueType; 74 74 AnimatedPropertyValueType m_toPropertyValueType; 75 double m_fromNumber; 76 double m_toNumber; 77 double m_animatedNumber; 78 String m_numberUnit; 75 float m_fromNumber; 76 float m_toNumber; 77 float m_animatedNumber; 79 78 Color m_fromColor; 80 79 Color m_toColor; -
trunk/Source/WebCore/svg/SVGAnimatedAngle.h
r73254 r89187 23 23 #if ENABLE(SVG) 24 24 #include "SVGAngle.h" 25 #include "SVGAnimateElement.h" 25 26 #include "SVGAnimatedPropertyTearOff.h" 26 27 … … 36 37 DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedAngle, SVGAngle, UpperProperty, LowerProperty) 37 38 39 #if ENABLE(SVG_ANIMATION) 40 class SVGAnimatedAngleAnimator : public SVGAnimatedTypeAnimator { 41 42 public: 43 SVGAnimatedAngleAnimator(SVGElement* contextElement, const QualifiedName&); 44 virtual ~SVGAnimatedAngleAnimator() { } 45 46 virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&); 47 48 virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString); 49 virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString); 50 virtual void calculateAnimatedValue(SVGSMILElement*, float percentage, unsigned repeatCount, 51 OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue, 52 bool fromPropertyInherits, bool toPropertyInherits); 53 virtual float calculateDistance(SVGSMILElement*, const String& fromString, const String& toString); 54 }; 38 55 } // namespace WebCore 39 56 57 #endif // ENABLE(SVG_ANIMATION) 40 58 #endif // ENABLE(SVG) 41 59 #endif -
trunk/Source/WebCore/svg/SVGAnimatedLength.cpp
r88663 r89187 34 34 { 35 35 DEFINE_STATIC_LOCAL(SVGLength, sharedLength, ()); 36 sharedLength.setValueAsString(valueAsString, mode); 36 ExceptionCode ec = 0; 37 sharedLength.setValueAsString(valueAsString, mode, ec); 38 ASSERT(!ec); 37 39 return sharedLength; 38 40 } -
trunk/Source/WebCore/svg/SVGAnimatedType.h
r88663 r89187 22 22 23 23 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION) 24 #include "SVGAn imateElement.h"24 #include "SVGAngle.h" 25 25 #include "SVGElement.h" 26 26 #include "SVGLength.h" … … 31 31 WTF_MAKE_FAST_ALLOCATED; 32 32 public: 33 static PassOwnPtr<SVGAnimatedType> create(AnimatedAttributeType type) 34 { 35 return adoptPtr(new SVGAnimatedType(type)); 36 } 37 38 static PassOwnPtr<SVGAnimatedType> createAngle(SVGAngle* angle) 39 { 40 ASSERT(angle); 41 OwnPtr<SVGAnimatedType> animatedType = create(AnimatedAngle); 42 animatedType->m_data.angle = angle; 43 return animatedType.release(); 44 } 45 33 46 static PassOwnPtr<SVGAnimatedType> createLength(SVGLength* length) 34 47 { 35 return adoptPtr(new SVGAnimatedType(AnimatedLength, length)); 48 ASSERT(length); 49 OwnPtr<SVGAnimatedType> animatedType = create(AnimatedLength); 50 animatedType->m_data.length = length; 51 return animatedType.release(); 36 52 } 37 53 38 54 virtual ~SVGAnimatedType() 39 55 { 40 ASSERT(m_type == AnimatedLength); 41 delete m_data.length; 56 switch (m_type) { 57 case AnimatedAngle: 58 delete m_data.angle; 59 break; 60 case AnimatedLength: 61 delete m_data.length; 62 break; 63 default: 64 ASSERT_NOT_REACHED(); 65 break; 66 } 42 67 } 43 68 44 69 AnimatedAttributeType type() const { return m_type; } 45 70 71 SVGAngle& angle() 72 { 73 ASSERT(m_type == AnimatedAngle); 74 return *m_data.angle; 75 } 76 46 77 SVGLength& length() 47 78 { … … 50 81 } 51 82 83 String valueAsString() 84 { 85 switch (m_type) { 86 case AnimatedAngle: 87 ASSERT(m_data.angle); 88 return m_data.angle->valueAsString(); 89 case AnimatedLength: 90 ASSERT(m_data.length); 91 return m_data.length->valueAsString(); 92 default: 93 break; 94 } 95 ASSERT_NOT_REACHED(); 96 return String(); 97 } 98 99 bool setValueAsString(const QualifiedName& attrName, const String& value) 100 { 101 ExceptionCode ec = 0; 102 switch (m_type) { 103 case AnimatedAngle: 104 ASSERT(m_data.angle); 105 m_data.angle->setValueAsString(value, ec); 106 break; 107 case AnimatedLength: 108 ASSERT(m_data.length); 109 m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName), ec); 110 break; 111 default: 112 ASSERT_NOT_REACHED(); 113 break; 114 } 115 return !ec; 116 } 117 52 118 private: 53 SVGAnimatedType(AnimatedAttributeType type , SVGLength* length)119 SVGAnimatedType(AnimatedAttributeType type) 54 120 : m_type(type) 55 121 { 56 m_data.length = length;57 122 } 58 123 … … 66 131 67 132 // FIXME: More SVG primitive types need to be added step by step. 133 SVGAngle* angle; 68 134 SVGLength* length; 69 135 } m_data; -
trunk/Source/WebCore/svg/SVGAnimatorFactory.h
r88663 r89187 22 22 23 23 #if ENABLE(SVG) && ENABLE(SVG_ANIMATION) 24 #include "SVGAnimatedAngle.h" 24 25 #include "SVGAnimatedLength.h" 25 26 … … 32 33 // FIXME: Add animation support for all SVG units. 33 34 switch (attributeType) { 35 case AnimatedAngle: 36 return adoptPtr(new SVGAnimatedAngleAnimator(contextElement, attributeName)); 34 37 case AnimatedLength: 35 38 return adoptPtr(new SVGAnimatedLengthAnimator(contextElement, attributeName)); -
trunk/Source/WebCore/svg/SVGLength.cpp
r88663 r89187 133 133 } 134 134 135 void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode )135 void SVGLength::setValueAsString(const String& valueAsString, SVGLengthMode mode, ExceptionCode& ec) 136 136 { 137 137 m_valueInSpecifiedUnits = 0; 138 138 m_unit = storeUnit(mode, LengthTypeNumber); 139 ExceptionCode ec = 0;140 139 setValueAsString(valueAsString, ec); 141 ASSERT(!ec);142 140 } 143 141 -
trunk/Source/WebCore/svg/SVGLength.h
r88663 r89187 89 89 String valueAsString() const; 90 90 void setValueAsString(const String&, ExceptionCode&); 91 void setValueAsString(const String&, SVGLengthMode );91 void setValueAsString(const String&, SVGLengthMode, ExceptionCode&); 92 92 93 93 void newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits, ExceptionCode&); -
trunk/Source/WebCore/svg/SVGParserUtilities.cpp
r74493 r89187 148 148 } 149 149 150 bool parseNumberFromString(const String& string, float& number, bool skip) 151 { 152 const UChar* ptr = string.characters(); 153 const UChar* end = ptr + string.length(); 154 return genericParseNumber(ptr, end, number, skip); 155 } 156 150 157 // only used to parse largeArcFlag and sweepFlag which must be a "0" or "1" 151 158 // and might not have any whitespace/comma after it -
trunk/Source/WebCore/svg/SVGParserUtilities.h
r74493 r89187 34 34 35 35 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true); 36 bool parseNumberFromString(const String&, float& number, bool skip = true); 36 37 bool parseNumberOptionalNumber(const String& s, float& h, float& v); 37 38 bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag);
Note: See TracChangeset
for help on using the changeset viewer.