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