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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 for (unsigned i = m_currentTextFragment.metricsListOffset; i < m_vis
ualMetricsListOffset; ++i) | 136 for (unsigned i = m_currentTextFragment.metricsListOffset; i < m_vis
ualMetricsListOffset; ++i) |
137 length += textMetricsValues.at(i).width(); | 137 length += textMetricsValues.at(i).width(); |
138 m_currentTextFragment.width = length; | 138 m_currentTextFragment.width = length; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 textBox->textFragments().append(m_currentTextFragment); | 142 textBox->textFragments().append(m_currentTextFragment); |
143 m_currentTextFragment = SVGTextFragment(); | 143 m_currentTextFragment = SVGTextFragment(); |
144 } | 144 } |
145 | 145 |
146 bool SVGTextLayoutEngine::parentDefinesTextLength(RenderObject* parent) const | 146 bool SVGTextLayoutEngine::parentDefinesTextLength(LayoutObject* parent) const |
147 { | 147 { |
148 RenderObject* currentParent = parent; | 148 LayoutObject* currentParent = parent; |
149 while (currentParent) { | 149 while (currentParent) { |
150 if (SVGTextContentElement* textContentElement = SVGTextContentElement::e
lementFromRenderer(currentParent)) { | 150 if (SVGTextContentElement* textContentElement = SVGTextContentElement::e
lementFromRenderer(currentParent)) { |
151 SVGLengthContext lengthContext(textContentElement); | 151 SVGLengthContext lengthContext(textContentElement); |
152 if (textContentElement->lengthAdjust()->currentValue()->enumValue()
== SVGLengthAdjustSpacing && textContentElement->textLengthIsSpecifiedByUser()) | 152 if (textContentElement->lengthAdjust()->currentValue()->enumValue()
== SVGLengthAdjustSpacing && textContentElement->textLengthIsSpecifiedByUser()) |
153 return true; | 153 return true; |
154 } | 154 } |
155 | 155 |
156 if (currentParent->isSVGText()) | 156 if (currentParent->isSVGText()) |
157 return false; | 157 return false; |
158 | 158 |
159 currentParent = currentParent->parent(); | 159 currentParent = currentParent->parent(); |
160 } | 160 } |
161 | 161 |
162 ASSERT_NOT_REACHED(); | 162 ASSERT_NOT_REACHED(); |
163 return false; | 163 return false; |
164 } | 164 } |
165 | 165 |
166 void SVGTextLayoutEngine::beginTextPathLayout(RenderObject* object, SVGTextLayou
tEngine& lineLayout) | 166 void SVGTextLayoutEngine::beginTextPathLayout(LayoutObject* object, SVGTextLayou
tEngine& lineLayout) |
167 { | 167 { |
168 ASSERT(object); | 168 ASSERT(object); |
169 | 169 |
170 m_inPathLayout = true; | 170 m_inPathLayout = true; |
171 RenderSVGTextPath* textPath = toRenderSVGTextPath(object); | 171 RenderSVGTextPath* textPath = toRenderSVGTextPath(object); |
172 | 172 |
173 Path path = textPath->layoutPath(); | 173 Path path = textPath->layoutPath(); |
174 if (path.isEmpty()) | 174 if (path.isEmpty()) |
175 return; | 175 return; |
176 m_textPathCalculator = new Path::PositionCalculator(path); | 176 m_textPathCalculator = new Path::PositionCalculator(path); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 m_visualCharacterOffset += visualMetrics.length(); | 423 m_visualCharacterOffset += visualMetrics.length(); |
424 } | 424 } |
425 | 425 |
426 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, cons
t RenderSVGInlineText& text, const RenderStyle& style) | 426 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, cons
t RenderSVGInlineText& text, const RenderStyle& style) |
427 { | 427 { |
428 if (m_inPathLayout && !m_textPathCalculator) | 428 if (m_inPathLayout && !m_textPathCalculator) |
429 return; | 429 return; |
430 | 430 |
431 SVGElement* lengthContext = toSVGElement(text.parent()->node()); | 431 SVGElement* lengthContext = toSVGElement(text.parent()->node()); |
432 | 432 |
433 RenderObject* textParent = text.parent(); | 433 LayoutObject* textParent = text.parent(); |
434 bool definesTextLength = textParent ? parentDefinesTextLength(textParent) :
false; | 434 bool definesTextLength = textParent ? parentDefinesTextLength(textParent) :
false; |
435 | 435 |
436 const SVGRenderStyle& svgStyle = style.svgStyle(); | 436 const SVGRenderStyle& svgStyle = style.svgStyle(); |
437 | 437 |
438 m_visualMetricsListOffset = 0; | 438 m_visualMetricsListOffset = 0; |
439 m_visualCharacterOffset = 0; | 439 m_visualCharacterOffset = 0; |
440 | 440 |
441 const Vector<SVGTextMetrics>& visualMetricsValues = text.layoutAttributes()-
>textMetricsValues(); | 441 const Vector<SVGTextMetrics>& visualMetricsValues = text.layoutAttributes()-
>textMetricsValues(); |
442 ASSERT(!visualMetricsValues.isEmpty()); | 442 ASSERT(!visualMetricsValues.isEmpty()); |
443 | 443 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 637 } |
638 | 638 |
639 if (!didStartTextFragment) | 639 if (!didStartTextFragment) |
640 return; | 640 return; |
641 | 641 |
642 // Close last open fragment, if needed. | 642 // Close last open fragment, if needed. |
643 recordTextFragment(textBox, visualMetricsValues); | 643 recordTextFragment(textBox, visualMetricsValues); |
644 } | 644 } |
645 | 645 |
646 } | 646 } |
OLD | NEW |