| 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 22 matching lines...) Expand all Loading... |
| 33 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" | 33 #include "core/dom/IgnoreDestructiveWriteCountIncrementer.h" |
| 34 #include "core/dom/Microtask.h" | 34 #include "core/dom/Microtask.h" |
| 35 #include "core/dom/ScriptLoader.h" | 35 #include "core/dom/ScriptLoader.h" |
| 36 #include "core/fetch/ScriptResource.h" | 36 #include "core/fetch/ScriptResource.h" |
| 37 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
| 38 #include "core/html/parser/HTMLInputStream.h" | 38 #include "core/html/parser/HTMLInputStream.h" |
| 39 #include "core/html/parser/HTMLScriptRunnerHost.h" | 39 #include "core/html/parser/HTMLScriptRunnerHost.h" |
| 40 #include "core/html/parser/NestingLevelIncrementer.h" | 40 #include "core/html/parser/NestingLevelIncrementer.h" |
| 41 #include "platform/NotImplemented.h" | 41 #include "platform/NotImplemented.h" |
| 42 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
| 43 #include "public/platform/WebFrameScheduler.h" |
| 43 | 44 |
| 44 namespace blink { | 45 namespace blink { |
| 45 | 46 |
| 46 using namespace HTMLNames; | 47 using namespace HTMLNames; |
| 47 | 48 |
| 48 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) | 49 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) |
| 49 : m_document(document) | 50 : m_document(document) |
| 50 , m_host(host) | 51 , m_host(host) |
| 51 , m_scriptNestingLevel(0) | 52 , m_scriptNestingLevel(0) |
| 52 , m_hasScriptsWaitingForResources(false) | 53 , m_hasScriptsWaitingForResources(false) |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 281 |
| 281 ASSERT(m_parserBlockingScript.resource()); | 282 ASSERT(m_parserBlockingScript.resource()); |
| 282 | 283 |
| 283 // We only care about a load callback if resource is not already | 284 // We only care about a load callback if resource is not already |
| 284 // in the cache. Callers will attempt to run the m_parserBlockingScript | 285 // in the cache. Callers will attempt to run the m_parserBlockingScript |
| 285 // if possible before returning control to the parser. | 286 // if possible before returning control to the parser. |
| 286 if (!m_parserBlockingScript.isReady()) { | 287 if (!m_parserBlockingScript.isReady()) { |
| 287 if (m_document->frame()) { | 288 if (m_document->frame()) { |
| 288 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra
me()); | 289 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra
me()); |
| 289 if (scriptState->contextIsValid()) | 290 if (scriptState->contextIsValid()) |
| 290 ScriptStreamer::startStreaming(m_parserBlockingScript, PendingSc
ript::ParsingBlocking, m_document->frame()->settings(), scriptState); | 291 ScriptStreamer::startStreaming(m_parserBlockingScript, PendingSc
ript::ParsingBlocking, m_document->frame()->settings(), scriptState, m_document-
>loadingTaskRunner()); |
| 291 } | 292 } |
| 292 | 293 |
| 293 m_parserBlockingScript.watchForLoad(this); | 294 m_parserBlockingScript.watchForLoad(this); |
| 294 } | 295 } |
| 295 } | 296 } |
| 296 | 297 |
| 297 void HTMLScriptRunner::requestDeferredScript(Element* element) | 298 void HTMLScriptRunner::requestDeferredScript(Element* element) |
| 298 { | 299 { |
| 299 PendingScript pendingScript; | 300 PendingScript pendingScript; |
| 300 if (!requestPendingScript(pendingScript, element)) | 301 if (!requestPendingScript(pendingScript, element)) |
| 301 return; | 302 return; |
| 302 | 303 |
| 303 if (m_document->frame() && !pendingScript.isReady()) { | 304 if (m_document->frame() && !pendingScript.isReady()) { |
| 304 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame()
); | 305 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame()
); |
| 305 if (scriptState->contextIsValid()) | 306 if (scriptState->contextIsValid()) |
| 306 ScriptStreamer::startStreaming(pendingScript, PendingScript::Deferre
d, m_document->frame()->settings(), scriptState); | 307 ScriptStreamer::startStreaming(pendingScript, PendingScript::Deferre
d, m_document->frame()->settings(), scriptState, m_document->loadingTaskRunner()
); |
| 307 } | 308 } |
| 308 | 309 |
| 309 ASSERT(pendingScript.resource()); | 310 ASSERT(pendingScript.resource()); |
| 310 m_scriptsToExecuteAfterParsing.append(pendingScript); | 311 m_scriptsToExecuteAfterParsing.append(pendingScript); |
| 311 } | 312 } |
| 312 | 313 |
| 313 bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen
t* script) const | 314 bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen
t* script) const |
| 314 { | 315 { |
| 315 ASSERT(!pendingScript.element()); | 316 ASSERT(!pendingScript.element()); |
| 316 pendingScript.setElement(script); | 317 pendingScript.setElement(script); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 373 |
| 373 DEFINE_TRACE(HTMLScriptRunner) | 374 DEFINE_TRACE(HTMLScriptRunner) |
| 374 { | 375 { |
| 375 visitor->trace(m_document); | 376 visitor->trace(m_document); |
| 376 visitor->trace(m_host); | 377 visitor->trace(m_host); |
| 377 visitor->trace(m_parserBlockingScript); | 378 visitor->trace(m_parserBlockingScript); |
| 378 visitor->trace(m_scriptsToExecuteAfterParsing); | 379 visitor->trace(m_scriptsToExecuteAfterParsing); |
| 379 } | 380 } |
| 380 | 381 |
| 381 } // namespace blink | 382 } // namespace blink |
| OLD | NEW |