| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return m_treeBuilder->isParsingFragment(); | 200 return m_treeBuilder->isParsingFragment(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool HTMLDocumentParser::processingData() const | 203 bool HTMLDocumentParser::processingData() const |
| 204 { | 204 { |
| 205 return isScheduledForResume() || inPumpSession() || m_haveBackgroundParser; | 205 return isScheduledForResume() || inPumpSession() || m_haveBackgroundParser; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode) | 208 void HTMLDocumentParser::pumpTokenizerIfPossible(SynchronousMode mode) |
| 209 { | 209 { |
| 210 if (isStopped() || isWaitingForScripts()) | 210 if (isStopped()) |
| 211 return; |
| 212 if (isWaitingForScripts()) |
| 211 return; | 213 return; |
| 212 | 214 |
| 213 // Once a resume is scheduled, HTMLParserScheduler controls when we next pum
p. | 215 // Once a resume is scheduled, HTMLParserScheduler controls when we next pum
p. |
| 214 if (isScheduledForResume()) { | 216 if (isScheduledForResume()) { |
| 215 ASSERT(mode == AllowYield); | 217 ASSERT(mode == AllowYield); |
| 216 return; | 218 return; |
| 217 } | 219 } |
| 218 | 220 |
| 219 pumpTokenizer(mode); | 221 pumpTokenizer(mode); |
| 220 } | 222 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 if (isWaitingForScripts()) { | 266 if (isWaitingForScripts()) { |
| 265 if (mode == AllowYield) | 267 if (mode == AllowYield) |
| 266 m_parserScheduler->checkForYieldBeforeScript(session); | 268 m_parserScheduler->checkForYieldBeforeScript(session); |
| 267 | 269 |
| 268 // If we don't run the script, we cannot allow the next token to be take
n. | 270 // If we don't run the script, we cannot allow the next token to be take
n. |
| 269 if (session.needsYield) | 271 if (session.needsYield) |
| 270 return false; | 272 return false; |
| 271 | 273 |
| 272 // If we're paused waiting for a script, we try to execute scripts befor
e continuing. | 274 // If we're paused waiting for a script, we try to execute scripts befor
e continuing. |
| 273 runScriptsForPausedTreeBuilder(); | 275 runScriptsForPausedTreeBuilder(); |
| 274 if (isWaitingForScripts() || isStopped()) | 276 if (isStopped()) |
| 277 return false; |
| 278 if (isWaitingForScripts()) |
| 275 return false; | 279 return false; |
| 276 } | 280 } |
| 277 | 281 |
| 278 // FIXME: It's wrong for the HTMLDocumentParser to reach back to the | 282 // FIXME: It's wrong for the HTMLDocumentParser to reach back to the |
| 279 // Frame, but this approach is how the old parser handled | 283 // Frame, but this approach is how the old parser handled |
| 280 // stopping when the page assigns window.location. What really | 284 // stopping when the page assigns window.location. What really |
| 281 // should happen is that assigning window.location causes the | 285 // should happen is that assigning window.location causes the |
| 282 // parser to stop parsing cleanly. The problem is we're not | 286 // parser to stop parsing cleanly. The problem is we're not |
| 283 // perpared to do that at every point where we run JavaScript. | 287 // perpared to do that at every point where we run JavaScript. |
| 284 if (!isParsingFragment() | 288 if (!isParsingFragment() |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 ASSERT(!isStopped()); | 458 ASSERT(!isStopped()); |
| 455 | 459 |
| 456 // FIXME: Pass in current input length. | 460 // FIXME: Pass in current input length. |
| 457 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteH
TML(document(), lineNumber().zeroBasedInt()); | 461 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willWriteH
TML(document(), lineNumber().zeroBasedInt()); |
| 458 | 462 |
| 459 double startTime = currentTime(); | 463 double startTime = currentTime(); |
| 460 | 464 |
| 461 while (!m_speculations.isEmpty()) { | 465 while (!m_speculations.isEmpty()) { |
| 462 processParsedChunkFromBackgroundParser(m_speculations.takeFirst()); | 466 processParsedChunkFromBackgroundParser(m_speculations.takeFirst()); |
| 463 | 467 |
| 464 if (isWaitingForScripts() || isStopped()) | 468 // The order matters! If this isStopped(), isWaitingForScripts() can hit
and ASSERT since |
| 469 // m_document can be null which is used to decide the readiness. |
| 470 if (isStopped()) |
| 471 break; |
| 472 if (isWaitingForScripts()) |
| 465 break; | 473 break; |
| 466 | 474 |
| 467 if (currentTime() - startTime > parserTimeLimit && !m_speculations.isEmp
ty()) { | 475 if (currentTime() - startTime > parserTimeLimit && !m_speculations.isEmp
ty()) { |
| 468 m_parserScheduler->scheduleForResume(); | 476 m_parserScheduler->scheduleForResume(); |
| 469 break; | 477 break; |
| 470 } | 478 } |
| 471 } | 479 } |
| 472 | 480 |
| 473 InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt()); | 481 InspectorInstrumentation::didWriteHTML(cookie, lineNumber().zeroBasedInt()); |
| 474 } | 482 } |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 m_parserScheduler->suspend(); | 948 m_parserScheduler->suspend(); |
| 941 } | 949 } |
| 942 | 950 |
| 943 void HTMLDocumentParser::resumeScheduledTasks() | 951 void HTMLDocumentParser::resumeScheduledTasks() |
| 944 { | 952 { |
| 945 if (m_parserScheduler) | 953 if (m_parserScheduler) |
| 946 m_parserScheduler->resume(); | 954 m_parserScheduler->resume(); |
| 947 } | 955 } |
| 948 | 956 |
| 949 } | 957 } |
| OLD | NEW |