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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 m_parserBlockingScript = requestPendingScript(element); | 547 m_parserBlockingScript = requestPendingScript(element); |
548 if (!parserBlockingScript()) | 548 if (!parserBlockingScript()) |
549 return; | 549 return; |
550 | 550 |
551 DCHECK(parserBlockingScript()->resource()); | 551 DCHECK(parserBlockingScript()->resource()); |
552 | 552 |
553 // We only care about a load callback if resource is not already in the cache. | 553 // We only care about a load callback if resource is not already in the cache. |
554 // Callers will attempt to run the m_parserBlockingScript if possible before | 554 // Callers will attempt to run the m_parserBlockingScript if possible before |
555 // returning control to the parser. | 555 // returning control to the parser. |
556 if (!parserBlockingScript()->isReady()) { | 556 if (!parserBlockingScript()->isReady()) { |
557 if (m_document->frame()) { | 557 m_parserBlockingScript->startStreamingIfPossible( |
558 ScriptState* scriptState = toScriptStateForMainWorld(m_document->frame()); | 558 m_document, ScriptStreamer::ParsingBlocking); |
559 if (scriptState) { | |
560 ScriptStreamer::startStreaming( | |
561 m_parserBlockingScript, ScriptStreamer::ParsingBlocking, | |
562 m_document->frame()->settings(), scriptState, | |
563 TaskRunnerHelper::get(TaskType::Networking, m_document)); | |
564 } | |
565 } | |
566 | |
567 m_parserBlockingScript->watchForLoad(this); | 559 m_parserBlockingScript->watchForLoad(this); |
568 } | 560 } |
569 } | 561 } |
570 | 562 |
571 // 1st Clause, Step 23 of https://html.spec.whatwg.org/#prepare-a-script | 563 // 1st Clause, Step 23 of https://html.spec.whatwg.org/#prepare-a-script |
572 void HTMLParserScriptRunner::requestDeferredScript(Element* element) { | 564 void HTMLParserScriptRunner::requestDeferredScript(Element* element) { |
573 PendingScript* pendingScript = requestPendingScript(element); | 565 PendingScript* pendingScript = requestPendingScript(element); |
574 if (!pendingScript) | 566 if (!pendingScript) |
575 return; | 567 return; |
576 | 568 |
577 if (m_document->frame() && !pendingScript->isReady()) { | 569 if (!pendingScript->isReady()) { |
578 ScriptState* scriptState = toScriptStateForMainWorld(m_document->frame()); | 570 pendingScript->startStreamingIfPossible(m_document, |
579 if (scriptState) { | 571 ScriptStreamer::Deferred); |
580 ScriptStreamer::startStreaming( | |
581 pendingScript, ScriptStreamer::Deferred, | |
582 m_document->frame()->settings(), scriptState, | |
583 TaskRunnerHelper::get(TaskType::Networking, m_document)); | |
584 } | |
585 } | 572 } |
586 | 573 |
587 DCHECK(pendingScript->resource()); | 574 DCHECK(pendingScript->resource()); |
588 | 575 |
589 // "Add the element to the end of the list of scripts that will execute | 576 // "Add the element to the end of the list of scripts that will execute |
590 // when the document has finished parsing associated with the Document | 577 // when the document has finished parsing associated with the Document |
591 // of the parser that created the element." | 578 // of the parser that created the element." |
592 m_scriptsToExecuteAfterParsing.push_back(pendingScript); | 579 m_scriptsToExecuteAfterParsing.push_back(pendingScript); |
593 } | 580 } |
594 | 581 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 | 678 |
692 DEFINE_TRACE(HTMLParserScriptRunner) { | 679 DEFINE_TRACE(HTMLParserScriptRunner) { |
693 visitor->trace(m_document); | 680 visitor->trace(m_document); |
694 visitor->trace(m_host); | 681 visitor->trace(m_host); |
695 visitor->trace(m_parserBlockingScript); | 682 visitor->trace(m_parserBlockingScript); |
696 visitor->trace(m_scriptsToExecuteAfterParsing); | 683 visitor->trace(m_scriptsToExecuteAfterParsing); |
697 PendingScriptClient::trace(visitor); | 684 PendingScriptClient::trace(visitor); |
698 } | 685 } |
699 | 686 |
700 } // namespace blink | 687 } // namespace blink |
OLD | NEW |