void XMLTokenizer::notifyFinished(CachedResource* unusedResource) { ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); ASSERT(m_pendingScript->accessCount() > 0); ScriptSourceCode sourceCode(m_pendingScript.get()); bool errorOccurred = m_pendingScript->errorOccurred(); m_pendingScript->removeClient(this); m_pendingScript = 0; RefPtr<Element> e = m_scriptElement; m_scriptElement = 0; ScriptElement* scriptElement = toScriptElement(e.get()); ASSERT(scriptElement); if (errorOccurred) scriptElement->dispatchErrorEvent(); else { m_view->frame()->loader()->executeScript(sourceCode); scriptElement->dispatchLoadEvent(); } m_scriptElement = 0; if (!m_requestingScript) resumeParsing(); }
void XMLDocumentParser::notifyFinished(CachedResource* unusedResource) { ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); ASSERT(m_pendingScript->accessCount() > 0); ScriptSourceCode sourceCode(m_pendingScript.get()); bool errorOccurred = m_pendingScript->errorOccurred(); bool wasCanceled = m_pendingScript->wasCanceled(); m_pendingScript->removeClient(this); m_pendingScript = 0; RefPtr<Element> e = m_scriptElement; m_scriptElement = 0; ScriptElement* scriptElement = toScriptElement(e.get()); ASSERT(scriptElement); // JavaScript can detach this parser, make sure it's kept alive even if detached. RefPtr<XMLDocumentParser> protect(this); if (errorOccurred) scriptElement->dispatchErrorEvent(); else if (!wasCanceled) { scriptElement->executeScript(sourceCode); scriptElement->dispatchLoadEvent(); } m_scriptElement = 0; if (!isDetached() && !m_requestingScript) resumeParsing(); }
void XMLDocumentParser::notifyFinished(CachedResource* unusedResource) { ASSERT_UNUSED(unusedResource, unusedResource == m_pendingScript); #if PLATFORM(OLYMPIA) Settings* settings = document() ? document()->settings() : 0; ASSERT(m_pendingScript->accessCount() > 0 || cache()->disabled() || !settings || !settings->useCache()); #else ASSERT(m_pendingScript->accessCount() > 0); #endif ScriptSourceCode sourceCode(m_pendingScript.get()); bool errorOccurred = m_pendingScript->errorOccurred(); m_pendingScript->removeClient(this); m_pendingScript = 0; RefPtr<Element> e = m_scriptElement; m_scriptElement = 0; ScriptElement* scriptElement = toScriptElement(e.get()); ASSERT(scriptElement); // JavaScript can detach this parser, make sure it's kept alive even if detached. RefPtr<XMLDocumentParser> protect(this); if (errorOccurred) scriptElement->dispatchErrorEvent(); else { m_view->frame()->script()->executeScript(sourceCode); scriptElement->dispatchLoadEvent(); } m_scriptElement = 0; if (!isDetached() && !m_requestingScript) resumeParsing(); }