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 30 matching lines...) Expand all Loading... |
41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
42 #include "public/platform/WebFrameScheduler.h" | 42 #include "public/platform/WebFrameScheduler.h" |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 using namespace HTMLNames; | 46 using namespace HTMLNames; |
47 | 47 |
48 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) | 48 HTMLScriptRunner::HTMLScriptRunner(Document* document, HTMLScriptRunnerHost* hos
t) |
49 : m_document(document) | 49 : m_document(document) |
50 , m_host(host) | 50 , m_host(host) |
| 51 , m_parserBlockingScript(PendingScript::create(nullptr, nullptr)) |
51 , m_scriptNestingLevel(0) | 52 , m_scriptNestingLevel(0) |
52 , m_hasScriptsWaitingForResources(false) | 53 , m_hasScriptsWaitingForResources(false) |
53 , m_parserBlockingScriptAlreadyLoaded(false) | 54 , m_parserBlockingScriptAlreadyLoaded(false) |
54 { | 55 { |
55 ASSERT(m_host); | 56 ASSERT(m_host); |
| 57 #if ENABLE(OILPAN) |
| 58 ThreadState::current()->registerPreFinalizer(this); |
| 59 #endif |
56 } | 60 } |
57 | 61 |
58 HTMLScriptRunner::~HTMLScriptRunner() | 62 HTMLScriptRunner::~HTMLScriptRunner() |
59 { | 63 { |
60 #if ENABLE(OILPAN) | |
61 // If the document is destructed without having explicitly | |
62 // detached the parser (and this script runner object), perform | |
63 // detach steps now. This will happen if the Document, the parser | |
64 // and this script runner object are swept out in the same GC. | |
65 detach(); | |
66 #else | |
67 // Verify that detach() has been called. | 64 // Verify that detach() has been called. |
68 ASSERT(!m_document); | 65 ASSERT(!m_document); |
69 #endif | |
70 } | 66 } |
71 | 67 |
72 void HTMLScriptRunner::detach() | 68 void HTMLScriptRunner::detach() |
73 { | 69 { |
74 if (!m_document) | 70 if (!m_document) |
75 return; | 71 return; |
76 | 72 |
77 m_parserBlockingScript.stopWatchingForLoad(this); | 73 m_parserBlockingScript->stopWatchingForLoad(this); |
78 m_parserBlockingScript.releaseElementAndClear(); | 74 m_parserBlockingScript->releaseElementAndClear(); |
79 | 75 |
80 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { | 76 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { |
81 PendingScript pendingScript = m_scriptsToExecuteAfterParsing.takeFirst()
; | 77 OwnPtrWillBeRawPtr<PendingScript> pendingScript = m_scriptsToExecuteAfte
rParsing.takeFirst(); |
82 pendingScript.stopWatchingForLoad(this); | 78 pendingScript->stopWatchingForLoad(this); |
83 pendingScript.releaseElementAndClear(); | 79 pendingScript->releaseElementAndClear(); |
84 } | 80 } |
85 m_document = nullptr; | 81 m_document = nullptr; |
86 } | 82 } |
87 | 83 |
88 static KURL documentURLForScriptExecution(Document* document) | 84 static KURL documentURLForScriptExecution(Document* document) |
89 { | 85 { |
90 if (!document) | 86 if (!document) |
91 return KURL(); | 87 return KURL(); |
92 | 88 |
93 if (!document->frame()) { | 89 if (!document->frame()) { |
94 if (document->importsController()) | 90 if (document->importsController()) |
95 return document->url(); | 91 return document->url(); |
96 return KURL(); | 92 return KURL(); |
97 } | 93 } |
98 | 94 |
99 // Use the URL of the currently active document for this frame. | 95 // Use the URL of the currently active document for this frame. |
100 return document->frame()->document()->url(); | 96 return document->frame()->document()->url(); |
101 } | 97 } |
102 | 98 |
103 inline PassRefPtrWillBeRawPtr<Event> createScriptLoadEvent() | 99 inline PassRefPtrWillBeRawPtr<Event> createScriptLoadEvent() |
104 { | 100 { |
105 return Event::create(EventTypeNames::load); | 101 return Event::create(EventTypeNames::load); |
106 } | 102 } |
107 | 103 |
108 bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script) | 104 bool HTMLScriptRunner::isPendingScriptReady(const PendingScript* script) |
109 { | 105 { |
110 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady(); | 106 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionReady(); |
111 if (m_hasScriptsWaitingForResources) | 107 if (m_hasScriptsWaitingForResources) |
112 return false; | 108 return false; |
113 return script.isReady(); | 109 return script->isReady(); |
114 } | 110 } |
115 | 111 |
116 void HTMLScriptRunner::executeParsingBlockingScript() | 112 void HTMLScriptRunner::executeParsingBlockingScript() |
117 { | 113 { |
118 ASSERT(m_document); | 114 ASSERT(m_document); |
119 ASSERT(!isExecutingScript()); | 115 ASSERT(!isExecutingScript()); |
120 ASSERT(m_document->isScriptExecutionReady()); | 116 ASSERT(m_document->isScriptExecutionReady()); |
121 ASSERT(isPendingScriptReady(m_parserBlockingScript)); | 117 ASSERT(isPendingScriptReady(m_parserBlockingScript.get())); |
122 | 118 |
123 InsertionPointRecord insertionPointRecord(m_host->inputStream()); | 119 InsertionPointRecord insertionPointRecord(m_host->inputStream()); |
124 executePendingScriptAndDispatchEvent(m_parserBlockingScript, PendingScript::
ParsingBlocking); | 120 executePendingScriptAndDispatchEvent(m_parserBlockingScript.get(), PendingSc
ript::ParsingBlocking); |
125 } | 121 } |
126 | 122 |
127 void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
ngScript, PendingScript::Type pendingScriptType) | 123 void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript* pendi
ngScript, PendingScript::Type pendingScriptType) |
128 { | 124 { |
129 bool errorOccurred = false; | 125 bool errorOccurred = false; |
130 double loadFinishTime = pendingScript.resource() && pendingScript.resource()
->url().protocolIsInHTTPFamily() ? pendingScript.resource()->loadFinishTime() :
0; | 126 double loadFinishTime = pendingScript->resource() && pendingScript->resource
()->url().protocolIsInHTTPFamily() ? pendingScript->resource()->loadFinishTime()
: 0; |
131 ScriptSourceCode sourceCode = pendingScript.getSource(documentURLForScriptEx
ecution(m_document), errorOccurred); | 127 ScriptSourceCode sourceCode = pendingScript->getSource(documentURLForScriptE
xecution(m_document), errorOccurred); |
132 | 128 |
133 // Stop watching loads before executeScript to prevent recursion if the scri
pt reloads itself. | 129 // Stop watching loads before executeScript to prevent recursion if the scri
pt reloads itself. |
134 pendingScript.stopWatchingForLoad(this); | 130 pendingScript->stopWatchingForLoad(this); |
135 | 131 |
136 if (!isExecutingScript()) { | 132 if (!isExecutingScript()) { |
137 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); | 133 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); |
138 if (pendingScriptType == PendingScript::ParsingBlocking) { | 134 if (pendingScriptType == PendingScript::ParsingBlocking) { |
139 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionRead
y(); | 135 m_hasScriptsWaitingForResources = !m_document->isScriptExecutionRead
y(); |
140 // The parser cannot be unblocked as a microtask requested another r
esource | 136 // The parser cannot be unblocked as a microtask requested another r
esource |
141 if (m_hasScriptsWaitingForResources) | 137 if (m_hasScriptsWaitingForResources) |
142 return; | 138 return; |
143 } | 139 } |
144 } | 140 } |
145 | 141 |
146 // Clear the pending script before possible rentrancy from executeScript() | 142 // Clear the pending script before possible rentrancy from executeScript() |
147 RefPtrWillBeRawPtr<Element> element = pendingScript.releaseElementAndClear()
; | 143 RefPtrWillBeRawPtr<Element> element = pendingScript->releaseElementAndClear(
); |
148 double compilationFinishTime = 0; | 144 double compilationFinishTime = 0; |
149 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) { | 145 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) { |
150 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); | 146 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
151 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); | 147 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); |
152 if (errorOccurred) | 148 if (errorOccurred) |
153 scriptLoader->dispatchErrorEvent(); | 149 scriptLoader->dispatchErrorEvent(); |
154 else { | 150 else { |
155 ASSERT(isExecutingScript()); | 151 ASSERT(isExecutingScript()); |
156 if (!scriptLoader->executeScript(sourceCode, &compilationFinishTime)
) { | 152 if (!scriptLoader->executeScript(sourceCode, &compilationFinishTime)
) { |
157 scriptLoader->dispatchErrorEvent(); | 153 scriptLoader->dispatchErrorEvent(); |
158 } else { | 154 } else { |
159 element->dispatchEvent(createScriptLoadEvent()); | 155 element->dispatchEvent(createScriptLoadEvent()); |
160 } | 156 } |
161 } | 157 } |
162 } | 158 } |
163 // The exact value doesn't matter; valid time stamps are much bigger than th
is value. | 159 // The exact value doesn't matter; valid time stamps are much bigger than th
is value. |
164 const double epsilon = 1; | 160 const double epsilon = 1; |
165 if (pendingScriptType == PendingScript::ParsingBlocking && !m_parserBlocking
ScriptAlreadyLoaded && compilationFinishTime > epsilon && loadFinishTime > epsil
on) { | 161 if (pendingScriptType == PendingScript::ParsingBlocking && !m_parserBlocking
ScriptAlreadyLoaded && compilationFinishTime > epsilon && loadFinishTime > epsil
on) { |
166 Platform::current()->histogramCustomCounts("WebCore.Scripts.ParsingBlock
ing.TimeBetweenLoadedAndCompiled", (compilationFinishTime - loadFinishTime) * 10
00, 0, 10000, 50); | 162 Platform::current()->histogramCustomCounts("WebCore.Scripts.ParsingBlock
ing.TimeBetweenLoadedAndCompiled", (compilationFinishTime - loadFinishTime) * 10
00, 0, 10000, 50); |
167 } | 163 } |
168 | 164 |
169 ASSERT(!isExecutingScript()); | 165 ASSERT(!isExecutingScript()); |
170 } | 166 } |
171 | 167 |
172 void HTMLScriptRunner::stopWatchingResourceForLoad(Resource* resource) | 168 void HTMLScriptRunner::stopWatchingResourceForLoad(Resource* resource) |
173 { | 169 { |
174 if (m_parserBlockingScript.resource() == resource) { | 170 if (m_parserBlockingScript->resource() == resource) { |
175 m_parserBlockingScript.stopWatchingForLoad(this); | 171 m_parserBlockingScript->stopWatchingForLoad(this); |
176 m_parserBlockingScript.releaseElementAndClear(); | 172 m_parserBlockingScript->releaseElementAndClear(); |
177 return; | 173 return; |
178 } | 174 } |
179 for (PendingScript& script : m_scriptsToExecuteAfterParsing) { | 175 for (auto& script : m_scriptsToExecuteAfterParsing) { |
180 if (script.resource() == resource) { | 176 if (script->resource() == resource) { |
181 script.stopWatchingForLoad(this); | 177 script->stopWatchingForLoad(this); |
182 script.releaseElementAndClear(); | 178 script->releaseElementAndClear(); |
183 return; | 179 return; |
184 } | 180 } |
185 } | 181 } |
186 } | 182 } |
187 | 183 |
188 void HTMLScriptRunner::notifyFinished(Resource* cachedResource) | 184 void HTMLScriptRunner::notifyFinished(Resource* cachedResource) |
189 { | 185 { |
190 // Handle cancellations of parser-blocking script loads without | 186 // Handle cancellations of parser-blocking script loads without |
191 // notifying the host (i.e., parser) if these were initiated by nested | 187 // notifying the host (i.e., parser) if these were initiated by nested |
192 // document.write()s. The cancellation may have been triggered by | 188 // document.write()s. The cancellation may have been triggered by |
(...skipping 25 matching lines...) Expand all Loading... |
218 return; // Unwind to the outermost HTMLScriptRunner::execute before
continuing parsing. | 214 return; // Unwind to the outermost HTMLScriptRunner::execute before
continuing parsing. |
219 // If preload scanner got created, it is missing the source after the cu
rrent insertion point. Append it and scan. | 215 // If preload scanner got created, it is missing the source after the cu
rrent insertion point. Append it and scan. |
220 if (!hadPreloadScanner && m_host->hasPreloadScanner()) | 216 if (!hadPreloadScanner && m_host->hasPreloadScanner()) |
221 m_host->appendCurrentInputStreamToPreloadScannerAndScan(); | 217 m_host->appendCurrentInputStreamToPreloadScannerAndScan(); |
222 executeParsingBlockingScripts(); | 218 executeParsingBlockingScripts(); |
223 } | 219 } |
224 } | 220 } |
225 | 221 |
226 bool HTMLScriptRunner::hasParserBlockingScript() const | 222 bool HTMLScriptRunner::hasParserBlockingScript() const |
227 { | 223 { |
228 return !!m_parserBlockingScript.element(); | 224 return !!m_parserBlockingScript->element(); |
229 } | 225 } |
230 | 226 |
231 void HTMLScriptRunner::executeParsingBlockingScripts() | 227 void HTMLScriptRunner::executeParsingBlockingScripts() |
232 { | 228 { |
233 while (hasParserBlockingScript() && isPendingScriptReady(m_parserBlockingScr
ipt)) | 229 while (hasParserBlockingScript() && isPendingScriptReady(m_parserBlockingScr
ipt.get())) |
234 executeParsingBlockingScript(); | 230 executeParsingBlockingScript(); |
235 } | 231 } |
236 | 232 |
237 void HTMLScriptRunner::executeScriptsWaitingForLoad(Resource* resource) | 233 void HTMLScriptRunner::executeScriptsWaitingForLoad(Resource* resource) |
238 { | 234 { |
239 ASSERT(!isExecutingScript()); | 235 ASSERT(!isExecutingScript()); |
240 ASSERT(hasParserBlockingScript()); | 236 ASSERT(hasParserBlockingScript()); |
241 ASSERT_UNUSED(resource, m_parserBlockingScript.resource() == resource); | 237 ASSERT_UNUSED(resource, m_parserBlockingScript->resource() == resource); |
242 ASSERT(m_parserBlockingScript.isReady()); | 238 ASSERT(m_parserBlockingScript->isReady()); |
243 executeParsingBlockingScripts(); | 239 executeParsingBlockingScripts(); |
244 } | 240 } |
245 | 241 |
246 void HTMLScriptRunner::executeScriptsWaitingForResources() | 242 void HTMLScriptRunner::executeScriptsWaitingForResources() |
247 { | 243 { |
248 ASSERT(m_document); | 244 ASSERT(m_document); |
249 // Callers should check hasScriptsWaitingForResources() before calling | 245 // Callers should check hasScriptsWaitingForResources() before calling |
250 // to prevent parser or script re-entry during </style> parsing. | 246 // to prevent parser or script re-entry during </style> parsing. |
251 ASSERT(hasScriptsWaitingForResources()); | 247 ASSERT(hasScriptsWaitingForResources()); |
252 ASSERT(!isExecutingScript()); | 248 ASSERT(!isExecutingScript()); |
253 ASSERT(m_document->isScriptExecutionReady()); | 249 ASSERT(m_document->isScriptExecutionReady()); |
254 executeParsingBlockingScripts(); | 250 executeParsingBlockingScripts(); |
255 } | 251 } |
256 | 252 |
257 bool HTMLScriptRunner::executeScriptsWaitingForParsing() | 253 bool HTMLScriptRunner::executeScriptsWaitingForParsing() |
258 { | 254 { |
259 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { | 255 while (!m_scriptsToExecuteAfterParsing.isEmpty()) { |
260 ASSERT(!isExecutingScript()); | 256 ASSERT(!isExecutingScript()); |
261 ASSERT(!hasParserBlockingScript()); | 257 ASSERT(!hasParserBlockingScript()); |
262 ASSERT(m_scriptsToExecuteAfterParsing.first().resource()); | 258 ASSERT(m_scriptsToExecuteAfterParsing.first()->resource()); |
263 if (!m_scriptsToExecuteAfterParsing.first().isReady()) { | 259 if (!m_scriptsToExecuteAfterParsing.first()->isReady()) { |
264 m_scriptsToExecuteAfterParsing.first().watchForLoad(this); | 260 m_scriptsToExecuteAfterParsing.first()->watchForLoad(this); |
265 return false; | 261 return false; |
266 } | 262 } |
267 PendingScript first = m_scriptsToExecuteAfterParsing.takeFirst(); | 263 OwnPtrWillBeRawPtr<PendingScript> first = m_scriptsToExecuteAfterParsing
.takeFirst(); |
268 executePendingScriptAndDispatchEvent(first, PendingScript::Deferred); | 264 executePendingScriptAndDispatchEvent(first.get(), PendingScript::Deferre
d); |
269 // FIXME: What is this m_document check for? | 265 // FIXME: What is this m_document check for? |
270 if (!m_document) | 266 if (!m_document) |
271 return false; | 267 return false; |
272 } | 268 } |
273 return true; | 269 return true; |
274 } | 270 } |
275 | 271 |
276 void HTMLScriptRunner::requestParsingBlockingScript(Element* element) | 272 void HTMLScriptRunner::requestParsingBlockingScript(Element* element) |
277 { | 273 { |
278 if (!requestPendingScript(m_parserBlockingScript, element)) | 274 if (!requestPendingScript(m_parserBlockingScript.get(), element)) |
279 return; | 275 return; |
280 | 276 |
281 ASSERT(m_parserBlockingScript.resource()); | 277 ASSERT(m_parserBlockingScript->resource()); |
282 | 278 |
283 // We only care about a load callback if resource is not already | 279 // We only care about a load callback if resource is not already |
284 // in the cache. Callers will attempt to run the m_parserBlockingScript | 280 // in the cache. Callers will attempt to run the m_parserBlockingScript |
285 // if possible before returning control to the parser. | 281 // if possible before returning control to the parser. |
286 if (!m_parserBlockingScript.isReady()) { | 282 if (!m_parserBlockingScript->isReady()) { |
287 if (m_document->frame()) { | 283 if (m_document->frame()) { |
288 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra
me()); | 284 ScriptState* scriptState = ScriptState::forMainWorld(m_document->fra
me()); |
289 if (scriptState) | 285 if (scriptState) |
290 ScriptStreamer::startStreaming(m_parserBlockingScript, PendingSc
ript::ParsingBlocking, m_document->frame()->settings(), scriptState, m_document-
>loadingTaskRunner()); | 286 ScriptStreamer::startStreaming(m_parserBlockingScript.get(), Pen
dingScript::ParsingBlocking, m_document->frame()->settings(), scriptState, m_doc
ument->loadingTaskRunner()); |
291 } | 287 } |
292 | 288 |
293 m_parserBlockingScript.watchForLoad(this); | 289 m_parserBlockingScript->watchForLoad(this); |
294 } | 290 } |
295 } | 291 } |
296 | 292 |
297 void HTMLScriptRunner::requestDeferredScript(Element* element) | 293 void HTMLScriptRunner::requestDeferredScript(Element* element) |
298 { | 294 { |
299 PendingScript pendingScript; | 295 OwnPtrWillBeRawPtr<PendingScript> pendingScript = PendingScript::create(null
ptr, nullptr); |
300 if (!requestPendingScript(pendingScript, element)) | 296 if (!requestPendingScript(pendingScript.get(), element)) |
301 return; | 297 return; |
302 | 298 |
303 if (m_document->frame() && !pendingScript.isReady()) { | 299 if (m_document->frame() && !pendingScript->isReady()) { |
304 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame()
); | 300 ScriptState* scriptState = ScriptState::forMainWorld(m_document->frame()
); |
305 if (scriptState) | 301 if (scriptState) |
306 ScriptStreamer::startStreaming(pendingScript, PendingScript::Deferre
d, m_document->frame()->settings(), scriptState, m_document->loadingTaskRunner()
); | 302 ScriptStreamer::startStreaming(pendingScript.get(), PendingScript::D
eferred, m_document->frame()->settings(), scriptState, m_document->loadingTaskRu
nner()); |
307 } | 303 } |
308 | 304 |
309 ASSERT(pendingScript.resource()); | 305 ASSERT(pendingScript->resource()); |
310 m_scriptsToExecuteAfterParsing.append(pendingScript); | 306 m_scriptsToExecuteAfterParsing.append(pendingScript.release()); |
311 } | 307 } |
312 | 308 |
313 bool HTMLScriptRunner::requestPendingScript(PendingScript& pendingScript, Elemen
t* script) const | 309 bool HTMLScriptRunner::requestPendingScript(PendingScript* pendingScript, Elemen
t* script) const |
314 { | 310 { |
315 ASSERT(!pendingScript.element()); | 311 ASSERT(!pendingScript->element()); |
316 pendingScript.setElement(script); | 312 pendingScript->setElement(script); |
317 // This should correctly return 0 for empty or invalid srcValues. | 313 // This should correctly return 0 for empty or invalid srcValues. |
318 ScriptResource* resource = toScriptLoaderIfPossible(script)->resource().get(
); | 314 ScriptResource* resource = toScriptLoaderIfPossible(script)->resource().get(
); |
319 if (!resource) { | 315 if (!resource) { |
320 notImplemented(); // Dispatch error event. | 316 notImplemented(); // Dispatch error event. |
321 return false; | 317 return false; |
322 } | 318 } |
323 pendingScript.setScriptResource(resource); | 319 pendingScript->setScriptResource(resource); |
324 return true; | 320 return true; |
325 } | 321 } |
326 | 322 |
327 // Implements the initial steps for 'An end tag whose tag name is "script"' | 323 // Implements the initial steps for 'An end tag whose tag name is "script"' |
328 // http://whatwg.org/html#scriptEndTag | 324 // http://whatwg.org/html#scriptEndTag |
329 void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
tPosition) | 325 void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
tPosition) |
330 { | 326 { |
331 ASSERT(m_document); | 327 ASSERT(m_document); |
332 ASSERT(!hasParserBlockingScript()); | 328 ASSERT(!hasParserBlockingScript()); |
333 { | 329 { |
(...skipping 17 matching lines...) Expand all Loading... |
351 | 347 |
352 scriptLoader->prepareScript(scriptStartPosition); | 348 scriptLoader->prepareScript(scriptStartPosition); |
353 | 349 |
354 if (!scriptLoader->willBeParserExecuted()) | 350 if (!scriptLoader->willBeParserExecuted()) |
355 return; | 351 return; |
356 | 352 |
357 if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) { | 353 if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) { |
358 requestDeferredScript(script); | 354 requestDeferredScript(script); |
359 } else if (scriptLoader->readyToBeParserExecuted()) { | 355 } else if (scriptLoader->readyToBeParserExecuted()) { |
360 if (m_scriptNestingLevel == 1) { | 356 if (m_scriptNestingLevel == 1) { |
361 m_parserBlockingScript.setElement(script); | 357 m_parserBlockingScript->setElement(script); |
362 m_parserBlockingScript.setStartingPosition(scriptStartPosition); | 358 m_parserBlockingScript->setStartingPosition(scriptStartPosition)
; |
363 } else { | 359 } else { |
364 ScriptSourceCode sourceCode(script->textContent(), documentURLFo
rScriptExecution(m_document), scriptStartPosition); | 360 ScriptSourceCode sourceCode(script->textContent(), documentURLFo
rScriptExecution(m_document), scriptStartPosition); |
365 scriptLoader->executeScript(sourceCode); | 361 scriptLoader->executeScript(sourceCode); |
366 } | 362 } |
367 } else { | 363 } else { |
368 requestParsingBlockingScript(script); | 364 requestParsingBlockingScript(script); |
369 } | 365 } |
370 } | 366 } |
371 } | 367 } |
372 | 368 |
373 DEFINE_TRACE(HTMLScriptRunner) | 369 DEFINE_TRACE(HTMLScriptRunner) |
374 { | 370 { |
375 visitor->trace(m_document); | 371 visitor->trace(m_document); |
376 visitor->trace(m_host); | 372 visitor->trace(m_host); |
377 visitor->trace(m_parserBlockingScript); | 373 visitor->trace(m_parserBlockingScript); |
378 visitor->trace(m_scriptsToExecuteAfterParsing); | 374 visitor->trace(m_scriptsToExecuteAfterParsing); |
379 } | 375 } |
380 | 376 |
381 } // namespace blink | 377 } // namespace blink |
OLD | NEW |