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

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

Issue 19520011: Remove the last SVG callers of bloatedCharacters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010-2011. 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 26 matching lines...) Expand all
37 ASSERT(text); 37 ASSERT(text);
38 38
39 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text); 39 RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);
40 if (!textRoot) 40 if (!textRoot)
41 return; 41 return;
42 42
43 if (m_textPositions.isEmpty()) { 43 if (m_textPositions.isEmpty()) {
44 m_characterDataMap.clear(); 44 m_characterDataMap.clear();
45 45
46 m_textLength = 0; 46 m_textLength = 0;
47 const UChar* lastCharacter = 0; 47 UChar lastCharacter = ' ';
48 collectTextPositioningElements(textRoot, lastCharacter); 48 collectTextPositioningElements(textRoot, lastCharacter);
49 49
50 if (!m_textLength) 50 if (!m_textLength)
51 return; 51 return;
52 52
53 buildCharacterDataMap(textRoot); 53 buildCharacterDataMap(textRoot);
54 } 54 }
55 55
56 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, text, m_character DataMap); 56 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, text, m_character DataMap);
57 } 57 }
58 58
59 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV GText* textRoot) 59 bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV GText* textRoot)
60 { 60 {
61 ASSERT(textRoot); 61 ASSERT(textRoot);
62 62
63 m_characterDataMap.clear(); 63 m_characterDataMap.clear();
64 64
65 if (m_textPositions.isEmpty()) { 65 if (m_textPositions.isEmpty()) {
66 m_textLength = 0; 66 m_textLength = 0;
67 const UChar* lastCharacter = 0; 67 UChar lastCharacter = ' ';
68 collectTextPositioningElements(textRoot, lastCharacter); 68 collectTextPositioningElements(textRoot, lastCharacter);
69 } 69 }
70 70
71 if (!m_textLength) 71 if (!m_textLength)
72 return false; 72 return false;
73 73
74 buildCharacterDataMap(textRoot); 74 buildCharacterDataMap(textRoot);
75 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDat aMap); 75 m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDat aMap);
76 return true; 76 return true;
77 } 77 }
78 78
79 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInli neText* text) 79 void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInli neText* text)
80 { 80 {
81 ASSERT(text); 81 ASSERT(text);
82 m_metricsBuilder.measureTextRenderer(text); 82 m_metricsBuilder.measureTextRenderer(text);
83 } 83 }
84 84
85 static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne d& atCharacter, const UChar*& lastCharacter) 85 static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne d& atCharacter, UChar& lastCharacter)
86 { 86 {
87 if (text->style()->whiteSpace() == PRE) { 87 if (text->style()->whiteSpace() == PRE) {
88 atCharacter += text->textLength(); 88 atCharacter += text->textLength();
89 return; 89 return;
90 } 90 }
91 91
92 const UChar* characters = text->bloatedCharacters();
93 unsigned textLength = text->textLength(); 92 unsigned textLength = text->textLength();
94 for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) { 93 for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) {
95 const UChar* currentCharacter = characters + textPosition; 94 UChar currentCharacter = text->characterAt(textPosition);
96 if (*currentCharacter == ' ' && (!lastCharacter || *lastCharacter == ' ' )) 95 if (currentCharacter == ' ' && lastCharacter == ' ')
97 continue; 96 continue;
98 97
99 lastCharacter = currentCharacter; 98 lastCharacter = currentCharacter;
100 ++atCharacter; 99 ++atCharacter;
101 } 100 }
102 } 101 }
103 102
104 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject * start, const UChar*& lastCharacter) 103 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject * start, UChar& lastCharacter)
105 { 104 {
106 ASSERT(!start->isSVGText() || m_textPositions.isEmpty()); 105 ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
107 106
108 for (RenderObject* child = start->firstChild(); child; child = child->nextSi bling()) { 107 for (RenderObject* child = start->firstChild(); child; child = child->nextSi bling()) {
109 if (child->isSVGInlineText()) { 108 if (child->isSVGInlineText()) {
110 processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLengt h, lastCharacter); 109 processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLengt h, lastCharacter);
111 continue; 110 continue;
112 } 111 }
113 112
114 if (!child->isSVGInline()) 113 if (!child->isSVGInline())
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 data.rotate = lastRotation; 225 data.rotate = lastRotation;
227 m_characterDataMap.set(position.start + i + 1, data); 226 m_characterDataMap.set(position.start + i + 1, data);
228 continue; 227 continue;
229 } 228 }
230 229
231 it->value.rotate = lastRotation; 230 it->value.rotate = lastRotation;
232 } 231 }
233 } 232 }
234 233
235 } 234 }
OLDNEW
« no previous file with comments | « Source/core/rendering/svg/SVGTextLayoutAttributesBuilder.h ('k') | Source/core/rendering/svg/SVGTextLayoutEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698