SVGStringListValues.cpp [plain text]
#include "config.h"
#include "SVGStringListValues.h"
#include "SVGElement.h"
#include "SVGParserUtilities.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
void SVGStringListValues::commitChange(SVGElement& contextElement)
{
contextElement.invalidateSVGAttributes();
contextElement.svgAttributeChanged(m_attributeName);
}
void SVGStringListValues::reset(const String& string)
{
parse(string, ' ');
if (isEmpty())
append(emptyString());
}
void SVGStringListValues::parse(const String& data, UChar delimiter)
{
clear();
auto upconvertedCharacters = StringView(data).upconvertedCharacters();
const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + data.length();
while (ptr < end) {
const UChar* start = ptr;
while (ptr < end && *ptr != delimiter && !isSVGSpace(*ptr))
ptr++;
if (ptr == start)
break;
append(String(start, ptr - start));
skipOptionalSVGSpacesOrDelimiter(ptr, end, delimiter);
}
}
String SVGStringListValues::valueAsString() const
{
StringBuilder builder;
unsigned size = this->size();
for (unsigned i = 0; i < size; ++i) {
if (i > 0)
builder.append(' ');
builder.append(at(i));
}
return builder.toString();
}
}