| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 { | 43 { |
| 44 unsigned numLeadingSpaces = 0; | 44 unsigned numLeadingSpaces = 0; |
| 45 unsigned numTrailingSpaces = 0; | 45 unsigned numTrailingSpaces = 0; |
| 46 | 46 |
| 47 for (; numLeadingSpaces < length; ++numLeadingSpaces) { | 47 for (; numLeadingSpaces < length; ++numLeadingSpaces) { |
| 48 if (isNotHTMLSpace<CharType>(characters[numLeadingSpaces])) | 48 if (isNotHTMLSpace<CharType>(characters[numLeadingSpaces])) |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 | 51 |
| 52 if (numLeadingSpaces == length) | 52 if (numLeadingSpaces == length) |
| 53 return string.isNull() ? string : emptyAtom.string(); | 53 return string.isNull() ? string : emptyAtom.getString(); |
| 54 | 54 |
| 55 for (; numTrailingSpaces < length; ++numTrailingSpaces) { | 55 for (; numTrailingSpaces < length; ++numTrailingSpaces) { |
| 56 if (isNotHTMLSpace<CharType>(characters[length - numTrailingSpaces - 1])
) | 56 if (isNotHTMLSpace<CharType>(characters[length - numTrailingSpaces - 1])
) |
| 57 break; | 57 break; |
| 58 } | 58 } |
| 59 | 59 |
| 60 ASSERT(numLeadingSpaces + numTrailingSpaces < length); | 60 ASSERT(numLeadingSpaces + numTrailingSpaces < length); |
| 61 | 61 |
| 62 if (!(numLeadingSpaces | numTrailingSpaces)) | 62 if (!(numLeadingSpaces | numTrailingSpaces)) |
| 63 return string; | 63 return string; |
| 64 | 64 |
| 65 return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTr
ailingSpaces)); | 65 return string.substring(numLeadingSpaces, length - (numLeadingSpaces + numTr
ailingSpaces)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 String stripLeadingAndTrailingHTMLSpaces(const String& string) | 68 String stripLeadingAndTrailingHTMLSpaces(const String& string) |
| 69 { | 69 { |
| 70 unsigned length = string.length(); | 70 unsigned length = string.length(); |
| 71 | 71 |
| 72 if (!length) | 72 if (!length) |
| 73 return string.isNull() ? string : emptyAtom.string(); | 73 return string.isNull() ? string : emptyAtom.getString(); |
| 74 | 74 |
| 75 if (string.is8Bit()) | 75 if (string.is8Bit()) |
| 76 return stripLeadingAndTrailingHTMLSpaces<LChar>(string, string.character
s8(), length); | 76 return stripLeadingAndTrailingHTMLSpaces<LChar>(string, string.character
s8(), length); |
| 77 | 77 |
| 78 return stripLeadingAndTrailingHTMLSpaces<UChar>(string, string.characters16(
), length); | 78 return stripLeadingAndTrailingHTMLSpaces<UChar>(string, string.characters16(
), length); |
| 79 } | 79 } |
| 80 | 80 |
| 81 String serializeForNumberType(const Decimal& number) | 81 String serializeForNumberType(const Decimal& number) |
| 82 { | 82 { |
| 83 if (number.isZero()) { | 83 if (number.isZero()) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 string = StringImpl::create8BitIfPossible(characters, size); | 477 string = StringImpl::create8BitIfPossible(characters, size); |
| 478 else if (width == Force8Bit) | 478 else if (width == Force8Bit) |
| 479 string = String::make8BitFrom16BitSource(characters, size); | 479 string = String::make8BitFrom16BitSource(characters, size); |
| 480 else | 480 else |
| 481 string = String(characters, size); | 481 string = String(characters, size); |
| 482 | 482 |
| 483 return string; | 483 return string; |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace blink | 486 } // namespace blink |
| OLD | NEW |