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

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: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in platform/text 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 m_builder.append( 160 m_builder.append(
161 m_localizer.convertToLocalizedNumber(zeroPaddedSecondString)); 161 m_localizer.convertToLocalizedNumber(zeroPaddedSecondString));
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 m_builder.append(text); 171 m_builder.append(text);
172 } 172 }
173 173
174 String DateTimeStringBuilder::toString() { 174 String DateTimeStringBuilder::toString() {
175 return m_builder.toString(); 175 return m_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(literalStart, length - literalStart), builder); 243 templ.substring(literalStart, length - literalStart), builder);
244 return builder.toString(); 244 return builder.toString();
245 } 245 }
246 246
247 void Locale::setLocaleData(const Vector<String, DecimalSymbolsSize>& symbols, 247 void Locale::setLocaleData(const Vector<String, DecimalSymbolsSize>& symbols,
248 const String& positivePrefix, 248 const String& positivePrefix,
249 const String& positiveSuffix, 249 const String& positiveSuffix,
250 const String& negativePrefix, 250 const String& negativePrefix,
251 const String& negativeSuffix) { 251 const String& negativeSuffix) {
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 m_decimalSymbols[i] = symbols[i]; 254 m_decimalSymbols[i] = symbols[i];
255 } 255 }
256 m_positivePrefix = positivePrefix; 256 m_positivePrefix = positivePrefix;
257 m_positiveSuffix = positiveSuffix; 257 m_positiveSuffix = positiveSuffix;
258 m_negativePrefix = negativePrefix; 258 m_negativePrefix = negativePrefix;
259 m_negativeSuffix = negativeSuffix; 259 m_negativeSuffix = negativeSuffix;
260 ASSERT(!m_positivePrefix.isEmpty() || !m_positiveSuffix.isEmpty() || 260 DCHECK(!m_positivePrefix.isEmpty() || !m_positiveSuffix.isEmpty() ||
261 !m_negativePrefix.isEmpty() || !m_negativeSuffix.isEmpty()); 261 !m_negativePrefix.isEmpty() || !m_negativeSuffix.isEmpty());
262 m_hasLocaleData = true; 262 m_hasLocaleData = true;
263 263
264 StringBuilder builder; 264 StringBuilder builder;
265 for (size_t i = 0; i < DecimalSymbolsSize; ++i) { 265 for (size_t i = 0; i < DecimalSymbolsSize; ++i) {
266 // We don't accept group separatros. 266 // We don't accept group separatros.
267 if (i != GroupSeparatorIndex) 267 if (i != GroupSeparatorIndex)
268 builder.append(m_decimalSymbols[i]); 268 builder.append(m_decimalSymbols[i]);
269 } 269 }
270 builder.append(m_positivePrefix); 270 builder.append(m_positivePrefix);
(...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(m_decimalSymbols[input[i] - '0']); 307 builder.append(m_decimalSymbols[input[i] - '0']);
308 break; 308 break;
309 case '.': 309 case '.':
310 builder.append(m_decimalSymbols[DecimalSeparatorIndex]); 310 builder.append(m_decimalSymbols[DecimalSeparatorIndex]);
311 break; 311 break;
312 default: 312 default:
313 ASSERT_NOT_REACHED(); 313 NOTREACHED();
314 } 314 }
315 } 315 }
316 316
317 builder.append(isNegative ? m_negativeSuffix : m_positiveSuffix); 317 builder.append(isNegative ? m_negativeSuffix : m_positiveSuffix);
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::Week: 458 case DateComponents::Week:
459 builder.build(weekFormatInLDML()); 459 builder.build(weekFormatInLDML());
460 break; 460 break;
461 case DateComponents::DateTime: 461 case DateComponents::DateTime:
462 case DateComponents::DateTimeLocal: 462 case DateComponents::DateTimeLocal:
463 builder.build(formatType == FormatTypeShort 463 builder.build(formatType == FormatTypeShort
464 ? dateTimeFormatWithoutSeconds() 464 ? dateTimeFormatWithoutSeconds()
465 : dateTimeFormatWithSeconds()); 465 : dateTimeFormatWithSeconds());
466 break; 466 break;
467 case DateComponents::Invalid: 467 case DateComponents::Invalid:
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

Powered by Google App Engine
This is Rietveld 408576698