OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #ifndef SVGTextLayoutAttributes_h | 20 #ifndef SVGTextLayoutAttributes_h |
21 #define SVGTextLayoutAttributes_h | 21 #define SVGTextLayoutAttributes_h |
22 | 22 |
23 #include "core/layout/svg/SVGTextMetrics.h" | 23 #include "core/layout/svg/SVGTextMetrics.h" |
24 #include "wtf/HashMap.h" | 24 #include "wtf/HashMap.h" |
| 25 #include "wtf/MathExtras.h" |
25 #include "wtf/Noncopyable.h" | 26 #include "wtf/Noncopyable.h" |
26 #include "wtf/Vector.h" | 27 #include "wtf/Vector.h" |
27 | 28 |
28 namespace blink { | 29 namespace blink { |
29 | 30 |
30 class LayoutSVGInlineText; | 31 class LayoutSVGInlineText; |
31 | 32 |
32 struct SVGCharacterData { | 33 struct SVGCharacterData { |
33 SVGCharacterData(); | 34 SVGCharacterData(); |
34 | 35 |
35 float x; | 36 float x; |
36 float y; | 37 float y; |
37 float dx; | 38 float dx; |
38 float dy; | 39 float dy; |
39 float rotate; | 40 float rotate; |
40 }; | 41 }; |
41 | 42 |
42 typedef HashMap<unsigned, SVGCharacterData> SVGCharacterDataMap; | 43 typedef HashMap<unsigned, SVGCharacterData> SVGCharacterDataMap; |
43 | 44 |
44 class SVGTextLayoutAttributes { | 45 class SVGTextLayoutAttributes { |
45 WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributes); | 46 WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributes); |
46 public: | 47 public: |
47 SVGTextLayoutAttributes(LayoutSVGInlineText*); | 48 SVGTextLayoutAttributes(LayoutSVGInlineText*); |
48 | 49 |
49 void clear(); | 50 void clear(); |
50 static float emptyValue(); | 51 static float emptyValue() { return std::numeric_limits<float>::quiet_NaN();
} |
| 52 static bool isEmptyValue(float value) { return std::isnan(value); } |
51 | 53 |
52 LayoutSVGInlineText* context() const { return m_context; } | 54 LayoutSVGInlineText* context() const { return m_context; } |
53 | 55 |
54 SVGCharacterDataMap& characterDataMap() { return m_characterDataMap; } | 56 SVGCharacterDataMap& characterDataMap() { return m_characterDataMap; } |
55 const SVGCharacterDataMap& characterDataMap() const { return m_characterData
Map; } | 57 const SVGCharacterDataMap& characterDataMap() const { return m_characterData
Map; } |
56 | 58 |
57 Vector<SVGTextMetrics>& textMetricsValues() { return m_textMetricsValues; } | 59 Vector<SVGTextMetrics>& textMetricsValues() { return m_textMetricsValues; } |
58 const Vector<SVGTextMetrics>& textMetricsValues() const { return m_textMetri
csValues; } | 60 const Vector<SVGTextMetrics>& textMetricsValues() const { return m_textMetri
csValues; } |
59 | 61 |
60 private: | 62 private: |
61 LayoutSVGInlineText* m_context; | 63 LayoutSVGInlineText* m_context; |
62 SVGCharacterDataMap m_characterDataMap; | 64 SVGCharacterDataMap m_characterDataMap; |
63 Vector<SVGTextMetrics> m_textMetricsValues; | 65 Vector<SVGTextMetrics> m_textMetricsValues; |
64 }; | 66 }; |
65 | 67 |
66 inline SVGCharacterData::SVGCharacterData() | 68 inline SVGCharacterData::SVGCharacterData() |
67 : x(SVGTextLayoutAttributes::emptyValue()) | 69 : x(SVGTextLayoutAttributes::emptyValue()) |
68 , y(SVGTextLayoutAttributes::emptyValue()) | 70 , y(SVGTextLayoutAttributes::emptyValue()) |
69 , dx(SVGTextLayoutAttributes::emptyValue()) | 71 , dx(SVGTextLayoutAttributes::emptyValue()) |
70 , dy(SVGTextLayoutAttributes::emptyValue()) | 72 , dy(SVGTextLayoutAttributes::emptyValue()) |
71 , rotate(SVGTextLayoutAttributes::emptyValue()) | 73 , rotate(SVGTextLayoutAttributes::emptyValue()) |
72 { | 74 { |
73 } | 75 } |
74 | 76 |
75 } // namespace blink | 77 } // namespace blink |
76 | 78 |
77 #endif | 79 #endif |
OLD | NEW |