OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. 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 29 matching lines...) Expand all Loading... | |
40 , m_logicalCharacterOffset(0) | 40 , m_logicalCharacterOffset(0) |
41 , m_logicalMetricsListOffset(0) | 41 , m_logicalMetricsListOffset(0) |
42 , m_visualCharacterOffset(0) | 42 , m_visualCharacterOffset(0) |
43 , m_visualMetricsListOffset(0) | 43 , m_visualMetricsListOffset(0) |
44 , m_x(0) | 44 , m_x(0) |
45 , m_y(0) | 45 , m_y(0) |
46 , m_dx(0) | 46 , m_dx(0) |
47 , m_dy(0) | 47 , m_dy(0) |
48 , m_isVerticalText(false) | 48 , m_isVerticalText(false) |
49 , m_inPathLayout(false) | 49 , m_inPathLayout(false) |
50 , m_textPathCalculator(0) | |
50 , m_textPathLength(0) | 51 , m_textPathLength(0) |
51 , m_textPathCurrentOffset(0) | 52 , m_textPathCurrentOffset(0) |
52 , m_textPathSpacing(0) | 53 , m_textPathSpacing(0) |
53 , m_textPathScaling(1) | 54 , m_textPathScaling(1) |
54 { | 55 { |
55 ASSERT(!m_layoutAttributes.isEmpty()); | 56 ASSERT(!m_layoutAttributes.isEmpty()); |
56 } | 57 } |
57 | 58 |
58 void SVGTextLayoutEngine::updateCharacerPositionIfNeeded(float& x, float& y) | 59 void SVGTextLayoutEngine::updateCharacerPositionIfNeeded(float& x, float& y) |
59 { | 60 { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 return false; | 163 return false; |
163 } | 164 } |
164 | 165 |
165 void SVGTextLayoutEngine::beginTextPathLayout(RenderObject* object, SVGTextLayou tEngine& lineLayout) | 166 void SVGTextLayoutEngine::beginTextPathLayout(RenderObject* object, SVGTextLayou tEngine& lineLayout) |
166 { | 167 { |
167 ASSERT(object); | 168 ASSERT(object); |
168 | 169 |
169 m_inPathLayout = true; | 170 m_inPathLayout = true; |
170 RenderSVGTextPath* textPath = toRenderSVGTextPath(object); | 171 RenderSVGTextPath* textPath = toRenderSVGTextPath(object); |
171 | 172 |
172 m_textPath = textPath->layoutPath(); | 173 Path path = textPath->layoutPath(); |
173 if (m_textPath.isEmpty()) | 174 if (path.isEmpty()) |
174 return; | 175 return; |
176 m_textPathCalculator = new Path::PositionCalculator(path); | |
175 m_textPathStartOffset = textPath->startOffset(); | 177 m_textPathStartOffset = textPath->startOffset(); |
176 m_textPathLength = m_textPath.length(); | 178 m_textPathLength = path.length(); |
177 if (m_textPathStartOffset > 0 && m_textPathStartOffset <= 1) | 179 if (m_textPathStartOffset > 0 && m_textPathStartOffset <= 1) |
178 m_textPathStartOffset *= m_textPathLength; | 180 m_textPathStartOffset *= m_textPathLength; |
179 | 181 |
180 float totalLength = 0; | 182 float totalLength = 0; |
181 unsigned totalCharacters = 0; | 183 unsigned totalCharacters = 0; |
182 | 184 |
183 lineLayout.m_chunkLayoutBuilder.buildTextChunks(lineLayout.m_lineLayoutBoxes ); | 185 lineLayout.m_chunkLayoutBuilder.buildTextChunks(lineLayout.m_lineLayoutBoxes ); |
184 const Vector<SVGTextChunk>& textChunks = lineLayout.m_chunkLayoutBuilder.tex tChunks(); | 186 const Vector<SVGTextChunk>& textChunks = lineLayout.m_chunkLayoutBuilder.tex tChunks(); |
185 | 187 |
186 unsigned size = textChunks.size(); | 188 unsigned size = textChunks.size(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 | 220 |
219 if (lengthAdjust == SVGLengthAdjustSpacing) | 221 if (lengthAdjust == SVGLengthAdjustSpacing) |
220 m_textPathSpacing = (desiredTextLength - totalLength) / totalCharacters; | 222 m_textPathSpacing = (desiredTextLength - totalLength) / totalCharacters; |
221 else | 223 else |
222 m_textPathScaling = desiredTextLength / totalLength; | 224 m_textPathScaling = desiredTextLength / totalLength; |
223 } | 225 } |
224 | 226 |
225 void SVGTextLayoutEngine::endTextPathLayout() | 227 void SVGTextLayoutEngine::endTextPathLayout() |
226 { | 228 { |
227 m_inPathLayout = false; | 229 m_inPathLayout = false; |
228 m_textPath = Path(); | 230 m_textPathCalculator = 0; |
fs
2014/02/07 17:12:01
Crap, it's too late here...
fs
2014/02/07 17:12:40
Fixed...
| |
229 m_textPathLength = 0; | 231 m_textPathLength = 0; |
230 m_textPathStartOffset = 0; | 232 m_textPathStartOffset = 0; |
231 m_textPathCurrentOffset = 0; | 233 m_textPathCurrentOffset = 0; |
232 m_textPathSpacing = 0; | 234 m_textPathSpacing = 0; |
233 m_textPathScaling = 1; | 235 m_textPathScaling = 1; |
234 } | 236 } |
235 | 237 |
236 void SVGTextLayoutEngine::layoutInlineTextBox(SVGInlineTextBox* textBox) | 238 void SVGTextLayoutEngine::layoutInlineTextBox(SVGInlineTextBox* textBox) |
237 { | 239 { |
238 ASSERT(textBox); | 240 ASSERT(textBox); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 } | 419 } |
418 | 420 |
419 void SVGTextLayoutEngine::advanceToNextVisualCharacter(const SVGTextMetrics& vis ualMetrics) | 421 void SVGTextLayoutEngine::advanceToNextVisualCharacter(const SVGTextMetrics& vis ualMetrics) |
420 { | 422 { |
421 ++m_visualMetricsListOffset; | 423 ++m_visualMetricsListOffset; |
422 m_visualCharacterOffset += visualMetrics.length(); | 424 m_visualCharacterOffset += visualMetrics.length(); |
423 } | 425 } |
424 | 426 |
425 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, Rend erSVGInlineText* text, const RenderStyle* style) | 427 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, Rend erSVGInlineText* text, const RenderStyle* style) |
426 { | 428 { |
427 if (m_inPathLayout && m_textPath.isEmpty()) | 429 if (m_inPathLayout && !m_textPathCalculator) |
428 return; | 430 return; |
429 | 431 |
430 SVGElement* lengthContext = toSVGElement(text->parent()->node()); | 432 SVGElement* lengthContext = toSVGElement(text->parent()->node()); |
431 | 433 |
432 RenderObject* textParent = text->parent(); | 434 RenderObject* textParent = text->parent(); |
433 bool definesTextLength = textParent ? parentDefinesTextLength(textParent) : false; | 435 bool definesTextLength = textParent ? parentDefinesTextLength(textParent) : false; |
434 | 436 |
435 const SVGRenderStyle* svgStyle = style->svgStyle(); | 437 const SVGRenderStyle* svgStyle = style->svgStyle(); |
436 ASSERT(svgStyle); | 438 ASSERT(svgStyle); |
437 | 439 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 advanceToNextLogicalCharacter(logicalMetrics); | 551 advanceToNextLogicalCharacter(logicalMetrics); |
550 advanceToNextVisualCharacter(visualMetrics); | 552 advanceToNextVisualCharacter(visualMetrics); |
551 continue; | 553 continue; |
552 } | 554 } |
553 | 555 |
554 // Stop processing, if the next character lies behind the path. | 556 // Stop processing, if the next character lies behind the path. |
555 if (textPathOffset > m_textPathLength) | 557 if (textPathOffset > m_textPathLength) |
556 break; | 558 break; |
557 | 559 |
558 FloatPoint point; | 560 FloatPoint point; |
559 bool ok = m_textPath.pointAndNormalAtLength(textPathOffset, point, a ngle); | 561 bool ok = m_textPathCalculator->pointAndNormalAtLength(textPathOffse t, point, angle); |
560 ASSERT_UNUSED(ok, ok); | 562 ASSERT_UNUSED(ok, ok); |
561 x = point.x(); | 563 x = point.x(); |
562 y = point.y(); | 564 y = point.y(); |
563 | 565 |
564 // For vertical text on path, the actual angle has to be rotated 90 degrees anti-clockwise, not the orientation angle! | 566 // For vertical text on path, the actual angle has to be rotated 90 degrees anti-clockwise, not the orientation angle! |
565 if (m_isVerticalText) | 567 if (m_isVerticalText) |
566 angle -= 90; | 568 angle -= 90; |
567 } else { | 569 } else { |
568 // Apply all previously calculated shift values. | 570 // Apply all previously calculated shift values. |
569 if (m_isVerticalText) { | 571 if (m_isVerticalText) { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
643 } | 645 } |
644 | 646 |
645 if (!didStartTextFragment) | 647 if (!didStartTextFragment) |
646 return; | 648 return; |
647 | 649 |
648 // Close last open fragment, if needed. | 650 // Close last open fragment, if needed. |
649 recordTextFragment(textBox, visualMetricsValues); | 651 recordTextFragment(textBox, visualMetricsValues); |
650 } | 652 } |
651 | 653 |
652 } | 654 } |
OLD | NEW |