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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 RenderSVGInlineText& text = toRenderSVGInlineText(textBox->textRenderer()); | 243 RenderSVGInlineText& text = toRenderSVGInlineText(textBox->textRenderer()); |
244 ASSERT(text.parent()); | 244 ASSERT(text.parent()); |
245 ASSERT(text.parent()->node()); | 245 ASSERT(text.parent()->node()); |
246 ASSERT(text.parent()->node()->isSVGElement()); | 246 ASSERT(text.parent()->node()->isSVGElement()); |
247 | 247 |
248 const RenderStyle* style = text.style(); | 248 const RenderStyle* style = text.style(); |
249 ASSERT(style); | 249 ASSERT(style); |
250 | 250 |
251 textBox->clearTextFragments(); | 251 textBox->clearTextFragments(); |
252 m_isVerticalText = style->svgStyle().isVerticalWritingMode(); | 252 m_isVerticalText = style->svgStyle().isVerticalWritingMode(); |
253 layoutTextOnLineOrPath(textBox, &text, style); | 253 layoutTextOnLineOrPath(textBox, text, *style); |
254 | 254 |
255 if (m_inPathLayout) { | 255 if (m_inPathLayout) { |
256 m_pathLayoutBoxes.append(textBox); | 256 m_pathLayoutBoxes.append(textBox); |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 m_lineLayoutBoxes.append(textBox); | 260 m_lineLayoutBoxes.append(textBox); |
261 } | 261 } |
262 | 262 |
263 #if DUMP_TEXT_FRAGMENTS > 0 | 263 #if DUMP_TEXT_FRAGMENTS > 0 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 ++m_logicalMetricsListOffset; | 416 ++m_logicalMetricsListOffset; |
417 m_logicalCharacterOffset += logicalMetrics.length(); | 417 m_logicalCharacterOffset += logicalMetrics.length(); |
418 } | 418 } |
419 | 419 |
420 void SVGTextLayoutEngine::advanceToNextVisualCharacter(const SVGTextMetrics& vis
ualMetrics) | 420 void SVGTextLayoutEngine::advanceToNextVisualCharacter(const SVGTextMetrics& vis
ualMetrics) |
421 { | 421 { |
422 ++m_visualMetricsListOffset; | 422 ++m_visualMetricsListOffset; |
423 m_visualCharacterOffset += visualMetrics.length(); | 423 m_visualCharacterOffset += visualMetrics.length(); |
424 } | 424 } |
425 | 425 |
426 void SVGTextLayoutEngine::layoutTextOnLineOrPath(SVGInlineTextBox* textBox, Rend
erSVGInlineText* 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 RenderObject* 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 |
444 const Font& font = style->font(); | 444 const Font& font = style.font(); |
445 | 445 |
446 SVGTextLayoutEngineSpacing spacingLayout(font, style->effectiveZoom()); | 446 SVGTextLayoutEngineSpacing spacingLayout(font, style.effectiveZoom()); |
447 SVGTextLayoutEngineBaseline baselineLayout(font); | 447 SVGTextLayoutEngineBaseline baselineLayout(font); |
448 | 448 |
449 bool didStartTextFragment = false; | 449 bool didStartTextFragment = false; |
450 bool applySpacingToNextCharacter = false; | 450 bool applySpacingToNextCharacter = false; |
451 | 451 |
452 float lastAngle = 0; | 452 float lastAngle = 0; |
453 float baselineShift = baselineLayout.calculateBaselineShift(svgStyle, length
Context); | 453 float baselineShift = baselineLayout.calculateBaselineShift(svgStyle, length
Context); |
454 baselineShift -= baselineLayout.calculateAlignmentBaselineShift(m_isVertical
Text, text); | 454 baselineShift -= baselineLayout.calculateAlignmentBaselineShift(m_isVertical
Text, &text); |
455 | 455 |
456 // Main layout algorithm. | 456 // Main layout algorithm. |
457 while (true) { | 457 while (true) { |
458 // Find the start of the current text box in this list, respecting ligat
ures. | 458 // Find the start of the current text box in this list, respecting ligat
ures. |
459 SVGTextMetrics visualMetrics(SVGTextMetrics::SkippedSpaceMetrics); | 459 SVGTextMetrics visualMetrics(SVGTextMetrics::SkippedSpaceMetrics); |
460 if (!currentVisualCharacterMetrics(textBox, visualMetricsValues, visualM
etrics)) | 460 if (!currentVisualCharacterMetrics(textBox, visualMetricsValues, visualM
etrics)) |
461 break; | 461 break; |
462 | 462 |
463 if (visualMetrics.isEmpty()) { | 463 if (visualMetrics.isEmpty()) { |
464 advanceToNextVisualCharacter(visualMetrics); | 464 advanceToNextVisualCharacter(visualMetrics); |
(...skipping 19 matching lines...) Expand all Loading... |
484 float y = data.y; | 484 float y = data.y; |
485 | 485 |
486 // When we've advanced to the box start offset, determine using the orig
inal x/y values, | 486 // When we've advanced to the box start offset, determine using the orig
inal x/y values, |
487 // whether this character starts a new text chunk, before doing any furt
her processing. | 487 // whether this character starts a new text chunk, before doing any furt
her processing. |
488 if (m_visualCharacterOffset == textBox->start()) | 488 if (m_visualCharacterOffset == textBox->start()) |
489 textBox->setStartsNewTextChunk(logicalAttributes->context()->charact
erStartsNewTextChunk(m_logicalCharacterOffset)); | 489 textBox->setStartsNewTextChunk(logicalAttributes->context()->charact
erStartsNewTextChunk(m_logicalCharacterOffset)); |
490 | 490 |
491 float angle = data.rotate == SVGTextLayoutAttributes::emptyValue() ? 0 :
data.rotate; | 491 float angle = data.rotate == SVGTextLayoutAttributes::emptyValue() ? 0 :
data.rotate; |
492 | 492 |
493 // Calculate glyph orientation angle. | 493 // Calculate glyph orientation angle. |
494 UChar currentCharacter = text->characterAt(m_visualCharacterOffset); | 494 UChar currentCharacter = text.characterAt(m_visualCharacterOffset); |
495 float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m
_isVerticalText, svgStyle, currentCharacter); | 495 float orientationAngle = baselineLayout.calculateGlyphOrientationAngle(m
_isVerticalText, svgStyle, currentCharacter); |
496 | 496 |
497 // Calculate glyph advance & x/y orientation shifts. | 497 // Calculate glyph advance & x/y orientation shifts. |
498 float xOrientationShift = 0; | 498 float xOrientationShift = 0; |
499 float yOrientationShift = 0; | 499 float yOrientationShift = 0; |
500 float glyphAdvance = baselineLayout.calculateGlyphAdvanceAndOrientation(
m_isVerticalText, visualMetrics, orientationAngle, xOrientationShift, yOrientati
onShift); | 500 float glyphAdvance = baselineLayout.calculateGlyphAdvanceAndOrientation(
m_isVerticalText, visualMetrics, orientationAngle, xOrientationShift, yOrientati
onShift); |
501 | 501 |
502 // Assign current text position to x/y values, if needed. | 502 // Assign current text position to x/y values, if needed. |
503 updateCharacterPositionIfNeeded(x, y); | 503 updateCharacterPositionIfNeeded(x, y); |
504 | 504 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 643 } |
644 | 644 |
645 if (!didStartTextFragment) | 645 if (!didStartTextFragment) |
646 return; | 646 return; |
647 | 647 |
648 // Close last open fragment, if needed. | 648 // Close last open fragment, if needed. |
649 recordTextFragment(textBox, visualMetricsValues); | 649 recordTextFragment(textBox, visualMetricsValues); |
650 } | 650 } |
651 | 651 |
652 } | 652 } |
OLD | NEW |