diff options
Diffstat (limited to 'WebCore/svg/SVGPointList.cpp')
-rw-r--r-- | WebCore/svg/SVGPointList.cpp | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/WebCore/svg/SVGPointList.cpp b/WebCore/svg/SVGPointList.cpp index 0d8e10c..ae460a1 100644 --- a/WebCore/svg/SVGPointList.cpp +++ b/WebCore/svg/SVGPointList.cpp @@ -22,32 +22,27 @@ #if ENABLE(SVG) #include "SVGPointList.h" -#include "SVGPathSegList.h" -#include "PlatformString.h" -namespace WebCore { +#include "FloatPoint.h" +#include <wtf/text/StringBuilder.h> +#include <wtf/text/StringConcatenate.h> -SVGPointList::SVGPointList(const QualifiedName& attributeName) - : SVGPODList<FloatPoint>(attributeName) -{ -} +namespace WebCore { String SVGPointList::valueAsString() const { - String result; + StringBuilder builder; - ExceptionCode ec = 0; - for (unsigned int i = 0; i < numberOfItems(); ++i) { + unsigned size = this->size(); + for (unsigned i = 0; i < size; ++i) { if (i > 0) - result += " "; - - FloatPoint point = getItem(i, ec); - ASSERT(ec == 0); + builder.append(" "); // FIXME: Shouldn't we use commas to seperate? - result += String::format("%.6lg %.6lg", point.x(), point.y()); + const FloatPoint& point = at(i); + builder.append(makeString(String::number(point.x()), ' ', String::number(point.y()))); } - return result; + return builder.toString(); } float inline adjustAnimatedValue(float from, float to, float progress) @@ -55,27 +50,19 @@ float inline adjustAnimatedValue(float from, float to, float progress) return (to - from) * progress + from; } -PassRefPtr<SVGPointList> SVGPointList::createAnimated(const SVGPointList* fromList, const SVGPointList* toList, float progress) +bool SVGPointList::createAnimated(const SVGPointList& fromList, const SVGPointList& toList, SVGPointList& resultList, float progress) { - unsigned itemCount = fromList->numberOfItems(); - if (!itemCount || itemCount != toList->numberOfItems()) - return 0; - RefPtr<SVGPointList> result = create(fromList->associatedAttributeName()); - ExceptionCode ec = 0; + unsigned itemCount = fromList.size(); + if (!itemCount || itemCount != toList.size()) + return false; for (unsigned n = 0; n < itemCount; ++n) { - FloatPoint from = fromList->getItem(n, ec); - if (ec) - return 0; - FloatPoint to = toList->getItem(n, ec); - if (ec) - return 0; + const FloatPoint& from = fromList.at(n); + const FloatPoint& to = toList.at(n); FloatPoint segment = FloatPoint(adjustAnimatedValue(from.x(), to.x(), progress), adjustAnimatedValue(from.y(), to.y(), progress)); - result->appendItem(segment, ec); - if (ec) - return 0; + resultList.append(segment); } - return result.release(); + return true; } } |