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 SVGTextFragment_h
21 #define SVGTextFragment_h
24 #include "AffineTransform.h"
28 // A SVGTextFragment describes a text fragment of a RenderSVGInlineText which can be rendered at once.
29 struct SVGTextFragment {
32 , metricsListOffset(0)
43 TransformRespectingTextLength,
44 TransformIgnoringTextLength
47 void buildFragmentTransform(AffineTransform& result, TransformType type = TransformRespectingTextLength) const
49 if (type == TransformIgnoringTextLength) {
51 transformAroundOrigin(result);
56 buildTransformForTextOnPath(result);
58 buildTransformForTextOnLine(result);
61 // The first rendered character starts at RenderSVGInlineText::characters() + characterOffset.
62 unsigned characterOffset;
63 unsigned metricsListOffset;
65 bool isTextOnPath : 1;
72 // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as well as orientation related shifts
73 // (see SVGTextLayoutEngine, which builds this transformation).
74 AffineTransform transform;
76 // Contains lengthAdjust related transformations, which are not allowd to influence the SVGTextQuery code.
77 AffineTransform lengthAdjustTransform;
80 void transformAroundOrigin(AffineTransform& result) const
82 // Returns (translate(x, y) * result) * translate(-x, -y).
83 result.setE(result.e() + x);
84 result.setF(result.f() + y);
85 result.translate(-x, -y);
88 void buildTransformForTextOnPath(AffineTransform& result) const
90 // For text-on-path layout, multiply the transform with the lengthAdjustTransform before orienting the resulting transform.
91 result = lengthAdjustTransform.isIdentity() ? transform : transform * lengthAdjustTransform;
92 if (!result.isIdentity())
93 transformAroundOrigin(result);
96 void buildTransformForTextOnLine(AffineTransform& result) const
98 // For text-on-line layout, orient the transform first, then multiply the lengthAdjustTransform with the oriented transform.
99 if (transform.isIdentity()) {
100 result = lengthAdjustTransform;
105 transformAroundOrigin(result);
107 if (!lengthAdjustTransform.isIdentity())
108 result = lengthAdjustTransform * result;
112 } // namespace WebCore
114 #endif // ENABLE(SVG)