Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 , m_fatal(fatal) | 61 , m_fatal(fatal) |
| 62 { | 62 { |
| 63 } | 63 } |
| 64 | 64 |
| 65 TextDecoder::~TextDecoder() | 65 TextDecoder::~TextDecoder() |
| 66 { | 66 { |
| 67 } | 67 } |
| 68 | 68 |
| 69 String TextDecoder::encoding() const | 69 String TextDecoder::encoding() const |
| 70 { | 70 { |
| 71 return String(m_encoding.name()).lower(); | 71 String name = String(m_encoding.name()).lower(); |
| 72 // The same codec is used, but WTF maintains a different name/identity for t hese. | |
| 73 if (name == "iso-8859-1" || name == "us-ascii") | |
|
jsbell
2013/08/27 00:21:04
This could also be done around line 44, during the
Ken Russell (switch to Gerrit)
2013/08/27 03:32:54
I defer to your judgment. If the number of aliases
| |
| 74 return "windows-1252"; | |
| 75 return name; | |
| 72 } | 76 } |
| 73 | 77 |
| 74 String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex ceptionState& es) | 78 String TextDecoder::decode(ArrayBufferView* input, const Dictionary& options, Ex ceptionState& es) |
| 75 { | 79 { |
| 76 bool stream = false; | 80 bool stream = false; |
| 77 options.get("stream", stream); | 81 options.get("stream", stream); |
| 78 | 82 |
| 79 const char* start = input ? static_cast<const char*>(input->baseAddress()) : 0; | 83 const char* start = input ? static_cast<const char*>(input->baseAddress()) : 0; |
| 80 size_t length = input ? input->byteLength() : 0; | 84 size_t length = input ? input->byteLength() : 0; |
| 81 | 85 |
| 82 bool flush = !stream; | 86 bool flush = !stream; |
| 83 | 87 |
| 84 // FIXME: Not all TextCodec implementations handle |flush| - notably TextCod ecUTF16 | 88 // FIXME: Not all TextCodec implementations handle |flush| - notably TextCod ecUTF16 |
| 85 // ignores it and never flushes! | 89 // ignores it and never flushes! |
| 86 | 90 |
| 87 bool sawError = false; | 91 bool sawError = false; |
| 88 String s = m_codec->decode(start, length, flush, m_fatal, sawError); | 92 String s = m_codec->decode(start, length, flush, m_fatal, sawError); |
| 89 | 93 |
| 90 if (m_fatal && sawError) { | 94 if (m_fatal && sawError) { |
| 91 es.throwDOMException(EncodingError, "The encoded data was not valid."); | 95 es.throwDOMException(EncodingError, "The encoded data was not valid."); |
| 92 return String(); | 96 return String(); |
| 93 } | 97 } |
| 94 | 98 |
| 95 return s; | 99 return s; |
| 96 } | 100 } |
| 97 | 101 |
| 98 } // namespace WebCore | 102 } // namespace WebCore |
| OLD | NEW |