| 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 reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 executeScript(ScriptSourceCode(resource)); | 360 executeScript(ScriptSourceCode(resource)); |
| 361 dispatchLoadEvent(); | 361 dispatchLoadEvent(); |
| 362 } | 362 } |
| 363 resource->removeClient(this); | 363 resource->removeClient(this); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void ScriptLoader::cancel(Document* contextDocument) | 366 void ScriptLoader::cancel(Document* contextDocument) |
| 367 { | 367 { |
| 368 if (!m_resource) | 368 if (!m_resource) |
| 369 return; | 369 return; |
| 370 finishLoading(contextDocument, FinishWithErrorOrCancel); | 370 finishLoading(contextDocument, FinishWithCancel); |
| 371 stopLoadRequest(); | |
| 372 } | 371 } |
| 373 | 372 |
| 374 void ScriptLoader::notifyFinished(Resource* resource) | 373 void ScriptLoader::notifyFinished(Resource* resource) |
| 375 { | 374 { |
| 376 // Resource possibly invokes this notifyFinished() more than | 375 // Resource possibly invokes this notifyFinished() more than |
| 377 // once because ScriptLoader doesn't unsubscribe itself from | 376 // once because ScriptLoader doesn't unsubscribe itself from |
| 378 // Resource here and does it in execute() instead. | 377 // Resource here and does it in execute() instead. |
| 379 // We use m_resource to check if this function is already called. | 378 // We use m_resource to check if this function is already called. |
| 380 ASSERT_UNUSED(resource, resource == m_resource); | 379 ASSERT_UNUSED(resource, resource == m_resource); |
| 381 if (!m_resource) | 380 if (!m_resource) |
| 382 return; | 381 return; |
| 383 | 382 |
| 384 RefPtr<Document> elementDocument(m_element->document()); | 383 RefPtr<Document> elementDocument(m_element->document()); |
| 385 RefPtr<Document> contextDocument = elementDocument->contextDocument().get(); | 384 RefPtr<Document> contextDocument = elementDocument->contextDocument().get(); |
| 386 finishLoading(contextDocument.get(), resource->errorOccurred() ? FinishWithE
rrorOrCancel : FinishSuccessfully); | 385 finishLoading(contextDocument.get(), resource->errorOccurred() ? FinishWithE
rror : FinishSuccessfully); |
| 387 } | 386 } |
| 388 | 387 |
| 389 void ScriptLoader::finishLoading(Document* contextDocument, ScriptLoader::Finish
Type type) | 388 void ScriptLoader::finishLoading(Document* contextDocument, ScriptLoader::Finish
Type type) |
| 390 { | 389 { |
| 391 ASSERT(!m_willBeParserExecuted); | |
| 392 | |
| 393 if (!contextDocument) | 390 if (!contextDocument) |
| 394 return; | 391 return; |
| 395 | 392 |
| 396 if (type == FinishWithErrorOrCancel) { | 393 switch (type) { |
| 394 case FinishWithCancel: |
| 395 if (!m_willBeParserExecuted) |
| 396 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willE
xecuteInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION
); |
| 397 stopLoadRequest(); |
| 398 break; |
| 399 case FinishWithError: |
| 400 ASSERT(!m_willBeParserExecuted); |
| 397 dispatchErrorEvent(); | 401 dispatchErrorEvent(); |
| 398 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu
teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); | 402 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu
teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); |
| 399 return; | 403 m_resource = 0; |
| 404 break; |
| 405 case FinishSuccessfully: |
| 406 ASSERT(!m_willBeParserExecuted); |
| 407 contextDocument->scriptRunner()->notifyScriptReady(this, m_willExecuteIn
Order ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); |
| 408 m_resource = 0; |
| 409 break; |
| 400 } | 410 } |
| 401 if (m_willExecuteInOrder) | |
| 402 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::I
N_ORDER_EXECUTION); | |
| 403 else | |
| 404 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::A
SYNC_EXECUTION); | |
| 405 | |
| 406 m_resource = 0; | |
| 407 } | 411 } |
| 408 | 412 |
| 409 bool ScriptLoader::ignoresLoadRequest() const | 413 bool ScriptLoader::ignoresLoadRequest() const |
| 410 { | 414 { |
| 411 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen
t() || !element()->inDocument(); | 415 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen
t() || !element()->inDocument(); |
| 412 } | 416 } |
| 413 | 417 |
| 414 bool ScriptLoader::isScriptForEventSupported() const | 418 bool ScriptLoader::isScriptForEventSupported() const |
| 415 { | 419 { |
| 416 String eventAttribute = client()->eventAttributeValue(); | 420 String eventAttribute = client()->eventAttributeValue(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (isHTMLScriptLoader(element)) | 453 if (isHTMLScriptLoader(element)) |
| 450 return toHTMLScriptElement(element)->loader(); | 454 return toHTMLScriptElement(element)->loader(); |
| 451 | 455 |
| 452 if (isSVGScriptLoader(element)) | 456 if (isSVGScriptLoader(element)) |
| 453 return toSVGScriptElement(element)->loader(); | 457 return toSVGScriptElement(element)->loader(); |
| 454 | 458 |
| 455 return 0; | 459 return 0; |
| 456 } | 460 } |
| 457 | 461 |
| 458 } | 462 } |
| OLD | NEW |