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

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

Issue 1233043003: Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | ui/gfx/font_list_impl.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // The last item is "[STYLE1] [STYLE2] [...] SIZE". 43 // The last item is "[STYLE1] [STYLE2] [...] SIZE".
44 std::vector<std::string> styles; 44 std::vector<std::string> styles;
45 base::SplitStringAlongWhitespace(families_out->back(), &styles); 45 base::SplitStringAlongWhitespace(families_out->back(), &styles);
46 families_out->pop_back(); 46 families_out->pop_back();
47 if (styles.empty()) 47 if (styles.empty())
48 return false; 48 return false;
49 49
50 // The size takes the form "<INT>px". 50 // The size takes the form "<INT>px".
51 std::string size_string = styles.back(); 51 std::string size_string = styles.back();
52 styles.pop_back(); 52 styles.pop_back();
53 if (!base::EndsWith(size_string, "px", true /* case_sensitive */)) 53 if (!base::EndsWith(size_string, "px", base::CompareCase::SENSITIVE))
54 return false; 54 return false;
55 size_string.resize(size_string.size() - 2); 55 size_string.resize(size_string.size() - 2);
56 if (!base::StringToInt(size_string, size_pixels_out) || 56 if (!base::StringToInt(size_string, size_pixels_out) ||
57 *size_pixels_out <= 0) 57 *size_pixels_out <= 0)
58 return false; 58 return false;
59 59
60 // Font supports BOLD and ITALIC; underline is supported via RenderText. 60 // Font supports BOLD and ITALIC; underline is supported via RenderText.
61 *style_out = gfx::Font::NORMAL; 61 *style_out = gfx::Font::NORMAL;
62 for (const auto& style_string : styles) { 62 for (const auto& style_string : styles) {
63 if (style_string == "Bold") 63 if (style_string == "Bold")
(...skipping 29 matching lines...) Expand all
93 FontList& FontList::operator=(const FontList& other) { 93 FontList& FontList::operator=(const FontList& other) {
94 impl_ = other.impl_; 94 impl_ = other.impl_;
95 return *this; 95 return *this;
96 } 96 }
97 97
98 // static 98 // static
99 void FontList::SetDefaultFontDescription(const std::string& font_description) { 99 void FontList::SetDefaultFontDescription(const std::string& font_description) {
100 // The description string must end with "px" for size in pixel, or must be 100 // The description string must end with "px" for size in pixel, or must be
101 // the empty string, which specifies to use a single default font. 101 // the empty string, which specifies to use a single default font.
102 DCHECK(font_description.empty() || 102 DCHECK(font_description.empty() ||
103 base::EndsWith(font_description, "px", true)); 103 base::EndsWith(font_description, "px", base::CompareCase::SENSITIVE));
104 104
105 g_default_font_description.Get() = font_description; 105 g_default_font_description.Get() = font_description;
106 g_default_impl_initialized = false; 106 g_default_impl_initialized = false;
107 } 107 }
108 108
109 FontList FontList::Derive(int size_delta, int font_style) const { 109 FontList FontList::Derive(int size_delta, int font_style) const {
110 return FontList(impl_->Derive(size_delta, font_style)); 110 return FontList(impl_->Derive(size_delta, font_style));
111 } 111 }
112 112
113 FontList FontList::DeriveWithSizeDelta(int size_delta) const { 113 FontList FontList::DeriveWithSizeDelta(int size_delta) const {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 g_default_font_description.Get().empty() ? 185 g_default_font_description.Get().empty() ?
186 new FontListImpl(Font()) : 186 new FontListImpl(Font()) :
187 new FontListImpl(g_default_font_description.Get()); 187 new FontListImpl(g_default_font_description.Get());
188 g_default_impl_initialized = true; 188 g_default_impl_initialized = true;
189 } 189 }
190 190
191 return g_default_impl.Get(); 191 return g_default_impl.Get();
192 } 192 }
193 193
194 } // namespace gfx 194 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | ui/gfx/font_list_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698