OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. 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 SVGTextMetrics_h | 20 #ifndef SVGTextMetrics_h |
21 #define SVGTextMetrics_h | 21 #define SVGTextMetrics_h |
22 | 22 |
23 #include "wtf/Allocator.h" | 23 #include "wtf/Allocator.h" |
24 | 24 |
25 namespace blink { | 25 namespace blink { |
26 | 26 |
27 enum class FontOrientation; | 27 enum class FontOrientation; |
28 class LineLayoutSVGInlineText; | |
29 | 28 |
30 class SVGTextMetrics { | 29 class SVGTextMetrics { |
31 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 30 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
32 public: | 31 public: |
33 enum MetricsType { | 32 enum MetricsType { |
34 SkippedSpaceMetrics | 33 SkippedSpaceMetrics |
35 }; | 34 }; |
36 | 35 |
37 SVGTextMetrics(); | 36 SVGTextMetrics(); |
38 SVGTextMetrics(MetricsType); | 37 SVGTextMetrics(MetricsType); |
39 SVGTextMetrics(LineLayoutSVGInlineText, unsigned length, float width); | 38 SVGTextMetrics(unsigned length, float width, float height); |
40 | 39 |
41 bool isEmpty() const { return !m_width && !m_height && m_length <= 1; } | 40 bool isEmpty() const { return !m_width && !m_height && m_length <= 1; } |
42 | 41 |
43 float width() const { return m_width; } | 42 float width() const { return m_width; } |
44 void setWidth(float width) { m_width = width; } | |
45 | |
46 float height() const { return m_height; } | 43 float height() const { return m_height; } |
47 | 44 |
48 // TODO(kojii): We should store logical width (advance) and height instead | 45 // TODO(kojii): We should store logical width (advance) and height instead |
49 // of storing physical and calculate logical. crbug.com/544767 | 46 // of storing physical and calculate logical. crbug.com/544767 |
50 float advance(FontOrientation) const; | 47 float advance(FontOrientation) const; |
51 unsigned length() const { return m_length; } | 48 unsigned length() const { return m_length; } |
52 | 49 |
53 private: | 50 private: |
54 float m_width; | 51 float m_width; |
55 float m_height; | 52 float m_height; |
56 unsigned m_length; | 53 unsigned m_length; |
57 }; | 54 }; |
58 | 55 |
59 } // namespace blink | 56 } // namespace blink |
60 | 57 |
61 #endif | 58 #endif |
OLD | NEW |