SVGTransformList.cpp [plain text]
#include "config.h"
#include "SVGTransformList.h"
#include "AffineTransform.h"
#include "SVGSVGElement.h"
#include "SVGTransform.h"
#include "SVGTransformable.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
SVGTransform SVGTransformList::createSVGTransformFromMatrix(const SVGMatrix& matrix) const
{
return SVGSVGElement::createSVGTransformFromMatrix(matrix);
}
SVGTransform SVGTransformList::consolidate()
{
AffineTransform matrix;
if (!concatenate(matrix))
return SVGTransform();
SVGTransform transform(matrix);
clear();
append(transform);
return transform;
}
bool SVGTransformList::concatenate(AffineTransform& result) const
{
unsigned size = this->size();
if (!size)
return false;
for (unsigned i = 0; i < size; ++i)
result *= at(i).matrix();
return true;
}
String SVGTransformList::valueAsString() const
{
StringBuilder builder;
unsigned size = this->size();
for (unsigned i = 0; i < size; ++i) {
if (i > 0)
builder.append(' ');
builder.append(at(i).valueAsString());
}
return builder.toString();
}
void SVGTransformList::parse(const String& transform)
{
auto upconvertedCharacters = StringView(transform).upconvertedCharacters();
const UChar* start = upconvertedCharacters;
if (!SVGTransformable::parseTransformAttribute(*this, start, start + transform.length()))
clear();
}
}