Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptLoader.cpp

Issue 1526293003: Gracefully discharge a failed script load in disposed documents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptRunner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 { 452 {
453 ASSERT(!m_willBeParserExecuted); 453 ASSERT(!m_willBeParserExecuted);
454 454
455 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); 455 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document());
456 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get(); 456 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum ent().get();
457 if (!contextDocument) 457 if (!contextDocument)
458 return; 458 return;
459 459
460 ASSERT_UNUSED(resource, resource == m_resource); 460 ASSERT_UNUSED(resource, resource == m_resource);
461 461
462 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner:: IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION;
462 if (m_resource->errorOccurred()) { 463 if (m_resource->errorOccurred()) {
463 dispatchErrorEvent(); 464 dispatchErrorEvent();
464 // dispatchErrorEvent might move the HTMLScriptElement to a new 465 // dispatchErrorEvent might move the HTMLScriptElement to a new
465 // document. In that case, we must notify the ScriptRunner of the new 466 // document. In that case, we must notify the ScriptRunner of the new
466 // document, not the ScriptRunner of the old docuemnt. 467 // document, not the ScriptRunner of the old docuemnt.
467 contextDocument = m_element->document().contextDocument().get(); 468 contextDocument = m_element->document().contextDocument().get();
468 if (!contextDocument) 469 if (!contextDocument)
469 return; 470 return;
470 contextDocument->scriptRunner()->notifyScriptLoadError(this, m_willExecu teInOrder ? ScriptRunner::IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION); 471 contextDocument->scriptRunner()->notifyScriptLoadError(this, runOrder);
471 return; 472 return;
472 } 473 }
473 if (m_willExecuteInOrder) 474 contextDocument->scriptRunner()->notifyScriptReady(this, runOrder);
474 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::I N_ORDER_EXECUTION);
475 else
476 contextDocument->scriptRunner()->notifyScriptReady(this, ScriptRunner::A SYNC_EXECUTION);
477
478 m_pendingScript.stopWatchingForLoad(this); 475 m_pendingScript.stopWatchingForLoad(this);
479 } 476 }
480 477
481 bool ScriptLoader::ignoresLoadRequest() const 478 bool ScriptLoader::ignoresLoadRequest() const
482 { 479 {
483 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen t() || !element()->inDocument(); 480 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen t() || !element()->inDocument();
484 } 481 }
485 482
486 bool ScriptLoader::isScriptForEventSupported() const 483 bool ScriptLoader::isScriptForEventSupported() const
487 { 484 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (isHTMLScriptLoader(element)) 516 if (isHTMLScriptLoader(element))
520 return toHTMLScriptElement(element)->loader(); 517 return toHTMLScriptElement(element)->loader();
521 518
522 if (isSVGScriptLoader(element)) 519 if (isSVGScriptLoader(element))
523 return toSVGScriptElement(element)->loader(); 520 return toSVGScriptElement(element)->loader();
524 521
525 return 0; 522 return 0;
526 } 523 }
527 524
528 } // namespace blink 525 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/ScriptRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698