OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. 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 27 matching lines...) Expand all Loading... |
38 , width(0) | 38 , width(0) |
39 , height(0) | 39 , height(0) |
40 { | 40 { |
41 } | 41 } |
42 | 42 |
43 enum TransformType { | 43 enum TransformType { |
44 TransformRespectingTextLength, | 44 TransformRespectingTextLength, |
45 TransformIgnoringTextLength | 45 TransformIgnoringTextLength |
46 }; | 46 }; |
47 | 47 |
48 void buildFragmentTransform(AffineTransform& result, TransformType type = Tr
ansformRespectingTextLength) const | 48 FloatRect boundingBox(float baseline) const |
| 49 { |
| 50 FloatRect fragmentRect(x, y - baseline, width, height); |
| 51 if (!isTransformed()) |
| 52 return fragmentRect; |
| 53 return buildNormalFragmentTransform().mapRect(fragmentRect); |
| 54 } |
| 55 |
| 56 FloatRect overflowBoundingBox(float baseline) const |
| 57 { |
| 58 FloatRect fragmentRect( |
| 59 x - glyphOverflowLeft, |
| 60 y - baseline - glyphOverflowTop, |
| 61 width + glyphOverflowLeft + glyphOverflowRight, |
| 62 height + glyphOverflowTop + glyphOverflowBottom); |
| 63 if (!isTransformed()) |
| 64 return fragmentRect; |
| 65 return buildNormalFragmentTransform().mapRect(fragmentRect); |
| 66 } |
| 67 |
| 68 FloatQuad boundingQuad(float baseline) const |
| 69 { |
| 70 FloatQuad fragmentQuad(FloatRect(x, y - baseline, width, height)); |
| 71 if (!isTransformed()) |
| 72 return fragmentQuad; |
| 73 return buildNormalFragmentTransform().mapQuad(fragmentQuad); |
| 74 } |
| 75 |
| 76 AffineTransform buildFragmentTransform(TransformType type = TransformRespect
ingTextLength) const |
49 { | 77 { |
50 if (type == TransformIgnoringTextLength) { | 78 if (type == TransformIgnoringTextLength) { |
51 result = transform; | 79 AffineTransform result = transform; |
52 transformAroundOrigin(result); | 80 transformAroundOrigin(result); |
53 return; | 81 return result; |
54 } | 82 } |
55 | 83 return buildNormalFragmentTransform(); |
56 if (isTextOnPath) | |
57 buildTransformForTextOnPath(result); | |
58 else | |
59 buildTransformForTextOnLine(result); | |
60 } | 84 } |
61 | 85 |
62 bool isTransformed() const { return affectedByTextLength() || !transform.isI
dentity(); } | 86 bool isTransformed() const { return affectedByTextLength() || !transform.isI
dentity(); } |
63 | 87 |
64 // The first laid out character starts at LayoutSVGInlineText::characters()
+ characterOffset. | 88 // The first laid out character starts at LayoutSVGInlineText::characters()
+ characterOffset. |
65 unsigned characterOffset; | 89 unsigned characterOffset; |
66 unsigned metricsListOffset; | 90 unsigned metricsListOffset; |
67 unsigned length : 31; | 91 unsigned length : 31; |
68 unsigned isTextOnPath : 1; | 92 unsigned isTextOnPath : 1; |
69 | 93 |
(...skipping 10 matching lines...) Expand all Loading... |
80 float glyphOverflowRight; | 104 float glyphOverflowRight; |
81 | 105 |
82 // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as
well as orientation related shifts | 106 // Includes rotation/glyph-orientation-(horizontal|vertical) transforms, as
well as orientation related shifts |
83 // (see SVGTextLayoutEngine, which builds this transformation). | 107 // (see SVGTextLayoutEngine, which builds this transformation). |
84 AffineTransform transform; | 108 AffineTransform transform; |
85 | 109 |
86 // Contains lengthAdjust related transformations, which are not allowd to in
fluence the SVGTextQuery code. | 110 // Contains lengthAdjust related transformations, which are not allowd to in
fluence the SVGTextQuery code. |
87 AffineTransform lengthAdjustTransform; | 111 AffineTransform lengthAdjustTransform; |
88 | 112 |
89 private: | 113 private: |
| 114 AffineTransform buildNormalFragmentTransform() const |
| 115 { |
| 116 if (isTextOnPath) |
| 117 return buildTransformForTextOnPath(); |
| 118 return buildTransformForTextOnLine(); |
| 119 } |
| 120 |
90 bool affectedByTextLength() const { return lengthAdjustTransform.a() != 1 ||
lengthAdjustTransform.d() != 1; } | 121 bool affectedByTextLength() const { return lengthAdjustTransform.a() != 1 ||
lengthAdjustTransform.d() != 1; } |
91 | 122 |
92 void transformAroundOrigin(AffineTransform& result) const | 123 void transformAroundOrigin(AffineTransform& result) const |
93 { | 124 { |
94 // Returns (translate(x, y) * result) * translate(-x, -y). | 125 // Returns (translate(x, y) * result) * translate(-x, -y). |
95 result.setE(result.e() + x); | 126 result.setE(result.e() + x); |
96 result.setF(result.f() + y); | 127 result.setF(result.f() + y); |
97 result.translate(-x, -y); | 128 result.translate(-x, -y); |
98 } | 129 } |
99 | 130 |
100 void buildTransformForTextOnPath(AffineTransform& result) const | 131 AffineTransform buildTransformForTextOnPath() const |
101 { | 132 { |
102 // For text-on-path layout, multiply the transform with the lengthAdjust
Transform before orienting the resulting transform. | 133 // For text-on-path layout, multiply the transform with the lengthAdjust
Transform before orienting the resulting transform. |
103 result = !affectedByTextLength() ? transform : transform * lengthAdjustT
ransform; | 134 AffineTransform result = !affectedByTextLength() ? transform : transform
* lengthAdjustTransform; |
104 if (!result.isIdentity()) | 135 if (!result.isIdentity()) |
105 transformAroundOrigin(result); | 136 transformAroundOrigin(result); |
| 137 return result; |
106 } | 138 } |
107 | 139 |
108 void buildTransformForTextOnLine(AffineTransform& result) const | 140 AffineTransform buildTransformForTextOnLine() const |
109 { | 141 { |
110 // For text-on-line layout, orient the transform first, then multiply th
e lengthAdjustTransform with the oriented transform. | 142 // For text-on-line layout, orient the transform first, then multiply th
e lengthAdjustTransform with the oriented transform. |
111 if (transform.isIdentity()) { | 143 if (transform.isIdentity()) |
112 result = lengthAdjustTransform; | 144 return lengthAdjustTransform; |
113 return; | |
114 } | |
115 | 145 |
116 result = transform; | 146 AffineTransform result = transform; |
117 transformAroundOrigin(result); | 147 transformAroundOrigin(result); |
118 result.preMultiply(lengthAdjustTransform); | 148 result.preMultiply(lengthAdjustTransform); |
| 149 return result; |
119 } | 150 } |
120 }; | 151 }; |
121 | 152 |
122 } // namespace blink | 153 } // namespace blink |
123 | 154 |
124 #endif | 155 #endif |
OLD | NEW |