#[allow(missing_docs)]
#[derive(Clone, Copy, PartialEq)]
pub enum EId {
A,
Circle,
ClipPath,
Defs,
Ellipse,
FeBlend,
FeColorMatrix,
FeComponentTransfer,
FeComposite,
FeConvolveMatrix,
FeDiffuseLighting,
FeDisplacementMap,
FeDistantLight,
FeDropShadow,
FeFlood,
FeFuncA,
FeFuncB,
FeFuncG,
FeFuncR,
FeGaussianBlur,
FeImage,
FeMerge,
FeMergeNode,
FeMorphology,
FeOffset,
FePointLight,
FeSpecularLighting,
FeSpotLight,
FeTile,
FeTurbulence,
Filter,
G,
Image,
Line,
LinearGradient,
Marker,
Mask,
Path,
Pattern,
Polygon,
Polyline,
RadialGradient,
Rect,
Stop,
Style,
Svg,
Switch,
Symbol,
Text,
TextPath,
Tref,
Tspan,
Use,
}
static ELEMENTS: Map<EId> = Map {
key: 732231254413039614,
disps: &[
(0, 12),
(1, 11),
(10, 26),
(2, 42),
(1, 19),
(0, 5),
(1, 13),
(8, 50),
(0, 0),
(1, 0),
(7, 45),
],
entries: &[
("feFlood", EId::FeFlood),
("radialGradient", EId::RadialGradient),
("feImage", EId::FeImage),
("stop", EId::Stop),
("fePointLight", EId::FePointLight),
("feConvolveMatrix", EId::FeConvolveMatrix),
("feComposite", EId::FeComposite),
("clipPath", EId::ClipPath),
("feMerge", EId::FeMerge),
("defs", EId::Defs),
("mask", EId::Mask),
("svg", EId::Svg),
("symbol", EId::Symbol),
("linearGradient", EId::LinearGradient),
("feSpecularLighting", EId::FeSpecularLighting),
("feFuncB", EId::FeFuncB),
("filter", EId::Filter),
("feFuncG", EId::FeFuncG),
("circle", EId::Circle),
("g", EId::G),
("tref", EId::Tref),
("feFuncA", EId::FeFuncA),
("image", EId::Image),
("text", EId::Text),
("line", EId::Line),
("pattern", EId::Pattern),
("use", EId::Use),
("feDropShadow", EId::FeDropShadow),
("feSpotLight", EId::FeSpotLight),
("marker", EId::Marker),
("style", EId::Style),
("switch", EId::Switch),
("tspan", EId::Tspan),
("feColorMatrix", EId::FeColorMatrix),
("feOffset", EId::FeOffset),
("path", EId::Path),
("feGaussianBlur", EId::FeGaussianBlur),
("feTile", EId::FeTile),
("feTurbulence", EId::FeTurbulence),
("feMergeNode", EId::FeMergeNode),
("feMorphology", EId::FeMorphology),
("a", EId::A),
("textPath", EId::TextPath),
("ellipse", EId::Ellipse),
("feComponentTransfer", EId::FeComponentTransfer),
("feDistantLight", EId::FeDistantLight),
("polyline", EId::Polyline),
("polygon", EId::Polygon),
("feBlend", EId::FeBlend),
("feDisplacementMap", EId::FeDisplacementMap),
("feDiffuseLighting", EId::FeDiffuseLighting),
("rect", EId::Rect),
("feFuncR", EId::FeFuncR),
],
};
impl EId {
pub(crate) fn from_str(text: &str) -> Option<EId> {
ELEMENTS.get(text).cloned()
}
#[inline(never)]
pub fn to_str(self) -> &'static str {
ELEMENTS.key(&self)
}
}
impl std::fmt::Debug for EId {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_str())
}
}
impl std::fmt::Display for EId {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
#[allow(missing_docs)]
#[derive(Clone, Copy, PartialEq)]
pub enum AId {
AlignmentBaseline,
Amplitude,
Azimuth,
BaseFrequency,
BaselineShift,
Bias,
Class,
Clip,
ClipPath,
ClipRule,
ClipPathUnits,
Color,
ColorInterpolation,
ColorInterpolationFilters,
ColorProfile,
ColorRendering,
Cx,
Cy,
D,
DiffuseConstant,
Direction,
Display,
Divisor,
DominantBaseline,
Dx,
Dy,
EdgeMode,
Elevation,
EnableBackground,
Exponent,
Fill,
FillOpacity,
FillRule,
Filter,
FilterUnits,
FloodColor,
FloodOpacity,
Font,
FontFamily,
FontFeatureSettings,
FontKerning,
FontSize,
FontSizeAdjust,
FontStretch,
FontStyle,
FontSynthesis,
FontVariant,
FontVariantCaps,
FontVariantEastAsian,
FontVariantLigatures,
FontVariantNumeric,
FontVariantPosition,
FontWeight,
Fr,
Fx,
Fy,
GlyphOrientationHorizontal,
GlyphOrientationVertical,
GradientTransform,
GradientUnits,
Height,
Href,
Id,
ImageRendering,
In,
In2,
InlineSize,
Intercept,
Isolation,
K1,
K2,
K3,
K4,
KernelMatrix,
KernelUnitLength,
Kerning,
LengthAdjust,
LetterSpacing,
LightingColor,
LimitingConeAngle,
LineHeight,
MarkerEnd,
MarkerMid,
MarkerStart,
MarkerHeight,
MarkerUnits,
MarkerWidth,
Mask,
MaskBorder,
MaskBorderMode,
MaskBorderOutset,
MaskBorderRepeat,
MaskBorderSlice,
MaskBorderSource,
MaskBorderWidth,
MaskClip,
MaskComposite,
MaskImage,
MaskMode,
MaskOrigin,
MaskPosition,
MaskSize,
MaskType,
MaskContentUnits,
MaskUnits,
MixBlendMode,
Mode,
NumOctaves,
Offset,
Opacity,
Operator,
Order,
Orient,
Overflow,
PaintOrder,
Path,
PathLength,
PatternContentUnits,
PatternTransform,
PatternUnits,
Points,
PointsAtX,
PointsAtY,
PointsAtZ,
PreserveAlpha,
PreserveAspectRatio,
PrimitiveUnits,
R,
Radius,
RefX,
RefY,
RequiredExtensions,
RequiredFeatures,
Result,
Rotate,
Rx,
Ry,
Scale,
Seed,
ShapeImageThreshold,
ShapeInside,
ShapeMargin,
ShapePadding,
ShapeRendering,
ShapeSubtract,
Side,
Slope,
Space,
SpecularConstant,
SpecularExponent,
SpreadMethod,
StartOffset,
StdDeviation,
StitchTiles,
StopColor,
StopOpacity,
Stroke,
StrokeDasharray,
StrokeDashoffset,
StrokeLinecap,
StrokeLinejoin,
StrokeMiterlimit,
StrokeOpacity,
StrokeWidth,
Style,
SurfaceScale,
SystemLanguage,
TableValues,
TargetX,
TargetY,
TextAlign,
TextAlignLast,
TextAnchor,
TextDecoration,
TextDecorationColor,
TextDecorationFill,
TextDecorationLine,
TextDecorationStroke,
TextDecorationStyle,
TextIndent,
TextOrientation,
TextOverflow,
TextRendering,
TextUnderlinePosition,
TextLength,
Transform,
TransformBox,
TransformOrigin,
Type,
UnicodeBidi,
UnicodeRange,
Values,
VectorEffect,
ViewBox,
Visibility,
WhiteSpace,
Width,
WordSpacing,
WritingMode,
X,
X1,
X2,
XChannelSelector,
Y,
Y1,
Y2,
YChannelSelector,
Z,
}
static ATTRIBUTES: Map<AId> = Map {
key: 732231254413039614,
disps: &[
(63, 17),
(0, 1),
(0, 113),
(0, 21),
(0, 8),
(0, 23),
(0, 15),
(0, 3),
(40, 203),
(0, 3),
(0, 6),
(1, 31),
(0, 68),
(11, 161),
(0, 41),
(2, 58),
(7, 10),
(0, 0),
(0, 39),
(7, 73),
(0, 5),
(65, 30),
(0, 71),
(0, 28),
(0, 7),
(2, 99),
(0, 168),
(1, 79),
(0, 0),
(0, 3),
(0, 21),
(1, 9),
(0, 0),
(5, 171),
(0, 45),
(0, 18),
(99, 110),
(31, 206),
(5, 125),
(0, 14),
(0, 4),
(0, 83),
],
entries: &[
("mask-type", AId::MaskType),
("markerWidth", AId::MarkerWidth),
("textLength", AId::TextLength),
("alignment-baseline", AId::AlignmentBaseline),
("unicode-bidi", AId::UnicodeBidi),
("dominant-baseline", AId::DominantBaseline),
("orient", AId::Orient),
("x", AId::X),
("font-style", AId::FontStyle),
("color-interpolation", AId::ColorInterpolation),
("style", AId::Style),
("clip-rule", AId::ClipRule),
("bias", AId::Bias),
("font-weight", AId::FontWeight),
("fill", AId::Fill),
("mask-border-outset", AId::MaskBorderOutset),
("x1", AId::X1),
("mask", AId::Mask),
("height", AId::Height),
("stroke", AId::Stroke),
("transform", AId::Transform),
("isolation", AId::Isolation),
("fy", AId::Fy),
("text-orientation", AId::TextOrientation),
("stop-opacity", AId::StopOpacity),
("fx", AId::Fx),
("font-kerning", AId::FontKerning),
("cx", AId::Cx),
("maskContentUnits", AId::MaskContentUnits),
("opacity", AId::Opacity),
("filterUnits", AId::FilterUnits),
("lengthAdjust", AId::LengthAdjust),
("text-anchor", AId::TextAnchor),
("stroke-miterlimit", AId::StrokeMiterlimit),
("viewBox", AId::ViewBox),
("visibility", AId::Visibility),
("ry", AId::Ry),
(
"glyph-orientation-horizontal",
AId::GlyphOrientationHorizontal,
),
("gradientTransform", AId::GradientTransform),
("markerUnits", AId::MarkerUnits),
("shape-inside", AId::ShapeInside),
("font-size", AId::FontSize),
("yChannelSelector", AId::YChannelSelector),
("clip-path", AId::ClipPath),
("flood-color", AId::FloodColor),
("marker-mid", AId::MarkerMid),
("surfaceScale", AId::SurfaceScale),
("color-profile", AId::ColorProfile),
("requiredFeatures", AId::RequiredFeatures),
("class", AId::Class),
("startOffset", AId::StartOffset),
("mask-origin", AId::MaskOrigin),
("stdDeviation", AId::StdDeviation),
("mode", AId::Mode),
("overflow", AId::Overflow),
("text-decoration-fill", AId::TextDecorationFill),
("mask-border-mode", AId::MaskBorderMode),
("divisor", AId::Divisor),
("marker-start", AId::MarkerStart),
("text-decoration-line", AId::TextDecorationLine),
("preserveAlpha", AId::PreserveAlpha),
("primitiveUnits", AId::PrimitiveUnits),
("in", AId::In),
("points", AId::Points),
("pointsAtY", AId::PointsAtY),
("specularExponent", AId::SpecularExponent),
("shape-rendering", AId::ShapeRendering),
("refY", AId::RefY),
("clip", AId::Clip),
("white-space", AId::WhiteSpace),
("vector-effect", AId::VectorEffect),
("image-rendering", AId::ImageRendering),
("stitchTiles", AId::StitchTiles),
("stroke-opacity", AId::StrokeOpacity),
("shape-margin", AId::ShapeMargin),
("y2", AId::Y2),
("operator", AId::Operator),
("pathLength", AId::PathLength),
("order", AId::Order),
("text-rendering", AId::TextRendering),
("mask-border", AId::MaskBorder),
("exponent", AId::Exponent),
(
"color-interpolation-filters",
AId::ColorInterpolationFilters,
),
("diffuseConstant", AId::DiffuseConstant),
("space", AId::Space),
("font-synthesis", AId::FontSynthesis),
("direction", AId::Direction),
("font-size-adjust", AId::FontSizeAdjust),
("kerning", AId::Kerning),
("flood-opacity", AId::FloodOpacity),
("mask-border-source", AId::MaskBorderSource),
("line-height", AId::LineHeight),
("mix-blend-mode", AId::MixBlendMode),
("scale", AId::Scale),
("mask-image", AId::MaskImage),
("dy", AId::Dy),
("xChannelSelector", AId::XChannelSelector),
("unicode-range", AId::UnicodeRange),
("y", AId::Y),
("fill-opacity", AId::FillOpacity),
("mask-composite", AId::MaskComposite),
("targetY", AId::TargetY),
("writing-mode", AId::WritingMode),
("transform-origin", AId::TransformOrigin),
("font-variant-caps", AId::FontVariantCaps),
("k2", AId::K2),
("transform-box", AId::TransformBox),
("text-decoration", AId::TextDecoration),
("filter", AId::Filter),
("enable-background", AId::EnableBackground),
("word-spacing", AId::WordSpacing),
("gradientUnits", AId::GradientUnits),
("font-feature-settings", AId::FontFeatureSettings),
("stroke-linecap", AId::StrokeLinecap),
("rx", AId::Rx),
("kernelUnitLength", AId::KernelUnitLength),
("shape-image-threshold", AId::ShapeImageThreshold),
("inline-size", AId::InlineSize),
("edgeMode", AId::EdgeMode),
("text-decoration-style", AId::TextDecorationStyle),
("pointsAtZ", AId::PointsAtZ),
("elevation", AId::Elevation),
("tableValues", AId::TableValues),
("kernelMatrix", AId::KernelMatrix),
("patternTransform", AId::PatternTransform),
("fill-rule", AId::FillRule),
("color", AId::Color),
("lighting-color", AId::LightingColor),
("cy", AId::Cy),
("fr", AId::Fr),
("systemLanguage", AId::SystemLanguage),
("text-indent", AId::TextIndent),
("slope", AId::Slope),
("font", AId::Font),
("requiredExtensions", AId::RequiredExtensions),
("href", AId::Href),
("baseFrequency", AId::BaseFrequency),
("stroke-dashoffset", AId::StrokeDashoffset),
("text-decoration-stroke", AId::TextDecorationStroke),
("display", AId::Display),
("amplitude", AId::Amplitude),
("mask-size", AId::MaskSize),
("font-variant-ligatures", AId::FontVariantLigatures),
("in2", AId::In2),
("maskUnits", AId::MaskUnits),
("k4", AId::K4),
("shape-padding", AId::ShapePadding),
("r", AId::R),
("text-underline-position", AId::TextUnderlinePosition),
("font-variant-east-asian", AId::FontVariantEastAsian),
("z", AId::Z),
("text-decoration-color", AId::TextDecorationColor),
("intercept", AId::Intercept),
("side", AId::Side),
("x2", AId::X2),
("mask-position", AId::MaskPosition),
("pointsAtX", AId::PointsAtX),
("patternUnits", AId::PatternUnits),
("result", AId::Result),
("baseline-shift", AId::BaselineShift),
("stop-color", AId::StopColor),
("k3", AId::K3),
("stroke-dasharray", AId::StrokeDasharray),
("y1", AId::Y1),
("targetX", AId::TargetX),
("stroke-width", AId::StrokeWidth),
("limitingConeAngle", AId::LimitingConeAngle),
("id", AId::Id),
("mask-border-width", AId::MaskBorderWidth),
("shape-subtract", AId::ShapeSubtract),
("font-variant", AId::FontVariant),
("glyph-orientation-vertical", AId::GlyphOrientationVertical),
("offset", AId::Offset),
("type", AId::Type),
("numOctaves", AId::NumOctaves),
("font-stretch", AId::FontStretch),
("mask-clip", AId::MaskClip),
("clipPathUnits", AId::ClipPathUnits),
("path", AId::Path),
("seed", AId::Seed),
("font-variant-position", AId::FontVariantPosition),
("rotate", AId::Rotate),
("text-overflow", AId::TextOverflow),
("mask-border-repeat", AId::MaskBorderRepeat),
("stroke-linejoin", AId::StrokeLinejoin),
("mask-mode", AId::MaskMode),
("specularConstant", AId::SpecularConstant),
("spreadMethod", AId::SpreadMethod),
("letter-spacing", AId::LetterSpacing),
("font-family", AId::FontFamily),
("azimuth", AId::Azimuth),
("refX", AId::RefX),
("color-rendering", AId::ColorRendering),
("values", AId::Values),
("marker-end", AId::MarkerEnd),
("font-variant-numeric", AId::FontVariantNumeric),
("markerHeight", AId::MarkerHeight),
("radius", AId::Radius),
("width", AId::Width),
("text-align-last", AId::TextAlignLast),
("preserveAspectRatio", AId::PreserveAspectRatio),
("patternContentUnits", AId::PatternContentUnits),
("k1", AId::K1),
("paint-order", AId::PaintOrder),
("d", AId::D),
("mask-border-slice", AId::MaskBorderSlice),
("dx", AId::Dx),
("text-align", AId::TextAlign),
],
};
impl AId {
pub(crate) fn from_str(text: &str) -> Option<AId> {
ATTRIBUTES.get(text).cloned()
}
#[inline(never)]
pub fn to_str(self) -> &'static str {
ATTRIBUTES.key(&self)
}
}
impl std::fmt::Debug for AId {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.to_str())
}
}
impl std::fmt::Display for AId {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
struct Map<V: 'static> {
pub key: u64,
pub disps: &'static [(u32, u32)],
pub entries: &'static [(&'static str, V)],
}
impl<V: PartialEq> Map<V> {
fn get(&self, key: &str) -> Option<&V> {
let hash = hash(key, self.key);
let index = get_index(hash, self.disps, self.entries.len());
let entry = &self.entries[index as usize];
if entry.0 == key {
Some(&entry.1)
} else {
None
}
}
fn key(&self, value: &V) -> &'static str {
self.entries.iter().find(|kv| kv.1 == *value).unwrap().0
}
}
#[inline]
fn hash(x: &str, key: u64) -> u64 {
use std::hash::Hasher;
let mut hasher = siphasher::sip::SipHasher13::new_with_keys(0, key);
hasher.write(x.as_bytes());
hasher.finish()
}
#[inline]
fn get_index(hash: u64, disps: &[(u32, u32)], len: usize) -> u32 {
let (g, f1, f2) = split(hash);
let (d1, d2) = disps[(g % (disps.len() as u32)) as usize];
displace(f1, f2, d1, d2) % (len as u32)
}
#[inline]
fn split(hash: u64) -> (u32, u32, u32) {
const BITS: u32 = 21;
const MASK: u64 = (1 << BITS) - 1;
(
(hash & MASK) as u32,
((hash >> BITS) & MASK) as u32,
((hash >> (2 * BITS)) & MASK) as u32,
)
}
#[inline]
fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 {
d2 + f1 * d1 + f2
}