Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
| diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
| index 49897d7c3ac409bd860dbaf44bbc4786a39ad3b4..6881b2ab106473377b9ed92399c3fcf896287f47 100644 |
| --- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
| +++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp |
| @@ -406,6 +406,8 @@ String TextResourceDecoder::decode(const char* data, size_t len) |
| WTF::TextEncoding detectedEncoding; |
| if (detectTextEncoding(data, len, m_hintEncoding, &detectedEncoding)) |
| setEncoding(detectedEncoding, EncodingFromContentSniffing); |
| + } else if ((m_source == DefaultEncoding || (m_source == EncodingFromParentFrame && m_hintEncoding)) && isUTF8Encoded(data, len)) { |
|
aelias_OOO_until_Jul13
2016/02/24 04:37:53
This if statement is duplicative with the other an
Jinsuk Kim
2016/02/24 06:54:54
Done.
|
| + setEncoding(UTF8Encoding(), EncodingFromContentSniffing); |
| } |
| ASSERT(m_encoding.isValid()); |
| @@ -424,11 +426,15 @@ String TextResourceDecoder::flush() |
| // If we can not identify the encoding even after a document is completely |
| // loaded, we need to detect the encoding if other conditions for |
| // autodetection is satisfied. |
| - if (m_buffer.size() && shouldAutoDetect() |
| + if (m_buffer.size() |
| && ((!m_checkedForXMLCharset && (m_contentType == HTMLContent || m_contentType == XMLContent)) || (!m_checkedForCSSCharset && (m_contentType == CSSContent)))) { |
| - WTF::TextEncoding detectedEncoding; |
| - if (detectTextEncoding(m_buffer.data(), m_buffer.size(), m_hintEncoding, &detectedEncoding)) |
| - setEncoding(detectedEncoding, EncodingFromContentSniffing); |
| + if (shouldAutoDetect()) { |
| + WTF::TextEncoding detectedEncoding; |
| + if (detectTextEncoding(m_buffer.data(), m_buffer.size(), m_hintEncoding, &detectedEncoding)) |
| + setEncoding(detectedEncoding, EncodingFromContentSniffing); |
| + } else if ((m_source == DefaultEncoding || (m_source == EncodingFromParentFrame && m_hintEncoding)) && isUTF8Encoded(m_buffer.data(), m_buffer.size())) { |
| + setEncoding(UTF8Encoding(), EncodingFromContentSniffing); |
| + } |
| } |
| if (!m_codec) |