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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 auto boxIter = lineLayoutBoxes.begin(); | 119 auto boxIter = lineLayoutBoxes.begin(); |
120 auto endBox = lineLayoutBoxes.end(); | 120 auto endBox = lineLayoutBoxes.end(); |
121 auto chunkStartBox = boxIter; | 121 auto chunkStartBox = boxIter; |
122 for (; boxIter != endBox; ++boxIter) { | 122 for (; boxIter != endBox; ++boxIter) { |
123 if (!(*boxIter)->startsNewTextChunk()) | 123 if (!(*boxIter)->startsNewTextChunk()) |
124 continue; | 124 continue; |
125 | 125 |
126 if (!foundStart) { | 126 if (!foundStart) { |
127 foundStart = true; | 127 foundStart = true; |
128 } else { | 128 } else { |
129 ASSERT(boxIter != chunkStartBox); | 129 DCHECK_NE(boxIter, chunkStartBox); |
130 handleTextChunk(chunkStartBox, boxIter); | 130 handleTextChunk(chunkStartBox, boxIter); |
131 } | 131 } |
132 chunkStartBox = boxIter; | 132 chunkStartBox = boxIter; |
133 } | 133 } |
134 | 134 |
135 if (!foundStart) | 135 if (!foundStart) |
136 return; | 136 return; |
137 | 137 |
138 if (boxIter != chunkStartBox) | 138 if (boxIter != chunkStartBox) |
139 handleTextChunk(chunkStartBox, boxIter); | 139 handleTextChunk(chunkStartBox, boxIter); |
(...skipping 21 matching lines...) Expand all Loading... |
161 } | 161 } |
162 | 162 |
163 static float computeTextLengthBias(const SVGTextFragment& fragment, | 163 static float computeTextLengthBias(const SVGTextFragment& fragment, |
164 float scale) { | 164 float scale) { |
165 float initialPosition = fragment.isVertical ? fragment.y : fragment.x; | 165 float initialPosition = fragment.isVertical ? fragment.y : fragment.x; |
166 return initialPosition + scale * -initialPosition; | 166 return initialPosition + scale * -initialPosition; |
167 } | 167 } |
168 | 168 |
169 void SVGTextChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, | 169 void SVGTextChunkBuilder::handleTextChunk(BoxListConstIterator boxStart, |
170 BoxListConstIterator boxEnd) { | 170 BoxListConstIterator boxEnd) { |
171 ASSERT(*boxStart); | 171 DCHECK(*boxStart); |
172 | 172 |
173 const LineLayoutSVGInlineText textLineLayout = | 173 const LineLayoutSVGInlineText textLineLayout = |
174 LineLayoutSVGInlineText((*boxStart)->getLineLayoutItem()); | 174 LineLayoutSVGInlineText((*boxStart)->getLineLayoutItem()); |
175 const ComputedStyle& style = textLineLayout.styleRef(); | 175 const ComputedStyle& style = textLineLayout.styleRef(); |
176 | 176 |
177 // Handle 'lengthAdjust' property. | 177 // Handle 'lengthAdjust' property. |
178 float desiredTextLength = 0; | 178 float desiredTextLength = 0; |
179 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; | 179 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; |
180 if (SVGTextContentElement* textContentElement = | 180 if (SVGTextContentElement* textContentElement = |
181 SVGTextContentElement::elementFromLineLayoutItem( | 181 SVGTextContentElement::elementFromLineLayoutItem( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 fragments, atCharacter); | 218 fragments, atCharacter); |
219 } | 219 } |
220 | 220 |
221 // Fragments have been adjusted, we have to recalculate the chunk | 221 // Fragments have been adjusted, we have to recalculate the chunk |
222 // length, to be able to apply the text-anchor shift. | 222 // length, to be able to apply the text-anchor shift. |
223 if (processTextAnchor) { | 223 if (processTextAnchor) { |
224 lengthAccumulator.reset(); | 224 lengthAccumulator.reset(); |
225 lengthAccumulator.processRange(boxStart, boxEnd); | 225 lengthAccumulator.processRange(boxStart, boxEnd); |
226 } | 226 } |
227 } else { | 227 } else { |
228 ASSERT(lengthAdjust == SVGLengthAdjustSpacingAndGlyphs); | 228 DCHECK_EQ(lengthAdjust, SVGLengthAdjustSpacingAndGlyphs); |
229 float textLengthScale = desiredTextLength / chunkLength; | 229 float textLengthScale = desiredTextLength / chunkLength; |
230 float textLengthBias = 0; | 230 float textLengthBias = 0; |
231 | 231 |
232 bool foundFirstFragment = false; | 232 bool foundFirstFragment = false; |
233 for (auto boxIter = boxStart; boxIter != boxEnd; ++boxIter) { | 233 for (auto boxIter = boxStart; boxIter != boxEnd; ++boxIter) { |
234 SVGInlineTextBox* textBox = *boxIter; | 234 SVGInlineTextBox* textBox = *boxIter; |
235 Vector<SVGTextFragment>& fragments = textBox->textFragments(); | 235 Vector<SVGTextFragment>& fragments = textBox->textFragments(); |
236 if (fragments.isEmpty()) | 236 if (fragments.isEmpty()) |
237 continue; | 237 continue; |
238 | 238 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 atCharacter += fragment.length; | 275 atCharacter += fragment.length; |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 void SVGTextChunkBuilder::applyTextLengthScaleAdjustment( | 279 void SVGTextChunkBuilder::applyTextLengthScaleAdjustment( |
280 float textLengthScale, | 280 float textLengthScale, |
281 float textLengthBias, | 281 float textLengthBias, |
282 Vector<SVGTextFragment>& fragments) { | 282 Vector<SVGTextFragment>& fragments) { |
283 for (SVGTextFragment& fragment : fragments) { | 283 for (SVGTextFragment& fragment : fragments) { |
284 ASSERT(fragment.lengthAdjustScale == 1); | 284 DCHECK_EQ(fragment.lengthAdjustScale, 1u); |
285 fragment.lengthAdjustScale = textLengthScale; | 285 fragment.lengthAdjustScale = textLengthScale; |
286 fragment.lengthAdjustBias = textLengthBias; | 286 fragment.lengthAdjustBias = textLengthBias; |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
290 void SVGTextChunkBuilder::processTextAnchorCorrection( | 290 void SVGTextChunkBuilder::processTextAnchorCorrection( |
291 bool isVerticalText, | 291 bool isVerticalText, |
292 float textAnchorShift, | 292 float textAnchorShift, |
293 Vector<SVGTextFragment>& fragments) { | 293 Vector<SVGTextFragment>& fragments) { |
294 for (SVGTextFragment& fragment : fragments) { | 294 for (SVGTextFragment& fragment : fragments) { |
295 if (isVerticalText) | 295 if (isVerticalText) |
296 fragment.y += textAnchorShift; | 296 fragment.y += textAnchorShift; |
297 else | 297 else |
298 fragment.x += textAnchorShift; | 298 fragment.x += textAnchorShift; |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 } // namespace blink | 302 } // namespace blink |
OLD | NEW |