Commit 207887a0 authored by ap's avatar ap

Reviewed by Darin.

        http://bugs.webkit.org/show_bug.cgi?id=10313
        xsl:import doesn't work in stylesheets loaded via XMLHttpRequest

        This is a partial fix that makes a couple more steps towards fixing the problem.

        Test: fast/xsl/transform-xhr-doc.xhtml

        * xml/XSLTProcessor.cpp:
        (WebCore::xsltStylesheetPointer): Pass an URL for the stylesheet. I'm not sure why this constructor even needs it, 
        given that it has a Node, but this is a small modifications that makes XSLImportRule try to load from a correct URL.
        (WebCore::XSLTProcessor::transformToString): Fix the crash for real this time.



git-svn-id: svn://svn.chromium.org/blink/trunk@18644 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 264e92e1
2007-01-07 Lamar Goddard <lamargoddard@gmail.com>
Reviewed by Darin.
Test for http://bugs.webkit.org/show_bug.cgi?id=10313
xsl:import doesn't work in stylesheets loaded via XMLHttpRequest
* fast/xsl/resources/xhr-doc-imported.xsl: Added.
* fast/xsl/resources/xhr-doc.xml: Added.
* fast/xsl/resources/xhr-doc.xsl: Added.
* fast/xsl/transform-xhr-doc-expected.txt: Added.
* fast/xsl/transform-xhr-doc.xhtml: Added.
2007-01-06 Rob Buis <buis@kde.org> 2007-01-06 Rob Buis <buis@kde.org>
Reviewed by Darin. Reviewed by Darin.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/root">
<div class="default">FAIL: Incorrect transformation.</div>
</xsl:template>
<xsl:template name="works">
<div class="overridden">SUCCESS</div>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xhr-doc.xsl"?>
<root/>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:import href="xhr-doc-imported.xsl" />
<xsl:template match="/root">
<xsl:call-template name="works" />
</xsl:template>
</xsl:stylesheet>
Test for bug 10313: xsl:import doesn't work in stylesheets loaded via XMLHttpRequest.
It's nice that this hasn't crashed, but the XSL transformation has failed.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>xsl import test</title>
<script type="text/javascript">
function load() {
if (window.layoutTestController)
layoutTestController.dumpAsText();
var req = new XMLHttpRequest();
var xslt = new XSLTProcessor();
req.open('GET', 'resources/xhr-doc.xsl', false);
req.send(null);
xslt.importStylesheet(req.responseXML);
req.open('GET', 'resources/xhr-doc.xml', false);
req.send(null);
var doc = xslt.transformToDocument(req.responseXML);
var fragment = document.importNode(doc.documentElement, true);
var div = document.getElementById('div');
div.parentNode.replaceChild(fragment, div);
}
</script>
</head>
<body onload="load()">
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=10313">bug 10313</a>:
xsl:import doesn't work in stylesheets loaded via XMLHttpRequest.</p>
<div id="div">It's nice that this hasn't crashed, but the XSL transformation has failed.</div>
</body>
</html>
2007-01-07 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
http://bugs.webkit.org/show_bug.cgi?id=10313
xsl:import doesn't work in stylesheets loaded via XMLHttpRequest
This is a partial fix that makes a couple more steps towards fixing the problem.
Test: fast/xsl/transform-xhr-doc.xhtml
* xml/XSLTProcessor.cpp:
(WebCore::xsltStylesheetPointer): Pass an URL for the stylesheet. I'm not sure why this constructor even needs it,
given that it has a Node, but this is a small modifications that makes XSLImportRule try to load from a correct URL.
(WebCore::XSLTProcessor::transformToString): Fix the crash for real this time.
2007-01-06 Rob Buis <buis@kde.org> 2007-01-06 Rob Buis <buis@kde.org>
Reviewed by Darin. Reviewed by Darin.
......
...@@ -256,7 +256,7 @@ static inline RefPtr<DocumentFragment> createFragmentFromSource(DeprecatedString ...@@ -256,7 +256,7 @@ static inline RefPtr<DocumentFragment> createFragmentFromSource(DeprecatedString
static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet> &cachedStylesheet, Node *stylesheetRootNode) static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet> &cachedStylesheet, Node *stylesheetRootNode)
{ {
if (!cachedStylesheet && stylesheetRootNode) { if (!cachedStylesheet && stylesheetRootNode) {
cachedStylesheet = new XSLStyleSheet(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode); cachedStylesheet = new XSLStyleSheet(stylesheetRootNode->parent() ? stylesheetRootNode->parent() : stylesheetRootNode, stylesheetRootNode->document()->URL());
cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); cachedStylesheet->parseString(createMarkup(stylesheetRootNode));
} }
...@@ -303,18 +303,14 @@ static inline DeprecatedString resultMIMEType(xmlDocPtr resultDoc, xsltStyleshee ...@@ -303,18 +303,14 @@ static inline DeprecatedString resultMIMEType(xmlDocPtr resultDoc, xsltStyleshee
bool XSLTProcessor::transformToString(Node *sourceNode, DeprecatedString &mimeType, DeprecatedString &resultString, DeprecatedString &resultEncoding) bool XSLTProcessor::transformToString(Node *sourceNode, DeprecatedString &mimeType, DeprecatedString &resultString, DeprecatedString &resultEncoding)
{ {
RefPtr<Document> ownerDocument = sourceNode->document(); RefPtr<Document> ownerDocument = sourceNode->document();
RefPtr<XSLStyleSheet> cachedStylesheet = m_stylesheet;
setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->docLoader()); setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->docLoader());
xsltStylesheetPtr sheet = xsltStylesheetPointer(cachedStylesheet, m_stylesheetRootNode.get()); xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRootNode.get());
if (!sheet) { if (!sheet) {
setXSLTLoadCallBack(0, 0, 0); setXSLTLoadCallBack(0, 0, 0);
return false; return false;
} }
cachedStylesheet->clearDocuments(); m_stylesheet->clearDocuments();
if (!m_stylesheet)
m_stylesheet = cachedStylesheet;
xmlChar* origMethod = sheet->method; xmlChar* origMethod = sheet->method;
if (!origMethod && mimeType == "text/html") if (!origMethod && mimeType == "text/html")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment