| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 // 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. |
| 160 const double epsilon = 1; | 160 const double epsilon = 1; |
| 161 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) { |
| 162 blink::Platform::current()->histogramCustomCounts("WebCore.Scripts.Parsi
ngBlocking.TimeBetweenLoadedAndCompiled", (compilationFinishTime - loadFinishTim
e) * 1000, 0, 10000, 50); | 162 blink::Platform::current()->histogramCustomCounts("WebCore.Scripts.Parsi
ngBlocking.TimeBetweenLoadedAndCompiled", (compilationFinishTime - loadFinishTim
e) * 1000, 0, 10000, 50); |
| 163 } | 163 } |
| 164 | 164 |
| 165 ASSERT(!isExecutingScript()); | 165 ASSERT(!isExecutingScript()); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void HTMLScriptRunner::stopWatchingResourceForLoad(Resource* resource) |
| 169 { |
| 170 if (m_parserBlockingScript.resource() == resource) { |
| 171 m_parserBlockingScript.stopWatchingForLoad(this); |
| 172 m_parserBlockingScript.releaseElementAndClear(); |
| 173 return; |
| 174 } |
| 175 for (PendingScript& script : m_scriptsToExecuteAfterParsing) { |
| 176 if (script.resource() == resource) { |
| 177 script.stopWatchingForLoad(this); |
| 178 script.releaseElementAndClear(); |
| 179 return; |
| 180 } |
| 181 } |
| 182 } |
| 183 |
| 168 void HTMLScriptRunner::notifyFinished(Resource* cachedResource) | 184 void HTMLScriptRunner::notifyFinished(Resource* cachedResource) |
| 169 { | 185 { |
| 186 // Handle cancellations of parser-blocking script loads without |
| 187 // notifying the host (i.e., parser) if these were initiated by nested |
| 188 // document.write()s. The cancellation may have been triggered by |
| 189 // script execution to signal an abrupt stop (e.g., window.close().) |
| 190 // |
| 191 // The parser is unprepared to be told, and doesn't need to be. |
| 192 if (isExecutingScript() && cachedResource->wasCanceled()) { |
| 193 stopWatchingResourceForLoad(cachedResource); |
| 194 return; |
| 195 } |
| 170 m_host->notifyScriptLoaded(cachedResource); | 196 m_host->notifyScriptLoaded(cachedResource); |
| 171 } | 197 } |
| 172 | 198 |
| 173 // Implements the steps for 'An end tag whose tag name is "script"' | 199 // Implements the steps for 'An end tag whose tag name is "script"' |
| 174 // http://whatwg.org/html#scriptEndTag | 200 // http://whatwg.org/html#scriptEndTag |
| 175 // Script handling lives outside the tree builder to keep each class simple. | 201 // Script handling lives outside the tree builder to keep each class simple. |
| 176 void HTMLScriptRunner::execute(PassRefPtrWillBeRawPtr<Element> scriptElement, co
nst TextPosition& scriptStartPosition) | 202 void HTMLScriptRunner::execute(PassRefPtrWillBeRawPtr<Element> scriptElement, co
nst TextPosition& scriptStartPosition) |
| 177 { | 203 { |
| 178 ASSERT(scriptElement); | 204 ASSERT(scriptElement); |
| 179 // FIXME: If scripting is disabled, always just return. | 205 // FIXME: If scripting is disabled, always just return. |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 368 |
| 343 void HTMLScriptRunner::trace(Visitor* visitor) | 369 void HTMLScriptRunner::trace(Visitor* visitor) |
| 344 { | 370 { |
| 345 visitor->trace(m_document); | 371 visitor->trace(m_document); |
| 346 visitor->trace(m_host); | 372 visitor->trace(m_host); |
| 347 visitor->trace(m_parserBlockingScript); | 373 visitor->trace(m_parserBlockingScript); |
| 348 visitor->trace(m_scriptsToExecuteAfterParsing); | 374 visitor->trace(m_scriptsToExecuteAfterParsing); |
| 349 } | 375 } |
| 350 | 376 |
| 351 } | 377 } |
| OLD | NEW |