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

Side by Side Diff: Source/core/platform/text/LocaleWin.cpp

Issue 25674007: Remove core/platform/text/{mac, win} (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/platform/text/LocaleWin.h ('k') | Source/core/platform/text/mac/LocaleMac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/platform/text/win/LocaleWin.h" 32 #include "core/platform/text/LocaleWin.h"
33 33
34 #include <windows.h>
35 #include <limits>
36 #include "platform/DateComponents.h" 34 #include "platform/DateComponents.h"
37 #include "platform/Language.h" 35 #include "platform/Language.h"
38 #include "platform/LayoutTestSupport.h" 36 #include "platform/LayoutTestSupport.h"
39 #include "platform/LocalizedStrings.h" 37 #include "platform/LocalizedStrings.h"
40 #include "platform/text/DateTimeFormat.h" 38 #include "platform/text/DateTimeFormat.h"
41 #include "wtf/CurrentTime.h" 39 #include "wtf/CurrentTime.h"
42 #include "wtf/DateMath.h" 40 #include "wtf/DateMath.h"
43 #include "wtf/HashMap.h" 41 #include "wtf/HashMap.h"
44 #include "wtf/OwnPtr.h" 42 #include "wtf/OwnPtr.h"
45 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
46 #include "wtf/text/StringBuffer.h" 44 #include "wtf/text/StringBuffer.h"
47 #include "wtf/text/StringBuilder.h" 45 #include "wtf/text/StringBuilder.h"
48 #include "wtf/text/StringHash.h" 46 #include "wtf/text/StringHash.h"
47 #include <limits>
48 #include <windows.h>
49 49
50 using namespace std; 50 using namespace std;
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD); 54 typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
55 typedef HashMap<String, LCID> NameToLCIDMap; 55 typedef HashMap<String, LCID> NameToLCIDMap;
56 56
57 static String extractLanguageCode(const String& locale) 57 static String extractLanguageCode(const String& locale)
58 { 58 {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 bool lastQuoteCanBeLiteral = false; 273 bool lastQuoteCanBeLiteral = false;
274 for (unsigned i = 0; i < format.length(); ++i) { 274 for (unsigned i = 0; i < format.length(); ++i) {
275 UChar ch = format[i]; 275 UChar ch = format[i];
276 if (inQuote) { 276 if (inQuote) {
277 if (ch == '\'') { 277 if (ch == '\'') {
278 inQuote = false; 278 inQuote = false;
279 ASSERT(i); 279 ASSERT(i);
280 if (lastQuoteCanBeLiteral && format[i - 1] == '\'') { 280 if (lastQuoteCanBeLiteral && format[i - 1] == '\'') {
281 literalBuffer.append('\''); 281 literalBuffer.append('\'');
282 lastQuoteCanBeLiteral = false; 282 lastQuoteCanBeLiteral = false;
283 } else 283 } else {
284 lastQuoteCanBeLiteral = true; 284 lastQuoteCanBeLiteral = true;
285 } else 285 }
286 } else {
286 literalBuffer.append(ch); 287 literalBuffer.append(ch);
288 }
287 continue; 289 continue;
288 } 290 }
289 291
290 if (ch == '\'') { 292 if (ch == '\'') {
291 inQuote = true; 293 inQuote = true;
292 if (lastQuoteCanBeLiteral && i > 0 && format[i - 1] == '\'') { 294 if (lastQuoteCanBeLiteral && i > 0 && format[i - 1] == '\'') {
293 literalBuffer.append(ch); 295 literalBuffer.append(ch);
294 lastQuoteCanBeLiteral = false; 296 lastQuoteCanBeLiteral = false;
295 } else 297 } else {
296 lastQuoteCanBeLiteral = true; 298 lastQuoteCanBeLiteral = true;
299 }
297 } else if (isASCIIAlpha(ch)) { 300 } else if (isASCIIAlpha(ch)) {
298 commitLiteralToken(literalBuffer, converted); 301 commitLiteralToken(literalBuffer, converted);
299 unsigned symbolStart = i; 302 unsigned symbolStart = i;
300 unsigned count = countContinuousLetters(format, i); 303 unsigned count = countContinuousLetters(format, i);
301 i += count - 1; 304 i += count - 1;
302 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') 305 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') {
303 converted.append(format, symbolStart, count); 306 converted.append(format, symbolStart, count);
304 else if (ch == 'd') { 307 } else if (ch == 'd') {
305 if (count <= 2) 308 if (count <= 2)
306 converted.append(format, symbolStart, count); 309 converted.append(format, symbolStart, count);
307 else if (count == 3) 310 else if (count == 3)
308 converted.append("EEE"); 311 converted.append("EEE");
309 else 312 else
310 converted.append("EEEE"); 313 converted.append("EEEE");
311 } else if (ch == 'g') { 314 } else if (ch == 'g') {
312 if (count == 1) 315 if (count == 1) {
313 converted.append('G'); 316 converted.append('G');
314 else { 317 } else {
315 // gg means imperial era in Windows. 318 // gg means imperial era in Windows.
316 // Just ignore it. 319 // Just ignore it.
317 } 320 }
318 } else if (ch == 't') 321 } else if (ch == 't') {
319 converted.append('a'); 322 converted.append('a');
320 else 323 } else {
321 literalBuffer.append(format, symbolStart, count); 324 literalBuffer.append(format, symbolStart, count);
322 } else 325 }
326 } else {
323 literalBuffer.append(ch); 327 literalBuffer.append(ch);
328 }
324 } 329 }
325 commitLiteralToken(literalBuffer, converted); 330 commitLiteralToken(literalBuffer, converted);
326 return converted.toString(); 331 return converted.toString();
327 } 332 }
328 333
329 void LocaleWin::ensureMonthLabels() 334 void LocaleWin::ensureMonthLabels()
330 { 335 {
331 if (!m_monthLabels.isEmpty()) 336 if (!m_monthLabels.isEmpty())
332 return; 337 return;
333 const LCTYPE types[12] = { 338 const LCTYPE types[12] = {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 case NegativeFormatSignPrefix: // Fall through. 583 case NegativeFormatSignPrefix: // Fall through.
579 default: 584 default:
580 negativePrefix = negativeSign; 585 negativePrefix = negativeSign;
581 break; 586 break;
582 } 587 }
583 m_didInitializeNumberData = true; 588 m_didInitializeNumberData = true;
584 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix); 589 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix);
585 } 590 }
586 591
587 } 592 }
OLDNEW
« no previous file with comments | « Source/core/platform/text/LocaleWin.h ('k') | Source/core/platform/text/mac/LocaleMac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698