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