Commit cae0ffba authored by tkent@chromium.org's avatar tkent@chromium.org

Fix style errors in core/xml/.

BUG=

Review URL: https://codereview.chromium.org/333143003

git-svn-id: svn://svn.chromium.org/blink/trunk@176505 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3adad0ac
...@@ -61,13 +61,13 @@ void XMLErrors::handleError(ErrorType type, const char* message, int lineNumber, ...@@ -61,13 +61,13 @@ void XMLErrors::handleError(ErrorType type, const char* message, int lineNumber,
void XMLErrors::handleError(ErrorType type, const char* message, TextPosition position) void XMLErrors::handleError(ErrorType type, const char* message, TextPosition position)
{ {
if (type == fatal || (m_errorCount < maxErrors && m_lastErrorPosition.m_line != position.m_line && m_lastErrorPosition.m_column != position.m_column)) { if (type == ErrorTypeFatal || (m_errorCount < maxErrors && m_lastErrorPosition.m_line != position.m_line && m_lastErrorPosition.m_column != position.m_column)) {
switch (type) { switch (type) {
case warning: case ErrorTypeWarning:
appendErrorMessage("warning", position, message); appendErrorMessage("warning", position, message);
break; break;
case fatal: case ErrorTypeFatal:
case nonFatal: case ErrorTypeNonFatal:
appendErrorMessage("error", position, message); appendErrorMessage("error", position, message);
} }
......
...@@ -44,7 +44,7 @@ public: ...@@ -44,7 +44,7 @@ public:
void trace(Visitor*); void trace(Visitor*);
// Exposed for callbacks: // Exposed for callbacks:
enum ErrorType { warning, nonFatal, fatal }; enum ErrorType { ErrorTypeWarning, ErrorTypeNonFatal, ErrorTypeFatal };
void handleError(ErrorType, const char* message, int lineNumber, int columnNumber); void handleError(ErrorType, const char* message, int lineNumber, int columnNumber);
void handleError(ErrorType, const char* message, TextPosition); void handleError(ErrorType, const char* message, TextPosition);
......
...@@ -717,10 +717,11 @@ void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) ...@@ -717,10 +717,11 @@ void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState)
if (areMethodAndURLValidForSend()) { if (areMethodAndURLValidForSend()) {
if (getRequestHeader("Content-Type").isEmpty()) { if (getRequestHeader("Content-Type").isEmpty()) {
const String& blobType = body->type(); const String& blobType = body->type();
if (!blobType.isEmpty() && isValidContentType(blobType)) if (!blobType.isEmpty() && isValidContentType(blobType)) {
setRequestHeaderInternal("Content-Type", AtomicString(blobType)); setRequestHeaderInternal("Content-Type", AtomicString(blobType));
else { } else {
// From FileAPI spec, whenever media type cannot be determined, empty string must be returned. // From FileAPI spec, whenever media type cannot be determined,
// empty string must be returned.
setRequestHeaderInternal("Content-Type", ""); setRequestHeaderInternal("Content-Type", "");
} }
} }
...@@ -1345,19 +1346,22 @@ void XMLHttpRequest::didReceiveData(const char* data, int len) ...@@ -1345,19 +1346,22 @@ void XMLHttpRequest::didReceiveData(const char* data, int len)
bool useDecoder = m_responseTypeCode == ResponseTypeDefault || m_responseTypeCode == ResponseTypeText || m_responseTypeCode == ResponseTypeJSON || m_responseTypeCode == ResponseTypeDocument; bool useDecoder = m_responseTypeCode == ResponseTypeDefault || m_responseTypeCode == ResponseTypeText || m_responseTypeCode == ResponseTypeJSON || m_responseTypeCode == ResponseTypeDocument;
if (useDecoder && !m_decoder) { if (useDecoder && !m_decoder) {
if (m_responseTypeCode == ResponseTypeJSON) if (m_responseTypeCode == ResponseTypeJSON) {
m_decoder = TextResourceDecoder::create("application/json", "UTF-8"); m_decoder = TextResourceDecoder::create("application/json", "UTF-8");
else if (!m_responseEncoding.isEmpty()) } else if (!m_responseEncoding.isEmpty()) {
m_decoder = TextResourceDecoder::create("text/plain", m_responseEncoding); m_decoder = TextResourceDecoder::create("text/plain", m_responseEncoding);
// allow TextResourceDecoder to look inside the m_response if it's XML or HTML // allow TextResourceDecoder to look inside the m_response if it's XML or HTML
else if (responseIsXML()) { } else if (responseIsXML()) {
m_decoder = TextResourceDecoder::create("application/xml"); m_decoder = TextResourceDecoder::create("application/xml");
// Don't stop on encoding errors, unlike it is done for other kinds of XML resources. This matches the behavior of previous WebKit versions, Firefox and Opera. // Don't stop on encoding errors, unlike it is done for other kinds
// of XML resources. This matches the behavior of previous WebKit
// versions, Firefox and Opera.
m_decoder->useLenientXMLDecoding(); m_decoder->useLenientXMLDecoding();
} else if (equalIgnoringCase(responseMIMEType(), "text/html")) } else if (equalIgnoringCase(responseMIMEType(), "text/html")) {
m_decoder = TextResourceDecoder::create("text/html", "UTF-8"); m_decoder = TextResourceDecoder::create("text/html", "UTF-8");
else } else {
m_decoder = TextResourceDecoder::create("text/plain", "UTF-8"); m_decoder = TextResourceDecoder::create("text/plain", "UTF-8");
}
} }
if (!len) if (!len)
......
...@@ -53,7 +53,12 @@ class ThreadableLoader; ...@@ -53,7 +53,12 @@ class ThreadableLoader;
typedef int ExceptionCode; typedef int ExceptionCode;
class XMLHttpRequest FINAL : public RefCountedWillBeRefCountedGarbageCollected<XMLHttpRequest>, public ScriptWrappable, public XMLHttpRequestEventTarget, private ThreadableLoaderClient, public ActiveDOMObject { class XMLHttpRequest FINAL
: public RefCountedWillBeRefCountedGarbageCollected<XMLHttpRequest>
, public ScriptWrappable
, public XMLHttpRequestEventTarget
, private ThreadableLoaderClient
, public ActiveDOMObject {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
REFCOUNTED_EVENT_TARGET(XMLHttpRequest); REFCOUNTED_EVENT_TARGET(XMLHttpRequest);
WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(XMLHttpRequest); WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(XMLHttpRequest);
......
...@@ -101,8 +101,9 @@ void XMLHttpRequestProgressEventThrottle::dispatchEvent(PassRefPtrWillBeRawPtr<E ...@@ -101,8 +101,9 @@ void XMLHttpRequestProgressEventThrottle::dispatchEvent(PassRefPtrWillBeRawPtr<E
return; return;
} }
m_deferredEvents.append(event); m_deferredEvents.append(event);
} else } else {
m_target->dispatchEvent(event); m_target->dispatchEvent(event);
}
} }
bool XMLHttpRequestProgressEventThrottle::flushDeferredProgressEvent() bool XMLHttpRequestProgressEventThrottle::flushDeferredProgressEvent()
......
...@@ -69,13 +69,12 @@ void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, co ...@@ -69,13 +69,12 @@ void XSLImportRule::setXSLStyleSheet(const String& href, const KURL& baseURL, co
bool XSLImportRule::isLoading() bool XSLImportRule::isLoading()
{ {
return (m_loading || (m_styleSheet && m_styleSheet->isLoading())); return m_loading || (m_styleSheet && m_styleSheet->isLoading());
} }
void XSLImportRule::loadSheet() void XSLImportRule::loadSheet()
{ {
ResourceFetcher* fetcher = 0; ResourceFetcher* fetcher = 0;
XSLStyleSheet* rootSheet = parentStyleSheet(); XSLStyleSheet* rootSheet = parentStyleSheet();
if (rootSheet) { if (rootSheet) {
...@@ -88,12 +87,13 @@ void XSLImportRule::loadSheet() ...@@ -88,12 +87,13 @@ void XSLImportRule::loadSheet()
String absHref = m_strHref; String absHref = m_strHref;
XSLStyleSheet* parentSheet = parentStyleSheet(); XSLStyleSheet* parentSheet = parentStyleSheet();
if (!parentSheet->baseURL().isNull()) if (!parentSheet->baseURL().isNull()) {
// use parent styleheet's URL as the base URL // Use parent styleheet's URL as the base URL
absHref = KURL(parentSheet->baseURL(), m_strHref).string(); absHref = KURL(parentSheet->baseURL(), m_strHref).string();
}
// Check for a cycle in our import chain. If we encounter a stylesheet // Check for a cycle in our import chain. If we encounter a stylesheet in
// in our parent chain with the same URL, then just bail. // our parent chain with the same URL, then just bail.
for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentSheet = parentSheet->parentStyleSheet()) { for (XSLStyleSheet* parentSheet = parentStyleSheet(); parentSheet; parentSheet = parentSheet->parentStyleSheet()) {
if (absHref == parentSheet->baseURL().string()) if (absHref == parentSheet->baseURL().string())
return; return;
...@@ -105,10 +105,10 @@ void XSLImportRule::loadSheet() ...@@ -105,10 +105,10 @@ void XSLImportRule::loadSheet()
if (m_resource) { if (m_resource) {
m_resource->addClient(this); m_resource->addClient(this);
// If the imported sheet is in the cache, then setXSLStyleSheet gets called, // If the imported sheet is in the cache, then setXSLStyleSheet gets
// and the sheet even gets parsed (via parseString). In this case we have // called, and the sheet even gets parsed (via parseString). In this
// loaded (even if our subresources haven't), so if we have a stylesheet after // case we have loaded (even if our subresources haven't), so if we have
// checking the cache, then we've clearly loaded. // a stylesheet after checking the cache, then we've clearly loaded.
if (!m_styleSheet) if (!m_styleSheet)
m_loading = true; m_loading = true;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "core/dom/ProcessingInstruction.h" #include "core/dom/ProcessingInstruction.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "wtf/PassRefPtr.h" #include "wtf/PassRefPtr.h"
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxslt/transform.h> #include <libxslt/transform.h>
...@@ -54,8 +53,9 @@ public: ...@@ -54,8 +53,9 @@ public:
return adoptRefWillBeNoop(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true)); return adoptRefWillBeNoop(new XSLStyleSheet(parentNode, finalURL.string(), finalURL, true));
} }
// Taking an arbitrary node is unsafe, because owner node pointer can become stale. // Taking an arbitrary node is unsafe, because owner node pointer can become
// XSLTProcessor ensures that the stylesheet doesn't outlive its parent, in part by not exposing it to JavaScript. // stale. XSLTProcessor ensures that the stylesheet doesn't outlive its
// parent, in part by not exposing it to JavaScript.
static PassRefPtrWillBeRawPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const KURL& finalURL) static PassRefPtrWillBeRawPtr<XSLStyleSheet> createForXSLTProcessor(Node* parentNode, const String& originalURL, const KURL& finalURL)
{ {
ASSERT(RuntimeEnabledFeatures::xsltEnabled()); ASSERT(RuntimeEnabledFeatures::xsltEnabled());
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
Document* ownerDocument(); Document* ownerDocument();
virtual XSLStyleSheet* parentStyleSheet() const OVERRIDE { return m_parentStyleSheet; } virtual XSLStyleSheet* parentStyleSheet() const OVERRIDE { return m_parentStyleSheet; }
void setParentStyleSheet(XSLStyleSheet* parent); void setParentStyleSheet(XSLStyleSheet*);
xmlDocPtr document(); xmlDocPtr document();
xsltStylesheetPtr compileStyleSheet(); xsltStylesheetPtr compileStyleSheet();
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "core/xml/parser/XMLDocumentParserScope.h" #include "core/xml/parser/XMLDocumentParserScope.h"
#include "core/xml/parser/XMLParserInput.h" #include "core/xml/parser/XMLParserInput.h"
#include "wtf/text/CString.h" #include "wtf/text/CString.h"
#include <libxml/uri.h> #include <libxml/uri.h>
#include <libxslt/xsltutils.h> #include <libxslt/xsltutils.h>
...@@ -44,7 +43,9 @@ XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR ...@@ -44,7 +43,9 @@ XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
, m_finalURL(finalURL) , m_finalURL(finalURL)
, m_isDisabled(false) , m_isDisabled(false)
, m_embedded(false) , m_embedded(false)
, m_processed(false) // Child sheets get marked as processed when the libxslt engine has finally seen them. // Child sheets get marked as processed when the libxslt engine has finally
// seen them.
, m_processed(false)
, m_stylesheetDoc(0) , m_stylesheetDoc(0)
, m_stylesheetDocTaken(false) , m_stylesheetDocTaken(false)
, m_compilationFailed(false) , m_compilationFailed(false)
...@@ -116,10 +117,9 @@ void XSLStyleSheet::clearDocuments() ...@@ -116,10 +117,9 @@ void XSLStyleSheet::clearDocuments()
ResourceFetcher* XSLStyleSheet::fetcher() ResourceFetcher* XSLStyleSheet::fetcher()
{ {
Document* document = ownerDocument(); if (Document* document = ownerDocument())
if (!document) return document->fetcher();
return 0; return 0;
return document->fetcher();
} }
bool XSLStyleSheet::parseString(const String& source) bool XSLStyleSheet::parseString(const String& source)
...@@ -130,8 +130,7 @@ bool XSLStyleSheet::parseString(const String& source) ...@@ -130,8 +130,7 @@ bool XSLStyleSheet::parseString(const String& source)
m_stylesheetDocTaken = false; m_stylesheetDocTaken = false;
FrameConsole* console = 0; FrameConsole* console = 0;
LocalFrame* frame = ownerDocument()->frame(); if (LocalFrame* frame = ownerDocument()->frame())
if (frame)
console = &frame->console(); console = &frame->console();
XMLDocumentParserScope scope(fetcher(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console); XMLDocumentParserScope scope(fetcher(), XSLTProcessor::genericErrorFunc, XSLTProcessor::parseErrorFunc, console);
...@@ -169,25 +168,26 @@ void XSLStyleSheet::loadChildSheets() ...@@ -169,25 +168,26 @@ void XSLStyleSheet::loadChildSheets()
xmlNodePtr stylesheetRoot = document()->children; xmlNodePtr stylesheetRoot = document()->children;
// Top level children may include other things such as DTD nodes, we ignore those. // Top level children may include other things such as DTD nodes, we ignore
// those.
while (stylesheetRoot && stylesheetRoot->type != XML_ELEMENT_NODE) while (stylesheetRoot && stylesheetRoot->type != XML_ELEMENT_NODE)
stylesheetRoot = stylesheetRoot->next; stylesheetRoot = stylesheetRoot->next;
if (m_embedded) { if (m_embedded) {
// We have to locate (by ID) the appropriate embedded stylesheet element, so that we can walk the // We have to locate (by ID) the appropriate embedded stylesheet
// import/include list. // element, so that we can walk the import/include list.
xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(finalURL().string().utf8().data())); xmlAttrPtr idNode = xmlGetID(document(), (const xmlChar*)(finalURL().string().utf8().data()));
if (!idNode) if (!idNode)
return; return;
stylesheetRoot = idNode->parent; stylesheetRoot = idNode->parent;
} else { } else {
// FIXME: Need to handle an external URI with a # in it. This is a pretty minor edge case, so we'll deal // FIXME: Need to handle an external URI with a # in it. This is a
// with it later. // pretty minor edge case, so we'll deal with it later.
} }
if (stylesheetRoot) { if (stylesheetRoot) {
// Walk the children of the root element and look for import/include elements. // Walk the children of the root element and look for import/include
// Imports must occur first. // elements. Imports must occur first.
xmlNodePtr curr = stylesheetRoot->children; xmlNodePtr curr = stylesheetRoot->children;
while (curr) { while (curr) {
if (curr->type != XML_ELEMENT_NODE) { if (curr->type != XML_ELEMENT_NODE) {
...@@ -198,8 +198,9 @@ void XSLStyleSheet::loadChildSheets() ...@@ -198,8 +198,9 @@ void XSLStyleSheet::loadChildSheets()
xmlChar* uriRef = xsltGetNsProp(curr, (const xmlChar*)"href", XSLT_NAMESPACE); xmlChar* uriRef = xsltGetNsProp(curr, (const xmlChar*)"href", XSLT_NAMESPACE);
loadChildSheet(String::fromUTF8((const char*)uriRef)); loadChildSheet(String::fromUTF8((const char*)uriRef));
xmlFree(uriRef); xmlFree(uriRef);
} else } else {
break; break;
}
curr = curr->next; curr = curr->next;
} }
...@@ -229,8 +230,8 @@ xsltStylesheetPtr XSLStyleSheet::compileStyleSheet() ...@@ -229,8 +230,8 @@ xsltStylesheetPtr XSLStyleSheet::compileStyleSheet()
if (m_embedded) if (m_embedded)
return xsltLoadStylesheetPI(document()); return xsltLoadStylesheetPI(document());
// Certain libxslt versions are corrupting the xmlDoc on compilation failures - // Certain libxslt versions are corrupting the xmlDoc on compilation
// hence attempting to recompile after a failure is unsafe. // failures - hence attempting to recompile after a failure is unsafe.
if (m_compilationFailed) if (m_compilationFailed)
return 0; return 0;
...@@ -273,9 +274,9 @@ xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const ...@@ -273,9 +274,9 @@ xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const
continue; // libxslt has been given this sheet already. continue; // libxslt has been given this sheet already.
// Check the URI of the child stylesheet against the doc URI. // Check the URI of the child stylesheet against the doc URI.
// In order to ensure that libxml canonicalized both URLs, we get the original href // In order to ensure that libxml canonicalized both URLs, we get
// string from the import rule and canonicalize it using libxml before comparing it // the original href string from the import rule and canonicalize it
// with the URI argument. // using libxml before comparing it with the URI argument.
CString importHref = import->href().utf8(); CString importHref = import->href().utf8();
xmlChar* base = xmlNodeGetBase(parentDoc, (xmlNodePtr)parentDoc); xmlChar* base = xmlNodeGetBase(parentDoc, (xmlNodePtr)parentDoc);
xmlChar* childURI = xmlBuildURI((const xmlChar*)importHref.data(), base); xmlChar* childURI = xmlBuildURI((const xmlChar*)importHref.data(), base);
......
...@@ -25,23 +25,22 @@ ...@@ -25,23 +25,22 @@
*/ */
#include "config.h" #include "config.h"
#include "core/xml/XSLTExtensions.h" #include "core/xml/XSLTExtensions.h"
#include "platform/RuntimeEnabledFeatures.h" #include "platform/RuntimeEnabledFeatures.h"
#include "wtf/Assertions.h" #include "wtf/Assertions.h"
#include <libxml/xpathInternals.h> #include <libxml/xpathInternals.h>
#include <libxslt/extensions.h> #include <libxslt/extensions.h>
#include <libxslt/extra.h> #include <libxslt/extra.h>
#include <libxslt/xsltutils.h> #include <libxslt/xsltutils.h>
namespace WebCore { namespace WebCore {
// FIXME: This code is taken from libexslt 1.1.11; should sync with newer versions. // FIXME: This code is taken from libexslt 1.1.11; should sync with newer
// versions.
static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs) static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs)
{ {
xmlChar *strval; xmlChar* strval;
xmlNodePtr retNode; xmlNodePtr retNode;
xmlXPathObjectPtr ret; xmlXPathObjectPtr ret;
...@@ -56,15 +55,15 @@ static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs) ...@@ -56,15 +55,15 @@ static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs)
} }
strval = xmlXPathPopString(ctxt); strval = xmlXPathPopString(ctxt);
retNode = xmlNewDocText(NULL, strval); retNode = xmlNewDocText(0, strval);
ret = xmlXPathNewValueTree(retNode); ret = xmlXPathNewValueTree(retNode);
// FIXME: It might be helpful to push any errors from xmlXPathNewValueTree // FIXME: It might be helpful to push any errors from xmlXPathNewValueTree
// up to the Javascript Console. // up to the Javascript Console.
if (ret != NULL) if (ret)
ret->type = XPATH_NODESET; ret->type = XPATH_NODESET;
if (strval != NULL) if (strval)
xmlFree(strval); xmlFree(strval);
valuePush(ctxt, ret); valuePush(ctxt, ret);
......
...@@ -85,11 +85,9 @@ void XSLTProcessor::parseErrorFunc(void* userData, xmlError* error) ...@@ -85,11 +85,9 @@ void XSLTProcessor::parseErrorFunc(void* userData, xmlError* error)
// FIXME: There seems to be no way to control the ctxt pointer for loading here, thus we have globals. // FIXME: There seems to be no way to control the ctxt pointer for loading here, thus we have globals.
static XSLTProcessor* globalProcessor = 0; static XSLTProcessor* globalProcessor = 0;
static ResourceFetcher* globalResourceFetcher = 0; static ResourceFetcher* globalResourceFetcher = 0;
static xmlDocPtr docLoaderFunc(const xmlChar* uri,
xmlDictPtr, static xmlDocPtr docLoaderFunc(
int options, const xmlChar* uri, xmlDictPtr, int options, void* ctxt, xsltLoadType type)
void* ctxt,
xsltLoadType type)
{ {
if (!globalProcessor) if (!globalProcessor)
return 0; return 0;
...@@ -179,7 +177,8 @@ static bool saveResultToString(xmlDocPtr resultDoc, xsltStylesheetPtr sheet, Str ...@@ -179,7 +177,8 @@ static bool saveResultToString(xmlDocPtr resultDoc, xsltStylesheetPtr sheet, Str
if (retval < 0) if (retval < 0)
return false; return false;
// Workaround for <http://bugzilla.gnome.org/show_bug.cgi?id=495668>: libxslt appends an extra line feed to the result. // Workaround for <http://bugzilla.gnome.org/show_bug.cgi?id=495668>:
// libxslt appends an extra line feed to the result.
if (resultBuilder.length() > 0 && resultBuilder[resultBuilder.length() - 1] == '\n') if (resultBuilder.length() > 0 && resultBuilder[resultBuilder.length() - 1] == '\n')
resultBuilder.resize(resultBuilder.length() - 1); resultBuilder.resize(resultBuilder.length() - 1);
...@@ -193,7 +192,7 @@ static const char** xsltParamArrayFromParameterMap(XSLTProcessor::ParameterMap& ...@@ -193,7 +192,7 @@ static const char** xsltParamArrayFromParameterMap(XSLTProcessor::ParameterMap&
if (parameters.isEmpty()) if (parameters.isEmpty())
return 0; return 0;
const char** parameterArray = (const char**)fastMalloc(((parameters.size() * 2) + 1) * sizeof(char*)); const char** parameterArray = static_cast<const char**>(fastMalloc(((parameters.size() * 2) + 1) * sizeof(char*)));
XSLTProcessor::ParameterMap::iterator end = parameters.end(); XSLTProcessor::ParameterMap::iterator end = parameters.end();
unsigned index = 0; unsigned index = 0;
...@@ -213,8 +212,8 @@ static void freeXsltParamArray(const char** params) ...@@ -213,8 +212,8 @@ static void freeXsltParamArray(const char** params)
return; return;
while (*temp) { while (*temp) {
fastFree((void*)*(temp++)); fastFree(const_cast<char*>(*(temp++)));
fastFree((void*)*(temp++)); fastFree(const_cast<char*>(*(temp++)));
} }
fastFree(params); fastFree(params);
} }
...@@ -222,12 +221,14 @@ static void freeXsltParamArray(const char** params) ...@@ -222,12 +221,14 @@ static void freeXsltParamArray(const char** params)
static xsltStylesheetPtr xsltStylesheetPointer(RefPtrWillBeMember<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode) static xsltStylesheetPtr xsltStylesheetPointer(RefPtrWillBeMember<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode)
{ {
if (!cachedStylesheet && stylesheetRootNode) { if (!cachedStylesheet && stylesheetRootNode) {
cachedStylesheet = XSLStyleSheet::createForXSLTProcessor(stylesheetRootNode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode, cachedStylesheet = XSLStyleSheet::createForXSLTProcessor(
stylesheetRootNode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode,
stylesheetRootNode->document().url().string(), stylesheetRootNode->document().url().string(),
stylesheetRootNode->document().url()); // FIXME: Should we use baseURL here? 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. // According to Mozilla documentation, the node must be a Document node,
// But we just use text content regardless of node type. // an xsl:stylesheet or xsl:transform element. But we just use text
// content regardless of node type.
cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); cachedStylesheet->parseString(createMarkup(stylesheetRootNode));
} }
...@@ -292,8 +293,9 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String ...@@ -292,8 +293,9 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
bool success = false; bool success = false;
bool shouldFreeSourceDoc = false; bool shouldFreeSourceDoc = false;
if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) { if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) {
// The XML declaration would prevent parsing the result as a fragment, and it's not needed even for documents, // The XML declaration would prevent parsing the result as a fragment,
// as the result of this function is always immediately parsed. // and it's not needed even for documents, as the result of this
// function is always immediately parsed.
sheet->omitXmlDeclaration = true; sheet->omitXmlDeclaration = true;
xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc); xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc);
...@@ -310,13 +312,15 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String ...@@ -310,13 +312,15 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
if (0 != xsltSetCtxtSecurityPrefs(securityPrefs, transformContext)) if (0 != xsltSetCtxtSecurityPrefs(securityPrefs, transformContext))
CRASH(); CRASH();
// <http://bugs.webkit.org/show_bug.cgi?id=16077>: XSLT processor <xsl:sort> algorithm only compares by code point. // <http://bugs.webkit.org/show_bug.cgi?id=16077>: XSLT processor
// <xsl:sort> algorithm only compares by code point.
xsltSetCtxtSortFunc(transformContext, xsltUnicodeSortFunction); xsltSetCtxtSortFunc(transformContext, xsltUnicodeSortFunction);
// This is a workaround for a bug in libxslt. // This is a workaround for a bug in libxslt.
// The bug has been fixed in version 1.1.13, so once we ship that this can be removed. // The bug has been fixed in version 1.1.13, so once we ship that this
// can be removed.
if (!transformContext->globalVars) if (!transformContext->globalVars)
transformContext->globalVars = xmlHashCreate(20); transformContext->globalVars = xmlHashCreate(20);
const char** params = xsltParamArrayFromParameterMap(m_parameters); const char** params = xsltParamArrayFromParameterMap(m_parameters);
xsltQuoteUserParams(transformContext, params); xsltQuoteUserParams(transformContext, params);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
namespace WebCore { namespace WebCore {
void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr* sorts, int nbsorts); void xsltUnicodeSortFunction(xsltTransformContextPtr ctxt, xmlNodePtr* sorts, int nbsorts);
} }
......
...@@ -33,23 +33,22 @@ namespace WebCore { ...@@ -33,23 +33,22 @@ namespace WebCore {
class ResourceFetcher; class ResourceFetcher;
class XMLDocumentParserScope { class XMLDocumentParserScope {
WTF_MAKE_NONCOPYABLE(XMLDocumentParserScope); WTF_MAKE_NONCOPYABLE(XMLDocumentParserScope);
public: public:
explicit XMLDocumentParserScope(ResourceFetcher*); explicit XMLDocumentParserScope(ResourceFetcher*);
~XMLDocumentParserScope(); XMLDocumentParserScope(ResourceFetcher*, xmlGenericErrorFunc, xmlStructuredErrorFunc = 0, void* errorContext = 0);
~XMLDocumentParserScope();
static ResourceFetcher* currentFetcher;
static ResourceFetcher* currentFetcher;
XMLDocumentParserScope(ResourceFetcher*, xmlGenericErrorFunc, xmlStructuredErrorFunc = 0, void* errorContext = 0);
private:
private: ResourceFetcher* m_oldFetcher;
ResourceFetcher* m_oldFetcher;
xmlGenericErrorFunc m_oldGenericErrorFunc;
xmlGenericErrorFunc m_oldGenericErrorFunc; xmlStructuredErrorFunc m_oldStructuredErrorFunc;
xmlStructuredErrorFunc m_oldStructuredErrorFunc; void* m_oldErrorContext;
void* m_oldErrorContext; };
};
} // namespace WebCore } // namespace WebCore
......
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