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

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

Issue 2017053003: Remove StringBuilder::appendLiteral. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 break; 162 break;
163 ++count; 163 ++count;
164 } 164 }
165 return count; 165 return count;
166 } 166 }
167 167
168 static void commitLiteralToken(StringBuilder& literalBuffer, StringBuilder& conv erted) 168 static void commitLiteralToken(StringBuilder& literalBuffer, StringBuilder& conv erted)
169 { 169 {
170 if (literalBuffer.length() <= 0) 170 if (literalBuffer.length() <= 0)
171 return; 171 return;
172 DateTimeFormat::quoteAndAppendLiteral(literalBuffer.toString(), converted); 172 DateTimeFormat::quoteAndappend(literalBuffer.toString(), converted);
173 literalBuffer.clear(); 173 literalBuffer.clear();
174 } 174 }
175 175
176 // This function converts Windows date/time pattern format [1][2] into LDML date 176 // This function converts Windows date/time pattern format [1][2] into LDML date
177 // format pattern [3]. 177 // format pattern [3].
178 // 178 //
179 // i.e. 179 // i.e.
180 // We set h, H, m, s, d, dd, M, or y as is. They have same meaning in both of 180 // We set h, H, m, s, d, dd, M, or y as is. They have same meaning in both of
181 // Windows and LDML. 181 // Windows and LDML.
182 // We need to convert the following patterns: 182 // We need to convert the following patterns:
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 commitLiteralToken(literalBuffer, converted); 226 commitLiteralToken(literalBuffer, converted);
227 unsigned symbolStart = i; 227 unsigned symbolStart = i;
228 unsigned count = countContinuousLetters(format, i); 228 unsigned count = countContinuousLetters(format, i);
229 i += count - 1; 229 i += count - 1;
230 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') { 230 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') {
231 converted.append(format, symbolStart, count); 231 converted.append(format, symbolStart, count);
232 } else if (ch == 'd') { 232 } else if (ch == 'd') {
233 if (count <= 2) 233 if (count <= 2)
234 converted.append(format, symbolStart, count); 234 converted.append(format, symbolStart, count);
235 else if (count == 3) 235 else if (count == 3)
236 converted.appendLiteral("EEE"); 236 converted.append("EEE");
237 else 237 else
238 converted.appendLiteral("EEEE"); 238 converted.append("EEEE");
239 } else if (ch == 'g') { 239 } else if (ch == 'g') {
240 if (count == 1) { 240 if (count == 1) {
241 converted.append('G'); 241 converted.append('G');
242 } else { 242 } else {
243 // gg means imperial era in Windows. 243 // gg means imperial era in Windows.
244 // Just ignore it. 244 // Just ignore it.
245 } 245 }
246 } else if (ch == 't') { 246 } else if (ch == 't') {
247 converted.append('a'); 247 converted.append('a');
248 } else { 248 } else {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 String LocaleWin::shortTimeFormat() 374 String LocaleWin::shortTimeFormat()
375 { 375 {
376 if (!m_timeFormatWithoutSeconds.isNull()) 376 if (!m_timeFormatWithoutSeconds.isNull())
377 return m_timeFormatWithoutSeconds; 377 return m_timeFormatWithoutSeconds;
378 String format = getLocaleInfoString(LOCALE_SSHORTTIME); 378 String format = getLocaleInfoString(LOCALE_SSHORTTIME);
379 // Vista or older Windows doesn't support LOCALE_SSHORTTIME. 379 // Vista or older Windows doesn't support LOCALE_SSHORTTIME.
380 if (format.isEmpty()) { 380 if (format.isEmpty()) {
381 format = getLocaleInfoString(LOCALE_STIMEFORMAT); 381 format = getLocaleInfoString(LOCALE_STIMEFORMAT);
382 StringBuilder builder; 382 StringBuilder builder;
383 builder.append(getLocaleInfoString(LOCALE_STIME)); 383 builder.append(getLocaleInfoString(LOCALE_STIME));
384 builder.appendLiteral("ss"); 384 builder.append("ss");
385 size_t pos = format.reverseFind(builder.toString()); 385 size_t pos = format.reverseFind(builder.toString());
386 if (pos != kNotFound) 386 if (pos != kNotFound)
387 format.remove(pos, builder.length()); 387 format.remove(pos, builder.length());
388 } 388 }
389 m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format); 389 m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format);
390 return m_timeFormatWithoutSeconds; 390 return m_timeFormatWithoutSeconds;
391 } 391 }
392 392
393 String LocaleWin::dateTimeFormatWithSeconds() 393 String LocaleWin::dateTimeFormatWithSeconds()
394 { 394 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 case NegativeFormatSignPrefix: // Fall through. 506 case NegativeFormatSignPrefix: // Fall through.
507 default: 507 default:
508 negativePrefix = negativeSign; 508 negativePrefix = negativeSign;
509 break; 509 break;
510 } 510 }
511 m_didInitializeNumberData = true; 511 m_didInitializeNumberData = true;
512 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix); 512 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix);
513 } 513 }
514 514
515 } 515 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/LocaleICUTest.cpp ('k') | third_party/WebKit/Source/platform/text/PlatformLocale.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698