| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> | 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> |
| 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "wtf/OwnPtr.h" | 33 #include "wtf/OwnPtr.h" |
| 34 #include "wtf/StdLibExtras.h" | 34 #include "wtf/StdLibExtras.h" |
| 35 #include "wtf/Threading.h" | 35 #include "wtf/Threading.h" |
| 36 #include "wtf/text/CString.h" | 36 #include "wtf/text/CString.h" |
| 37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 38 | 38 |
| 39 namespace WTF { | 39 namespace WTF { |
| 40 | 40 |
| 41 static const TextEncoding& UTF7Encoding() | 41 static const TextEncoding& UTF7Encoding() |
| 42 { | 42 { |
| 43 AtomicallyInitializedStatic(const TextEncoding&, globalUTF7Encoding = *new T
extEncoding("UTF-7")); | 43 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF7Encoding,
new TextEncoding("UTF-7")); |
| 44 return globalUTF7Encoding; | 44 return globalUTF7Encoding; |
| 45 } | 45 } |
| 46 | 46 |
| 47 TextEncoding::TextEncoding(const char* name) | 47 TextEncoding::TextEncoding(const char* name) |
| 48 : m_name(atomicCanonicalTextEncodingName(name)) | 48 : m_name(atomicCanonicalTextEncodingName(name)) |
| 49 { | 49 { |
| 50 // Aliases are valid, but not "replacement" itself. | 50 // Aliases are valid, but not "replacement" itself. |
| 51 if (m_name && isReplacementEncoding(name)) | 51 if (m_name && isReplacementEncoding(name)) |
| 52 m_name = 0; | 52 m_name = 0; |
| 53 } | 53 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // but it's fraught with problems and we'd rather steer clear of it. | 168 // but it's fraught with problems and we'd rather steer clear of it. |
| 169 const TextEncoding& TextEncoding::encodingForFormSubmission() const | 169 const TextEncoding& TextEncoding::encodingForFormSubmission() const |
| 170 { | 170 { |
| 171 if (isNonByteBasedEncoding() || isUTF7Encoding()) | 171 if (isNonByteBasedEncoding() || isUTF7Encoding()) |
| 172 return UTF8Encoding(); | 172 return UTF8Encoding(); |
| 173 return *this; | 173 return *this; |
| 174 } | 174 } |
| 175 | 175 |
| 176 const TextEncoding& ASCIIEncoding() | 176 const TextEncoding& ASCIIEncoding() |
| 177 { | 177 { |
| 178 AtomicallyInitializedStatic(const TextEncoding&, globalASCIIEncoding = *new
TextEncoding("ASCII")); | 178 AtomicallyInitializedStaticReference(const TextEncoding, globalASCIIEncoding
, new TextEncoding("ASCII")); |
| 179 return globalASCIIEncoding; | 179 return globalASCIIEncoding; |
| 180 } | 180 } |
| 181 | 181 |
| 182 const TextEncoding& Latin1Encoding() | 182 const TextEncoding& Latin1Encoding() |
| 183 { | 183 { |
| 184 AtomicallyInitializedStatic(const TextEncoding&, globalLatin1Encoding = *new
TextEncoding("latin1")); | 184 AtomicallyInitializedStaticReference(const TextEncoding, globalLatin1Encodin
g, new TextEncoding("latin1")); |
| 185 return globalLatin1Encoding; | 185 return globalLatin1Encoding; |
| 186 } | 186 } |
| 187 | 187 |
| 188 const TextEncoding& UTF16BigEndianEncoding() | 188 const TextEncoding& UTF16BigEndianEncoding() |
| 189 { | 189 { |
| 190 AtomicallyInitializedStatic(const TextEncoding&, globalUTF16BigEndianEncodin
g = *new TextEncoding("UTF-16BE")); | 190 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF16BigEndia
nEncoding, new TextEncoding("UTF-16BE")); |
| 191 return globalUTF16BigEndianEncoding; | 191 return globalUTF16BigEndianEncoding; |
| 192 } | 192 } |
| 193 | 193 |
| 194 const TextEncoding& UTF16LittleEndianEncoding() | 194 const TextEncoding& UTF16LittleEndianEncoding() |
| 195 { | 195 { |
| 196 AtomicallyInitializedStatic(const TextEncoding&, globalUTF16LittleEndianEnco
ding = *new TextEncoding("UTF-16LE")); | 196 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF16LittleEn
dianEncoding, new TextEncoding("UTF-16LE")); |
| 197 return globalUTF16LittleEndianEncoding; | 197 return globalUTF16LittleEndianEncoding; |
| 198 } | 198 } |
| 199 | 199 |
| 200 const TextEncoding& UTF32BigEndianEncoding() | 200 const TextEncoding& UTF32BigEndianEncoding() |
| 201 { | 201 { |
| 202 AtomicallyInitializedStatic(const TextEncoding&, globalUTF32BigEndianEncodin
g = *new TextEncoding("UTF-32BE")); | 202 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF32BigEndia
nEncoding, new TextEncoding("UTF-32BE")); |
| 203 return globalUTF32BigEndianEncoding; | 203 return globalUTF32BigEndianEncoding; |
| 204 } | 204 } |
| 205 | 205 |
| 206 const TextEncoding& UTF32LittleEndianEncoding() | 206 const TextEncoding& UTF32LittleEndianEncoding() |
| 207 { | 207 { |
| 208 AtomicallyInitializedStatic(const TextEncoding&, globalUTF32LittleEndianEnco
ding = *new TextEncoding("UTF-32LE")); | 208 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF32LittleEn
dianEncoding, new TextEncoding("UTF-32LE")); |
| 209 return globalUTF32LittleEndianEncoding; | 209 return globalUTF32LittleEndianEncoding; |
| 210 } | 210 } |
| 211 | 211 |
| 212 const TextEncoding& UTF8Encoding() | 212 const TextEncoding& UTF8Encoding() |
| 213 { | 213 { |
| 214 AtomicallyInitializedStatic(const TextEncoding&, globalUTF8Encoding = *new T
extEncoding("UTF-8")); | 214 AtomicallyInitializedStaticReference(const TextEncoding, globalUTF8Encoding,
new TextEncoding("UTF-8")); |
| 215 ASSERT(globalUTF8Encoding.isValid()); | 215 ASSERT(globalUTF8Encoding.isValid()); |
| 216 return globalUTF8Encoding; | 216 return globalUTF8Encoding; |
| 217 } | 217 } |
| 218 | 218 |
| 219 const TextEncoding& WindowsLatin1Encoding() | 219 const TextEncoding& WindowsLatin1Encoding() |
| 220 { | 220 { |
| 221 AtomicallyInitializedStatic(const TextEncoding&, globalWindowsLatin1Encoding
= *new TextEncoding("WinLatin1")); | 221 AtomicallyInitializedStaticReference(const TextEncoding, globalWindowsLatin1
Encoding, new TextEncoding("WinLatin1")); |
| 222 return globalWindowsLatin1Encoding; | 222 return globalWindowsLatin1Encoding; |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace WTF | 225 } // namespace WTF |
| OLD | NEW |