22 #include "wtf/Platform.h"
36 using namespace SVGNames;
38 SVGGlyphElement::SVGGlyphElement(
const QualifiedName& tagName, Document* doc)
39 : SVGStyledElement(tagName, doc)
43 SVGGlyphElement::~SVGGlyphElement()
47 void SVGGlyphElement::insertedIntoDocument()
49 Node* fontNode = parentNode();
50 if (fontNode && fontNode->hasTagName(
fontTag)) {
51 if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
52 element->invalidateGlyphCache();
54 SVGStyledElement::insertedIntoDocument();
57 void SVGGlyphElement::removedFromDocument()
59 Node* fontNode = parentNode();
60 if (fontNode && fontNode->hasTagName(
fontTag)) {
61 if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
62 element->invalidateGlyphCache();
64 SVGStyledElement::removedFromDocument();
67 static inline SVGGlyphIdentifier::ArabicForm parseArabicForm(
const AtomicString& value)
69 if (value ==
"medial")
70 return SVGGlyphIdentifier::Medial;
71 else if (value ==
"terminal")
72 return SVGGlyphIdentifier::Terminal;
73 else if (value ==
"isolated")
74 return SVGGlyphIdentifier::Isolated;
75 else if (value ==
"initial")
76 return SVGGlyphIdentifier::Initial;
78 return SVGGlyphIdentifier::None;
81 static inline SVGGlyphIdentifier::Orientation parseOrientation(
const AtomicString& value)
84 return SVGGlyphIdentifier::Horizontal;
85 else if (value ==
"v")
86 return SVGGlyphIdentifier::Vertical;
88 return SVGGlyphIdentifier::Both;
91 static inline Path parsePathData(
const AtomicString& value)
94 pathFromSVGData(result, value);
99 void SVGGlyphElement::inheritUnspecifiedAttributes(SVGGlyphIdentifier& identifier,
const SVGFontData* svgFontData)
101 if (identifier.horizontalAdvanceX == SVGGlyphIdentifier::inheritedValue())
102 identifier.horizontalAdvanceX = svgFontData->horizontalAdvanceX();
104 if (identifier.verticalOriginX == SVGGlyphIdentifier::inheritedValue())
105 identifier.verticalOriginX = svgFontData->verticalOriginX();
107 if (identifier.verticalOriginY == SVGGlyphIdentifier::inheritedValue())
108 identifier.verticalOriginY = svgFontData->verticalOriginY();
110 if (identifier.verticalAdvanceY == SVGGlyphIdentifier::inheritedValue())
111 identifier.verticalAdvanceY = svgFontData->verticalAdvanceY();
114 static inline float parseSVGGlyphAttribute(
const SVGElement* element,
const WebCore::QualifiedName& name)
116 AtomicString value(element->getAttribute(name));
118 return SVGGlyphIdentifier::inheritedValue();
120 return value.string().string().toFloat();
123 SVGGlyphIdentifier SVGGlyphElement::buildGenericGlyphIdentifier(
const SVGElement* element)
125 SVGGlyphIdentifier identifier;
126 identifier.pathData = parsePathData(element->getAttribute(
dAttr));
132 identifier.horizontalAdvanceX = parseSVGGlyphAttribute(element,
horiz_adv_xAttr);
147 identifier.verticalAdvanceY = parseSVGGlyphAttribute(element,
vert_adv_yAttr);
152 SVGGlyphIdentifier SVGGlyphElement::buildGlyphIdentifier()
const
154 SVGGlyphIdentifier identifier(buildGenericGlyphIdentifier(
this));
156 identifier.orientation = parseOrientation(getAttribute(
orientationAttr));
157 identifier.arabicForm = parseArabicForm(getAttribute(
arabic_formAttr));
160 if (!language.isEmpty())
161 identifier.languages = parseDelimitedString(language,
',');
168 #endif // ENABLE(SVG_FONTS)
DOM::QualifiedName horiz_adv_xAttr
DOM::QualifiedName fontTag
DOM::QualifiedName orientationAttr
DOM::QualifiedName arabic_formAttr
DOM::QualifiedName vert_origin_xAttr
DOM::QualifiedName glyph_nameAttr
DOM::QualifiedName langAttr
DOM::QualifiedName vert_adv_yAttr
DOM::QualifiedName vert_origin_yAttr