Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: Source/core/rendering/svg/SVGTextLayoutEngine.cpp

Issue 390873002: Constify metrics list references in SVGTextLayoutEngine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/svg/SVGTextLayoutEngine.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 m_dy += dy; 105 m_dy += dy;
106 } 106 }
107 107
108 return; 108 return;
109 } 109 }
110 110
111 m_dx = dx; 111 m_dx = dx;
112 m_dy = dy; 112 m_dy = dy;
113 } 113 }
114 114
115 void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox, Vector<S VGTextMetrics>& textMetricsValues) 115 void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox, const Ve ctor<SVGTextMetrics>& textMetricsValues)
116 { 116 {
117 ASSERT(!m_currentTextFragment.length); 117 ASSERT(!m_currentTextFragment.length);
118 ASSERT(m_visualMetricsListOffset > 0); 118 ASSERT(m_visualMetricsListOffset > 0);
119 119
120 // Figure out length of fragment. 120 // Figure out length of fragment.
121 m_currentTextFragment.length = m_visualCharacterOffset - m_currentTextFragme nt.characterOffset; 121 m_currentTextFragment.length = m_visualCharacterOffset - m_currentTextFragme nt.characterOffset;
122 122
123 // Figure out fragment metrics. 123 // Figure out fragment metrics.
124 SVGTextMetrics& lastCharacterMetrics = textMetricsValues.at(m_visualMetricsL istOffset - 1); 124 const SVGTextMetrics& lastCharacterMetrics = textMetricsValues.at(m_visualMe tricsListOffset - 1);
125 m_currentTextFragment.width = lastCharacterMetrics.width(); 125 m_currentTextFragment.width = lastCharacterMetrics.width();
126 m_currentTextFragment.height = lastCharacterMetrics.height(); 126 m_currentTextFragment.height = lastCharacterMetrics.height();
127 127
128 if (m_currentTextFragment.length > 1) { 128 if (m_currentTextFragment.length > 1) {
129 // SVGTextLayoutAttributesBuilder assures that the length of the range i s equal to the sum of the individual lengths of the glyphs. 129 // SVGTextLayoutAttributesBuilder assures that the length of the range i s equal to the sum of the individual lengths of the glyphs.
130 float length = 0; 130 float length = 0;
131 if (m_isVerticalText) { 131 if (m_isVerticalText) {
132 for (unsigned i = m_currentTextFragment.metricsListOffset; i < m_vis ualMetricsListOffset; ++i) 132 for (unsigned i = m_currentTextFragment.metricsListOffset; i < m_vis ualMetricsListOffset; ++i)
133 length += textMetricsValues.at(i).height(); 133 length += textMetricsValues.at(i).height();
134 m_currentTextFragment.height = length; 134 m_currentTextFragment.height = length;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return false; 351 return false;
352 352
353 logicalAttributes = m_layoutAttributes[m_layoutAttributesPosition]; 353 logicalAttributes = m_layoutAttributes[m_layoutAttributesPosition];
354 m_logicalMetricsListOffset = 0; 354 m_logicalMetricsListOffset = 0;
355 m_logicalCharacterOffset = 0; 355 m_logicalCharacterOffset = 0;
356 return true; 356 return true;
357 } 357 }
358 358
359 bool SVGTextLayoutEngine::currentLogicalCharacterMetrics(SVGTextLayoutAttributes *& logicalAttributes, SVGTextMetrics& logicalMetrics) 359 bool SVGTextLayoutEngine::currentLogicalCharacterMetrics(SVGTextLayoutAttributes *& logicalAttributes, SVGTextMetrics& logicalMetrics)
360 { 360 {
361 Vector<SVGTextMetrics>* textMetricsValues = &logicalAttributes->textMetricsV alues(); 361 const Vector<SVGTextMetrics>* textMetricsValues = &logicalAttributes->textMe tricsValues();
362 unsigned textMetricsSize = textMetricsValues->size(); 362 unsigned textMetricsSize = textMetricsValues->size();
363 while (true) { 363 while (true) {
364 if (m_logicalMetricsListOffset == textMetricsSize) { 364 if (m_logicalMetricsListOffset == textMetricsSize) {
365 if (!currentLogicalCharacterAttributes(logicalAttributes)) 365 if (!currentLogicalCharacterAttributes(logicalAttributes))
366 return false; 366 return false;
367 367
368 textMetricsValues = &logicalAttributes->textMetricsValues(); 368 textMetricsValues = &logicalAttributes->textMetricsValues();
369 textMetricsSize = textMetricsValues->size(); 369 textMetricsSize = textMetricsValues->size();
370 continue; 370 continue;
371 } 371 }
372 372
373 ASSERT(textMetricsSize); 373 ASSERT(textMetricsSize);
374 ASSERT(m_logicalMetricsListOffset < textMetricsSize); 374 ASSERT(m_logicalMetricsListOffset < textMetricsSize);
375 logicalMetrics = textMetricsValues->at(m_logicalMetricsListOffset); 375 logicalMetrics = textMetricsValues->at(m_logicalMetricsListOffset);
376 if (logicalMetrics.isEmpty() || (!logicalMetrics.width() && !logicalMetr ics.height())) { 376 if (logicalMetrics.isEmpty() || (!logicalMetrics.width() && !logicalMetr ics.height())) {
377 advanceToNextLogicalCharacter(logicalMetrics); 377 advanceToNextLogicalCharacter(logicalMetrics);
378 continue; 378 continue;
379 } 379 }
380 380
381 // Stop if we found the next valid logical text metrics object. 381 // Stop if we found the next valid logical text metrics object.
382 return true; 382 return true;
383 } 383 }
384 384
385 ASSERT_NOT_REACHED(); 385 ASSERT_NOT_REACHED();
386 return true; 386 return true;
387 } 387 }
388 388
389 bool SVGTextLayoutEngine::currentVisualCharacterMetrics(SVGInlineTextBox* textBo x, Vector<SVGTextMetrics>& visualMetricsValues, SVGTextMetrics& visualMetrics) 389 bool SVGTextLayoutEngine::currentVisualCharacterMetrics(SVGInlineTextBox* textBo x, const Vector<SVGTextMetrics>& visualMetricsValues, SVGTextMetrics& visualMetr ics)
390 { 390 {
391 ASSERT(!visualMetricsValues.isEmpty()); 391 ASSERT(!visualMetricsValues.isEmpty());
392 unsigned textMetricsSize = visualMetricsValues.size(); 392 unsigned textMetricsSize = visualMetricsValues.size();
393 unsigned boxStart = textBox->start(); 393 unsigned boxStart = textBox->start();
394 unsigned boxLength = textBox->len(); 394 unsigned boxLength = textBox->len();
395 395
396 while (m_visualMetricsListOffset < textMetricsSize) { 396 while (m_visualMetricsListOffset < textMetricsSize) {
397 // Advance to text box start location. 397 // Advance to text box start location.
398 if (m_visualCharacterOffset < boxStart) { 398 if (m_visualCharacterOffset < boxStart) {
399 advanceToNextVisualCharacter(visualMetricsValues[m_visualMetricsList Offset]); 399 advanceToNextVisualCharacter(visualMetricsValues[m_visualMetricsList Offset]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Vector<SVGTextMetrics>& visualMetricsValues = text->layoutAttributes()->text MetricsValues(); 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
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGTextLayoutEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698