Chromium Code Reviews| Index: Source/core/dom/DecodedDataDocumentParser.cpp |
| diff --git a/Source/core/dom/DecodedDataDocumentParser.cpp b/Source/core/dom/DecodedDataDocumentParser.cpp |
| index 5450170442c19280cc284535fd7b65d94d262301..3d558f45233f0b3d72a4848fdc8844ea7ab50663 100644 |
| --- a/Source/core/dom/DecodedDataDocumentParser.cpp |
| +++ b/Source/core/dom/DecodedDataDocumentParser.cpp |
| @@ -85,6 +85,15 @@ DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document) |
| { |
| } |
| +DecodedDataDocumentParser::~DecodedDataDocumentParser() |
| +{ |
| +} |
| + |
| +void DecodedDataDocumentParser::setDecoder(PassRefPtr<TextResourceDecoder> decoder) |
| +{ |
| + m_decoder = decoder; |
| +} |
| + |
| size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length) |
| { |
| if (!length) |
| @@ -92,8 +101,12 @@ size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length) |
| TitleEncodingFixer encodingFixer(document()); |
| - String decoded = document()->decoder()->decode(data, length); |
| - document()->setEncoding(document()->decoder()->encoding()); |
| + String decoded = m_decoder->decode(data, length); |
| + Document::DocumentEncodingData encodingData; |
| + encodingData.encoding = m_decoder->encoding(); |
| + encodingData.wasDetectedHeuristically = m_decoder->encodingWasDetectedHeuristically(); |
| + encodingData.sawDecodingError = m_decoder->sawError(); |
| + document()->setEncoding(encodingData); |
|
abarth-chromium
2013/08/30 22:50:38
This happens for every call to appendBytes? We ca
|
| encodingFixer.fixTitleEncodingIfNeeded(); |
| @@ -110,11 +123,15 @@ size_t DecodedDataDocumentParser::flush() |
| { |
| // null decoder indicates there is no data received. |
| // We have nothing to do in that case. |
| - TextResourceDecoder* decoder = document()->decoder(); |
| - if (!decoder) |
| + if (!m_decoder) |
| return 0; |
| - String remainingData = decoder->flush(); |
| - document()->setEncoding(document()->decoder()->encoding()); |
| + String remainingData = m_decoder->flush(); |
| + Document::DocumentEncodingData encodingData; |
| + encodingData.encoding = m_decoder->encoding(); |
| + encodingData.wasDetectedHeuristically = m_decoder->encodingWasDetectedHeuristically(); |
| + encodingData.sawDecodingError = m_decoder->sawError(); |
| + document()->setEncoding(encodingData); |
|
abarth-chromium
2013/08/30 22:50:38
Copy/paste code makes me a sad panda.
|
| + |
| if (remainingData.isEmpty()) |
| return 0; |