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

Side by Side Diff: third_party/WebKit/Source/platform/text/DecodeEscapeSequences.h

Issue 1521923002: Make platform/text to use USING_FAST_MALLOC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 Daniel Bates (dbates@intudata.com). All Rights Reserved. 2 * Copyright (C) 2011 Daniel Bates (dbates@intudata.com). All Rights Reserved.
3 * Copyright (c) 2012 Google, inc. All Rights Reserved. 3 * Copyright (c) 2012 Google, inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #ifndef DecodeEscapeSequences_h 30 #ifndef DecodeEscapeSequences_h
31 #define DecodeEscapeSequences_h 31 #define DecodeEscapeSequences_h
32 32
33 #include "wtf/ASCIICType.h" 33 #include "wtf/ASCIICType.h"
34 #include "wtf/Allocator.h"
34 #include "wtf/Assertions.h" 35 #include "wtf/Assertions.h"
35 #include "wtf/text/StringBuilder.h" 36 #include "wtf/text/StringBuilder.h"
36 #include "wtf/text/TextEncoding.h" 37 #include "wtf/text/TextEncoding.h"
37 38
38 namespace blink { 39 namespace blink {
39 40
40 // See <http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementatio ns>. 41 // See <http://en.wikipedia.org/wiki/Percent-encoding#Non-standard_implementatio ns>.
41 struct Unicode16BitEscapeSequence { 42 struct Unicode16BitEscapeSequence {
43 STATIC_ONLY(Unicode16BitEscapeSequence);
42 enum { sequenceSize = 6 }; // e.g. %u26C4 44 enum { sequenceSize = 6 }; // e.g. %u26C4
43 static size_t findInString(const String& string, size_t startPosition) { ret urn string.find("%u", startPosition); } 45 static size_t findInString(const String& string, size_t startPosition) { ret urn string.find("%u", startPosition); }
44 static size_t findEndOfRun(const String& string, size_t startPosition, size_ t endPosition) 46 static size_t findEndOfRun(const String& string, size_t startPosition, size_ t endPosition)
45 { 47 {
46 size_t runEnd = startPosition; 48 size_t runEnd = startPosition;
47 while (endPosition - runEnd >= sequenceSize && string[runEnd] == '%' && string[runEnd + 1] == 'u' 49 while (endPosition - runEnd >= sequenceSize && string[runEnd] == '%' && string[runEnd + 1] == 'u'
48 && isASCIIHexDigit(string[runEnd + 2]) && isASCIIHexDigit(string[ runEnd + 3]) 50 && isASCIIHexDigit(string[runEnd + 2]) && isASCIIHexDigit(string[ runEnd + 3])
49 && isASCIIHexDigit(string[runEnd + 4]) && isASCIIHexDigit(string[ runEnd + 5])) { 51 && isASCIIHexDigit(string[runEnd + 4]) && isASCIIHexDigit(string[ runEnd + 5])) {
50 runEnd += sequenceSize; 52 runEnd += sequenceSize;
51 } 53 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 result.append(decoded); 151 result.append(decoded);
150 decodedPosition = encodedRunEnd; 152 decodedPosition = encodedRunEnd;
151 } 153 }
152 result.append(string, decodedPosition, length - decodedPosition); 154 result.append(string, decodedPosition, length - decodedPosition);
153 return result.toString(); 155 return result.toString();
154 } 156 }
155 157
156 } // namespace blink 158 } // namespace blink
157 159
158 #endif // DecodeEscapeSequences_h 160 #endif // DecodeEscapeSequences_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/DateTimeFormat.h ('k') | third_party/WebKit/Source/platform/text/LineEnding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698