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