Changeset 56795 in webkit
- Timestamp:
- Mar 30, 2010 9:40:50 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r56793 r56795 1 2010-03-30 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Cannot animate "points" attribute for <svg:polygon> 6 https://bugs.webkit.org/show_bug.cgi?id=21371 7 8 Tests if points of a polygon are animateable. 9 10 * svg/animations/animate-points-expected.txt: Added. 11 * svg/animations/animate-points.html: Added. 12 * svg/animations/script-tests/animate-points.js: Added. 13 (sample1): 14 (sample2): 15 (sample3): 16 (executeTest): 17 1 18 2010-03-30 Pavel Feldman <pfeldman@chromium.org> 2 19 -
trunk/WebCore/ChangeLog
r56792 r56795 1 2010-03-30 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Cannot animate "points" attribute for <svg:polygon> 6 https://bugs.webkit.org/show_bug.cgi?id=21371 7 8 Add animation support for 'points' on polygons in SVG. 9 10 Test: svg/animations/animate-points.html 11 12 * svg/SVGAnimateElement.cpp: 13 (WebCore::SVGAnimateElement::determinePropertyType): 14 (WebCore::SVGAnimateElement::calculateAnimatedValue): 15 (WebCore::SVGAnimateElement::calculateFromAndToValues): 16 (WebCore::SVGAnimateElement::resetToBaseValue): 17 (WebCore::SVGAnimateElement::applyResultsToTarget): 18 * svg/SVGAnimateElement.h: 19 (WebCore::SVGAnimateElement::): added PropertyType PointsProperty 20 * svg/SVGPointList.cpp: 21 (WebCore::blendFunc): 22 (WebCore::SVGPointList::createAnimated): calculates animated PointList 23 * svg/SVGPointList.h: 24 1 25 2010-03-30 Alexander Pavlov <apavlov@chromium.org> 2 26 -
trunk/WebCore/svg/SVGAnimateElement.cpp
r50675 r56795 29 29 #include "SVGParserUtilities.h" 30 30 #include "SVGPathSegList.h" 31 #include "SVGPointList.h" 31 32 #include <math.h> 32 33 … … 81 82 if (attribute == "d") 82 83 return PathProperty; 84 if (attribute == "points") 85 return PointsProperty; 83 86 if (attribute == "color" || attribute == "fill" || attribute == "stroke") 84 87 return ColorProperty; … … 143 146 } 144 147 return; 148 } else if (m_propertyType == PointsProperty) { 149 if (percentage == 0) 150 results->m_animatedPoints = m_fromPoints; 151 else if (percentage == 1.f) 152 results->m_animatedPoints = m_toPoints; 153 else { 154 if (m_fromPoints && m_toPoints) 155 results->m_animatedPoints = SVGPointList::createAnimated(m_fromPoints.get(), m_toPoints.get(), percentage); 156 else 157 results->m_animatedPoints.clear(); 158 // Fall back to discrete animation if the points are not compatible 159 if (!results->m_animatedPoints) 160 results->m_animatedPoints = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1.0f) 161 ? m_toPoints : m_fromPoints; 162 } 163 return; 145 164 } 146 165 ASSERT(animationMode == FromToAnimation || animationMode == ToAnimation || animationMode == ValuesAnimation); … … 178 197 m_fromPath.clear(); 179 198 m_toPath.clear(); 199 } else if (m_propertyType == PointsProperty) { 200 m_fromPoints = SVGPointList::create(SVGNames::pointsAttr); 201 if (pointsListFromSVGData(m_fromPoints.get(), fromString)) { 202 m_toPoints = SVGPointList::create(SVGNames::pointsAttr); 203 if (pointsListFromSVGData(m_toPoints.get(), toString)) 204 return true; 205 } 206 m_fromPoints.clear(); 207 m_toPoints.clear(); 180 208 } 181 209 m_fromString = fromString; … … 224 252 } else if (m_propertyType == PathProperty) { 225 253 m_animatedPath.clear(); 254 return; 255 } else if (m_propertyType == PointsProperty) { 256 m_animatedPoints.clear(); 226 257 return; 227 258 } … … 251 282 } 252 283 } 284 } else if (m_propertyType == PointsProperty) { 285 if (!m_animatedPoints || !m_animatedPoints->numberOfItems()) 286 valueToApply = m_animatedString; 287 else 288 valueToApply = m_animatedPoints->valueAsString(); 253 289 } else 254 290 valueToApply = m_animatedString; -
trunk/WebCore/svg/SVGAnimateElement.h
r50583 r56795 30 30 namespace WebCore { 31 31 class SVGPathSegList; 32 class SVGPointList; 32 33 33 34 class SVGAnimateElement : public SVGAnimationElement { … … 45 46 46 47 private: 47 enum PropertyType { NumberProperty, ColorProperty, StringProperty, PathProperty };48 enum PropertyType { NumberProperty, ColorProperty, StringProperty, PathProperty, PointsProperty }; 48 49 PropertyType determinePropertyType(const String& attribute) const; 49 50 PropertyType m_propertyType; … … 62 63 RefPtr<SVGPathSegList> m_toPath; 63 64 RefPtr<SVGPathSegList> m_animatedPath; 65 RefPtr<SVGPointList> m_fromPoints; 66 RefPtr<SVGPointList> m_toPoints; 67 RefPtr<SVGPointList> m_animatedPoints; 64 68 }; 65 69 -
trunk/WebCore/svg/SVGPathSegList.cpp
r51627 r56795 145 145 } 146 146 147 static inline float blendFunc(float from, float to, float progress)147 float adjustAnimatedValue(float from, float to, float progress) 148 148 { 149 149 return (to - from) * progress + from; … … 151 151 152 152 #define BLENDPATHSEG1(class, attr1) \ 153 class::create( blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress))153 class::create(adjustAnimatedValue(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress)) 154 154 155 155 #define BLENDPATHSEG2(class, attr1, attr2) \ 156 class::create( blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \157 blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress))156 class::create(adjustAnimatedValue(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \ 157 adjustAnimatedValue(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress)) 158 158 159 159 #define BLENDPATHSEG4(class, attr1, attr2, attr3, attr4) \ 160 class::create( blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \161 blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \162 blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \163 blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress))160 class::create(adjustAnimatedValue(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \ 161 adjustAnimatedValue(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \ 162 adjustAnimatedValue(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \ 163 adjustAnimatedValue(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress)) 164 164 165 165 #define BLENDPATHSEG6(class, attr1, attr2, attr3, attr4, attr5, attr6) \ 166 class::create( blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \167 blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \168 blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \169 blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \170 blendFunc(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \171 blendFunc(static_cast<class*>(from)->attr6(), static_cast<class*>(to)->attr6(), progress))166 class::create(adjustAnimatedValue(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \ 167 adjustAnimatedValue(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \ 168 adjustAnimatedValue(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \ 169 adjustAnimatedValue(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \ 170 adjustAnimatedValue(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \ 171 adjustAnimatedValue(static_cast<class*>(from)->attr6(), static_cast<class*>(to)->attr6(), progress)) 172 172 173 173 #define BLENDPATHSEG7(class, attr1, attr2, attr3, attr4, attr5, bool1, bool2) \ 174 class::create( blendFunc(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \175 blendFunc(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \176 blendFunc(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \177 blendFunc(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \178 blendFunc(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \179 static_cast<bool>( blendFunc(static_cast<class*>(from)->bool1(), static_cast<class*>(to)->bool1(), progress)), \180 static_cast<bool>( blendFunc(static_cast<class*>(from)->bool2(), static_cast<class*>(to)->bool2(), progress)))174 class::create(adjustAnimatedValue(static_cast<class*>(from)->attr1(), static_cast<class*>(to)->attr1(), progress), \ 175 adjustAnimatedValue(static_cast<class*>(from)->attr2(), static_cast<class*>(to)->attr2(), progress), \ 176 adjustAnimatedValue(static_cast<class*>(from)->attr3(), static_cast<class*>(to)->attr3(), progress), \ 177 adjustAnimatedValue(static_cast<class*>(from)->attr4(), static_cast<class*>(to)->attr4(), progress), \ 178 adjustAnimatedValue(static_cast<class*>(from)->attr5(), static_cast<class*>(to)->attr5(), progress), \ 179 static_cast<bool>(adjustAnimatedValue(static_cast<class*>(from)->bool1(), static_cast<class*>(to)->bool1(), progress)), \ 180 static_cast<bool>(adjustAnimatedValue(static_cast<class*>(from)->bool2(), static_cast<class*>(to)->bool2(), progress))) 181 181 182 182 PassRefPtr<SVGPathSegList> SVGPathSegList::createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress) -
trunk/WebCore/svg/SVGPathSegList.h
r51627 r56795 46 46 }; 47 47 48 float adjustAnimatedValue(float from, float to, float progress); 49 48 50 } // namespace WebCore 49 51 -
trunk/WebCore/svg/SVGPointList.cpp
r50583 r56795 23 23 #if ENABLE(SVG) 24 24 #include "SVGPointList.h" 25 #include "SVGPathSegList.h" 25 26 #include "PlatformString.h" 26 27 … … 54 55 } 55 56 57 PassRefPtr<SVGPointList> SVGPointList::createAnimated(const SVGPointList* fromList, const SVGPointList* toList, float progress) 58 { 59 unsigned itemCount = fromList->numberOfItems(); 60 if (!itemCount || itemCount != toList->numberOfItems()) 61 return 0; 62 RefPtr<SVGPointList> result = create(fromList->associatedAttributeName()); 63 ExceptionCode ec = 0; 64 for (unsigned n = 0; n < itemCount; ++n) { 65 FloatPoint from = fromList->getItem(n, ec); 66 if (ec) 67 return 0; 68 FloatPoint to = toList->getItem(n, ec); 69 if (ec) 70 return 0; 71 FloatPoint segment = FloatPoint(adjustAnimatedValue(from.x(), to.x(), progress), 72 adjustAnimatedValue(from.y(), to.y(), progress)); 73 result->appendItem(segment, ec); 74 if (ec) 75 return 0; 76 } 77 return result.release(); 78 } 79 56 80 } 57 81 -
trunk/WebCore/svg/SVGPointList.h
r50583 r56795 38 38 String valueAsString() const; 39 39 40 static PassRefPtr<SVGPointList> createAnimated(const SVGPointList* fromList, const SVGPointList* toList, float progress); 41 40 42 private: 41 43 SVGPointList(const QualifiedName&);
Note: See TracChangeset
for help on using the changeset viewer.