| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
| 4 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 default: | 94 default: |
| 95 return false; | 95 return false; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 #define HTML_BEGIN_STATE(stateName) BEGIN_STATE(HTMLTokenizer, stateName) | 99 #define HTML_BEGIN_STATE(stateName) BEGIN_STATE(HTMLTokenizer, stateName) |
| 100 #define HTML_RECONSUME_IN(stateName) RECONSUME_IN(HTMLTokenizer, stateName) | 100 #define HTML_RECONSUME_IN(stateName) RECONSUME_IN(HTMLTokenizer, stateName) |
| 101 #define HTML_ADVANCE_TO(stateName) ADVANCE_TO(HTMLTokenizer, stateName) | 101 #define HTML_ADVANCE_TO(stateName) ADVANCE_TO(HTMLTokenizer, stateName) |
| 102 #define HTML_SWITCH_TO(stateName) SWITCH_TO(HTMLTokenizer, stateName) | 102 #define HTML_SWITCH_TO(stateName) SWITCH_TO(HTMLTokenizer, stateName) |
| 103 | 103 |
| 104 HTMLTokenizer::HTMLTokenizer(const HTMLParserOptions& options) | 104 HTMLTokenizer::HTMLTokenizer() |
| 105 : m_inputStreamPreprocessor(this) | 105 : m_inputStreamPreprocessor(this) |
| 106 , m_options(options) | |
| 107 { | 106 { |
| 108 reset(); | 107 reset(); |
| 109 } | 108 } |
| 110 | 109 |
| 111 HTMLTokenizer::~HTMLTokenizer() | 110 HTMLTokenizer::~HTMLTokenizer() |
| 112 { | 111 { |
| 113 } | 112 } |
| 114 | 113 |
| 115 void HTMLTokenizer::reset() | 114 void HTMLTokenizer::reset() |
| 116 { | 115 { |
| 117 m_state = HTMLTokenizer::DataState; | 116 m_state = HTMLTokenizer::DataState; |
| 118 m_token = 0; | 117 m_token = 0; |
| 119 m_additionalAllowedCharacter = '\0'; | 118 m_additionalAllowedCharacter = '\0'; |
| 120 } | 119 } |
| 121 | 120 |
| 122 bool HTMLTokenizer::canCreateCheckpoint() const | |
| 123 { | |
| 124 if (!m_appropriateEndTagName.isEmpty()) | |
| 125 return false; | |
| 126 if (!m_temporaryBuffer.isEmpty()) | |
| 127 return false; | |
| 128 if (!m_bufferedEndTagName.isEmpty()) | |
| 129 return false; | |
| 130 return true; | |
| 131 } | |
| 132 | |
| 133 void HTMLTokenizer::createCheckpoint(Checkpoint& result) const | |
| 134 { | |
| 135 ASSERT(canCreateCheckpoint()); | |
| 136 result.options = m_options; | |
| 137 result.state = m_state; | |
| 138 result.additionalAllowedCharacter = m_additionalAllowedCharacter; | |
| 139 result.skipNextNewLine = m_inputStreamPreprocessor.skipNextNewLine(); | |
| 140 } | |
| 141 | |
| 142 void HTMLTokenizer::restoreFromCheckpoint(const Checkpoint& checkpoint) | |
| 143 { | |
| 144 m_token = 0; | |
| 145 m_options = checkpoint.options; | |
| 146 m_state = checkpoint.state; | |
| 147 m_additionalAllowedCharacter = checkpoint.additionalAllowedCharacter; | |
| 148 m_inputStreamPreprocessor.reset(checkpoint.skipNextNewLine); | |
| 149 } | |
| 150 | |
| 151 inline bool HTMLTokenizer::processEntity(SegmentedString& source) | 121 inline bool HTMLTokenizer::processEntity(SegmentedString& source) |
| 152 { | 122 { |
| 153 bool notEnoughCharacters = false; | 123 bool notEnoughCharacters = false; |
| 154 DecodedHTMLEntity decodedEntity; | 124 DecodedHTMLEntity decodedEntity; |
| 155 bool success = consumeHTMLEntity(source, decodedEntity, notEnoughCharacters)
; | 125 bool success = consumeHTMLEntity(source, decodedEntity, notEnoughCharacters)
; |
| 156 if (notEnoughCharacters) | 126 if (notEnoughCharacters) |
| 157 return false; | 127 return false; |
| 158 if (!success) { | 128 if (!success) { |
| 159 ASSERT(decodedEntity.isEmpty()); | 129 ASSERT(decodedEntity.isEmpty()); |
| 160 bufferCharacter('&'); | 130 bufferCharacter('&'); |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1121 |
| 1152 return true; | 1122 return true; |
| 1153 } | 1123 } |
| 1154 | 1124 |
| 1155 inline void HTMLTokenizer::parseError() | 1125 inline void HTMLTokenizer::parseError() |
| 1156 { | 1126 { |
| 1157 notImplemented(); | 1127 notImplemented(); |
| 1158 } | 1128 } |
| 1159 | 1129 |
| 1160 } | 1130 } |
| OLD | NEW |