Changeset 65065 in webkit
- Timestamp:
- Aug 10, 2010 4:12:09 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r65064 r65065 1 2010-08-10 Dirk Schulze <krit@webkit.org> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Use SVGPathParser to create SVG paths and to perform path animations 6 https://bugs.webkit.org/show_bug.cgi?id=43696 7 8 Removed toString() functions in all SVGPathSeg* objects as well as toPath() in SVGPathSegList. 9 These hacks were used to create a SVG path data string or a platform path from a SVGPathSegList. 10 Use the new SVGPathParser instead. 11 12 Doesn't affect any tests. 13 14 * svg/SVGAnimateElement.cpp: 15 (WebCore::SVGAnimateElement::applyResultsToTarget): 16 * svg/SVGPathElement.cpp: 17 (WebCore::SVGPathElement::toPathData): 18 * svg/SVGPathParserFactory.cpp: 19 (WebCore::SVGPathParserFactory::buildPathFromSVGPathSegList): 20 (WebCore::SVGPathParserFactory::buildStringFromByteStream): 21 (WebCore::SVGPathParserFactory::buildStringFromSVGPathSegList): 22 * svg/SVGPathParserFactory.h: 23 * svg/SVGPathSeg.cpp: 24 * svg/SVGPathSeg.h: 25 * svg/SVGPathSegArc.cpp: 26 * svg/SVGPathSegArc.h: 27 * svg/SVGPathSegClosePath.h: 28 (WebCore::SVGPathSegClosePath::pathSegTypeAsLetter): 29 * svg/SVGPathSegCurvetoCubic.h: 30 * svg/SVGPathSegCurvetoCubicSmooth.h: 31 * svg/SVGPathSegCurvetoQuadratic.h: 32 * svg/SVGPathSegLinetoHorizontal.h: 33 * svg/SVGPathSegLinetoVertical.h: 34 * svg/SVGPathSegList.cpp: 35 (WebCore::SVGPathSegList::getPathSegAtLength): 36 * svg/SVGPathSegList.h: 37 1 38 2010-08-10 Sheriff Bot <webkit.review.bot@gmail.com> 2 39 -
trunk/WebCore/svg/SVGAnimateElement.cpp
r64898 r65065 280 280 // morphing needs to be done with unprocessed paths. 281 281 // FIXME: This could be optimized if paths were not processed at parse time. 282 unsigned itemCount = m_animatedPath->numberOfItems(); 283 ExceptionCode ec; 284 for (unsigned n = 0; n < itemCount; ++n) { 285 RefPtr<SVGPathSeg> segment = m_animatedPath->getItem(n, ec); 286 valueToApply.append(segment->toString() + " "); 287 } 282 SVGPathParserFactory* factory = SVGPathParserFactory::self(); 283 factory->buildStringFromSVGPathSegList(m_animatedPath.get(), valueToApply, UnalteredParsing); 288 284 } 289 285 } else if (m_propertyType == PointsProperty) { -
trunk/WebCore/svg/SVGPathElement.cpp
r64898 r65065 264 264 Path SVGPathElement::toPathData() const 265 265 { 266 return pathSegList()->toPathData(); 266 Path result; 267 SVGPathParserFactory* factory = SVGPathParserFactory::self(); 268 factory->buildPathFromSVGPathSegList(pathSegList(), result); 269 return result; 267 270 } 268 271 -
trunk/WebCore/svg/SVGPathParserFactory.cpp
r64949 r65065 27 27 #include "SVGPathByteStreamBuilder.h" 28 28 #include "SVGPathByteStreamSource.h" 29 #include "SVGPathStringBuilder.h"30 29 #include "SVGPathParser.h" 31 30 #include "SVGPathSegListBuilder.h" 31 #include "SVGPathSegListSource.h" 32 #include "SVGPathStringBuilder.h" 32 33 #include "SVGPathStringSource.h" 33 34 … … 124 125 125 126 OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream); 127 SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 128 bool ok = parser->parsePathDataFromSource(NormalizedParsing); 129 parser->cleanup(); 130 return ok; 131 } 132 133 bool SVGPathParserFactory::buildPathFromSVGPathSegList(SVGPathSegList* pathSegList, Path& result) 134 { 135 ASSERT(pathSegList); 136 if (!pathSegList->numberOfItems()) 137 return false; 138 139 SVGPathBuilder* builder = globalSVGPathBuilder(result); 140 141 OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); 126 142 SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 127 143 bool ok = parser->parsePathDataFromSource(NormalizedParsing); … … 172 188 SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 173 189 bool ok = parser->parsePathDataFromSource(parsingMode); 174 parser->cleanup();175 190 result = builder->result(); 191 parser->cleanup(); 192 return ok; 193 } 194 195 bool SVGPathParserFactory::buildStringFromSVGPathSegList(SVGPathSegList* pathSegList, String& result, PathParsingMode parsingMode) 196 { 197 ASSERT(pathSegList); 198 if (!pathSegList->numberOfItems()) 199 return false; 200 201 SVGPathStringBuilder* builder = globalSVGPathStringBuilder(); 202 203 OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList); 204 SVGPathParser* parser = globalSVGPathParser(source.get(), builder); 205 bool ok = parser->parsePathDataFromSource(parsingMode); 206 result = builder->result(); 207 parser->cleanup(); 176 208 return ok; 177 209 } -
trunk/WebCore/svg/SVGPathParserFactory.h
r64949 r65065 36 36 37 37 bool buildPathFromString(const String&, Path&); 38 bool buildPathFromByteStream(SVGPathByteStream*, Path& result); 38 bool buildPathFromByteStream(SVGPathByteStream*, Path&); 39 bool buildPathFromSVGPathSegList(SVGPathSegList*, Path&); 39 40 40 41 bool buildSVGPathSegListFromString(const String&, SVGPathSegList*, PathParsingMode); … … 42 43 43 44 bool buildStringFromByteStream(SVGPathByteStream*, String&, PathParsingMode); 45 bool buildStringFromSVGPathSegList(SVGPathSegList*, String&, PathParsingMode); 44 46 45 47 bool buildSVGPathByteStreamFromString(const String&, OwnPtr<SVGPathByteStream>&, PathParsingMode); -
trunk/WebCore/svg/SVGPathSeg.cpp
r64807 r65065 46 46 } 47 47 48 String SVGPathSeg::toString() const49 {50 return "";51 }52 53 48 const QualifiedName& SVGPathSeg::associatedAttributeName() const 54 49 { … … 56 51 } 57 52 58 String SVGPathSegSingleCoord::toString() const59 {60 return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg", m_x, m_y);61 }62 63 53 } // namespace WebCore 64 54 #endif // ENABLE(SVG) -
trunk/WebCore/svg/SVGPathSeg.h
r65021 r65065 86 86 virtual unsigned short pathSegType() const; 87 87 virtual String pathSegTypeAsLetter() const; 88 virtual String toString() const;89 88 90 89 const QualifiedName& associatedAttributeName() const; … … 108 107 float y() const { return m_y; } 109 108 110 virtual String toString() const;111 112 109 private: 113 110 float m_x; -
trunk/WebCore/svg/SVGPathSegArc.cpp
r64793 r65065 26 26 namespace WebCore { 27 27 28 String SVGPathSegArc::toString() const29 {30 return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", m_r1, m_r2, m_angle, m_largeArcFlag, m_sweepFlag, m_x, m_y);31 }32 33 28 SVGPathSegArcAbs::SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag) 34 29 : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, sweepFlag) -
trunk/WebCore/svg/SVGPathSegArc.h
r64793 r65065 41 41 { 42 42 } 43 44 virtual String toString() const;45 43 46 44 void setX(float x) { m_x = x; } -
trunk/WebCore/svg/SVGPathSegClosePath.h
r64793 r65065 36 36 virtual unsigned short pathSegType() const { return PATHSEG_CLOSEPATH; } 37 37 virtual String pathSegTypeAsLetter() const { return "Z"; } 38 virtual String toString() const { return "Z"; }39 38 40 39 private: -
trunk/WebCore/svg/SVGPathSegCurvetoCubic.h
r64793 r65065 32 32 public: 33 33 SVGPathSegCurvetoCubic(float x, float y, float x1, float y1, float x2, float y2) : SVGPathSeg() , m_x(x) , m_y(y) , m_x1(x1) , m_y1(y1) , m_x2(x2) , m_y2(y2) {} 34 35 virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x2, m_y2, m_x, m_y); }36 34 37 35 void setX(float x) { m_x = x; } -
trunk/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
r64793 r65065 33 33 SVGPathSegCurvetoCubicSmooth(float x, float y, float x2, float y2) 34 34 : m_x(x), m_y(y), m_x2(x2), m_y2(y2) { } 35 36 virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }37 35 38 36 void setX(float x) { m_x = x; } -
trunk/WebCore/svg/SVGPathSegCurvetoQuadratic.h
r64793 r65065 33 33 SVGPathSegCurvetoQuadratic(float x, float y, float x1, float y1) 34 34 : SVGPathSeg(), m_x(x), m_y(y), m_x1(x1), m_y1(y1) {} 35 36 virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x, m_y); }37 35 38 36 void setX(float x) { m_x = x; } -
trunk/WebCore/svg/SVGPathSegLinetoHorizontal.h
r64793 r65065 32 32 public: 33 33 SVGPathSegLinetoHorizontal(float x) : SVGPathSeg(), m_x(x) {} 34 35 virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_x); }36 34 37 35 void setX(float x) { m_x = x; } -
trunk/WebCore/svg/SVGPathSegLinetoVertical.h
r64793 r65065 32 32 public: 33 33 SVGPathSegLinetoVertical(float y) : SVGPathSeg(), m_y(y) {} 34 35 virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_y); }36 34 37 35 void setY(float y) { m_y = y; } -
trunk/WebCore/svg/SVGPathSegList.cpp
r64898 r65065 104 104 return traversalState.m_segmentIndex ? traversalState.m_segmentIndex - 1 : 0; 105 105 } 106 107 Path SVGPathSegList::toPathData()108 {109 // FIXME : This should also support non-normalized PathSegLists110 Path pathData;111 int len = numberOfItems();112 ExceptionCode ec = 0;113 FloatPoint previousEndPoint(0, 0);114 for (int i = 0; i < len; ++i) {115 SVGPathSeg* segment = getItem(i, ec).get();116 if (ec)117 return Path();118 switch (segment->pathSegType()) {119 case PathSegMoveToAbs: {120 SVGPathSegMovetoAbs* moveTo = static_cast<SVGPathSegMovetoAbs*>(segment);121 FloatPoint endPoint(moveTo->x(), moveTo->y());122 pathData.moveTo(endPoint);123 previousEndPoint = endPoint;124 break;125 }126 case PathSegLineToAbs: {127 SVGPathSegLinetoAbs* lineTo = static_cast<SVGPathSegLinetoAbs*>(segment);128 FloatPoint endPoint(lineTo->x(), lineTo->y());129 pathData.addLineTo(endPoint);130 previousEndPoint = endPoint;131 break;132 }133 case PathSegCurveToCubicAbs: {134 SVGPathSegCurvetoCubicAbs* curveTo = static_cast<SVGPathSegCurvetoCubicAbs*>(segment);135 FloatPoint endPoint(curveTo->x(), curveTo->y());136 pathData.addBezierCurveTo(FloatPoint(curveTo->x1(), curveTo->y1()),137 FloatPoint(curveTo->x2(), curveTo->y2()),138 endPoint);139 previousEndPoint = endPoint;140 break;141 }142 case PathSegCurveToCubicRel: {143 SVGPathSegCurvetoCubicRel* curveTo = static_cast<SVGPathSegCurvetoCubicRel*>(segment);144 FloatSize endPoint(curveTo->x(), curveTo->y());145 pathData.addBezierCurveTo(previousEndPoint + FloatSize(curveTo->x1(), curveTo->y1()),146 previousEndPoint + FloatSize(curveTo->x2(), curveTo->y2()),147 previousEndPoint + endPoint);148 previousEndPoint += endPoint;149 break;150 }151 case PathSegClosePath:152 pathData.closeSubpath();153 break;154 default:155 ASSERT(false); // FIXME: This only works with normalized/processed path data.156 break;157 }158 }159 160 return pathData;161 }162 106 163 107 float adjustAnimatedValue(float from, float to, float progress) -
trunk/WebCore/svg/SVGPathSegList.h
r64579 r65065 36 36 37 37 unsigned getPathSegAtLength(double, ExceptionCode&); 38 Path toPathData();39 38 40 39 static PassRefPtr<SVGPathSegList> createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress);
Note: See TracChangeset
for help on using the changeset viewer.