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 SVGTextLayoutEngine_h | 20 #ifndef SVGTextLayoutEngine_h |
21 #define SVGTextLayoutEngine_h | 21 #define SVGTextLayoutEngine_h |
22 | 22 |
| 23 #include "core/layout/svg/LayoutSVGInlineText.h" |
23 #include "core/layout/svg/SVGTextFragment.h" | 24 #include "core/layout/svg/SVGTextFragment.h" |
24 #include "core/layout/svg/SVGTextLayoutAttributes.h" | 25 #include "core/layout/svg/SVGTextLayoutAttributes.h" |
25 #include "core/layout/svg/SVGTextMetrics.h" | 26 #include "core/layout/svg/SVGTextMetrics.h" |
26 #include "platform/graphics/Path.h" | 27 #include "platform/graphics/Path.h" |
27 #include "wtf/Vector.h" | 28 #include "wtf/Vector.h" |
28 | 29 |
29 namespace blink { | 30 namespace blink { |
30 | 31 |
31 class LayoutObject; | 32 class LayoutObject; |
32 class ComputedStyle; | 33 class ComputedStyle; |
33 class LayoutSVGInlineText; | |
34 class SVGInlineTextBox; | 34 class SVGInlineTextBox; |
35 | 35 |
36 // SVGTextLayoutEngine performs the second layout phase for SVG text. | 36 // SVGTextLayoutEngine performs the second layout phase for SVG text. |
37 // | 37 // |
38 // The InlineBox tree was created, containing the text chunk information, necess
ary to apply | 38 // The InlineBox tree was created, containing the text chunk information, necess
ary to apply |
39 // certain SVG specific text layout properties (text-length adjustments and text
-anchor). | 39 // certain SVG specific text layout properties (text-length adjustments and text
-anchor). |
40 // The second layout phase uses the SVGTextLayoutAttributes stored in the indivi
dual | 40 // The second layout phase uses the SVGTextLayoutAttributes stored in the indivi
dual |
41 // LayoutSVGInlineText layoutObjects to compute the final positions for each cha
racter | 41 // LayoutSVGInlineText layoutObjects to compute the final positions for each cha
racter |
42 // which are stored in the SVGInlineTextBox objects. | 42 // which are stored in the SVGInlineTextBox objects. |
43 | 43 |
44 class SVGTextLayoutEngine { | 44 class SVGTextLayoutEngine { |
45 WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngine); | 45 WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngine); |
46 public: | 46 public: |
47 SVGTextLayoutEngine(Vector<SVGTextLayoutAttributes*>&); | 47 SVGTextLayoutEngine(Vector<SVGTextLayoutAttributes*>&); |
48 | 48 |
49 Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttrib
utes; } | 49 Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttrib
utes; } |
50 | 50 |
51 void beginTextPathLayout(LayoutObject*, SVGTextLayoutEngine& lineLayout); | 51 void beginTextPathLayout(LayoutObject*, SVGTextLayoutEngine& lineLayout); |
52 void endTextPathLayout(); | 52 void endTextPathLayout(); |
53 | 53 |
54 void layoutInlineTextBox(SVGInlineTextBox*); | 54 void layoutInlineTextBox(SVGInlineTextBox*); |
55 void finishLayout(); | 55 void finishLayout(); |
56 | 56 |
57 private: | 57 private: |
58 void updateCharacterPositionIfNeeded(float& x, float& y); | 58 void updateCharacterPositionIfNeeded(float& x, float& y); |
59 void updateCurrentTextPosition(float x, float y, float glyphAdvance); | 59 void updateCurrentTextPosition(float x, float y, float glyphAdvance); |
60 void updateRelativePositionAdjustmentsIfNeeded(float dx, float dy); | 60 void updateRelativePositionAdjustmentsIfNeeded(float dx, float dy); |
61 | 61 |
62 void recordTextFragment(SVGInlineTextBox*, const Vector<SVGTextMetrics>&); | 62 void recordTextFragment(SVGInlineTextBox*); |
63 bool parentDefinesTextLength(LayoutObject*) const; | 63 bool parentDefinesTextLength(LayoutObject*) const; |
64 | 64 |
65 void layoutTextOnLineOrPath(SVGInlineTextBox*, const LayoutSVGInlineText&, c
onst ComputedStyle&); | 65 void layoutTextOnLineOrPath(SVGInlineTextBox*, const LayoutSVGInlineText&, c
onst ComputedStyle&); |
66 | 66 |
67 bool currentLogicalCharacterAttributes(SVGTextLayoutAttributes*&); | 67 bool currentLogicalCharacterAttributes(SVGTextLayoutAttributes*&); |
68 bool currentLogicalCharacterMetrics(SVGTextLayoutAttributes*&, SVGTextMetric
s&); | 68 bool currentLogicalCharacterMetrics(SVGTextLayoutAttributes*&, SVGTextMetric
s&); |
69 bool currentVisualCharacterMetrics(SVGInlineTextBox*, const Vector<SVGTextMe
trics>&, SVGTextMetrics&); | |
70 | |
71 void advanceToNextLogicalCharacter(const SVGTextMetrics&); | 69 void advanceToNextLogicalCharacter(const SVGTextMetrics&); |
72 void advanceToNextVisualCharacter(const SVGTextMetrics&); | |
73 | 70 |
74 private: | 71 private: |
75 Vector<SVGTextLayoutAttributes*>& m_layoutAttributes; | 72 Vector<SVGTextLayoutAttributes*>& m_layoutAttributes; |
76 | 73 |
77 Vector<SVGInlineTextBox*> m_lineLayoutBoxes; | 74 Vector<SVGInlineTextBox*> m_lineLayoutBoxes; |
78 Vector<SVGInlineTextBox*> m_pathLayoutBoxes; | 75 Vector<SVGInlineTextBox*> m_pathLayoutBoxes; |
79 | 76 |
80 SVGTextFragment m_currentTextFragment; | 77 SVGTextFragment m_currentTextFragment; |
81 unsigned m_layoutAttributesPosition; | 78 unsigned m_layoutAttributesPosition; |
82 unsigned m_logicalCharacterOffset; | 79 unsigned m_logicalCharacterOffset; |
83 unsigned m_logicalMetricsListOffset; | 80 unsigned m_logicalMetricsListOffset; |
84 unsigned m_visualCharacterOffset; | 81 SVGInlineTextMetricsIterator m_visualMetricsIterator; |
85 unsigned m_visualMetricsListOffset; | |
86 float m_x; | 82 float m_x; |
87 float m_y; | 83 float m_y; |
88 float m_dx; | 84 float m_dx; |
89 float m_dy; | 85 float m_dy; |
90 bool m_isVerticalText; | 86 bool m_isVerticalText; |
91 bool m_inPathLayout; | 87 bool m_inPathLayout; |
92 | 88 |
93 // Text on path layout | 89 // Text on path layout |
94 Path::PositionCalculator* m_textPathCalculator; | 90 Path::PositionCalculator* m_textPathCalculator; |
95 float m_textPathLength; | 91 float m_textPathLength; |
96 float m_textPathStartOffset; | 92 float m_textPathStartOffset; |
97 float m_textPathCurrentOffset; | 93 float m_textPathCurrentOffset; |
98 float m_textPathSpacing; | 94 float m_textPathSpacing; |
99 float m_textPathScaling; | 95 float m_textPathScaling; |
100 }; | 96 }; |
101 | 97 |
102 } // namespace blink | 98 } // namespace blink |
103 | 99 |
104 #endif | 100 #endif |
OLD | NEW |