| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 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 | 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 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "core/dom/DecodedDataDocumentParser.h" | 26 #include "core/dom/DecodedDataDocumentParser.h" |
| 27 | 27 |
| 28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 29 #include "core/dom/DocumentEncodingData.h" | 29 #include "core/dom/DocumentEncodingData.h" |
| 30 #include "core/html/parser/TextResourceDecoder.h" | 30 #include "core/html/parser/TextResourceDecoder.h" |
| 31 #include <memory> | |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 35 DecodedDataDocumentParser::DecodedDataDocumentParser(Document& document) | 34 DecodedDataDocumentParser::DecodedDataDocumentParser(Document& document) |
| 36 : DocumentParser(&document) | 35 : DocumentParser(&document) |
| 37 , m_needsDecoder(true) | 36 , m_needsDecoder(true) |
| 38 { | 37 { |
| 39 } | 38 } |
| 40 | 39 |
| 41 DecodedDataDocumentParser::~DecodedDataDocumentParser() | 40 DecodedDataDocumentParser::~DecodedDataDocumentParser() |
| 42 { | 41 { |
| 43 } | 42 } |
| 44 | 43 |
| 45 void DecodedDataDocumentParser::setDecoder(std::unique_ptr<TextResourceDecoder>
decoder) | 44 void DecodedDataDocumentParser::setDecoder(PassOwnPtr<TextResourceDecoder> decod
er) |
| 46 { | 45 { |
| 47 // If the decoder is explicitly unset rather than having ownership | 46 // If the decoder is explicitly unset rather than having ownership |
| 48 // transferred away by takeDecoder(), we need to make sure it's recreated | 47 // transferred away by takeDecoder(), we need to make sure it's recreated |
| 49 // next time data is appended. | 48 // next time data is appended. |
| 50 m_needsDecoder = !decoder; | 49 m_needsDecoder = !decoder; |
| 51 m_decoder = std::move(decoder); | 50 m_decoder = std::move(decoder); |
| 52 } | 51 } |
| 53 | 52 |
| 54 TextResourceDecoder* DecodedDataDocumentParser::decoder() | 53 TextResourceDecoder* DecodedDataDocumentParser::decoder() |
| 55 { | 54 { |
| 56 return m_decoder.get(); | 55 return m_decoder.get(); |
| 57 } | 56 } |
| 58 | 57 |
| 59 std::unique_ptr<TextResourceDecoder> DecodedDataDocumentParser::takeDecoder() | 58 PassOwnPtr<TextResourceDecoder> DecodedDataDocumentParser::takeDecoder() |
| 60 { | 59 { |
| 61 return std::move(m_decoder); | 60 return std::move(m_decoder); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void DecodedDataDocumentParser::appendBytes(const char* data, size_t length) | 63 void DecodedDataDocumentParser::appendBytes(const char* data, size_t length) |
| 65 { | 64 { |
| 66 if (!length) | 65 if (!length) |
| 67 return; | 66 return; |
| 68 | 67 |
| 69 // This should be checking isStopped(), but XMLDocumentParser prematurely | 68 // This should be checking isStopped(), but XMLDocumentParser prematurely |
| (...skipping 25 matching lines...) Expand all Loading... |
| 95 | 94 |
| 96 void DecodedDataDocumentParser::updateDocument(String& decodedData) | 95 void DecodedDataDocumentParser::updateDocument(String& decodedData) |
| 97 { | 96 { |
| 98 document()->setEncodingData(DocumentEncodingData(*m_decoder.get())); | 97 document()->setEncodingData(DocumentEncodingData(*m_decoder.get())); |
| 99 | 98 |
| 100 if (!decodedData.isEmpty()) | 99 if (!decodedData.isEmpty()) |
| 101 append(decodedData); | 100 append(decodedData); |
| 102 } | 101 } |
| 103 | 102 |
| 104 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |