2 * Copyright (C) Research In Motion Limited 2010. 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 SVGTextChunk_h
21 #define SVGTextChunk_h
24 #include "SVGRenderStyleDefs.h"
25 #include "SVGTextContentElement.h"
29 class SVGInlineTextBox;
31 // A SVGTextChunk describes a range of SVGTextFragments, see the SVG spec definition of a "text chunk".
35 DefaultStyle = 1 << 0,
36 MiddleAnchor = 1 << 1,
38 RightToLeftText = 1 << 3,
39 VerticalText = 1 << 4,
40 LengthAdjustSpacing = 1 << 5,
41 LengthAdjustSpacingAndGlyphs = 1 << 6
44 SVGTextChunk(unsigned chunkStyle, float desiredTextLength);
46 void calculateLength(float& length, unsigned& characters) const;
47 float calculateTextAnchorShift(float length) const;
49 bool isVerticalText() const { return m_chunkStyle & VerticalText; }
50 float desiredTextLength() const { return m_desiredTextLength; }
52 Vector<SVGInlineTextBox*>& boxes() { return m_boxes; }
53 const Vector<SVGInlineTextBox*>& boxes() const { return m_boxes; }
55 bool hasDesiredTextLength() const { return m_desiredTextLength > 0 && ((m_chunkStyle & LengthAdjustSpacing) || (m_chunkStyle & LengthAdjustSpacingAndGlyphs)); }
56 bool hasTextAnchor() const { return m_chunkStyle & RightToLeftText ? !(m_chunkStyle & EndAnchor) : (m_chunkStyle & MiddleAnchor) || (m_chunkStyle & EndAnchor); }
57 bool hasLengthAdjustSpacing() const { return m_chunkStyle & LengthAdjustSpacing; }
58 bool hasLengthAdjustSpacingAndGlyphs() const { return m_chunkStyle & LengthAdjustSpacingAndGlyphs; }
61 // Contains all SVGInlineTextBoxes this chunk spans.
62 Vector<SVGInlineTextBox*> m_boxes;
64 unsigned m_chunkStyle;
65 float m_desiredTextLength;
68 } // namespace WebCore