#pragma once
#include "SVGAngleValue.h"
#include "SVGPropertyTraits.h"
namespace WebCore {
enum SVGMarkerUnitsType {
SVGMarkerUnitsUnknown = 0,
SVGMarkerUnitsUserSpaceOnUse,
SVGMarkerUnitsStrokeWidth
};
enum SVGMarkerOrientType {
SVGMarkerOrientUnknown = 0,
SVGMarkerOrientAuto,
SVGMarkerOrientAngle,
SVGMarkerOrientAutoStartReverse,
SVGMarkerOrientMax
};
template<>
struct SVGPropertyTraits<SVGMarkerUnitsType> {
static unsigned highestEnumValue() { return SVGMarkerUnitsStrokeWidth; }
static String toString(SVGMarkerUnitsType type)
{
switch (type) {
case SVGMarkerUnitsUnknown:
return emptyString();
case SVGMarkerUnitsUserSpaceOnUse:
return "userSpaceOnUse"_s;
case SVGMarkerUnitsStrokeWidth:
return "strokeWidth"_s;
}
ASSERT_NOT_REACHED();
return emptyString();
}
static SVGMarkerUnitsType fromString(const String& value)
{
if (value == "userSpaceOnUse")
return SVGMarkerUnitsUserSpaceOnUse;
if (value == "strokeWidth")
return SVGMarkerUnitsStrokeWidth;
return SVGMarkerUnitsUnknown;
}
};
template<>
struct SVGPropertyTraits<SVGMarkerOrientType> {
static unsigned highestEnumValue() { return SVGMarkerOrientAutoStartReverse; }
static SVGMarkerOrientType fromString(const String& value, SVGAngleValue& angle)
{
if (value == "auto")
return SVGMarkerOrientAuto;
if (value == "auto-start-reverse")
return SVGMarkerOrientAutoStartReverse;
auto setValueResult = angle.setValueAsString(value);
if (setValueResult.hasException())
return SVGMarkerOrientUnknown;
return SVGMarkerOrientAngle;
}
};
template<>
inline unsigned SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue() { return SVGMarkerOrientAngle; }
template<>
struct SVGPropertyTraits<std::pair<SVGAngleValue, unsigned>> {
static std::pair<SVGAngleValue, unsigned> initialValue() { return { }; }
static std::pair<SVGAngleValue, unsigned> fromString(const String& string)
{
SVGAngleValue angle;
SVGMarkerOrientType orientType = SVGPropertyTraits<SVGMarkerOrientType>::fromString(string, angle);
if (orientType != SVGMarkerOrientAngle)
angle = { };
return std::pair<SVGAngleValue, unsigned>(angle, orientType);
}
static std::optional<std::pair<SVGAngleValue, unsigned>> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); }
static String toString(const std::pair<SVGAngleValue, unsigned>&) { ASSERT_NOT_REACHED(); return emptyString(); }
};
}