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

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

Issue 235273003: parsing input type=number should skip spaces (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: incorporated review comments Created 6 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 { 341 {
342 for (unsigned symbolIndex = 0; symbolIndex < DecimalSymbolsSize; ++symbolInd ex) { 342 for (unsigned symbolIndex = 0; symbolIndex < DecimalSymbolsSize; ++symbolInd ex) {
343 if (m_decimalSymbols[symbolIndex].length() && matches(input, position, m _decimalSymbols[symbolIndex])) { 343 if (m_decimalSymbols[symbolIndex].length() && matches(input, position, m _decimalSymbols[symbolIndex])) {
344 position += m_decimalSymbols[symbolIndex].length(); 344 position += m_decimalSymbols[symbolIndex].length();
345 return symbolIndex; 345 return symbolIndex;
346 } 346 }
347 } 347 }
348 return DecimalSymbolsSize; 348 return DecimalSymbolsSize;
349 } 349 }
350 350
351 static bool isSpaceCharacter(UChar c)
352 {
353 return c == ' ';
354 }
355
351 String Locale::convertFromLocalizedNumber(const String& localized) 356 String Locale::convertFromLocalizedNumber(const String& localized)
352 { 357 {
353 initializeLocaleData(); 358 initializeLocaleData();
354 String input = localized.stripWhiteSpace(); 359 String input = localized.removeCharacters(isSpaceCharacter);
tkent 2014/04/16 01:52:51 Let's use isASCIISpace in wtf/ASCIICType.h for sim
gnana 2014/04/16 14:13:56 Done.
355 if (!m_hasLocaleData || input.isEmpty()) 360 if (!m_hasLocaleData || input.isEmpty())
356 return input; 361 return input;
357 362
358 bool isNegative; 363 bool isNegative;
359 unsigned startIndex; 364 unsigned startIndex;
360 unsigned endIndex; 365 unsigned endIndex;
361 if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex)) 366 if (!detectSignAndGetDigitRange(input, isNegative, startIndex, endIndex))
362 return input; 367 return input;
363 368
364 StringBuilder builder; 369 StringBuilder builder;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 builder.build(formatType == FormatTypeShort ? dateTimeFormatWithoutSecon ds() : dateTimeFormatWithSeconds()); 416 builder.build(formatType == FormatTypeShort ? dateTimeFormatWithoutSecon ds() : dateTimeFormatWithSeconds());
412 break; 417 break;
413 case DateComponents::Invalid: 418 case DateComponents::Invalid:
414 ASSERT_NOT_REACHED(); 419 ASSERT_NOT_REACHED();
415 break; 420 break;
416 } 421 }
417 return builder.toString(); 422 return builder.toString();
418 } 423 }
419 424
420 } 425 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698