Index: third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
index e656de67ada8e2be16cbce860cb73955745b1ffc..9ef296bdf1e6bad5b392442aac55c9286b972ebd 100644 |
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp |
@@ -78,7 +78,17 @@ ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt |
ScriptLoader::~ScriptLoader() |
{ |
- m_pendingScript.stopWatchingForLoad(this); |
+#if !ENABLE(OILPAN) |
+ dispose(); |
haraken
2016/01/12 00:22:52
I think it's better to call detach() (i.e., it's n
Nate Chapin
2016/01/13 20:36:33
Done.
|
+#endif |
+} |
+ |
+void ScriptLoader::dispose() |
+{ |
+ if (m_pendingScript) { |
+ m_pendingScript->stopWatchingForLoad(this); |
+ m_pendingScript = nullptr; |
+ } |
} |
DEFINE_TRACE(ScriptLoader) |
@@ -114,8 +124,11 @@ void ScriptLoader::handleAsyncAttribute() |
void ScriptLoader::detach() |
{ |
- m_pendingScript.stopWatchingForLoad(this); |
- m_pendingScript.releaseElementAndClear(); |
+ if (!m_pendingScript) |
+ return; |
+ m_pendingScript->stopWatchingForLoad(this); |
+ m_pendingScript->releaseElementAndClear(); |
+ m_pendingScript = nullptr; |
} |
// Helper function |
@@ -250,21 +263,21 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy |
m_readyToBeParserExecuted = true; |
} else if (client->hasSourceAttribute() && !client->asyncAttributeValue() && !m_forceAsync) { |
m_willExecuteInOrder = true; |
- m_pendingScript = PendingScript(m_element, m_resource.get()); |
+ m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
contextDocument->scriptRunner()->queueScriptForExecution(this, ScriptRunner::IN_ORDER_EXECUTION); |
// Note that watchForLoad can immediately call notifyFinished. |
- m_pendingScript.watchForLoad(this); |
+ m_pendingScript->watchForLoad(this); |
} else if (client->hasSourceAttribute()) { |
- m_pendingScript = PendingScript(m_element, m_resource.get()); |
+ m_pendingScript = PendingScript::create(m_element, m_resource.get()); |
LocalFrame* frame = m_element->document().frame(); |
if (frame) { |
ScriptState* scriptState = ScriptState::forMainWorld(frame); |
if (scriptState) |
- ScriptStreamer::startStreaming(m_pendingScript, PendingScript::Async, frame->settings(), scriptState, frame->frameScheduler()->loadingTaskRunner()); |
+ ScriptStreamer::startStreaming(m_pendingScript.get(), PendingScript::Async, frame->settings(), scriptState, frame->frameScheduler()->loadingTaskRunner()); |
} |
contextDocument->scriptRunner()->queueScriptForExecution(this, ScriptRunner::ASYNC_EXECUTION); |
// Note that watchForLoad can immediately call notifyFinished. |
- m_pendingScript.watchForLoad(this); |
+ m_pendingScript->watchForLoad(this); |
} else { |
// Reset line numbering for nested writes. |
TextPosition position = elementDocument.isInDocumentWrite() ? TextPosition() : scriptStartPosition; |
@@ -429,10 +442,10 @@ bool ScriptLoader::executeScript(const ScriptSourceCode& sourceCode, double* com |
void ScriptLoader::execute() |
{ |
ASSERT(!m_willBeParserExecuted); |
- ASSERT(m_pendingScript.resource()); |
+ ASSERT(m_pendingScript->resource()); |
bool errorOccurred = false; |
- ScriptSourceCode source = m_pendingScript.getSource(KURL(), errorOccurred); |
- RefPtrWillBeRawPtr<Element> element = m_pendingScript.releaseElementAndClear(); |
+ ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); |
+ RefPtrWillBeRawPtr<Element> element = m_pendingScript->releaseElementAndClear(); |
ALLOW_UNUSED_LOCAL(element); |
if (errorOccurred) { |
dispatchErrorEvent(); |
@@ -469,7 +482,7 @@ void ScriptLoader::notifyFinished(Resource* resource) |
return; |
} |
contextDocument->scriptRunner()->notifyScriptReady(this, runOrder); |
- m_pendingScript.stopWatchingForLoad(this); |
+ m_pendingScript->stopWatchingForLoad(this); |
} |
bool ScriptLoader::ignoresLoadRequest() const |