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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutAttributesBuilder.cpp

Issue 1988063002: Use SVGInlineTextMetricsIterator in updateLayoutAttributes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.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-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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "core/layout/svg/SVGTextLayoutAttributesBuilder.h" 20 #include "core/layout/svg/SVGTextLayoutAttributesBuilder.h"
21 21
22 #include "core/layout/api/LineLayoutSVGInlineText.h"
22 #include "core/layout/svg/LayoutSVGInline.h" 23 #include "core/layout/svg/LayoutSVGInline.h"
23 #include "core/layout/svg/LayoutSVGInlineText.h" 24 #include "core/layout/svg/LayoutSVGInlineText.h"
24 #include "core/layout/svg/LayoutSVGText.h" 25 #include "core/layout/svg/LayoutSVGText.h"
25 #include "core/svg/SVGTextPositioningElement.h" 26 #include "core/svg/SVGTextPositioningElement.h"
26 27
27 namespace blink { 28 namespace blink {
28 29
29 namespace { 30 namespace {
30 31
31 void updateLayoutAttributes(LayoutSVGInlineText& text, unsigned& valueListPositi on, const SVGCharacterDataMap& allCharactersMap) 32 void updateLayoutAttributes(LayoutSVGInlineText& text, unsigned& valueListPositi on, const SVGCharacterDataMap& allCharactersMap)
32 { 33 {
33 SVGCharacterDataMap& characterDataMap = text.characterDataMap(); 34 SVGCharacterDataMap& characterDataMap = text.characterDataMap();
34 characterDataMap.clear(); 35 characterDataMap.clear();
35 36
36 const Vector<SVGTextMetrics>& metricsList = text.metricsList(); 37 LineLayoutSVGInlineText textLineLayout(&text);
37 auto metricsEnd = metricsList.end(); 38 for (SVGInlineTextMetricsIterator iterator(textLineLayout); !iterator.isAtEn d(); iterator.next()) {
38 unsigned currentPosition = 0; 39 if (iterator.metrics().isEmpty())
39 for (auto metrics = metricsList.begin(); metrics != metricsEnd; currentPosit ion += metrics->length(), ++metrics) {
40 if (metrics->isEmpty())
41 continue; 40 continue;
42 41
43 auto it = allCharactersMap.find(valueListPosition + 1); 42 auto it = allCharactersMap.find(valueListPosition + 1);
44 if (it != allCharactersMap.end()) 43 if (it != allCharactersMap.end())
45 characterDataMap.set(currentPosition + 1, it->value); 44 characterDataMap.set(iterator.characterOffset() + 1, it->value);
46 45
47 // Increase the position in the value/attribute list with one for each 46 // Increase the position in the value/attribute list with one for each
48 // "character unit" (that will be displayed.) 47 // "character unit" (that will be displayed.)
49 valueListPosition++; 48 valueListPosition++;
50 } 49 }
51 } 50 }
52 51
53 } // namespace 52 } // namespace
54 53
55 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder(LayoutSVGText& te xtRoot) 54 SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder(LayoutSVGText& te xtRoot)
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 attrLists.updateCharacterData(i, data); 232 attrLists.updateCharacterData(i, data);
234 } 233 }
235 } 234 }
236 235
237 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) 236 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition)
238 { 237 {
239 visitor->trace(element); 238 visitor->trace(element);
240 } 239 }
241 240
242 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698