summaryrefslogtreecommitdiff
path: root/src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h')
-rw-r--r--src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h b/src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h
index 8bbe85e3c4..fb755c9664 100644
--- a/src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h
+++ b/src/3rdparty/webkit/WebCore/loader/TextResourceDecoder.h
@@ -23,7 +23,7 @@
#ifndef TextResourceDecoder_h
#define TextResourceDecoder_h
-#include "TextDecoder.h"
+#include "TextEncoding.h"
namespace WebCore {
@@ -36,43 +36,59 @@ public:
EncodingFromMetaTag,
EncodingFromCSSCharset,
EncodingFromHTTPHeader,
- UserChosenEncoding
+ UserChosenEncoding,
+ EncodingFromParentFrame
};
- static PassRefPtr<TextResourceDecoder> create(const String& mimeType, const TextEncoding& defaultEncoding = TextEncoding())
+ static PassRefPtr<TextResourceDecoder> create(const String& mimeType, const TextEncoding& defaultEncoding = TextEncoding(), bool usesEncodingDetector = false)
{
- return adoptRef(new TextResourceDecoder(mimeType, defaultEncoding));
+ return adoptRef(new TextResourceDecoder(mimeType, defaultEncoding, usesEncodingDetector));
}
~TextResourceDecoder();
void setEncoding(const TextEncoding&, EncodingSource);
- const TextEncoding& encoding() const { return m_decoder.encoding(); }
+ const TextEncoding& encoding() const { return m_encoding; }
String decode(const char* data, size_t length);
String flush();
-
+
+ void setHintEncoding(const TextResourceDecoder* hintDecoder)
+ {
+ // hintEncoding is for use with autodetection, which should be
+ // only invoked when hintEncoding comes from auto-detection.
+ if (hintDecoder && hintDecoder->m_source == AutoDetectedEncoding)
+ m_hintEncoding = hintDecoder->encoding().name();
+ }
+
+ void useLenientXMLDecoding() { m_useLenientXMLDecoding = true; }
bool sawError() const { return m_sawError; }
private:
- TextResourceDecoder(const String& mimeType, const TextEncoding& defaultEncoding);
+ TextResourceDecoder(const String& mimeType, const TextEncoding& defaultEncoding,
+ bool usesEncodingDetector);
- enum ContentType { PlainText, HTML, XML, CSS }; // PlainText is equivalent to directly using TextDecoder.
+ enum ContentType { PlainText, HTML, XML, CSS }; // PlainText only checks for BOM.
static ContentType determineContentType(const String& mimeType);
static const TextEncoding& defaultEncoding(ContentType, const TextEncoding& defaultEncoding);
- void checkForBOM(const char*, size_t);
+ size_t checkForBOM(const char*, size_t);
bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer);
bool checkForHeadCharset(const char*, size_t, bool& movedDataToBuffer);
void detectJapaneseEncoding(const char*, size_t);
+ bool shouldAutoDetect() const;
ContentType m_contentType;
- TextDecoder m_decoder;
+ TextEncoding m_encoding;
+ OwnPtr<TextCodec> m_codec;
EncodingSource m_source;
+ const char* m_hintEncoding;
Vector<char> m_buffer;
bool m_checkedForBOM;
bool m_checkedForCSSCharset;
bool m_checkedForHeadCharset;
+ bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors.
bool m_sawError;
+ bool m_usesEncodingDetector;
};
}