2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 * Copyright (C) 2008 Rob Buis <buis@kde.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef SVGGlyphElement_h
23 #define SVGGlyphElement_h
27 #include "SVGStyledElement.h"
30 #include <wtf/Forward.h>
36 // Describe a SVG <glyph> element
37 struct SVGGlyphIdentifier {
44 // SVG Font depends on exactly this order.
59 , horizontalAdvanceX(0.0f)
60 , verticalOriginX(0.0f)
61 , verticalOriginY(0.0f)
62 , verticalAdvanceY(0.0f)
66 // Used to mark our float properties as "to be inherited from SVGFontData"
67 static float inheritedValue()
69 static float s_inheritedValue = std::numeric_limits<float>::infinity();
70 return s_inheritedValue;
73 bool operator==(const SVGGlyphIdentifier& other) const
75 return isValid == other.isValid
76 && orientation == other.orientation
77 && arabicForm == other.arabicForm
78 && glyphName == other.glyphName
79 && horizontalAdvanceX == other.horizontalAdvanceX
80 && verticalOriginX == other.verticalOriginX
81 && verticalOriginY == other.verticalOriginY
82 && verticalAdvanceY == other.verticalAdvanceY
83 && languages == other.languages;
88 unsigned orientation : 2; // Orientation
89 unsigned arabicForm : 3; // ArabicForm
94 float horizontalAdvanceX;
95 float verticalOriginX;
96 float verticalOriginY;
97 float verticalAdvanceY;
100 Vector<String> languages;
103 class SVGGlyphElement : public SVGStyledElement {
105 static PassRefPtr<SVGGlyphElement> create(const QualifiedName&, Document*);
107 SVGGlyphIdentifier buildGlyphIdentifier() const;
109 // Helper function used by SVGFont
110 static void inheritUnspecifiedAttributes(SVGGlyphIdentifier&, const SVGFontData*);
111 static String querySVGFontLanguage(const SVGElement*);
113 // Helper function shared between SVGGlyphElement & SVGMissingGlyphElement
114 static SVGGlyphIdentifier buildGenericGlyphIdentifier(const SVGElement*);
117 SVGGlyphElement(const QualifiedName&, Document*);
119 virtual void parseMappedAttribute(Attribute*);
120 virtual void fillAttributeToPropertyTypeMap();
121 virtual AttributeToPropertyTypeMap& attributeToPropertyTypeMap();
123 virtual void insertedIntoDocument();
124 virtual void removedFromDocument();
126 virtual bool rendererIsNeeded(RenderStyle*) { return false; }
128 void invalidateGlyphCache();
131 } // namespace WebCore
133 #endif // ENABLE(SVG_FONTS)