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

Side by Side Diff: third_party/WebKit/Source/platform/text/PlatformLocale.cpp

Issue 2811453002: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text (Closed)
Patch Set: fix Created 3 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011,2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011,2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 builder_.Append( 160 builder_.Append(
161 localizer_.ConvertToLocalizedNumber(zero_padded_second_string)); 161 localizer_.ConvertToLocalizedNumber(zero_padded_second_string));
162 } 162 }
163 return; 163 return;
164 default: 164 default:
165 return; 165 return;
166 } 166 }
167 } 167 }
168 168
169 void DateTimeStringBuilder::VisitLiteral(const String& text) { 169 void DateTimeStringBuilder::VisitLiteral(const String& text) {
170 ASSERT(text.length()); 170 DCHECK(text.length());
171 builder_.Append(text); 171 builder_.Append(text);
172 } 172 }
173 173
174 String DateTimeStringBuilder::ToString() { 174 String DateTimeStringBuilder::ToString() {
175 return builder_.ToString(); 175 return builder_.ToString();
176 } 176 }
177 177
178 Locale& Locale::DefaultLocale() { 178 Locale& Locale::DefaultLocale() {
179 static Locale* locale = Locale::Create(DefaultLanguage()).release(); 179 static Locale* locale = Locale::Create(DefaultLanguage()).release();
180 ASSERT(IsMainThread()); 180 DCHECK(IsMainThread());
181 return *locale; 181 return *locale;
182 } 182 }
183 183
184 Locale::~Locale() {} 184 Locale::~Locale() {}
185 185
186 String Locale::QueryString(WebLocalizedString::Name name) { 186 String Locale::QueryString(WebLocalizedString::Name name) {
187 // FIXME: Returns a string locazlied for this locale. 187 // FIXME: Returns a string locazlied for this locale.
188 return Platform::Current()->QueryLocalizedString(name); 188 return Platform::Current()->QueryLocalizedString(name);
189 } 189 }
190 190
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 templ.Substring(literal_start, length - literal_start), builder); 243 templ.Substring(literal_start, length - literal_start), builder);
244 return builder.ToString(); 244 return builder.ToString();
245 } 245 }
246 246
247 void Locale::SetLocaleData(const Vector<String, kDecimalSymbolsSize>& symbols, 247 void Locale::SetLocaleData(const Vector<String, kDecimalSymbolsSize>& symbols,
248 const String& positive_prefix, 248 const String& positive_prefix,
249 const String& positive_suffix, 249 const String& positive_suffix,
250 const String& negative_prefix, 250 const String& negative_prefix,
251 const String& negative_suffix) { 251 const String& negative_suffix) {
252 for (size_t i = 0; i < symbols.size(); ++i) { 252 for (size_t i = 0; i < symbols.size(); ++i) {
253 ASSERT(!symbols[i].IsEmpty()); 253 DCHECK(!symbols[i].IsEmpty());
254 decimal_symbols_[i] = symbols[i]; 254 decimal_symbols_[i] = symbols[i];
255 } 255 }
256 positive_prefix_ = positive_prefix; 256 positive_prefix_ = positive_prefix;
257 positive_suffix_ = positive_suffix; 257 positive_suffix_ = positive_suffix;
258 negative_prefix_ = negative_prefix; 258 negative_prefix_ = negative_prefix;
259 negative_suffix_ = negative_suffix; 259 negative_suffix_ = negative_suffix;
260 ASSERT(!positive_prefix_.IsEmpty() || !positive_suffix_.IsEmpty() || 260 DCHECK(!positive_prefix_.IsEmpty() || !positive_suffix_.IsEmpty() ||
261 !negative_prefix_.IsEmpty() || !negative_suffix_.IsEmpty()); 261 !negative_prefix_.IsEmpty() || !negative_suffix_.IsEmpty());
262 has_locale_data_ = true; 262 has_locale_data_ = true;
263 263
264 StringBuilder builder; 264 StringBuilder builder;
265 for (size_t i = 0; i < kDecimalSymbolsSize; ++i) { 265 for (size_t i = 0; i < kDecimalSymbolsSize; ++i) {
266 // We don't accept group separatros. 266 // We don't accept group separatros.
267 if (i != kGroupSeparatorIndex) 267 if (i != kGroupSeparatorIndex)
268 builder.Append(decimal_symbols_[i]); 268 builder.Append(decimal_symbols_[i]);
269 } 269 }
270 builder.Append(positive_prefix_); 270 builder.Append(positive_prefix_);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 case '6': 303 case '6':
304 case '7': 304 case '7':
305 case '8': 305 case '8':
306 case '9': 306 case '9':
307 builder.Append(decimal_symbols_[input[i] - '0']); 307 builder.Append(decimal_symbols_[input[i] - '0']);
308 break; 308 break;
309 case '.': 309 case '.':
310 builder.Append(decimal_symbols_[kDecimalSeparatorIndex]); 310 builder.Append(decimal_symbols_[kDecimalSeparatorIndex]);
311 break; 311 break;
312 default: 312 default:
313 ASSERT_NOT_REACHED(); 313 NOTREACHED();
314 } 314 }
315 } 315 }
316 316
317 builder.Append(is_negative ? negative_suffix_ : positive_suffix_); 317 builder.Append(is_negative ? negative_suffix_ : positive_suffix_);
318 318
319 return builder.ToString(); 319 return builder.ToString();
320 } 320 }
321 321
322 static bool Matches(const String& text, unsigned position, const String& part) { 322 static bool Matches(const String& text, unsigned position, const String& part) {
323 if (part.IsEmpty()) 323 if (part.IsEmpty())
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 case DateComponents::kWeek: 458 case DateComponents::kWeek:
459 builder.Build(WeekFormatInLDML()); 459 builder.Build(WeekFormatInLDML());
460 break; 460 break;
461 case DateComponents::kDateTime: 461 case DateComponents::kDateTime:
462 case DateComponents::kDateTimeLocal: 462 case DateComponents::kDateTimeLocal:
463 builder.Build(format_type == kFormatTypeShort 463 builder.Build(format_type == kFormatTypeShort
464 ? DateTimeFormatWithoutSeconds() 464 ? DateTimeFormatWithoutSeconds()
465 : DateTimeFormatWithSeconds()); 465 : DateTimeFormatWithSeconds());
466 break; 466 break;
467 case DateComponents::kInvalid: 467 case DateComponents::kInvalid:
468 ASSERT_NOT_REACHED(); 468 NOTREACHED();
469 break; 469 break;
470 } 470 }
471 return builder.ToString(); 471 return builder.ToString();
472 } 472 }
473 473
474 } // namespace blink 474 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/LocaleWin.cpp ('k') | third_party/WebKit/Source/platform/text/SegmentedString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698