| 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/api/LineLayoutSVGInlineText.h" | 23 #include "core/layout/api/LineLayoutSVGInlineText.h" |
| 24 #include "core/layout/svg/LayoutSVGInlineText.h" | 24 #include "core/layout/svg/LayoutSVGInlineText.h" |
| 25 #include "core/layout/svg/SVGTextFragment.h" | 25 #include "core/layout/svg/SVGTextFragment.h" |
| 26 #include "core/layout/svg/SVGTextLayoutAttributes.h" | |
| 27 #include "core/layout/svg/SVGTextMetrics.h" | |
| 28 #include "wtf/Allocator.h" | 26 #include "wtf/Allocator.h" |
| 29 #include "wtf/Vector.h" | 27 #include "wtf/Vector.h" |
| 30 | 28 |
| 31 namespace blink { | 29 namespace blink { |
| 32 | 30 |
| 33 class ComputedStyle; | 31 class ComputedStyle; |
| 34 class InlineFlowBox; | 32 class InlineFlowBox; |
| 35 class LayoutObject; | 33 class LayoutObject; |
| 36 class PathPositionMapper; | 34 class PathPositionMapper; |
| 37 class SVGInlineFlowBox; | 35 class SVGInlineFlowBox; |
| 38 class SVGInlineTextBox; | 36 class SVGInlineTextBox; |
| 37 class SVGTextMetrics; |
| 39 | 38 |
| 40 // SVGTextLayoutEngine performs the second layout phase for SVG text. | 39 // SVGTextLayoutEngine performs the second layout phase for SVG text. |
| 41 // | 40 // |
| 42 // The InlineBox tree was created, containing the text chunk information, necess
ary to apply | 41 // The InlineBox tree was created, containing the text chunk information, necess
ary to apply |
| 43 // certain SVG specific text layout properties (text-length adjustments and text
-anchor). | 42 // certain SVG specific text layout properties (text-length adjustments and text
-anchor). |
| 44 // The second layout phase uses the SVGTextLayoutAttributes stored in the indivi
dual | 43 // The second layout phase uses the SVGTextLayoutAttributes stored in the indivi
dual |
| 45 // LayoutSVGInlineText layoutObjects to compute the final positions for each cha
racter | 44 // LayoutSVGInlineText layoutObjects to compute the final positions for each cha
racter |
| 46 // which are stored in the SVGInlineTextBox objects. | 45 // which are stored in the SVGInlineTextBox objects. |
| 47 | 46 |
| 48 class SVGTextLayoutEngine { | 47 class SVGTextLayoutEngine { |
| 49 STACK_ALLOCATED(); | 48 STACK_ALLOCATED(); |
| 50 WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngine); | 49 WTF_MAKE_NONCOPYABLE(SVGTextLayoutEngine); |
| 51 public: | 50 public: |
| 52 SVGTextLayoutEngine(Vector<SVGTextLayoutAttributes*>&); | 51 SVGTextLayoutEngine(const Vector<LayoutSVGInlineText*>&); |
| 53 ~SVGTextLayoutEngine(); | 52 ~SVGTextLayoutEngine(); |
| 54 | 53 |
| 55 Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttrib
utes; } | |
| 56 | |
| 57 void layoutCharactersInTextBoxes(InlineFlowBox* start); | 54 void layoutCharactersInTextBoxes(InlineFlowBox* start); |
| 58 void finishLayout(); | 55 void finishLayout(); |
| 59 | 56 |
| 60 private: | 57 private: |
| 61 bool setCurrentTextPosition(const SVGCharacterData&); | 58 bool setCurrentTextPosition(const SVGCharacterData&); |
| 62 void advanceCurrentTextPosition(float glyphAdvance); | 59 void advanceCurrentTextPosition(float glyphAdvance); |
| 63 bool applyRelativePositionAdjustmentsIfNeeded(const SVGCharacterData&); | 60 bool applyRelativePositionAdjustmentsIfNeeded(const SVGCharacterData&); |
| 64 | 61 |
| 65 void computeCurrentFragmentMetrics(SVGInlineTextBox*); | 62 void computeCurrentFragmentMetrics(SVGInlineTextBox*); |
| 66 void recordTextFragment(SVGInlineTextBox*); | 63 void recordTextFragment(SVGInlineTextBox*); |
| 67 | 64 |
| 68 void beginTextPathLayout(SVGInlineFlowBox*); | 65 void beginTextPathLayout(SVGInlineFlowBox*); |
| 69 void endTextPathLayout(); | 66 void endTextPathLayout(); |
| 70 | 67 |
| 71 void layoutInlineTextBox(SVGInlineTextBox*); | 68 void layoutInlineTextBox(SVGInlineTextBox*); |
| 72 void layoutTextOnLineOrPath(SVGInlineTextBox*, LineLayoutSVGInlineText, cons
t ComputedStyle&); | 69 void layoutTextOnLineOrPath(SVGInlineTextBox*, LineLayoutSVGInlineText, cons
t ComputedStyle&); |
| 73 | 70 |
| 74 const SVGTextLayoutAttributes* nextLogicalAttributes(); | 71 const LayoutSVGInlineText* nextLogicalTextNode(); |
| 75 const SVGTextLayoutAttributes* currentLogicalCharacterMetrics(SVGTextMetrics
&); | 72 const LayoutSVGInlineText* currentLogicalCharacterMetrics(SVGTextMetrics&); |
| 76 void advanceToNextLogicalCharacter(const SVGTextMetrics&); | 73 void advanceToNextLogicalCharacter(const SVGTextMetrics&); |
| 77 | 74 |
| 78 // Logical iteration state. | 75 // Logical iteration state. |
| 79 Vector<SVGTextLayoutAttributes*>& m_layoutAttributes; | 76 const Vector<LayoutSVGInlineText*>& m_descendantTextNodes; |
| 80 unsigned m_layoutAttributesPosition; | 77 unsigned m_currentLogicalTextNodeIndex; |
| 81 unsigned m_logicalCharacterOffset; | 78 unsigned m_logicalCharacterOffset; |
| 82 unsigned m_logicalMetricsListOffset; | 79 unsigned m_logicalMetricsListOffset; |
| 83 | 80 |
| 84 Vector<SVGInlineTextBox*> m_lineLayoutBoxes; | 81 Vector<SVGInlineTextBox*> m_lineLayoutBoxes; |
| 85 | 82 |
| 86 SVGTextFragment m_currentTextFragment; | 83 SVGTextFragment m_currentTextFragment; |
| 87 SVGInlineTextMetricsIterator m_visualMetricsIterator; | 84 SVGInlineTextMetricsIterator m_visualMetricsIterator; |
| 88 FloatPoint m_textPosition; | 85 FloatPoint m_textPosition; |
| 89 bool m_isVerticalText; | 86 bool m_isVerticalText; |
| 90 bool m_inPathLayout; | 87 bool m_inPathLayout; |
| 91 bool m_textLengthSpacingInEffect; | 88 bool m_textLengthSpacingInEffect; |
| 92 | 89 |
| 93 // Text on path layout | 90 // Text on path layout |
| 94 OwnPtr<PathPositionMapper> m_textPath; | 91 OwnPtr<PathPositionMapper> m_textPath; |
| 95 float m_textPathStartOffset; | 92 float m_textPathStartOffset; |
| 96 float m_textPathCurrentOffset; | 93 float m_textPathCurrentOffset; |
| 97 float m_textPathDisplacement; | 94 float m_textPathDisplacement; |
| 98 float m_textPathSpacing; | 95 float m_textPathSpacing; |
| 99 float m_textPathScaling; | 96 float m_textPathScaling; |
| 100 }; | 97 }; |
| 101 | 98 |
| 102 } // namespace blink | 99 } // namespace blink |
| 103 | 100 |
| 104 #endif | 101 #endif |
| OLD | NEW |