| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
| 6 * reserved. | 6 * reserved. |
| 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 m_startLineNumber = | 84 m_startLineNumber = |
| 85 element->document().scriptableDocumentParser()->lineNumber(); | 85 element->document().scriptableDocumentParser()->lineNumber(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 ScriptLoader::~ScriptLoader() {} | 88 ScriptLoader::~ScriptLoader() {} |
| 89 | 89 |
| 90 DEFINE_TRACE(ScriptLoader) { | 90 DEFINE_TRACE(ScriptLoader) { |
| 91 visitor->trace(m_element); | 91 visitor->trace(m_element); |
| 92 visitor->trace(m_resource); | 92 visitor->trace(m_resource); |
| 93 visitor->trace(m_pendingScript); | 93 visitor->trace(m_pendingScript); |
| 94 ScriptResourceClient::trace(visitor); | 94 PendingScriptClient::trace(visitor); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void ScriptLoader::setFetchDocWrittenScriptDeferIdle() { | 97 void ScriptLoader::setFetchDocWrittenScriptDeferIdle() { |
| 98 DCHECK(!m_createdDuringDocumentWrite); | 98 DCHECK(!m_createdDuringDocumentWrite); |
| 99 m_documentWriteIntervention = | 99 m_documentWriteIntervention = |
| 100 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle; | 100 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle; |
| 101 } | 101 } |
| 102 | 102 |
| 103 void ScriptLoader::didNotifySubtreeInsertionsToDocument() { | 103 void ScriptLoader::didNotifySubtreeInsertionsToDocument() { |
| 104 if (!m_parserInserted) | 104 if (!m_parserInserted) |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } else if (!client->hasSourceAttribute() && m_parserInserted && | 284 } else if (!client->hasSourceAttribute() && m_parserInserted && |
| 285 !elementDocument.isScriptExecutionReady()) { | 285 !elementDocument.isScriptExecutionReady()) { |
| 286 m_willBeParserExecuted = true; | 286 m_willBeParserExecuted = true; |
| 287 m_readyToBeParserExecuted = true; | 287 m_readyToBeParserExecuted = true; |
| 288 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && | 288 } else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && |
| 289 !m_forceAsync) { | 289 !m_forceAsync) { |
| 290 m_pendingScript = PendingScript::create(m_element, m_resource.get()); | 290 m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| 291 m_asyncExecType = ScriptRunner::InOrder; | 291 m_asyncExecType = ScriptRunner::InOrder; |
| 292 contextDocument->scriptRunner()->queueScriptForExecution(this, | 292 contextDocument->scriptRunner()->queueScriptForExecution(this, |
| 293 m_asyncExecType); | 293 m_asyncExecType); |
| 294 // Note that watchForLoad can immediately call notifyFinished. | 294 // Note that watchForLoad can immediately call pendingScriptFinished. |
| 295 m_pendingScript->watchForLoad(this); | 295 m_pendingScript->watchForLoad(this); |
| 296 } else if (client->hasSourceAttribute()) { | 296 } else if (client->hasSourceAttribute()) { |
| 297 m_pendingScript = PendingScript::create(m_element, m_resource.get()); | 297 m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
| 298 m_asyncExecType = ScriptRunner::Async; | 298 m_asyncExecType = ScriptRunner::Async; |
| 299 LocalFrame* frame = m_element->document().frame(); | 299 LocalFrame* frame = m_element->document().frame(); |
| 300 if (frame) { | 300 if (frame) { |
| 301 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 301 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
| 302 if (scriptState) | 302 if (scriptState) |
| 303 ScriptStreamer::startStreaming( | 303 ScriptStreamer::startStreaming( |
| 304 m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), | 304 m_pendingScript.get(), ScriptStreamer::Async, frame->settings(), |
| 305 scriptState, frame->frameScheduler()->loadingTaskRunner()); | 305 scriptState, frame->frameScheduler()->loadingTaskRunner()); |
| 306 } | 306 } |
| 307 contextDocument->scriptRunner()->queueScriptForExecution(this, | 307 contextDocument->scriptRunner()->queueScriptForExecution(this, |
| 308 m_asyncExecType); | 308 m_asyncExecType); |
| 309 // Note that watchForLoad can immediately call notifyFinished. | 309 // Note that watchForLoad can immediately call pendingScriptFinished. |
| 310 m_pendingScript->watchForLoad(this); | 310 m_pendingScript->watchForLoad(this); |
| 311 } else { | 311 } else { |
| 312 // Reset line numbering for nested writes. | 312 // Reset line numbering for nested writes. |
| 313 TextPosition position = elementDocument.isInDocumentWrite() | 313 TextPosition position = elementDocument.isInDocumentWrite() |
| 314 ? TextPosition() | 314 ? TextPosition() |
| 315 : scriptStartPosition; | 315 : scriptStartPosition; |
| 316 KURL scriptURL = (!elementDocument.isInDocumentWrite() && m_parserInserted) | 316 KURL scriptURL = (!elementDocument.isInDocumentWrite() && m_parserInserted) |
| 317 ? elementDocument.url() | 317 ? elementDocument.url() |
| 318 : KURL(); | 318 : KURL(); |
| 319 if (!executeScript( | 319 if (!executeScript( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 dispatchErrorEvent(); | 566 dispatchErrorEvent(); |
| 567 } else if (!m_resource->wasCanceled()) { | 567 } else if (!m_resource->wasCanceled()) { |
| 568 if (executeScript(source)) | 568 if (executeScript(source)) |
| 569 dispatchLoadEvent(); | 569 dispatchLoadEvent(); |
| 570 else | 570 else |
| 571 dispatchErrorEvent(); | 571 dispatchErrorEvent(); |
| 572 } | 572 } |
| 573 m_resource = nullptr; | 573 m_resource = nullptr; |
| 574 } | 574 } |
| 575 | 575 |
| 576 void ScriptLoader::notifyFinished(Resource* resource) { | 576 void ScriptLoader::pendingScriptFinished(PendingScript* pendingScript) { |
| 577 DCHECK(!m_willBeParserExecuted); | 577 DCHECK(!m_willBeParserExecuted); |
| 578 DCHECK_EQ(m_pendingScript, pendingScript); |
| 578 | 579 |
| 579 // We do not need this script in the memory cache. The primary goals of | 580 // We do not need this script in the memory cache. The primary goals of |
| 580 // sending this fetch request are to let the third party server know | 581 // sending this fetch request are to let the third party server know |
| 581 // about the document.write scripts intervention and populate the http | 582 // about the document.write scripts intervention and populate the http |
| 582 // cache for subsequent uses. | 583 // cache for subsequent uses. |
| 583 if (m_documentWriteIntervention == | 584 if (m_documentWriteIntervention == |
| 584 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { | 585 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { |
| 585 memoryCache()->remove(resource); | 586 memoryCache()->remove(m_pendingScript->resource()); |
| 586 m_pendingScript->stopWatchingForLoad(); | 587 m_pendingScript->stopWatchingForLoad(); |
| 587 return; | 588 return; |
| 588 } | 589 } |
| 589 | 590 |
| 590 DCHECK(m_asyncExecType != ScriptRunner::None); | 591 DCHECK(m_asyncExecType != ScriptRunner::None); |
| 591 | 592 |
| 592 Document* contextDocument = m_element->document().contextDocument(); | 593 Document* contextDocument = m_element->document().contextDocument(); |
| 593 if (!contextDocument) { | 594 if (!contextDocument) { |
| 594 detach(); | 595 detach(); |
| 595 return; | 596 return; |
| 596 } | 597 } |
| 597 | 598 |
| 598 DCHECK_EQ(resource, m_resource); | 599 DCHECK_EQ(pendingScript->resource(), m_resource); |
| 599 | 600 |
| 600 if (m_resource->errorOccurred()) { | 601 if (m_resource->errorOccurred()) { |
| 601 contextDocument->scriptRunner()->notifyScriptLoadError(this, | 602 contextDocument->scriptRunner()->notifyScriptLoadError(this, |
| 602 m_asyncExecType); | 603 m_asyncExecType); |
| 603 detach(); | 604 detach(); |
| 604 dispatchErrorEvent(); | 605 dispatchErrorEvent(); |
| 605 return; | 606 return; |
| 606 } | 607 } |
| 607 contextDocument->scriptRunner()->notifyScriptReady(this, m_asyncExecType); | 608 contextDocument->scriptRunner()->notifyScriptReady(this, m_asyncExecType); |
| 608 m_pendingScript->stopWatchingForLoad(); | 609 m_pendingScript->stopWatchingForLoad(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 if (isHTMLScriptLoader(element)) | 647 if (isHTMLScriptLoader(element)) |
| 647 return toHTMLScriptElement(element)->loader(); | 648 return toHTMLScriptElement(element)->loader(); |
| 648 | 649 |
| 649 if (isSVGScriptLoader(element)) | 650 if (isSVGScriptLoader(element)) |
| 650 return toSVGScriptElement(element)->loader(); | 651 return toSVGScriptElement(element)->loader(); |
| 651 | 652 |
| 652 return 0; | 653 return 0; |
| 653 } | 654 } |
| 654 | 655 |
| 655 } // namespace blink | 656 } // namespace blink |
| OLD | NEW |