| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 { | 106 { |
| 107 ASSERT(!m_input.isClosed()); | 107 ASSERT(!m_input.isClosed()); |
| 108 m_input.append(SegmentedString(String(&kEndOfFileMarker, 1))); | 108 m_input.append(SegmentedString(String(&kEndOfFileMarker, 1))); |
| 109 m_input.close(); | 109 m_input.close(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 bool BackgroundHTMLParser::updateTokenizerState(const CompactHTMLToken& token) | 112 bool BackgroundHTMLParser::updateTokenizerState(const CompactHTMLToken& token) |
| 113 { | 113 { |
| 114 if (token.type() == HTMLToken::StartTag) { | 114 if (token.type() == HTMLToken::StartTag) { |
| 115 const String& tagName = token.data(); | 115 const String& tagName = token.data(); |
| 116 // FIXME: This is just a copy of Tokenizer::updateStateFor which uses th
readSafeMatches. | 116 if (threadSafeMatch(tagName, HTMLNames::scriptTag) || threadSafeMatch(ta
gName, HTMLNames::styleTag)) |
| 117 if (threadSafeMatch(tagName, HTMLNames::scriptTag)) | |
| 118 m_tokenizer->setState(HTMLTokenizer::ScriptDataState); | |
| 119 else if (threadSafeMatch(tagName, HTMLNames::styleTag)) | |
| 120 m_tokenizer->setState(HTMLTokenizer::RAWTEXTState); | 117 m_tokenizer->setState(HTMLTokenizer::RAWTEXTState); |
| 121 } | 118 } |
| 122 | 119 |
| 123 if (token.type() == HTMLToken::EndTag) { | 120 return token.type() != HTMLToken::EndTag || !threadSafeMatch(token.data(), H
TMLNames::scriptTag); |
| 124 const String& tagName = token.data(); | |
| 125 if (threadSafeMatch(tagName, HTMLNames::scriptTag)) { | |
| 126 m_tokenizer->setState(HTMLTokenizer::DataState); | |
| 127 return false; | |
| 128 } | |
| 129 } | |
| 130 | |
| 131 return true; | |
| 132 } | 121 } |
| 133 | 122 |
| 134 void BackgroundHTMLParser::pumpTokenizer() | 123 void BackgroundHTMLParser::pumpTokenizer() |
| 135 { | 124 { |
| 136 while (true) { | 125 while (true) { |
| 137 if (!m_tokenizer->nextToken(m_input, *m_token)) { | 126 if (!m_tokenizer->nextToken(m_input, *m_token)) { |
| 138 // We've reached the end of our current input. | 127 // We've reached the end of our current input. |
| 139 sendTokensToMainThread(); | 128 sendTokensToMainThread(); |
| 140 break; | 129 break; |
| 141 } | 130 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 162 #endif | 151 #endif |
| 163 | 152 |
| 164 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); | 153 OwnPtr<HTMLDocumentParser::ParsedChunk> chunk = adoptPtr(new HTMLDocumentPar
ser::ParsedChunk); |
| 165 chunk->tokens = m_pendingTokens.release(); | 154 chunk->tokens = m_pendingTokens.release(); |
| 166 callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgrou
ndParser, m_parser, chunk.release())); | 155 callOnMainThread(bind(&HTMLDocumentParser::didReceiveParsedChunkFromBackgrou
ndParser, m_parser, chunk.release())); |
| 167 | 156 |
| 168 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 157 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 169 } | 158 } |
| 170 | 159 |
| 171 } | 160 } |
| OLD | NEW |