| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 void BackgroundHTMLParser::pumpTokenizer() | 217 void BackgroundHTMLParser::pumpTokenizer() |
| 218 { | 218 { |
| 219 HTMLTreeBuilderSimulator::SimulatedToken simulatedToken = HTMLTreeBuilderSim
ulator::OtherToken; | 219 HTMLTreeBuilderSimulator::SimulatedToken simulatedToken = HTMLTreeBuilderSim
ulator::OtherToken; |
| 220 | 220 |
| 221 // No need to start speculating until the main thread has almost caught up. | 221 // No need to start speculating until the main thread has almost caught up. |
| 222 if (m_input.totalCheckpointTokenCount() > m_outstandingTokenLimit) | 222 if (m_input.totalCheckpointTokenCount() > m_outstandingTokenLimit) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 while (true) { | 225 while (true) { |
| 226 m_sourceTracker.start(m_input.current(), m_tokenizer.get(), *m_token); | 226 if (m_xssAuditor->isEnabled()) |
| 227 m_sourceTracker.start(m_input.current(), m_tokenizer.get(), *m_token
); |
| 228 |
| 227 if (!m_tokenizer->nextToken(m_input.current(), *m_token)) { | 229 if (!m_tokenizer->nextToken(m_input.current(), *m_token)) { |
| 228 // We've reached the end of our current input. | 230 // We've reached the end of our current input. |
| 229 sendTokensToMainThread(); | 231 sendTokensToMainThread(); |
| 230 break; | 232 break; |
| 231 } | 233 } |
| 232 m_sourceTracker.end(m_input.current(), m_tokenizer.get(), *m_token); | 234 |
| 235 if (m_xssAuditor->isEnabled()) |
| 236 m_sourceTracker.end(m_input.current(), m_tokenizer.get(), *m_token); |
| 233 | 237 |
| 234 { | 238 { |
| 235 TextPosition position = TextPosition(m_input.current().currentLine()
, m_input.current().currentColumn()); | 239 TextPosition position = TextPosition(m_input.current().currentLine()
, m_input.current().currentColumn()); |
| 236 | 240 |
| 237 if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenR
equest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { | 241 if (OwnPtr<XSSInfo> xssInfo = m_xssAuditor->filterToken(FilterTokenR
equest(*m_token, m_sourceTracker, m_tokenizer->shouldAllowCDATA()))) { |
| 238 xssInfo->m_textPosition = position; | 242 xssInfo->m_textPosition = position; |
| 239 m_pendingXSSInfos.append(xssInfo.release()); | 243 m_pendingXSSInfos.append(xssInfo.release()); |
| 240 } | 244 } |
| 241 | 245 |
| 242 CompactHTMLToken token(m_token.get(), TextPosition(m_input.current()
.currentLine(), m_input.current().currentColumn())); | 246 CompactHTMLToken token(m_token.get(), position); |
| 243 | 247 |
| 244 m_preloadScanner->scan(token, m_input.current(), m_pendingPreloads); | 248 m_preloadScanner->scan(token, m_input.current(), m_pendingPreloads); |
| 245 simulatedToken = m_treeBuilderSimulator.simulate(token, m_tokenizer.
get()); | 249 simulatedToken = m_treeBuilderSimulator.simulate(token, m_tokenizer.
get()); |
| 246 | 250 |
| 247 // Break chunks before a script tag is inserted and flag the chunk a
s starting a script | 251 // Break chunks before a script tag is inserted and flag the chunk a
s starting a script |
| 248 // so the main parser can decide if it should yield before processin
g the chunk. | 252 // so the main parser can decide if it should yield before processin
g the chunk. |
| 249 if (simulatedToken == HTMLTreeBuilderSimulator::ScriptStart) { | 253 if (simulatedToken == HTMLTreeBuilderSimulator::ScriptStart) { |
| 250 sendTokensToMainThread(); | 254 sendTokensToMainThread(); |
| 251 m_startingScript = true; | 255 m_startingScript = true; |
| 252 } | 256 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 m_startingScript = false; | 292 m_startingScript = false; |
| 289 | 293 |
| 290 m_scheduler->postLoadingTask( | 294 m_scheduler->postLoadingTask( |
| 291 FROM_HERE, | 295 FROM_HERE, |
| 292 new Task(threadSafeBind(&HTMLDocumentParser::didReceiveParsedChunkFromBa
ckgroundParser, AllowCrossThreadAccess(m_parser), chunk.release()))); | 296 new Task(threadSafeBind(&HTMLDocumentParser::didReceiveParsedChunkFromBa
ckgroundParser, AllowCrossThreadAccess(m_parser), chunk.release()))); |
| 293 | 297 |
| 294 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); | 298 m_pendingTokens = adoptPtr(new CompactHTMLTokenStream); |
| 295 } | 299 } |
| 296 | 300 |
| 297 } | 301 } |
| OLD | NEW |