#pragma once
#include "SVGLength.h"
#include "SVGValuePropertyList.h"
namespace WebCore {
class SVGLengthList : public SVGValuePropertyList<SVGLength> {
using Base = SVGValuePropertyList<SVGLength>;
using Base::Base;
public:
static Ref<SVGLengthList> create(SVGLengthMode lengthMode = SVGLengthMode::Other)
{
return adoptRef(*new SVGLengthList(lengthMode));
}
static Ref<SVGLengthList> create(SVGPropertyOwner* owner, SVGPropertyAccess access, SVGLengthMode lengthMode)
{
return adoptRef(*new SVGLengthList(owner, access, lengthMode));
}
static Ref<SVGLengthList> create(const SVGLengthList& other, SVGPropertyAccess access)
{
return adoptRef(*new SVGLengthList(other, access));
}
SVGLengthMode lengthMode() const { return m_lengthMode; }
bool parse(const String& value)
{
clearItems();
auto upconvertedCharacters = StringView(value).upconvertedCharacters();
const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + value.length();
while (ptr < end) {
const UChar* start = ptr;
while (ptr < end && *ptr != ',' && !isSVGSpace(*ptr))
ptr++;
if (ptr == start)
break;
String valueString(start, ptr - start);
SVGLengthValue value(m_lengthMode);
if (value.setValueAsString(valueString).hasException())
break;
append(SVGLength::create(value));
skipOptionalSVGSpacesOrDelimiter(ptr, end);
}
return ptr == end;
}
String valueAsString() const override
{
StringBuilder builder;
for (const auto& length : m_items) {
if (builder.length())
builder.append(' ');
builder.append(length->value().valueAsString());
}
return builder.toString();
}
private:
SVGLengthList(SVGLengthMode lengthMode)
: m_lengthMode(lengthMode)
{
}
SVGLengthList(SVGPropertyOwner* owner, SVGPropertyAccess access, SVGLengthMode lengthMode)
: Base(owner, access)
, m_lengthMode(lengthMode)
{
}
SVGLengthList(const SVGLengthList& other, SVGPropertyAccess access)
: Base(other, access)
, m_lengthMode(other.lengthMode())
{
}
SVGLengthMode m_lengthMode { SVGLengthMode::Other };
};
}