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

Side by Side Diff: third_party/WebKit/Source/wtf/text/TextCodecLatin1.cpp

Issue 2373983006: reflow comments in wtf/text (Closed)
Patch Set: Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 static std::unique_ptr<TextCodec> newStreamingTextDecoderWindowsLatin1( 93 static std::unique_ptr<TextCodec> newStreamingTextDecoderWindowsLatin1(
94 const TextEncoding&, 94 const TextEncoding&,
95 const void*) { 95 const void*) {
96 return wrapUnique(new TextCodecLatin1); 96 return wrapUnique(new TextCodecLatin1);
97 } 97 }
98 98
99 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar) { 99 void TextCodecLatin1::registerCodecs(TextCodecRegistrar registrar) {
100 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0); 100 registrar("windows-1252", newStreamingTextDecoderWindowsLatin1, 0);
101 101
102 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain uniqu e identities. 102 // ASCII and Latin-1 both decode as Windows Latin-1 although they retain
103 // unique identities.
103 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0); 104 registrar("ISO-8859-1", newStreamingTextDecoderWindowsLatin1, 0);
104 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0); 105 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0);
105 } 106 }
106 107
107 String TextCodecLatin1::decode(const char* bytes, 108 String TextCodecLatin1::decode(const char* bytes,
108 size_t length, 109 size_t length,
109 FlushBehavior, 110 FlushBehavior,
110 bool, 111 bool,
111 bool&) { 112 bool&) {
112 LChar* characters; 113 LChar* characters;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 239 }
239 240
240 template <typename CharType> 241 template <typename CharType>
241 CString TextCodecLatin1::encodeCommon(const CharType* characters, 242 CString TextCodecLatin1::encodeCommon(const CharType* characters,
242 size_t length, 243 size_t length,
243 UnencodableHandling handling) { 244 UnencodableHandling handling) {
244 { 245 {
245 char* bytes; 246 char* bytes;
246 CString string = CString::newUninitialized(length, bytes); 247 CString string = CString::newUninitialized(length, bytes);
247 248
248 // Convert the string a fast way and simultaneously do an efficient check to see if it's all ASCII. 249 // Convert the string a fast way and simultaneously do an efficient check to
250 // see if it's all ASCII.
249 UChar ored = 0; 251 UChar ored = 0;
250 for (size_t i = 0; i < length; ++i) { 252 for (size_t i = 0; i < length; ++i) {
251 UChar c = characters[i]; 253 UChar c = characters[i];
252 bytes[i] = static_cast<char>(c); 254 bytes[i] = static_cast<char>(c);
253 ored |= c; 255 ored |= c;
254 } 256 }
255 257
256 if (!(ored & 0xFF80)) 258 if (!(ored & 0xFF80))
257 return string; 259 return string;
258 } 260 }
259 261
260 // If it wasn't all ASCII, call the function that handles more-complex cases. 262 // If it wasn't all ASCII, call the function that handles more-complex cases.
261 return encodeComplexWindowsLatin1(characters, length, handling); 263 return encodeComplexWindowsLatin1(characters, length, handling);
262 } 264 }
263 265
264 CString TextCodecLatin1::encode(const UChar* characters, 266 CString TextCodecLatin1::encode(const UChar* characters,
265 size_t length, 267 size_t length,
266 UnencodableHandling handling) { 268 UnencodableHandling handling) {
267 return encodeCommon(characters, length, handling); 269 return encodeCommon(characters, length, handling);
268 } 270 }
269 271
270 CString TextCodecLatin1::encode(const LChar* characters, 272 CString TextCodecLatin1::encode(const LChar* characters,
271 size_t length, 273 size_t length,
272 UnencodableHandling handling) { 274 UnencodableHandling handling) {
273 return encodeCommon(characters, length, handling); 275 return encodeCommon(characters, length, handling);
274 } 276 }
275 277
276 } // namespace WTF 278 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698