| 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 16 matching lines...) Expand all Loading... |
| 27 #define HTMLMetaCharsetParser_h | 27 #define HTMLMetaCharsetParser_h |
| 28 | 28 |
| 29 #include "core/html/parser/HTMLToken.h" | 29 #include "core/html/parser/HTMLToken.h" |
| 30 #include "platform/text/SegmentedString.h" | 30 #include "platform/text/SegmentedString.h" |
| 31 #include "wtf/Noncopyable.h" | 31 #include "wtf/Noncopyable.h" |
| 32 #include "wtf/text/TextCodec.h" | 32 #include "wtf/text/TextCodec.h" |
| 33 #include "wtf/text/TextEncoding.h" | 33 #include "wtf/text/TextEncoding.h" |
| 34 | 34 |
| 35 namespace WebCore { | 35 namespace WebCore { |
| 36 | 36 |
| 37 class HTMLIdentifier; |
| 37 class HTMLTokenizer; | 38 class HTMLTokenizer; |
| 38 | 39 |
| 39 class HTMLMetaCharsetParser { | 40 class HTMLMetaCharsetParser { |
| 40 WTF_MAKE_NONCOPYABLE(HTMLMetaCharsetParser); WTF_MAKE_FAST_ALLOCATED; | 41 WTF_MAKE_NONCOPYABLE(HTMLMetaCharsetParser); WTF_MAKE_FAST_ALLOCATED; |
| 41 public: | 42 public: |
| 42 static PassOwnPtr<HTMLMetaCharsetParser> create() { return adoptPtr(new HTML
MetaCharsetParser()); } | 43 static PassOwnPtr<HTMLMetaCharsetParser> create() { return adoptPtr(new HTML
MetaCharsetParser()); } |
| 43 | 44 |
| 44 ~HTMLMetaCharsetParser(); | 45 ~HTMLMetaCharsetParser(); |
| 45 | 46 |
| 46 // Returns true if done checking, regardless whether an encoding is found. | 47 // Returns true if done checking, regardless whether an encoding is found. |
| 47 bool checkForMetaCharset(const char*, size_t); | 48 bool checkForMetaCharset(const char*, size_t); |
| 48 | 49 |
| 49 const WTF::TextEncoding& encoding() { return m_encoding; } | 50 const WTF::TextEncoding& encoding() { return m_encoding; } |
| 50 | 51 |
| 51 typedef Vector<pair<String, String> > AttributeList; | 52 typedef Vector<pair<HTMLIdentifier, String> > AttributeList; |
| 52 // The returned encoding might not be valid. | 53 // The returned encoding might not be valid. |
| 53 static WTF::TextEncoding encodingFromMetaAttributes(const AttributeList& | 54 static WTF::TextEncoding encodingFromMetaAttributes(const AttributeList& |
| 54 ); | 55 ); |
| 55 | 56 |
| 56 private: | 57 private: |
| 57 HTMLMetaCharsetParser(); | 58 HTMLMetaCharsetParser(); |
| 58 | 59 |
| 59 bool processMeta(); | 60 bool processMeta(); |
| 60 static String extractCharset(const String&); | 61 static String extractCharset(const String&); |
| 61 | 62 |
| 62 enum Mode { | 63 enum Mode { |
| 63 None, | 64 None, |
| 64 Charset, | 65 Charset, |
| 65 Pragma, | 66 Pragma, |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 OwnPtr<HTMLTokenizer> m_tokenizer; | 69 OwnPtr<HTMLTokenizer> m_tokenizer; |
| 69 OwnPtr<TextCodec> m_assumedCodec; | 70 OwnPtr<TextCodec> m_assumedCodec; |
| 70 SegmentedString m_input; | 71 SegmentedString m_input; |
| 71 HTMLToken m_token; | 72 HTMLToken m_token; |
| 72 bool m_inHeadSection; | 73 bool m_inHeadSection; |
| 73 | 74 |
| 74 bool m_doneChecking; | 75 bool m_doneChecking; |
| 75 WTF::TextEncoding m_encoding; | 76 WTF::TextEncoding m_encoding; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 } | 79 } |
| 79 #endif | 80 #endif |
| OLD | NEW |