| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 ASSERT(resource); | 356 ASSERT(resource); |
| 357 if (resource->errorOccurred()) { | 357 if (resource->errorOccurred()) { |
| 358 dispatchErrorEvent(); | 358 dispatchErrorEvent(); |
| 359 } else if (!resource->wasCanceled()) { | 359 } else if (!resource->wasCanceled()) { |
| 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) |
| 367 { |
| 368 if (!m_resource) |
| 369 return; |
| 370 finishLoading(contextDocument, FinishWithErrorOrCancel); |
| 371 stopLoadRequest(); |
| 372 } |
| 373 |
| 366 void ScriptLoader::notifyFinished(Resource* resource) | 374 void ScriptLoader::notifyFinished(Resource* resource) |
| 367 { | 375 { |
| 368 ASSERT(!m_willBeParserExecuted); | |
| 369 | |
| 370 RefPtr<Document> elementDocument(m_element->document()); | |
| 371 RefPtr<Document> contextDocument = elementDocument->contextDocument().get(); | |
| 372 if (!contextDocument) | |
| 373 return; | |
| 374 | |
| 375 // Resource possibly invokes this notifyFinished() more than | 376 // Resource possibly invokes this notifyFinished() more than |
| 376 // once because ScriptLoader doesn't unsubscribe itself from | 377 // once because ScriptLoader doesn't unsubscribe itself from |
| 377 // Resource here and does it in execute() instead. | 378 // Resource here and does it in execute() instead. |
| 378 // We use m_resource to check if this function is already called. | 379 // We use m_resource to check if this function is already called. |
| 379 ASSERT_UNUSED(resource, resource == m_resource); | 380 ASSERT_UNUSED(resource, resource == m_resource); |
| 380 if (!m_resource) | 381 if (!m_resource) |
| 381 return; | 382 return; |
| 382 if (m_resource->errorOccurred()) { | 383 |
| 384 RefPtr<Document> elementDocument(m_element->document()); |
| 385 RefPtr<Document> contextDocument = elementDocument->contextDocument().get(); |
| 386 finishLoading(contextDocument.get(), resource->errorOccurred() ? FinishWithE
rrorOrCancel : FinishSuccessfully); |
| 387 } |
| 388 |
| 389 void ScriptLoader::finishLoading(Document* contextDocument, ScriptLoader::Finish
Type type) |
| 390 { |
| 391 ASSERT(!m_willBeParserExecuted); |
| 392 |
| 393 if (!contextDocument) |
| 394 return; |
| 395 |
| 396 if (type == FinishWithErrorOrCancel) { |
| 383 dispatchErrorEvent(); | 397 dispatchErrorEvent(); |
| 384 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu
teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); | 398 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu
teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); |
| 385 return; | 399 return; |
| 386 } | 400 } |
| 387 if (m_willExecuteInOrder) | 401 if (m_willExecuteInOrder) |
| 388 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::I
N_ORDER_EXECUTION); | 402 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::I
N_ORDER_EXECUTION); |
| 389 else | 403 else |
| 390 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::A
SYNC_EXECUTION); | 404 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::A
SYNC_EXECUTION); |
| 391 | 405 |
| 392 m_resource = 0; | 406 m_resource = 0; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 if (isHTMLScriptLoader(element)) | 449 if (isHTMLScriptLoader(element)) |
| 436 return toHTMLScriptElement(element)->loader(); | 450 return toHTMLScriptElement(element)->loader(); |
| 437 | 451 |
| 438 if (isSVGScriptLoader(element)) | 452 if (isSVGScriptLoader(element)) |
| 439 return toSVGScriptElement(element)->loader(); | 453 return toSVGScriptElement(element)->loader(); |
| 440 | 454 |
| 441 return 0; | 455 return 0; |
| 442 } | 456 } |
| 443 | 457 |
| 444 } | 458 } |
| OLD | NEW |