File indexing completed on 2024-04-28 15:24:34
0001 /* 0002 Copyright (C) 2007 Eric Seidel <eric@webkit.org> 0003 Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This library is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 Library General Public License for more details. 0014 0015 You should have received a copy of the GNU Library General Public License 0016 along with this library; see the file COPYING.LIB. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef SVGGlyphElement_h 0022 #define SVGGlyphElement_h 0023 0024 #if ENABLE(SVG_FONTS) 0025 #include "SVGStyledElement.h" 0026 0027 #include <limits> 0028 #include "Path.h" 0029 0030 namespace khtml 0031 { 0032 class AtomicString; 0033 } 0034 0035 namespace WebCore 0036 { 0037 0038 using khtml::AtomicString; 0039 class SVGFontData; 0040 0041 // Describe a SVG <glyph> element 0042 struct SVGGlyphIdentifier { 0043 enum Orientation { 0044 Vertical, 0045 Horizontal, 0046 Both 0047 }; 0048 0049 // SVG Font depends on exactly this order. 0050 enum ArabicForm { 0051 None = 0, 0052 Isolated, 0053 Terminal, 0054 Initial, 0055 Medial 0056 }; 0057 0058 SVGGlyphIdentifier() 0059 : isValid(false) 0060 , orientation(Both) 0061 , arabicForm(None) 0062 , priority(0) 0063 , nameLength(0) 0064 , horizontalAdvanceX(0.0f) 0065 , verticalOriginX(0.0f) 0066 , verticalOriginY(0.0f) 0067 , verticalAdvanceY(0.0f) 0068 { 0069 } 0070 0071 // Used to mark our float properties as "to be inherited from SVGFontData" 0072 static float inheritedValue() 0073 { 0074 static float s_inheritedValue = std::numeric_limits<float>::infinity(); 0075 return s_inheritedValue; 0076 } 0077 0078 bool operator==(const SVGGlyphIdentifier &other) const 0079 { 0080 return isValid == other.isValid && 0081 orientation == other.orientation && 0082 arabicForm == other.arabicForm && 0083 glyphName == other.glyphName && 0084 horizontalAdvanceX == other.horizontalAdvanceX && 0085 verticalOriginX == other.verticalOriginX && 0086 verticalOriginY == other.verticalOriginY && 0087 verticalAdvanceY == other.verticalAdvanceY && 0088 pathData.debugString() == other.pathData.debugString() && 0089 languages == other.languages; 0090 } 0091 0092 bool isValid : 1; 0093 0094 Orientation orientation : 2; 0095 ArabicForm arabicForm : 3; 0096 int priority; 0097 size_t nameLength; 0098 String glyphName; 0099 0100 float horizontalAdvanceX; 0101 float verticalOriginX; 0102 float verticalOriginY; 0103 float verticalAdvanceY; 0104 0105 Path pathData; 0106 Vector<String> languages; 0107 }; 0108 0109 class SVGGlyphElement : public SVGStyledElement 0110 { 0111 public: 0112 SVGGlyphElement(const QualifiedName &, Document *); 0113 virtual ~SVGGlyphElement(); 0114 0115 void insertedIntoDocument() override; 0116 void removedFromDocument() override; 0117 0118 bool rendererIsNeeded(RenderStyle *) override 0119 { 0120 return false; 0121 } 0122 0123 SVGGlyphIdentifier buildGlyphIdentifier() const; 0124 0125 // Helper function used by SVGFont 0126 static void inheritUnspecifiedAttributes(SVGGlyphIdentifier &, const SVGFontData *); 0127 static String querySVGFontLanguage(const SVGElement *); 0128 0129 // Helper function shared between SVGGlyphElement & SVGMissingGlyphElement 0130 static SVGGlyphIdentifier buildGenericGlyphIdentifier(const SVGElement *); 0131 }; 0132 0133 } // namespace WebCore 0134 0135 #endif // ENABLE(SVG_FONTS) 0136 #endif