2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
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.
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.
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.
20 #ifndef SVGTextLayoutAttributes_h
21 #define SVGTextLayoutAttributes_h
23 #include "core/layout/svg/SVGTextMetrics.h"
24 #include "wtf/Allocator.h"
25 #include "wtf/HashMap.h"
26 #include "wtf/MathExtras.h"
27 #include "wtf/Noncopyable.h"
28 #include "wtf/Vector.h"
32 class LayoutSVGInlineText
;
34 struct SVGCharacterData
{
35 ALLOW_ONLY_INLINE_ALLOCATION();
45 typedef HashMap
<unsigned, SVGCharacterData
> SVGCharacterDataMap
;
47 class SVGTextLayoutAttributes
{
48 DISALLOW_ALLOCATION();
49 WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributes
);
51 SVGTextLayoutAttributes(LayoutSVGInlineText
*);
54 static float emptyValue() { return std::numeric_limits
<float>::quiet_NaN(); }
55 static bool isEmptyValue(float value
) { return std::isnan(value
); }
57 LayoutSVGInlineText
* context() const { return m_context
; }
59 SVGCharacterDataMap
& characterDataMap() { return m_characterDataMap
; }
60 const SVGCharacterDataMap
& characterDataMap() const { return m_characterDataMap
; }
62 Vector
<SVGTextMetrics
>& textMetricsValues() { return m_textMetricsValues
; }
63 const Vector
<SVGTextMetrics
>& textMetricsValues() const { return m_textMetricsValues
; }
66 LayoutSVGInlineText
* m_context
;
67 SVGCharacterDataMap m_characterDataMap
;
68 Vector
<SVGTextMetrics
> m_textMetricsValues
;
71 inline SVGCharacterData::SVGCharacterData()
72 : x(SVGTextLayoutAttributes::emptyValue())
73 , y(SVGTextLayoutAttributes::emptyValue())
74 , dx(SVGTextLayoutAttributes::emptyValue())
75 , dy(SVGTextLayoutAttributes::emptyValue())
76 , rotate(SVGTextLayoutAttributes::emptyValue())