summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/XMLDocumentParserLibxml2.cpp')
-rw-r--r--Source/WebCore/dom/XMLDocumentParserLibxml2.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp b/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp
index 9214391..d806456 100644
--- a/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp
+++ b/Source/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -847,12 +847,16 @@ void XMLDocumentParser::endElementNs()
return;
}
+ // JavaScript can detach the parser. Make sure this is not released
+ // before the end of this method.
+ RefPtr<XMLDocumentParser> protect(this);
+
exitText();
- Node* n = m_currentNode;
+ RefPtr<Node> n = m_currentNode;
n->finishParsingChildren();
- if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n))) {
+ if (m_scriptingPermission == FragmentScriptingNotAllowed && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
popCurrentNode();
ExceptionCode ec;
n->remove(ec);
@@ -864,7 +868,7 @@ void XMLDocumentParser::endElementNs()
return;
}
- Element* element = static_cast<Element*>(n);
+ 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.
@@ -893,10 +897,6 @@ void XMLDocumentParser::endElementNs()
// FIXME: Script execution should be shared between
// the libxml2 and Qt XMLDocumentParser implementations.
- // JavaScript can detach the parser. Make sure this is not released
- // before the end of this method.
- RefPtr<XMLDocumentParser> protect(this);
-
if (scriptElement->readyToBeParserExecuted())
scriptElement->executeScript(ScriptSourceCode(scriptElement->scriptContent(), document()->url(), m_scriptStartPosition));
else if (scriptElement->willBeParserExecuted()) {
@@ -1341,25 +1341,21 @@ void XMLDocumentParser::doEnd()
#if ENABLE(XSLT)
XMLTreeViewer xmlTreeViewer(document());
-
bool xmlViewerMode = !m_sawError && !m_sawCSS && !m_sawXSLTransform && xmlTreeViewer.hasNoStyleInformation();
+ if (xmlViewerMode)
+ xmlTreeViewer.transformDocumentToTreeView();
- if (xmlViewerMode || m_sawXSLTransform) {
+ if (m_sawXSLTransform) {
void* doc = xmlDocPtrForString(document()->cachedResourceLoader(), m_originalSourceForTransform, document()->url().string());
document()->setTransformSource(new TransformSource(doc));
- if (xmlViewerMode)
- xmlTreeViewer.transformDocumentToTreeView();
- else {
- document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
- document()->styleSelectorChanged(RecalcStyleImmediately);
- document()->setParsing(true);
- }
+ document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
+ document()->styleSelectorChanged(RecalcStyleImmediately);
+ document()->setParsing(true);
DocumentParser::stopParsing();
}
#endif
-
}
#if ENABLE(XSLT)