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