| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 void SVGTextLayoutEngine::beginTextPathLayout(SVGInlineFlowBox* flowBox) | 165 void SVGTextLayoutEngine::beginTextPathLayout(SVGInlineFlowBox* flowBox) |
| 166 { | 166 { |
| 167 // Build text chunks for all <textPath> children, using the line layout algo
rithm. | 167 // Build text chunks for all <textPath> children, using the line layout algo
rithm. |
| 168 // This is needeed as text-anchor is just an additional startOffset for text
paths. | 168 // This is needeed as text-anchor is just an additional startOffset for text
paths. |
| 169 SVGTextLayoutEngine lineLayout(m_layoutAttributes); | 169 SVGTextLayoutEngine lineLayout(m_layoutAttributes); |
| 170 lineLayout.m_textLengthSpacingInEffect = m_textLengthSpacingInEffect; | 170 lineLayout.m_textLengthSpacingInEffect = m_textLengthSpacingInEffect; |
| 171 lineLayout.layoutCharactersInTextBoxes(flowBox); | 171 lineLayout.layoutCharactersInTextBoxes(flowBox); |
| 172 | 172 |
| 173 m_inPathLayout = true; | 173 m_inPathLayout = true; |
| 174 // Do we need to add a LineLayoutSVGTextPath class to handle this logic? |
| 175 // I'd imagine it'd only have 2 methods, startOffset() and layoutPath(). |
| 174 LayoutSVGTextPath* textPath = &toLayoutSVGTextPath(flowBox->layoutObject()); | 176 LayoutSVGTextPath* textPath = &toLayoutSVGTextPath(flowBox->layoutObject()); |
| 175 | 177 |
| 178 // Actually, what would I do with Path here? Would we have to add a LineLayo
utPath |
| 179 // class too? And then what would we do about PositionCalculator? |
| 180 // Does this pattern bring to mind any examples I can look at? |
| 176 Path path = textPath->layoutPath(); | 181 Path path = textPath->layoutPath(); |
| 177 if (path.isEmpty()) | 182 if (path.isEmpty()) |
| 178 return; | 183 return; |
| 179 m_textPathCalculator = new Path::PositionCalculator(path); | 184 m_textPathCalculator = new Path::PositionCalculator(path); |
| 180 m_textPathStartOffset = textPath->startOffset(); | 185 m_textPathStartOffset = textPath->startOffset(); |
| 181 m_textPathLength = path.length(); | 186 m_textPathLength = path.length(); |
| 182 if (m_textPathStartOffset > 0 && m_textPathStartOffset <= 1) | 187 if (m_textPathStartOffset > 0 && m_textPathStartOffset <= 1) |
| 183 m_textPathStartOffset *= m_textPathLength; | 188 m_textPathStartOffset *= m_textPathLength; |
| 184 | 189 |
| 185 SVGTextPathChunkBuilder textPathChunkLayoutBuilder; | 190 SVGTextPathChunkBuilder textPathChunkLayoutBuilder; |
| 186 textPathChunkLayoutBuilder.processTextChunks(lineLayout.m_lineLayoutBoxes); | 191 textPathChunkLayoutBuilder.processTextChunks(lineLayout.m_lineLayoutBoxes); |
| 187 | 192 |
| 188 m_textPathStartOffset += textPathChunkLayoutBuilder.totalTextAnchorShift(); | 193 m_textPathStartOffset += textPathChunkLayoutBuilder.totalTextAnchorShift(); |
| 189 m_textPathCurrentOffset = m_textPathStartOffset; | 194 m_textPathCurrentOffset = m_textPathStartOffset; |
| 190 | 195 |
| 191 // Eventually handle textLength adjustments. | 196 // Eventually handle textLength adjustments. |
| 192 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; | 197 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; |
| 193 float desiredTextLength = 0; | 198 float desiredTextLength = 0; |
| 194 | 199 |
| 195 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme
ntFromLayoutObject(textPath)) { | 200 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme
ntFromLayoutObject(flowBox->lineLayoutItem())) { |
| 196 SVGLengthContext lengthContext(textContentElement); | 201 SVGLengthContext lengthContext(textContentElement); |
| 197 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV
alue(); | 202 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV
alue(); |
| 198 if (textContentElement->textLengthIsSpecifiedByUser()) | 203 if (textContentElement->textLengthIsSpecifiedByUser()) |
| 199 desiredTextLength = textContentElement->textLength()->currentValue()
->value(lengthContext); | 204 desiredTextLength = textContentElement->textLength()->currentValue()
->value(lengthContext); |
| 200 else | 205 else |
| 201 desiredTextLength = 0; | 206 desiredTextLength = 0; |
| 202 } | 207 } |
| 203 | 208 |
| 204 if (!desiredTextLength) | 209 if (!desiredTextLength) |
| 205 return; | 210 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 layoutTextOnLineOrPath(textBox, textLineLayout, style); | 244 layoutTextOnLineOrPath(textBox, textLineLayout, style); |
| 240 | 245 |
| 241 if (m_inPathLayout) | 246 if (m_inPathLayout) |
| 242 return; | 247 return; |
| 243 | 248 |
| 244 m_lineLayoutBoxes.append(textBox); | 249 m_lineLayoutBoxes.append(textBox); |
| 245 } | 250 } |
| 246 | 251 |
| 247 static bool definesTextLengthWithSpacing(const InlineFlowBox* start) | 252 static bool definesTextLengthWithSpacing(const InlineFlowBox* start) |
| 248 { | 253 { |
| 249 SVGTextContentElement* textContentElement = SVGTextContentElement::elementFr
omLayoutObject(&start->layoutObject()); | 254 SVGTextContentElement* textContentElement = SVGTextContentElement::elementFr
omLayoutObject(start->lineLayoutItem()); |
| 250 return textContentElement | 255 return textContentElement |
| 251 && textContentElement->lengthAdjust()->currentValue()->enumValue() == SV
GLengthAdjustSpacing | 256 && textContentElement->lengthAdjust()->currentValue()->enumValue() == SV
GLengthAdjustSpacing |
| 252 && textContentElement->textLengthIsSpecifiedByUser(); | 257 && textContentElement->textLengthIsSpecifiedByUser(); |
| 253 } | 258 } |
| 254 | 259 |
| 255 void SVGTextLayoutEngine::layoutCharactersInTextBoxes(InlineFlowBox* start) | 260 void SVGTextLayoutEngine::layoutCharactersInTextBoxes(InlineFlowBox* start) |
| 256 { | 261 { |
| 257 bool textLengthSpacingInEffect = m_textLengthSpacingInEffect || definesTextL
engthWithSpacing(start); | 262 bool textLengthSpacingInEffect = m_textLengthSpacingInEffect || definesTextL
engthWithSpacing(start); |
| 258 TemporaryChange<bool> textLengthSpacingScope(m_textLengthSpacingInEffect, te
xtLengthSpacingInEffect); | 263 TemporaryChange<bool> textLengthSpacingScope(m_textLengthSpacingInEffect, te
xtLengthSpacingInEffect); |
| 259 | 264 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 557 } |
| 553 | 558 |
| 554 if (!didStartTextFragment) | 559 if (!didStartTextFragment) |
| 555 return; | 560 return; |
| 556 | 561 |
| 557 // Close last open fragment, if needed. | 562 // Close last open fragment, if needed. |
| 558 recordTextFragment(textBox); | 563 recordTextFragment(textBox); |
| 559 } | 564 } |
| 560 | 565 |
| 561 } | 566 } |
| OLD | NEW |