void XMLDocumentParser::parseEndElement() { exitText(); RefPtr<ContainerNode> n = m_currentNode; n->finishParsingChildren(); if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) { popCurrentNode(); ExceptionCode ec; n->remove(ec); return; } if (!n->isElementNode() || !m_view) { if (!m_currentNodeStack.isEmpty()) popCurrentNode(); return; } Element* element = static_cast<Element*>(n.get()); // The element's parent may have already been removed from document. // Parsing continues in this case, but scripts aren't executed. if (!element->inDocument()) { popCurrentNode(); return; } ScriptElement* scriptElement = toScriptElement(element); if (!scriptElement) { popCurrentNode(); return; } // don't load external scripts for standalone documents (for now) ASSERT(!m_pendingScript); m_requestingScript = true; if (scriptElement->prepareScript(m_scriptStartPosition, ScriptElement::AllowLegacyTypeInTypeAttribute)) { if (scriptElement->readyToBeParserExecuted()) scriptElement->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartPosition)); else if (scriptElement->willBeParserExecuted()) { m_pendingScript = scriptElement->cachedScript(); m_scriptElement = element; m_pendingScript->addClient(this); // m_pendingScript will be 0 if script was already loaded and addClient() executed it. if (m_pendingScript) pauseParsing(); } else m_scriptElement = 0; } m_requestingScript = false; popCurrentNode(); }
void XMLTreeBuilder::closeElement(PassRefPtr<Element> element) { element->finishParsingChildren(); ScriptElement* scriptElement = toScriptElement(element.get()); if (scriptElement) m_parser->processScript(scriptElement); popCurrentNode(); }