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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 SVGTextPathChunkBuilder::SVGTextPathChunkBuilder() | 151 SVGTextPathChunkBuilder::SVGTextPathChunkBuilder() |
152 : SVGTextChunkBuilder() | 152 : SVGTextChunkBuilder() |
153 , m_totalLength(0) | 153 , m_totalLength(0) |
154 , m_totalCharacters(0) | 154 , m_totalCharacters(0) |
155 , m_totalTextAnchorShift(0) | 155 , m_totalTextAnchorShift(0) |
156 { | 156 { |
157 } | 157 } |
158 | 158 |
159 void SVGTextPathChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, Box
ListConstIterator boxEnd) | 159 void SVGTextPathChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, Box
ListConstIterator boxEnd) |
160 { | 160 { |
161 const ComputedStyle& style = (*boxStart)->lineLayoutItem().styleRef(); | 161 const ComputedStyle& style = (*boxStart)->getLineLayoutItem().styleRef(); |
162 | 162 |
163 ChunkLengthAccumulator lengthAccumulator(!style.isHorizontalWritingMode()); | 163 ChunkLengthAccumulator lengthAccumulator(!style.isHorizontalWritingMode()); |
164 lengthAccumulator.processRange(boxStart, boxEnd); | 164 lengthAccumulator.processRange(boxStart, boxEnd); |
165 | 165 |
166 // Handle text-anchor as additional start offset for text paths. | 166 // Handle text-anchor as additional start offset for text paths. |
167 m_totalTextAnchorShift += calculateTextAnchorShift(style, lengthAccumulator.
length()); | 167 m_totalTextAnchorShift += calculateTextAnchorShift(style, lengthAccumulator.
length()); |
168 | 168 |
169 m_totalLength += lengthAccumulator.length(); | 169 m_totalLength += lengthAccumulator.length(); |
170 m_totalCharacters += lengthAccumulator.numCharacters(); | 170 m_totalCharacters += lengthAccumulator.numCharacters(); |
171 } | 171 } |
172 | 172 |
173 static float computeTextLengthBias(const SVGTextFragment& fragment, float scale) | 173 static float computeTextLengthBias(const SVGTextFragment& fragment, float scale) |
174 { | 174 { |
175 float initialPosition = fragment.isVertical ? fragment.y : fragment.x; | 175 float initialPosition = fragment.isVertical ? fragment.y : fragment.x; |
176 return initialPosition + scale * -initialPosition; | 176 return initialPosition + scale * -initialPosition; |
177 } | 177 } |
178 | 178 |
179 void SVGTextChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, BoxList
ConstIterator boxEnd) | 179 void SVGTextChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, BoxList
ConstIterator boxEnd) |
180 { | 180 { |
181 ASSERT(*boxStart); | 181 ASSERT(*boxStart); |
182 | 182 |
183 const LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText((*box
Start)->lineLayoutItem()); | 183 const LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText((*box
Start)->getLineLayoutItem()); |
184 const ComputedStyle& style = textLineLayout.styleRef(); | 184 const ComputedStyle& style = textLineLayout.styleRef(); |
185 | 185 |
186 // Handle 'lengthAdjust' property. | 186 // Handle 'lengthAdjust' property. |
187 float desiredTextLength = 0; | 187 float desiredTextLength = 0; |
188 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; | 188 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; |
189 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme
ntFromLineLayoutItem(textLineLayout.parent())) { | 189 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme
ntFromLineLayoutItem(textLineLayout.parent())) { |
190 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV
alue(); | 190 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV
alue(); |
191 | 191 |
192 SVGLengthContext lengthContext(textContentElement); | 192 SVGLengthContext lengthContext(textContentElement); |
193 if (textContentElement->textLengthIsSpecifiedByUser()) | 193 if (textContentElement->textLengthIsSpecifiedByUser()) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 { | 284 { |
285 for (SVGTextFragment& fragment : fragments) { | 285 for (SVGTextFragment& fragment : fragments) { |
286 if (isVerticalText) | 286 if (isVerticalText) |
287 fragment.y += textAnchorShift; | 287 fragment.y += textAnchorShift; |
288 else | 288 else |
289 fragment.x += textAnchorShift; | 289 fragment.x += textAnchorShift; |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 } // namespace blink | 293 } // namespace blink |
OLD | NEW |