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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 387 } |
388 | 388 |
389 bool HTMLDocumentParser::isWaitingForScripts() const | 389 bool HTMLDocumentParser::isWaitingForScripts() const |
390 { | 390 { |
391 return m_treeBuilder->hasParserBlockingScript() || m_scriptRunner || | 391 return m_treeBuilder->hasParserBlockingScript() || m_scriptRunner || |
392 !document()->haveImportsLoaded(); | 392 !document()->haveImportsLoaded(); |
393 } | 393 } |
394 | 394 |
395 void HTMLDocumentParser::resumeAfterWaitingForImports() | 395 void HTMLDocumentParser::resumeAfterWaitingForImports() |
396 { | 396 { |
397 RefPtr<HTMLDocumentParser> protect(this); | 397 if (isWaitingForScripts()) |
398 ASSERT(!isWaitingForScripts()); | 398 return; |
399 if (m_pendingChunks.isEmpty()) | 399 if (m_pendingChunks.isEmpty()) |
400 return; | 400 return; |
401 ASSERT(m_haveBackgroundParser); | 401 ASSERT(m_haveBackgroundParser); |
| 402 RefPtr<HTMLDocumentParser> protect(this); |
402 pumpPendingChunks(); | 403 pumpPendingChunks(); |
403 } | 404 } |
404 | 405 |
405 // HTMLScriptRunner has finished executing a script. | 406 // HTMLScriptRunner has finished executing a script. |
406 // Just call resumeAfterWaitingForImports since it happens to do what we need. | 407 // Just call resumeAfterWaitingForImports since it happens to do what we need. |
407 void HTMLDocumentParser::scriptExecutionCompleted() { | 408 void HTMLDocumentParser::scriptExecutionCompleted() { |
408 ASSERT(m_scriptRunner); | 409 ASSERT(m_scriptRunner); |
409 m_scriptRunner.clear(); | 410 m_scriptRunner.clear(); |
410 // To avoid re-entering the parser for synchronous scripts, we use a postTask. | 411 // To avoid re-entering the parser for synchronous scripts, we use a postTask. |
411 base::MessageLoop::current()->PostTask( | 412 base::MessageLoop::current()->PostTask( |
412 FROM_HERE, base::Bind(&HTMLDocumentParser::resumeAfterWaitingForImports, | 413 FROM_HERE, base::Bind(&HTMLDocumentParser::resumeAfterWaitingForImports, |
413 m_weakFactory.GetWeakPtr())); | 414 m_weakFactory.GetWeakPtr())); |
414 } | 415 } |
415 } | 416 } |
OLD | NEW |