--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x152
+ RenderBlock {HTML} at (0,0) size 800x152
+ RenderBody {BODY} at (8,16) size 784x120
+ RenderBlock {P} at (0,0) size 784x18
+ RenderText {TEXT} at (0,0) size 650x18
+ text run at (0,0) width 650: "This tests the xslt document() function. If this test is successful, there should be three paragraphs below."
+ RenderBlock {P} at (0,34) size 784x18
+ RenderText {TEXT} at (0,0) size 120x18
+ text run at (0,0) width 120: "This is a paragraph"
+ RenderBlock {P} at (0,68) size 784x18
+ RenderText {TEXT} at (0,0) size 160x18
+ text run at (0,0) width 160: "This is another paragraph"
+ RenderBlock {P} at (0,102) size 784x18
+ RenderText {TEXT} at (0,0) size 157x18
+ text run at (0,0) width 157: "This is a third paragraph."
--- /dev/null
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="document-function.xsl"?>
+<doc>
+<para>This tests the xslt document() function. If this test is successful, there should be three paragraphs below.</para>
+<para>This is a paragraph</para>
+<para>This is another paragraph</para>
+</doc>
--- /dev/null
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+ <html>
+ <xsl:apply-templates/>
+ <xsl:apply-templates select="document('resources/document-function-source.xml')/doc"/>
+ </html>
+</xsl:template>
+
+<xsl:template match="para">
+<p><xsl:value-of select="."/></p>
+</xsl:template>
+</xsl:stylesheet>
+2005-06-29 Anders Carlsson <andersca@mac.com>
+
+ Reviewed and landed by Darin Adler.
+
+ - Fix <http://bugzilla.opendarwin.org/show_bug.cgi?id=3274>
+ document() not supported
+
+ Test cases added:
+ * layout-tests/fast/xsl/document-function-expected.txt: Added.
+ * layout-tests/fast/xsl/document-function.xml: Added.
+ * layout-tests/fast/xsl/document-function.xsl: Added.
+ * layout-tests/fast/xsl/resources/document-function-source.xml: Added.
+
+ * khtml/xsl/xslt_processorimpl.cpp:
+ (DOM::parseErrorFunc):
+ Stub to prevent errors from getting written to the console.
+
+ (DOM::stylesheetLoadFunc):
+ Fetch and parse documents.
+
+ (DOM::XSLTProcessorImpl::transformDocument):
+ Use the processor as the global variable instead of the
+ style sheet.
+
+ * khtml/xsl/xslt_processorimpl.h:
+ (DOM::XSLTProcessorImpl::stylesheet):
+ (DOM::XSLTProcessorImpl::sourceDocument):
+ Add accessors for source document and stylesheet.
+
2005-06-29 Maciej Stachowiak <mjs@apple.com>
Unreviewed - fixing build breakage with gcc 4.
2005-06-29 David Harrison <harrison@apple.com>
- Temporarily enable tab coalescing ahead of white-space:pre-wrap
- change because of problems with keeping the tabs separate. Will
- revert when problems are fixed or remove if I do pre-wrap
- first.
+ Temporarily enable tab coalescing ahead of white-space:pre-wrap
+ change because of problems with keeping the tabs separate. Will
+ revert when problems are fixed or remove if I do pre-wrap
+ first.
* khtml/editing/insert_text_command.cpp:
(khtml::InsertTextCommand::prepareForTextInsertion):
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- Contributed by Francisco Tolmasky <tolmasky@gmail.com>
+ Contributed by Francisco Tolmasky <tolmasky@gmail.com>
- -test cases for fix to http://bugzilla.opendarwin.org/show_bug.cgi?id=3667
- Core JavaScript 1.5 Reference:Objects:Array:forEach
+ -test cases for fix to http://bugzilla.opendarwin.org/show_bug.cgi?id=3667
+ Core JavaScript 1.5 Reference:Objects:Array:forEach
- See JavaScriptCore Changelog for details on the patch.
+ See JavaScriptCore Changelog for details on the patch.
Reviewed by darin.
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- DOM compatibility tests for HTMLDocument::writeln
+ DOM compatibility tests for HTMLDocument::writeln
Reviewed by justing.
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- DOM compatibility tests for HTMLDocument::write
+ DOM compatibility tests for HTMLDocument::write
Reviewed by justing.
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- DOM compatibility tests for HTMLDocument::title
+ DOM compatibility tests for HTMLDocument::title
Reviewed by justing.
Reviewed by Darin.
Added iterator support to new hashtable class, the HashSet API is
- now essentially complete.
+ now essentially complete.
- Added support for consistency check mode.
+ Added support for consistency check mode.
* khtml/misc/hashset.h:
(khtml::HashSet::capacity): Added
* khtml/misc/hashtable.h:
(khtml::HashTableIterator): New class with all the obvious iterator stuff.
(khtml::HashTableConstIterator::HashTableConstIterator): New class with all the obvious
- const iterator stuff.
+ const iterator stuff.
(khtml::HashTable::begin): Added (both const and non-consts)
(khtml::HashTable::end): Added (both const and non-consts)
(khtml::HashTable::capacity): Added
(khtml::HashTable::insert): Implement non-template method in terms
- of template method.
+ of template method.
(khtml::HashTable::contains): Added (implemented in terms of find)
(khtml::HashTable::remove): Implemented key remove in terms of find and
- iterator remove.
+ iterator remove.
(khtml::HashTable::hash): Made static
(khtml::HashTable::equal): Made static
(khtml::HashTable::identityConvert): Added - no-op convert method so template insert
- method can be implemented in terms of non-template
+ method can be implemented in terms of non-template
(khtml::HashTable::insert): Changed to return iterator
(khtml::HashTable::reinsert): Recoded to be more like the other functions
(khtml::HashTable::find): Added
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- -added test case for fix to http://bugzilla.opendarwin.org/show_bug.cgi?id=3743
- Incorrect error message given for certain calls
-
- See JavaScriptCore Changelog for details about the patch.
+ -added test case for fix to http://bugzilla.opendarwin.org/show_bug.cgi?id=3743
+ Incorrect error message given for certain calls
+
+ See JavaScriptCore Changelog for details about the patch.
Reviewed by me.
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- Patch by Joost de Valk <webkit@joostdevalk.nl>
+ Patch by Joost de Valk <webkit@joostdevalk.nl>
- - http://bugzilla.opendarwin.org/show_bug.cgi?id=3732
- Testcase for accesskeys that will run with run-webkit-tests.
+ - http://bugzilla.opendarwin.org/show_bug.cgi?id=3732
+ Testcase for accesskeys that will run with run-webkit-tests.
Reviewed by Darin.
2005-06-29 Geoffrey Garen <ggaren@apple.com>
- Patch by Antoine Quint <ml@graougraou.com>
+ Patch by Antoine Quint <ml@graougraou.com>
- -fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=3648
- quadraticCurveTo() method in <canvas> APIs JS bindings does not exist
+ -fixes http://bugzilla.opendarwin.org/show_bug.cgi?id=3648
+ quadraticCurveTo() method in <canvas> APIs JS bindings does not exist
Reviewed by Darin.
#include "loader.h"
#include "khtmlview.h"
#include "khtml_part.h"
+#include "KWQLoader.h"
+
+#include <kio/job.h>
#include <libxslt/xsltutils.h>
#include <libxslt/documents.h>
m_sourceDocument->deref();
}
-static XSLStyleSheetImpl* globalSheet = 0;
+static void parseErrorFunc(void *ctxt, const char *msg, ...)
+{
+ // FIXME: It would be nice to display error messages somewhere.
+}
+
+static XSLTProcessorImpl *globalProcessor = 0;
static xmlDocPtr stylesheetLoadFunc(const xmlChar* uri,
xmlDictPtr dict,
int options,
void* ctxt,
xsltLoadType type)
{
- if (type != XSLT_LOAD_STYLESHEET)
- return NULL; // FIXME: Add support for XSLT_LOAD_DOCUMENT for the document() function.
-
- if (!globalSheet)
+ if (!globalProcessor)
return NULL;
- return globalSheet->locateStylesheetSubResource(((xsltStylesheetPtr)ctxt)->doc, uri);
+
+ switch (type) {
+ case XSLT_LOAD_DOCUMENT: {
+ KURL url = KURL((char *)uri);
+ KURL finalURL;
+ KIO::TransferJob *job = KIO::get(url, true, false);
+ QByteArray data;
+ QString headers;
+ xmlDocPtr doc;
+ xmlGenericErrorFunc oldErrorFunc = xmlGenericError;
+ void *oldErrorContext = xmlGenericErrorContext;
+
+ data = KWQServeSynchronousRequest(khtml::Cache::loader(),
+ globalProcessor->sourceDocument()->docLoader(), job, finalURL, headers);
+
+ xmlSetGenericErrorFunc(0, parseErrorFunc);
+ // We don't specify an encoding here. Neither Gecko nor WinIE respects
+ // the encoding specified in the HTTP headers.
+ doc = xmlReadMemory(data.data(), data.size(), (const char *)uri, 0, options);
+ xmlSetGenericErrorFunc(oldErrorContext, oldErrorFunc);
+ return doc;
+ }
+ case XSLT_LOAD_STYLESHEET:
+ return globalProcessor->stylesheet()->locateStylesheetSubResource(((xsltStylesheetPtr)ctxt)->doc, uri);
+ default:
+ break;
+ }
+
+ return NULL;
}
DocumentImpl* XSLTProcessorImpl::transformDocument(DocumentImpl* doc)
if (!m_stylesheet || !m_stylesheet->document()) return 0;
- globalSheet = m_stylesheet;
+ globalProcessor = this;
xsltSetLoaderFunc(stylesheetLoadFunc);
xsltStylesheetPtr sheet = m_stylesheet->compileStyleSheet();
- globalSheet = 0;
- xsltSetLoaderFunc(0);
-
- if (!sheet) return 0;
+ if (!sheet) {
+ globalProcessor = 0;
+ xsltSetLoaderFunc(0);
+ return 0;
+ }
+
m_stylesheet->clearDocuments();
// Get the parsed source document.
xmlDocPtr sourceDoc = (xmlDocPtr)doc->transformSource();
xmlDocPtr resultDoc = xsltApplyStylesheet(sheet, sourceDoc, NULL);
+
+ globalProcessor = 0;
+ xsltSetLoaderFunc(0);
+
DocumentImpl* result = documentFromXMLDocPtr(resultDoc, sheet);
xsltFreeStylesheet(sheet);
return result;
m_resultOutput += QString(buffer, len);
}
-DocumentImpl* XSLTProcessorImpl::documentFromXMLDocPtr(xmlDocPtr resultDoc, xsltStylesheetPtr sheet)
+DocumentImpl *XSLTProcessorImpl::documentFromXMLDocPtr(xmlDocPtr resultDoc, xsltStylesheetPtr sheet)
{
- // FIXME: For now we serialize and then reparse. It might be more optimal to write a DOM
- // converter.
- if (!resultDoc || !sheet) return 0;
- DocumentImpl* result = 0;
+ // FIXME: For now we serialize and then reparse. It might be more optimal to write a DOM converter.
+
+ if (!resultDoc || !sheet)
+ return 0;
+
+ DocumentImpl *result = 0;
xmlOutputBufferPtr outputBuf = xmlAllocOutputBuffer(NULL);
if (outputBuf) {
outputBuf->context = this;
// There are three types of output we need to be able to deal with:
// HTML (create an HTML document), XML (create an XML document), and text (wrap in a <pre> and
// make an XML document).
- KHTMLView* view = m_sourceDocument->view();
- const xmlChar* method;
+ KHTMLView *view = m_sourceDocument->view();
+ const xmlChar *method;
XSLT_GET_IMPORT_PTR(method, sheet, method);
if (method == NULL && resultDoc->type == XML_HTML_DOCUMENT_NODE)
- method = (const xmlChar*)"html";
- if (xmlStrEqual(method, (const xmlChar*)"html"))
+ method = (const xmlChar *)"html";
+ if (xmlStrEqual(method, (const xmlChar *)"html"))
result = m_sourceDocument->implementation()->createHTMLDocument(view);
else
result = m_sourceDocument->implementation()->createDocument(view);
result->docLoader()->setShowAnimations(m_sourceDocument->docLoader()->showAnimations());
result->setTransformSourceDocument(m_sourceDocument);
- if (xmlStrEqual(method, (const xmlChar*)"text")) {
- // Modify the output so that it is a well-formed XHTML document with a <pre> tag enclosing
- // the text.
- QString beforeString("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<body>\n<pre>\n<![CDATA[");
- QString afterString("]]>\n</pre>\n</body>\n</html>\n");
- m_resultOutput = beforeString + m_resultOutput + afterString;
+ if (xmlStrEqual(method, (const xmlChar *)"text")) {
+ // Modify the output so that it is a well-formed XHTML document with a <pre> tag enclosing the text.
+ m_resultOutput = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/strict.dtd\">\n"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
+ "<body>\n"
+ "<pre>\n"
+ "<![CDATA[" + m_resultOutput + "]]>\n"
+ "</pre>\n"
+ "</body>\n"
+ "</html>\n";
}
// Before parsing, we need to detach the old document completely and get the new document
- // in place. We have to do this only if we're rendering the result document.
+ // in place. We have to do this only if we're rendering the result document.
if (view) {
view->clear();
view->part()->replaceDocImpl(result);
}
}
+
#endif
// Helpers
void addToResult(const char* buffer, int len);
+ XSLStyleSheetImpl *stylesheet() { return m_stylesheet; }
+ DocumentImpl *sourceDocument() { return m_sourceDocument; }
+
protected:
XSLStyleSheetImpl* m_stylesheet;
QString m_resultOutput;