diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/xml | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/xml')
-rw-r--r-- | WebCore/xml/XMLHttpRequest.cpp | 138 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequest.h | 37 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequest.idl | 6 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequestProgressEvent.h | 50 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequestProgressEvent.idl | 6 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp | 2 | ||||
-rw-r--r-- | WebCore/xml/XMLHttpRequestProgressEventThrottle.h | 6 | ||||
-rw-r--r-- | WebCore/xml/XPathFunctions.cpp | 3 | ||||
-rw-r--r-- | WebCore/xml/XSLStyleSheet.h | 14 | ||||
-rw-r--r-- | WebCore/xml/XSLTProcessorLibxslt.cpp | 5 | ||||
-rw-r--r-- | WebCore/xml/XSLTProcessorQt.cpp | 5 |
11 files changed, 205 insertions, 67 deletions
diff --git a/WebCore/xml/XMLHttpRequest.cpp b/WebCore/xml/XMLHttpRequest.cpp index 782e159..fc7eb9e 100644 --- a/WebCore/xml/XMLHttpRequest.cpp +++ b/WebCore/xml/XMLHttpRequest.cpp @@ -22,6 +22,7 @@ #include "config.h" #include "XMLHttpRequest.h" +#include "ArrayBuffer.h" #include "Blob.h" #include "MemoryCache.h" #include "CrossOriginAccessControl.h" @@ -40,6 +41,7 @@ #include "ResourceRequest.h" #include "SecurityOrigin.h" #include "Settings.h" +#include "SharedBuffer.h" #include "TextResourceDecoder.h" #include "ThreadableLoader.h" #include "XMLHttpRequestException.h" @@ -169,9 +171,6 @@ XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext* context) : ActiveDOMObject(context, this) , m_async(true) , m_includeCredentials(false) -#if ENABLE(XHR_RESPONSE_BLOB) - , m_asBlob(false) -#endif , m_state(UNSENT) , m_createdDocument(false) , m_error(false) @@ -182,6 +181,7 @@ XMLHttpRequest::XMLHttpRequest(ScriptExecutionContext* context) , m_lastSendLineNumber(0) , m_exceptionCode(0) , m_progressEventThrottle(this) + , m_responseTypeCode(ResponseTypeDefault) { initializeXMLHttpRequestStaticData(); #ifndef NDEBUG @@ -222,25 +222,19 @@ XMLHttpRequest::State XMLHttpRequest::readyState() const String XMLHttpRequest::responseText(ExceptionCode& ec) { -#if ENABLE(XHR_RESPONSE_BLOB) - if (m_asBlob) + if (responseTypeCode() != ResponseTypeDefault && responseTypeCode() != ResponseTypeText) { ec = INVALID_STATE_ERR; -#else - UNUSED_PARAM(ec); -#endif + return ""; + } return m_responseBuilder.toStringPreserveCapacity(); } Document* XMLHttpRequest::responseXML(ExceptionCode& ec) { -#if ENABLE(XHR_RESPONSE_BLOB) - if (m_asBlob) { + if (responseTypeCode() != ResponseTypeDefault && responseTypeCode() != ResponseTypeText && responseTypeCode() != ResponseTypeDocument) { ec = INVALID_STATE_ERR; return 0; } -#else - UNUSED_PARAM(ec); -#endif if (m_state != DONE) return 0; @@ -269,7 +263,7 @@ Document* XMLHttpRequest::responseXML(ExceptionCode& ec) #if ENABLE(XHR_RESPONSE_BLOB) Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const { - if (!m_asBlob) { + if (responseTypeCode() != ResponseTypeBlob) { ec = INVALID_STATE_ERR; return 0; } @@ -277,6 +271,71 @@ Blob* XMLHttpRequest::responseBlob(ExceptionCode& ec) const } #endif +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) +ArrayBuffer* XMLHttpRequest::responseArrayBuffer(ExceptionCode& ec) +{ + if (m_responseTypeCode != ResponseTypeArrayBuffer) { + ec = INVALID_STATE_ERR; + return 0; + } + + if (m_state != DONE) + return 0; + + if (!m_responseArrayBuffer.get() && m_binaryResponseBuilder.get() && m_binaryResponseBuilder->size() > 0) { + m_responseArrayBuffer = ArrayBuffer::create(const_cast<char*>(m_binaryResponseBuilder->data()), static_cast<unsigned>(m_binaryResponseBuilder->size())); + m_binaryResponseBuilder.clear(); + } + + if (m_responseArrayBuffer.get()) + return m_responseArrayBuffer.get(); + + return 0; +} +#endif + +void XMLHttpRequest::setResponseType(const String& responseType, ExceptionCode& ec) +{ + if (m_state != OPENED || m_loader) { + ec = INVALID_STATE_ERR; + return; + } + + if (responseType == "") + m_responseTypeCode = ResponseTypeDefault; + else if (responseType == "text") + m_responseTypeCode = ResponseTypeText; + else if (responseType == "document") + m_responseTypeCode = ResponseTypeDocument; + else if (responseType == "blob") { +#if ENABLE(XHR_RESPONSE_BLOB) + m_responseTypeCode = ResponseTypeBlob; +#endif + } else if (responseType == "arraybuffer") { +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + m_responseTypeCode = ResponseTypeArrayBuffer; +#endif + } else + ec = SYNTAX_ERR; +} + +String XMLHttpRequest::responseType() +{ + switch (m_responseTypeCode) { + case ResponseTypeDefault: + return ""; + case ResponseTypeText: + return "text"; + case ResponseTypeDocument: + return "document"; + case ResponseTypeBlob: + return "blob"; + case ResponseTypeArrayBuffer: + return "arraybuffer"; + } + return ""; +} + XMLHttpRequestUpload* XMLHttpRequest::upload() { if (!m_upload) @@ -328,8 +387,8 @@ void XMLHttpRequest::setAsBlob(bool value, ExceptionCode& ec) ec = INVALID_STATE_ERR; return; } - - m_asBlob = value; + + m_responseTypeCode = value ? ResponseTypeBlob : ResponseTypeDefault; } #endif @@ -344,9 +403,7 @@ void XMLHttpRequest::open(const String& method, const KURL& url, bool async, Exc State previousState = m_state; m_state = UNSENT; m_error = false; -#if ENABLE(XHR_RESPONSE_BLOB) - m_asBlob = false; -#endif + m_responseTypeCode = ResponseTypeDefault; m_uploadComplete = false; // clear stuff from possible previous load @@ -529,6 +586,22 @@ void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec) createRequest(ec); } +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) +void XMLHttpRequest::send(ArrayBuffer* body, ExceptionCode& ec) +{ + if (!initSend(ec)) + return; + + if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) { + m_requestEntityBody = FormData::create(body->data(), body->byteLength()); + if (m_upload) + m_requestEntityBody->setAlwaysStream(true); + } + + createRequest(ec); +} +#endif + void XMLHttpRequest::createRequest(ExceptionCode& ec) { #if ENABLE(BLOB) @@ -666,6 +739,10 @@ void XMLHttpRequest::clearResponse() #if ENABLE(XHR_RESPONSE_BLOB) m_responseBlob = 0; #endif +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + m_binaryResponseBuilder.clear(); + m_responseArrayBuffer.clear(); +#endif } void XMLHttpRequest::clearRequest() @@ -920,9 +997,9 @@ void XMLHttpRequest::didFinishLoading(unsigned long identifier) m_responseBuilder.append(m_decoder->flush()); m_responseBuilder.shrinkToFit(); - + #if ENABLE(XHR_RESPONSE_BLOB) - // FIXME: Set m_responseBlob to something here in the m_asBlob case. + // FIXME: Set m_responseBlob to something here in the ResponseTypeBlob case. #endif #if ENABLE(INSPECTOR) @@ -946,7 +1023,7 @@ void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon return; if (m_uploadEventsAllowed) - m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, true, static_cast<unsigned>(bytesSent), static_cast<unsigned>(totalBytesToBeSent))); + m_upload->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, true, bytesSent, totalBytesToBeSent)); if (bytesSent == totalBytesToBeSent && !m_uploadComplete) { m_uploadComplete = true; @@ -976,7 +1053,9 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) if (m_state < HEADERS_RECEIVED) changeState(HEADERS_RECEIVED); - if (!m_decoder) { + bool useDecoder = responseTypeCode() == ResponseTypeDefault || responseTypeCode() == ResponseTypeText || responseTypeCode() == ResponseTypeDocument; + + if (useDecoder && !m_decoder) { if (!m_responseEncoding.isEmpty()) m_decoder = TextResourceDecoder::create("text/plain", m_responseEncoding); // allow TextResourceDecoder to look inside the m_response if it's XML or HTML @@ -996,7 +1075,16 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) if (len == -1) len = strlen(data); - m_responseBuilder.append(m_decoder->decode(data, len)); + if (useDecoder) + m_responseBuilder.append(m_decoder->decode(data, len)); +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + else if (responseTypeCode() == ResponseTypeArrayBuffer) { + // Buffer binary data. + if (!m_binaryResponseBuilder) + m_binaryResponseBuilder = SharedBuffer::create(); + m_binaryResponseBuilder->append(data, len); + } +#endif if (!m_error) { long long expectedLength = m_response.expectedContentLength(); @@ -1004,7 +1092,7 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) if (m_async) { bool lengthComputable = expectedLength && m_receivedLength <= expectedLength; - m_progressEventThrottle.dispatchProgressEvent(lengthComputable, static_cast<unsigned>(m_receivedLength), static_cast<unsigned>(expectedLength)); + m_progressEventThrottle.dispatchProgressEvent(lengthComputable, m_receivedLength, expectedLength); } if (m_state != LOADING) diff --git a/WebCore/xml/XMLHttpRequest.h b/WebCore/xml/XMLHttpRequest.h index 1b983e6..bc6815d 100644 --- a/WebCore/xml/XMLHttpRequest.h +++ b/WebCore/xml/XMLHttpRequest.h @@ -34,10 +34,12 @@ namespace WebCore { +class ArrayBuffer; class Blob; class Document; class DOMFormData; class ResourceRequest; +class SharedBuffer; class TextResourceDecoder; class ThreadableLoader; @@ -54,6 +56,14 @@ public: LOADING = 3, DONE = 4 }; + + enum ResponseTypeCode { + ResponseTypeDefault, + ResponseTypeText, + ResponseTypeDocument, + ResponseTypeBlob, + ResponseTypeArrayBuffer + }; virtual XMLHttpRequest* toXMLHttpRequest() { return this; } @@ -72,7 +82,7 @@ public: bool withCredentials() const { return m_includeCredentials; } void setWithCredentials(bool, ExceptionCode&); #if ENABLE(XHR_RESPONSE_BLOB) - bool asBlob() const { return m_asBlob; } + bool asBlob() const { return responseTypeCode() == ResponseTypeBlob; } void setAsBlob(bool, ExceptionCode&); #endif void open(const String& method, const KURL&, ExceptionCode&); @@ -84,6 +94,9 @@ public: void send(const String&, ExceptionCode&); void send(Blob*, ExceptionCode&); void send(DOMFormData*, ExceptionCode&); +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + void send(ArrayBuffer*, ExceptionCode&); +#endif void abort(); void setRequestHeader(const AtomicString& name, const String& value, ExceptionCode&); void overrideMimeType(const String& override); @@ -91,9 +104,22 @@ public: String getResponseHeader(const AtomicString& name, ExceptionCode&) const; String responseText(ExceptionCode&); Document* responseXML(ExceptionCode&); + Document* optionalResponseXML() const { return m_responseXML.get(); } #if ENABLE(XHR_RESPONSE_BLOB) Blob* responseBlob(ExceptionCode&) const; + Blob* optionalResponseBlob() const { return m_responseBlob.get(); } +#endif + + void setResponseType(const String&, ExceptionCode&); + String responseType(); + ResponseTypeCode responseTypeCode() const { return m_responseTypeCode; } + +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + // response attribute has custom getter. + ArrayBuffer* responseArrayBuffer(ExceptionCode&); + ArrayBuffer* optionalResponseArrayBuffer() const { return m_responseArrayBuffer.get(); } #endif + void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lineNumber; } void setLastSendURL(const String& url) { m_lastSendURL = url; } @@ -164,7 +190,6 @@ private: bool m_async; bool m_includeCredentials; #if ENABLE(XHR_RESPONSE_BLOB) - bool m_asBlob; RefPtr<Blob> m_responseBlob; #endif @@ -179,6 +204,11 @@ private: StringBuilder m_responseBuilder; mutable bool m_createdDocument; mutable RefPtr<Document> m_responseXML; + +#if ENABLE(3D_CANVAS) || ENABLE(BLOB) + RefPtr<SharedBuffer> m_binaryResponseBuilder; + mutable RefPtr<ArrayBuffer> m_responseArrayBuffer; +#endif bool m_error; @@ -197,6 +227,9 @@ private: EventTargetData m_eventTargetData; XMLHttpRequestProgressEventThrottle m_progressEventThrottle; + + // An enum corresponding to the allowed string values for the responseType attribute. + ResponseTypeCode m_responseTypeCode; }; } // namespace WebCore diff --git a/WebCore/xml/XMLHttpRequest.idl b/WebCore/xml/XMLHttpRequest.idl index 59997f8..2b0b177 100644 --- a/WebCore/xml/XMLHttpRequest.idl +++ b/WebCore/xml/XMLHttpRequest.idl @@ -95,6 +95,12 @@ module xml { readonly attribute [EnabledAtRuntime] Blob responseBlob getter raises(DOMException); #endif + + attribute DOMString responseType + setter raises(DOMException); + readonly attribute [CustomGetter] Object response + getter raises(DOMException); + readonly attribute unsigned short status getter raises(DOMException); readonly attribute DOMString statusText diff --git a/WebCore/xml/XMLHttpRequestProgressEvent.h b/WebCore/xml/XMLHttpRequestProgressEvent.h index 27f3b8c..009f1c0 100644 --- a/WebCore/xml/XMLHttpRequestProgressEvent.h +++ b/WebCore/xml/XMLHttpRequestProgressEvent.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. * Copyright (C) 2008 Julien Chaffraix <jchaffraix@webkit.org>. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,30 +31,30 @@ namespace WebCore { - class XMLHttpRequestProgressEvent : public ProgressEvent { - public: - static PassRefPtr<XMLHttpRequestProgressEvent> create() - { - return adoptRef(new XMLHttpRequestProgressEvent); - } - static PassRefPtr<XMLHttpRequestProgressEvent> create(const AtomicString& type, bool lengthComputable = false, unsigned loaded = 0, unsigned total = 0) - { - return adoptRef(new XMLHttpRequestProgressEvent(type, lengthComputable, loaded, total)); - } - - virtual bool isXMLHttpRequestProgressEvent() const { return true; } - - // Those 2 methods are to be compatible with Firefox and are only a wrapper on top of the real implementation. - unsigned position() const { return loaded(); } - unsigned totalSize() const { return total(); } - - private: - XMLHttpRequestProgressEvent() { } - XMLHttpRequestProgressEvent(const AtomicString& type, bool lengthComputable, unsigned loaded, unsigned total) - : ProgressEvent(type, lengthComputable, loaded, total) - { - } - }; +class XMLHttpRequestProgressEvent : public ProgressEvent { +public: + static PassRefPtr<XMLHttpRequestProgressEvent> create() + { + return adoptRef(new XMLHttpRequestProgressEvent); + } + static PassRefPtr<XMLHttpRequestProgressEvent> create(const AtomicString& type, bool lengthComputable = false, unsigned long long loaded = 0, unsigned long long total = 0) + { + return adoptRef(new XMLHttpRequestProgressEvent(type, lengthComputable, loaded, total)); + } + + // Those 2 synonyms are included for compatibility with Firefox. + unsigned long long position() const { return loaded(); } + unsigned long long totalSize() const { return total(); } + +private: + virtual bool isXMLHttpRequestProgressEvent() const { return true; } + + XMLHttpRequestProgressEvent() { } + XMLHttpRequestProgressEvent(const AtomicString& type, bool lengthComputable, unsigned long long loaded, unsigned long long total) + : ProgressEvent(type, lengthComputable, loaded, total) + { + } +}; } // namespace WebCore diff --git a/WebCore/xml/XMLHttpRequestProgressEvent.idl b/WebCore/xml/XMLHttpRequestProgressEvent.idl index bc5055a..05c984e 100644 --- a/WebCore/xml/XMLHttpRequestProgressEvent.idl +++ b/WebCore/xml/XMLHttpRequestProgressEvent.idl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,8 +29,8 @@ module events { NoStaticTables // We should also inherit from LSProgressEvent when the idl is added. ] XMLHttpRequestProgressEvent : ProgressEvent { - readonly attribute unsigned long position; - readonly attribute unsigned long totalSize; + readonly attribute unsigned long long position; + readonly attribute unsigned long long totalSize; }; } diff --git a/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp b/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp index 0eb6398..5d4afa3 100644 --- a/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp +++ b/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp @@ -47,7 +47,7 @@ XMLHttpRequestProgressEventThrottle::~XMLHttpRequestProgressEventThrottle() { } -void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(bool lengthComputable, unsigned loaded, unsigned total) +void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total) { ASSERT(!suspended()); if (!isActive()) { diff --git a/WebCore/xml/XMLHttpRequestProgressEventThrottle.h b/WebCore/xml/XMLHttpRequestProgressEventThrottle.h index f51aea1..036905e 100644 --- a/WebCore/xml/XMLHttpRequestProgressEventThrottle.h +++ b/WebCore/xml/XMLHttpRequestProgressEventThrottle.h @@ -48,7 +48,7 @@ public: XMLHttpRequestProgressEventThrottle(EventTarget*); virtual ~XMLHttpRequestProgressEventThrottle(); - void dispatchProgressEvent(bool lengthComputable, unsigned loaded, unsigned total); + void dispatchProgressEvent(bool lengthComputable, unsigned long long loaded, unsigned long long total); void dispatchEvent(PassRefPtr<Event>, ProgressEventAction = DoNotFlushProgressEvent); void suspend(); @@ -69,8 +69,8 @@ private: EventTarget* m_target; bool m_lengthComputable; - unsigned m_loaded; - unsigned m_total; + unsigned long long m_loaded; + unsigned long long m_total; bool m_suspended; RefPtr<Event> m_pausedEvent; diff --git a/WebCore/xml/XPathFunctions.cpp b/WebCore/xml/XPathFunctions.cpp index 8b4e720..2091aca 100644 --- a/WebCore/xml/XPathFunctions.cpp +++ b/WebCore/xml/XPathFunctions.cpp @@ -708,10 +708,9 @@ static void createFunctionMap() { "translate", { &createFunTranslate, 3 } }, { "true", { &createFunTrue, 0 } }, }; - const unsigned int numFunctions = sizeof(functions) / sizeof(functions[0]); functionMap = new HashMap<String, FunctionRec>; - for (unsigned i = 0; i < numFunctions; ++i) + for (size_t i = 0; i < WTF_ARRAY_LENGTH(functions); ++i) functionMap->set(functions[i].name, functions[i].function); } diff --git a/WebCore/xml/XSLStyleSheet.h b/WebCore/xml/XSLStyleSheet.h index acf5ea3..4312771 100644 --- a/WebCore/xml/XSLStyleSheet.h +++ b/WebCore/xml/XSLStyleSheet.h @@ -25,6 +25,7 @@ #if ENABLE(XSLT) +#include "ProcessingInstruction.h" #include "StyleSheet.h" #if !USE(QXMLQUERY) @@ -36,8 +37,6 @@ namespace WebCore { -class CachedResourceLoader; -class Document; class XSLImportRule; class XSLStyleSheet : public StyleSheet { @@ -48,15 +47,22 @@ public: return adoptRef(new XSLStyleSheet(parentImport, originalURL, finalURL)); } #endif - static PassRefPtr<XSLStyleSheet> create(Node* parentNode, const String& originalURL, const KURL& finalURL) + static PassRefPtr<XSLStyleSheet> create(ProcessingInstruction* parentNode, const String& originalURL, const KURL& finalURL) { return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false)); } - static PassRefPtr<XSLStyleSheet> createInline(Node* parentNode, const KURL& finalURL) + static PassRefPtr<XSLStyleSheet> createEmbedded(ProcessingInstruction* parentNode, const KURL& finalURL) { return adoptRef(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true)); } + // Taking an arbitrary node is unsafe, because owner node pointer can become stale. + // XSLTProcessor ensures that the stylesheet doesn't outlive its parent, in part by not exposing it to JavaScript. + static PassRefPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const KURL& finalURL) + { + return adoptRef(new XSLStyleSheet(parentNode, originalURL, finalURL, false)); + } + virtual ~XSLStyleSheet(); virtual bool isXSLStyleSheet() const { return true; } diff --git a/WebCore/xml/XSLTProcessorLibxslt.cpp b/WebCore/xml/XSLTProcessorLibxslt.cpp index 469cb64..af2987f 100644 --- a/WebCore/xml/XSLTProcessorLibxslt.cpp +++ b/WebCore/xml/XSLTProcessorLibxslt.cpp @@ -224,9 +224,12 @@ static void freeXsltParamArray(const char** params) static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode) { if (!cachedStylesheet && stylesheetRootNode) { - cachedStylesheet = XSLStyleSheet::create(stylesheetRootNode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode, + cachedStylesheet = XSLStyleSheet::createForXSLTProcessor(stylesheetRootNode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode, stylesheetRootNode->document()->url().string(), stylesheetRootNode->document()->url()); // FIXME: Should we use baseURL here? + + // According to Mozilla documentation, the node must be a Document node, an xsl:stylesheet or xsl:transform element. + // But we just use text content regardless of node type. cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); } diff --git a/WebCore/xml/XSLTProcessorQt.cpp b/WebCore/xml/XSLTProcessorQt.cpp index 29dbacf..b61025b 100644 --- a/WebCore/xml/XSLTProcessorQt.cpp +++ b/WebCore/xml/XSLTProcessorQt.cpp @@ -119,9 +119,12 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultS RefPtr<XSLStyleSheet> stylesheet = m_stylesheet; if (!stylesheet && m_stylesheetRootNode) { Node* node = m_stylesheetRootNode.get(); - stylesheet = XSLStyleSheet::create(node->parent() ? node->parent() : node, + stylesheet = XSLStyleSheet::createForXSLTProcessor(node->parentNode() ? node->parentNode() : node, node->document()->url().string(), node->document()->url()); // FIXME: Should we use baseURL here? + + // According to Mozilla documentation, the node must be a Document node, an xsl:stylesheet or xsl:transform element. + // But we just use text content regardless of node type. stylesheet->parseString(createMarkup(node)); } |