| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 3 Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 4 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | 4 Copyright (C) 2006, 2008 Apple Inc. All rights reserved. |
| 5 | 5 |
| 6 This library is free software; you can redistribute it and/or | 6 This library is free software; you can redistribute it and/or |
| 7 modify it under the terms of the GNU Library General Public | 7 modify it under the terms of the GNU Library General Public |
| 8 License as published by the Free Software Foundation; either | 8 License as published by the Free Software Foundation; either |
| 9 version 2 of the License, or (at your option) any later version. | 9 version 2 of the License, or (at your option) any later version. |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef TextResourceDecoder_h | 23 #ifndef TextResourceDecoder_h |
| 24 #define TextResourceDecoder_h | 24 #define TextResourceDecoder_h |
| 25 | 25 |
| 26 #include "wtf/RefCounted.h" | 26 #include "wtf/RefCounted.h" |
| 27 #include "wtf/text/TextEncoding.h" | 27 #include "wtf/text/TextEncoding.h" |
| 28 | 28 |
| 29 namespace WebCore { | 29 namespace WebCore { |
| 30 | 30 |
| 31 class DocumentEncodingData; | |
| 32 class HTMLMetaCharsetParser; | 31 class HTMLMetaCharsetParser; |
| 33 | 32 |
| 34 class TextResourceDecoder { | 33 class TextResourceDecoder { |
| 35 public: | 34 public: |
| 36 enum EncodingSource { | 35 enum EncodingSource { |
| 37 DefaultEncoding, | 36 DefaultEncoding, |
| 38 AutoDetectedEncoding, | 37 AutoDetectedEncoding, |
| 39 EncodingFromContentSniffing, | 38 EncodingFromContentSniffing, |
| 40 EncodingFromXMLHeader, | 39 EncodingFromXMLHeader, |
| 41 EncodingFromMetaTag, | 40 EncodingFromMetaTag, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 66 { | 65 { |
| 67 m_hintEncoding = encoding.name(); | 66 m_hintEncoding = encoding.name(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void useLenientXMLDecoding() { m_useLenientXMLDecoding = true; } | 69 void useLenientXMLDecoding() { m_useLenientXMLDecoding = true; } |
| 71 bool sawError() const { return m_sawError; } | 70 bool sawError() const { return m_sawError; } |
| 72 | 71 |
| 73 private: | 72 private: |
| 74 TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& default
Encoding, bool usesEncodingDetector); | 73 TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& default
Encoding, bool usesEncodingDetector); |
| 75 | 74 |
| 76 enum ContentType { PlainTextContent, HTMLContent, XMLContent, CSSContent };
// PlainText only checks for BOM. | 75 enum ContentType { PlainText, HTML, XML, CSS }; // PlainText only checks for
BOM. |
| 77 static ContentType determineContentType(const String& mimeType); | 76 static ContentType determineContentType(const String& mimeType); |
| 78 static const WTF::TextEncoding& defaultEncoding(ContentType, const WTF::Text
Encoding& defaultEncoding); | 77 static const WTF::TextEncoding& defaultEncoding(ContentType, const WTF::Text
Encoding& defaultEncoding); |
| 79 | 78 |
| 80 size_t checkForBOM(const char*, size_t); | 79 size_t checkForBOM(const char*, size_t); |
| 81 bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer); | 80 bool checkForCSSCharset(const char*, size_t, bool& movedDataToBuffer); |
| 82 bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer); | 81 bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer); |
| 83 void checkForMetaCharset(const char*, size_t); | 82 void checkForMetaCharset(const char*, size_t); |
| 84 void detectJapaneseEncoding(const char*, size_t); | 83 void detectJapaneseEncoding(const char*, size_t); |
| 85 bool shouldAutoDetect() const; | 84 bool shouldAutoDetect() const; |
| 86 | 85 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors. | 96 bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors. |
| 98 bool m_sawError; | 97 bool m_sawError; |
| 99 bool m_usesEncodingDetector; | 98 bool m_usesEncodingDetector; |
| 100 | 99 |
| 101 OwnPtr<HTMLMetaCharsetParser> m_charsetParser; | 100 OwnPtr<HTMLMetaCharsetParser> m_charsetParser; |
| 102 }; | 101 }; |
| 103 | 102 |
| 104 } | 103 } |
| 105 | 104 |
| 106 #endif | 105 #endif |
| OLD | NEW |