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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 getTraceArgsForScriptElement(element, scriptStartPosition)); | 255 getTraceArgsForScriptElement(element, scriptStartPosition)); |
256 scriptLoader->dispatchErrorEvent(); | 256 scriptLoader->dispatchErrorEvent(); |
257 } else { | 257 } else { |
258 DCHECK(isExecutingScript()); | 258 DCHECK(isExecutingScript()); |
259 if (scriptParserBlockingTime > 0.0) { | 259 if (scriptParserBlockingTime > 0.0) { |
260 DocumentParserTiming::from(*m_document) | 260 DocumentParserTiming::from(*m_document) |
261 .recordParserBlockedOnScriptLoadDuration( | 261 .recordParserBlockedOnScriptLoadDuration( |
262 monotonicallyIncreasingTime() - scriptParserBlockingTime, | 262 monotonicallyIncreasingTime() - scriptParserBlockingTime, |
263 scriptLoader->wasCreatedDuringDocumentWrite()); | 263 scriptLoader->wasCreatedDuringDocumentWrite()); |
264 } | 264 } |
| 265 #if DCHECK_IS_ON() |
| 266 DCHECK(scriptLoader->isExternalScript()); |
| 267 #endif |
265 if (!doExecuteScript(element, sourceCode, scriptStartPosition)) { | 268 if (!doExecuteScript(element, sourceCode, scriptStartPosition)) { |
266 scriptLoader->dispatchErrorEvent(); | 269 scriptLoader->dispatchErrorEvent(); |
267 } else { | 270 } else { |
268 element->dispatchEvent(Event::create(EventTypeNames::load)); | 271 element->dispatchEvent(Event::create(EventTypeNames::load)); |
269 } | 272 } |
270 } | 273 } |
271 | 274 |
272 // 9. "Decrement the parser's script nesting level by one. | 275 // 9. "Decrement the parser's script nesting level by one. |
273 // If the parser's script nesting level is zero | 276 // If the parser's script nesting level is zero |
274 // (which it always should be at this point), | 277 // (which it always should be at this point), |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 // "Immediately execute the script block, | 653 // "Immediately execute the script block, |
651 // even if other scripts are already executing." | 654 // even if other scripts are already executing." |
652 // TODO(hiroshige): Merge the block into ScriptLoader::prepareScript(). | 655 // TODO(hiroshige): Merge the block into ScriptLoader::prepareScript(). |
653 DCHECK_GT(m_reentryPermit->scriptNestingLevel(), 1u); | 656 DCHECK_GT(m_reentryPermit->scriptNestingLevel(), 1u); |
654 if (m_parserBlockingScript) | 657 if (m_parserBlockingScript) |
655 m_parserBlockingScript->dispose(); | 658 m_parserBlockingScript->dispose(); |
656 m_parserBlockingScript = nullptr; | 659 m_parserBlockingScript = nullptr; |
657 ScriptSourceCode sourceCode(script->textContent(), | 660 ScriptSourceCode sourceCode(script->textContent(), |
658 documentURLForScriptExecution(m_document), | 661 documentURLForScriptExecution(m_document), |
659 scriptStartPosition); | 662 scriptStartPosition); |
| 663 #if DCHECK_IS_ON() |
| 664 DCHECK(!scriptLoader->isExternalScript()); |
| 665 #endif |
660 doExecuteScript(script, sourceCode, scriptStartPosition); | 666 doExecuteScript(script, sourceCode, scriptStartPosition); |
661 } | 667 } |
662 } else { | 668 } else { |
663 // 2nd Clause of Step 23. | 669 // 2nd Clause of Step 23. |
664 requestParsingBlockingScript(script); | 670 requestParsingBlockingScript(script); |
665 } | 671 } |
666 | 672 |
667 // "Decrement the parser's script nesting level by one. | 673 // "Decrement the parser's script nesting level by one. |
668 // If the parser's script nesting level is zero, then set the parser | 674 // If the parser's script nesting level is zero, then set the parser |
669 // pause flag to false." | 675 // pause flag to false." |
670 // Implemented by ~ScriptNestingLevelIncrementer(). | 676 // Implemented by ~ScriptNestingLevelIncrementer(). |
671 | 677 |
672 // "Let the insertion point have the value of the old insertion point." | 678 // "Let the insertion point have the value of the old insertion point." |
673 // Implemented by ~InsertionPointRecord(). | 679 // Implemented by ~InsertionPointRecord(). |
674 } | 680 } |
675 } | 681 } |
676 | 682 |
677 DEFINE_TRACE(HTMLParserScriptRunner) { | 683 DEFINE_TRACE(HTMLParserScriptRunner) { |
678 visitor->trace(m_document); | 684 visitor->trace(m_document); |
679 visitor->trace(m_host); | 685 visitor->trace(m_host); |
680 visitor->trace(m_parserBlockingScript); | 686 visitor->trace(m_parserBlockingScript); |
681 visitor->trace(m_scriptsToExecuteAfterParsing); | 687 visitor->trace(m_scriptsToExecuteAfterParsing); |
682 PendingScriptClient::trace(visitor); | 688 PendingScriptClient::trace(visitor); |
683 } | 689 } |
684 | 690 |
685 } // namespace blink | 691 } // namespace blink |
OLD | NEW |