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

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

Issue 665253003: Remove SVGTextMetrics::m_glyph (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop WTFString.h include. Created 6 years, 2 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
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 11 matching lines...) Expand all
22 #include "core/rendering/svg/SVGTextMetrics.h" 22 #include "core/rendering/svg/SVGTextMetrics.h"
23 23
24 #include "core/rendering/svg/RenderSVGInlineText.h" 24 #include "core/rendering/svg/RenderSVGInlineText.h"
25 25
26 namespace blink { 26 namespace blink {
27 27
28 SVGTextMetrics::SVGTextMetrics() 28 SVGTextMetrics::SVGTextMetrics()
29 : m_width(0) 29 : m_width(0)
30 , m_height(0) 30 , m_height(0)
31 , m_length(0) 31 , m_length(0)
32 , m_glyph(0)
33 { 32 {
34 } 33 }
35 34
36 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) 35 SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType)
37 : m_width(0) 36 : m_width(0)
38 , m_height(0) 37 , m_height(0)
39 , m_length(1) 38 , m_length(1)
40 , m_glyph(0)
41 { 39 {
42 } 40 }
43 41
44 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun& run) 42 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun& run)
45 { 43 {
46 ASSERT(textRenderer); 44 ASSERT(textRenderer);
47 45
48 float scalingFactor = textRenderer->scalingFactor(); 46 float scalingFactor = textRenderer->scalingFactor();
49 ASSERT(scalingFactor); 47 ASSERT(scalingFactor);
50 48
51 const Font& scaledFont = textRenderer->scaledFont(); 49 const Font& scaledFont = textRenderer->scaledFont();
52 int length = 0;
53 50
54 // Calculate width/height using the scaled font, divide this result by the s calingFactor afterwards. 51 // Calculate width/height using the scaled font, divide this result by the s calingFactor afterwards.
55 m_width = scaledFont.width(run, length, m_glyph) / scalingFactor; 52 m_width = scaledFont.width(run) / scalingFactor;
56 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; 53 m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor;
57 54
58 ASSERT(length >= 0); 55 ASSERT(run.length() >= 0);
59 m_length = static_cast<unsigned>(length); 56 m_length = static_cast<unsigned>(run.length());
60 } 57 }
61 58
62 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos ition, unsigned length) 59 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos ition, unsigned length)
63 { 60 {
64 ASSERT(text->style()); 61 ASSERT(text->style());
65 return constructTextRun(text, position, length, text->style()->direction()); 62 return constructTextRun(text, position, length, text->style()->direction());
66 } 63 }
67 64
68 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos ition, unsigned length, TextDirection textDirection) 65 TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, unsigned pos ition, unsigned length, TextDirection textDirection)
69 { 66 {
(...skipping 29 matching lines...) Expand all
99 ASSERT(text); 96 ASSERT(text);
100 return SVGTextMetrics(text, constructTextRun(text, position, length, textDir ection)); 97 return SVGTextMetrics(text, constructTextRun(text, position, length, textDir ection));
101 } 98 }
102 99
103 SVGTextMetrics SVGTextMetrics::measureCharacterRange(RenderSVGInlineText* text, unsigned position, unsigned length) 100 SVGTextMetrics SVGTextMetrics::measureCharacterRange(RenderSVGInlineText* text, unsigned position, unsigned length)
104 { 101 {
105 ASSERT(text); 102 ASSERT(text);
106 return SVGTextMetrics(text, constructTextRun(text, position, length)); 103 return SVGTextMetrics(text, constructTextRun(text, position, length));
107 } 104 }
108 105
109 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, uns igned length, float width, Glyph glyphNameGlyphId) 106 SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, uns igned length, float width)
110 { 107 {
111 ASSERT(text); 108 ASSERT(text);
112 109
113 float scalingFactor = text->scalingFactor(); 110 float scalingFactor = text->scalingFactor();
114 ASSERT(scalingFactor); 111 ASSERT(scalingFactor);
115 112
116 m_width = width / scalingFactor; 113 m_width = width / scalingFactor;
117 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; 114 m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor;
118 m_glyph = 0;
119 115
120 m_length = length; 116 m_length = length;
121 } 117 }
122 118
123 } 119 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGTextMetrics.h ('k') | Source/core/rendering/svg/SVGTextMetricsBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698