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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
ngScript) | 119 void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
ngScript) |
120 { | 120 { |
121 bool errorOccurred = false; | 121 bool errorOccurred = false; |
122 ScriptSourceCode sourceCode = sourceFromPendingScript(pendingScript, errorOc
curred); | 122 ScriptSourceCode sourceCode = sourceFromPendingScript(pendingScript, errorOc
curred); |
123 | 123 |
124 // Stop watching loads before executeScript to prevent recursion if the scri
pt reloads itself. | 124 // Stop watching loads before executeScript to prevent recursion if the scri
pt reloads itself. |
125 if (pendingScript.resource() && pendingScript.watchingForLoad()) | 125 if (pendingScript.resource() && pendingScript.watchingForLoad()) |
126 stopWatchingForLoad(pendingScript); | 126 stopWatchingForLoad(pendingScript); |
127 | 127 |
128 if (!isExecutingScript()) | 128 if (!isExecutingScript()) |
129 Microtask::performCheckpoint(); | 129 Microtask::performMicrotaskCheckpoint(); |
130 | 130 |
131 // Clear the pending script before possible rentrancy from executeScript() | 131 // Clear the pending script before possible rentrancy from executeScript() |
132 RefPtr<Element> element = pendingScript.releaseElementAndClear(); | 132 RefPtr<Element> element = pendingScript.releaseElementAndClear(); |
133 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) { | 133 if (ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element.get())) { |
134 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); | 134 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
135 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); | 135 IgnoreDestructiveWriteCountIncrementer ignoreDestructiveWriteCountIncrem
enter(m_document); |
136 if (errorOccurred) | 136 if (errorOccurred) |
137 scriptLoader->dispatchErrorEvent(); | 137 scriptLoader->dispatchErrorEvent(); |
138 else { | 138 else { |
139 ASSERT(isExecutingScript()); | 139 ASSERT(isExecutingScript()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // is being tracked by <https://bugs.webkit.org/show_bug.cgi?id=60559>. | 283 // is being tracked by <https://bugs.webkit.org/show_bug.cgi?id=60559>. |
284 ASSERT(scriptLoader); | 284 ASSERT(scriptLoader); |
285 if (!scriptLoader) | 285 if (!scriptLoader) |
286 return; | 286 return; |
287 | 287 |
288 // FIXME: This may be too agressive as we always deliver mutations at | 288 // FIXME: This may be too agressive as we always deliver mutations at |
289 // every script element, even if it's not ready to execute yet. There's | 289 // every script element, even if it's not ready to execute yet. There's |
290 // unfortuantely no obvious way to tell if prepareScript is going to | 290 // unfortuantely no obvious way to tell if prepareScript is going to |
291 // execute the script from out here. | 291 // execute the script from out here. |
292 if (!isExecutingScript()) | 292 if (!isExecutingScript()) |
293 Microtask::performCheckpoint(); | 293 Microtask::performMicrotaskCheckpoint(); |
294 | 294 |
295 InsertionPointRecord insertionPointRecord(m_host->inputStream()); | 295 InsertionPointRecord insertionPointRecord(m_host->inputStream()); |
296 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); | 296 NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel); |
297 | 297 |
298 scriptLoader->prepareScript(scriptStartPosition); | 298 scriptLoader->prepareScript(scriptStartPosition); |
299 | 299 |
300 if (!scriptLoader->willBeParserExecuted()) | 300 if (!scriptLoader->willBeParserExecuted()) |
301 return; | 301 return; |
302 | 302 |
303 if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) { | 303 if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) { |
304 requestDeferredScript(script); | 304 requestDeferredScript(script); |
305 } else if (scriptLoader->readyToBeParserExecuted()) { | 305 } else if (scriptLoader->readyToBeParserExecuted()) { |
306 if (m_scriptNestingLevel == 1) { | 306 if (m_scriptNestingLevel == 1) { |
307 m_parserBlockingScript.setElement(script); | 307 m_parserBlockingScript.setElement(script); |
308 m_parserBlockingScript.setStartingPosition(scriptStartPosition); | 308 m_parserBlockingScript.setStartingPosition(scriptStartPosition); |
309 } else { | 309 } else { |
310 ScriptSourceCode sourceCode(script->textContent(), documentURLFo
rScriptExecution(m_document), scriptStartPosition); | 310 ScriptSourceCode sourceCode(script->textContent(), documentURLFo
rScriptExecution(m_document), scriptStartPosition); |
311 scriptLoader->executeScript(sourceCode); | 311 scriptLoader->executeScript(sourceCode); |
312 } | 312 } |
313 } else { | 313 } else { |
314 requestParsingBlockingScript(script); | 314 requestParsingBlockingScript(script); |
315 } | 315 } |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 } | 319 } |
OLD | NEW |