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

Side by Side Diff: ui/gfx/font_list.cc

Issue 1278973003: Revert of Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « ui/gfx/font_fallback_win.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/font_list.h" 5 #include "ui/gfx/font_list.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // static 28 // static
29 bool FontList::ParseDescription(const std::string& description, 29 bool FontList::ParseDescription(const std::string& description,
30 std::vector<std::string>* families_out, 30 std::vector<std::string>* families_out,
31 int* style_out, 31 int* style_out,
32 int* size_pixels_out) { 32 int* size_pixels_out) {
33 DCHECK(families_out); 33 DCHECK(families_out);
34 DCHECK(style_out); 34 DCHECK(style_out);
35 DCHECK(size_pixels_out); 35 DCHECK(size_pixels_out);
36 36
37 *families_out = base::SplitString( 37 base::SplitString(description, ',', families_out);
38 description, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
39 if (families_out->empty()) 38 if (families_out->empty())
40 return false; 39 return false;
41 for (auto& family : *families_out) 40 for (auto& family : *families_out)
42 base::TrimWhitespaceASCII(family, base::TRIM_ALL, &family); 41 base::TrimWhitespaceASCII(family, base::TRIM_ALL, &family);
43 42
44 // The last item is "[STYLE1] [STYLE2] [...] SIZE". 43 // The last item is "[STYLE1] [STYLE2] [...] SIZE".
45 std::vector<std::string> styles = base::SplitString( 44 std::vector<std::string> styles;
46 families_out->back(), base::kWhitespaceASCII, 45 base::SplitStringAlongWhitespace(families_out->back(), &styles);
47 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
48 families_out->pop_back(); 46 families_out->pop_back();
49 if (styles.empty()) 47 if (styles.empty())
50 return false; 48 return false;
51 49
52 // The size takes the form "<INT>px". 50 // The size takes the form "<INT>px".
53 std::string size_string = styles.back(); 51 std::string size_string = styles.back();
54 styles.pop_back(); 52 styles.pop_back();
55 if (!base::EndsWith(size_string, "px", base::CompareCase::SENSITIVE)) 53 if (!base::EndsWith(size_string, "px", base::CompareCase::SENSITIVE))
56 return false; 54 return false;
57 size_string.resize(size_string.size() - 2); 55 size_string.resize(size_string.size() - 2);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 g_default_font_description.Get().empty() ? 185 g_default_font_description.Get().empty() ?
188 new FontListImpl(Font()) : 186 new FontListImpl(Font()) :
189 new FontListImpl(g_default_font_description.Get()); 187 new FontListImpl(g_default_font_description.Get());
190 g_default_impl_initialized = true; 188 g_default_impl_initialized = true;
191 } 189 }
192 190
193 return g_default_impl.Get(); 191 return g_default_impl.Get();
194 } 192 }
195 193
196 } // namespace gfx 194 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_fallback_win.cc ('k') | ui/gfx/render_text_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698