Rubber-stamped by Brady Eidson.
[webbrowser.git] / WebCore / svg / SVGGlyphElement.h
blob0662097e0e2405baf630f212031a8b9f53cbc92b
1 /*
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
25 #if ENABLE(SVG_FONTS)
26 #include "SVGStyledElement.h"
28 #include <limits>
29 #include "Path.h"
31 namespace WebCore {
33 class AtomicString;
34 class SVGFontData;
36 // Describe a SVG <glyph> element
37 struct SVGGlyphIdentifier {
38 enum Orientation {
39 Vertical,
40 Horizontal,
41 Both
44 // SVG Font depends on exactly this order.
45 enum ArabicForm {
46 None = 0,
47 Isolated,
48 Terminal,
49 Initial,
50 Medial
53 SVGGlyphIdentifier()
54 : isValid(false)
55 , orientation(Both)
56 , arabicForm(None)
57 , priority(0)
58 , nameLength(0)
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 pathData.debugString() == other.pathData.debugString() &&
84 languages == other.languages;
87 bool isValid : 1;
89 unsigned orientation : 2; // Orientation
90 unsigned arabicForm : 3; // ArabicForm
91 int priority;
92 size_t nameLength;
93 String glyphName;
95 float horizontalAdvanceX;
96 float verticalOriginX;
97 float verticalOriginY;
98 float verticalAdvanceY;
100 Path pathData;
101 Vector<String> languages;
104 class SVGGlyphElement : public SVGStyledElement {
105 public:
106 SVGGlyphElement(const QualifiedName&, Document*);
107 virtual ~SVGGlyphElement();
109 virtual void parseMappedAttribute(MappedAttribute*);
111 virtual void insertedIntoDocument();
112 virtual void removedFromDocument();
114 virtual bool rendererIsNeeded(RenderStyle*) { return false; }
116 SVGGlyphIdentifier buildGlyphIdentifier() const;
118 // Helper function used by SVGFont
119 static void inheritUnspecifiedAttributes(SVGGlyphIdentifier&, const SVGFontData*);
120 static String querySVGFontLanguage(const SVGElement*);
122 // Helper function shared between SVGGlyphElement & SVGMissingGlyphElement
123 static SVGGlyphIdentifier buildGenericGlyphIdentifier(const SVGElement*);
124 private:
125 void invalidateGlyphCache();
128 } // namespace WebCore
130 #endif // ENABLE(SVG_FONTS)
131 #endif