Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * This file is part of the XSL implementation. | 2 * This file is part of the XSL implementation. |
| 3 * | 3 * |
| 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. |
| 5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org> | 5 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@webkit.org> |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 } | 83 } |
| 84 | 84 |
| 85 // FIXME: There seems to be no way to control the ctxt pointer for loading here, thus we have globals. | 85 // FIXME: There seems to be no way to control the ctxt pointer for loading here, thus we have globals. |
| 86 static XSLTProcessor* globalProcessor = 0; | 86 static XSLTProcessor* globalProcessor = 0; |
| 87 static ResourceFetcher* globalResourceFetcher = 0; | 87 static ResourceFetcher* globalResourceFetcher = 0; |
| 88 | 88 |
| 89 static xmlDocPtr docLoaderFunc( | 89 static xmlDocPtr docLoaderFunc( |
| 90 const xmlChar* uri, xmlDictPtr, int options, void* ctxt, xsltLoadType type) | 90 const xmlChar* uri, xmlDictPtr, int options, void* ctxt, xsltLoadType type) |
| 91 { | 91 { |
| 92 if (!globalProcessor) | 92 if (!globalProcessor) |
| 93 return 0; | 93 return nullptr; |
| 94 | 94 |
| 95 switch (type) { | 95 switch (type) { |
| 96 case XSLT_LOAD_DOCUMENT: { | 96 case XSLT_LOAD_DOCUMENT: { |
| 97 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; | 97 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; |
| 98 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); | 98 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); |
| 99 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei nterpret_cast<const char*>(uri)); | 99 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei nterpret_cast<const char*>(uri)); |
| 100 xmlFree(base); | 100 xmlFree(base); |
| 101 | 101 |
| 102 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptio ns()); | 102 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptio ns()); |
| 103 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, fetchOptions); | 103 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml, fetchOptions); |
| 104 request.setOriginRestriction(FetchRequest::RestrictToSameOrigin); | 104 request.setOriginRestriction(FetchRequest::RestrictToSameOrigin); |
| 105 ResourcePtr<Resource> resource = globalResourceFetcher->fetchSynchronous ly(request); | 105 ResourcePtr<Resource> resource = globalResourceFetcher->fetchSynchronous ly(request); |
| 106 if (!resource || !globalProcessor) | 106 if (!resource || !globalProcessor) |
| 107 return 0; | 107 return nullptr; |
| 108 | 108 |
| 109 FrameConsole* console = 0; | 109 FrameConsole* console = 0; |
|
sof
2015/06/08 07:09:06
s/0/nullptr/
| |
| 110 LocalFrame* frame = globalProcessor->xslStylesheet()->ownerDocument()->f rame(); | 110 LocalFrame* frame = globalProcessor->xslStylesheet()->ownerDocument()->f rame(); |
| 111 if (frame) | 111 if (frame) |
| 112 console = &frame->console(); | 112 console = &frame->console(); |
| 113 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc); | 113 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc); |
| 114 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc); | 114 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc); |
| 115 | 115 |
| 116 // We don't specify an encoding here. Neither Gecko nor WinIE respects | 116 // We don't specify an encoding here. Neither Gecko nor WinIE respects |
| 117 // the encoding specified in the HTTP headers. | 117 // the encoding specified in the HTTP headers. |
| 118 SharedBuffer* data = resource->resourceBuffer(); | 118 SharedBuffer* data = resource->resourceBuffer(); |
| 119 xmlDocPtr doc = data ? xmlReadMemory(data->data(), data->size(), (const char*)uri, 0, options) : 0; | 119 xmlDocPtr doc = data ? xmlReadMemory(data->data(), data->size(), (const char*)uri, 0, options) : 0; |
| 120 | 120 |
| 121 xmlSetStructuredErrorFunc(0, 0); | 121 xmlSetStructuredErrorFunc(0, 0); |
| 122 xmlSetGenericErrorFunc(0, 0); | 122 xmlSetGenericErrorFunc(0, 0); |
| 123 | 123 |
| 124 return doc; | 124 return doc; |
| 125 } | 125 } |
| 126 case XSLT_LOAD_STYLESHEET: | 126 case XSLT_LOAD_STYLESHEET: |
| 127 return globalProcessor->xslStylesheet()->locateStylesheetSubResource(((x sltStylesheetPtr)ctxt)->doc, uri); | 127 return globalProcessor->xslStylesheet()->locateStylesheetSubResource(((x sltStylesheetPtr)ctxt)->doc, uri); |
| 128 default: | 128 default: |
| 129 break; | 129 break; |
| 130 } | 130 } |
| 131 | 131 |
| 132 return 0; | 132 return nullptr; |
| 133 } | 133 } |
| 134 | 134 |
| 135 static inline void setXSLTLoadCallBack(xsltDocLoaderFunc func, XSLTProcessor* pr ocessor, ResourceFetcher* fetcher) | 135 static inline void setXSLTLoadCallBack(xsltDocLoaderFunc func, XSLTProcessor* pr ocessor, ResourceFetcher* fetcher) |
| 136 { | 136 { |
| 137 xsltSetLoaderFunc(func); | 137 xsltSetLoaderFunc(func); |
| 138 globalProcessor = processor; | 138 globalProcessor = processor; |
| 139 globalResourceFetcher = fetcher; | 139 globalResourceFetcher = fetcher; |
| 140 } | 140 } |
| 141 | 141 |
| 142 static int writeToStringBuilder(void* context, const char* buffer, int len) | 142 static int writeToStringBuilder(void* context, const char* buffer, int len) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 resultBuilder.resize(resultBuilder.length() - 1); | 183 resultBuilder.resize(resultBuilder.length() - 1); |
| 184 | 184 |
| 185 resultString = resultBuilder.toString(); | 185 resultString = resultBuilder.toString(); |
| 186 | 186 |
| 187 return true; | 187 return true; |
| 188 } | 188 } |
| 189 | 189 |
| 190 static const char** xsltParamArrayFromParameterMap(XSLTProcessor::ParameterMap& parameters) | 190 static const char** xsltParamArrayFromParameterMap(XSLTProcessor::ParameterMap& parameters) |
| 191 { | 191 { |
| 192 if (parameters.isEmpty()) | 192 if (parameters.isEmpty()) |
| 193 return 0; | 193 return nullptr; |
| 194 | 194 |
| 195 const char** parameterArray = static_cast<const char**>(fastMalloc(((paramet ers.size() * 2) + 1) * sizeof(char*))); | 195 const char** parameterArray = static_cast<const char**>(fastMalloc(((paramet ers.size() * 2) + 1) * sizeof(char*))); |
| 196 | 196 |
| 197 unsigned index = 0; | 197 unsigned index = 0; |
| 198 for (auto& parameter : parameters) { | 198 for (auto& parameter : parameters) { |
| 199 parameterArray[index++] = fastStrDup(parameter.key.utf8().data()); | 199 parameterArray[index++] = fastStrDup(parameter.key.utf8().data()); |
| 200 parameterArray[index++] = fastStrDup(parameter.value.utf8().data()); | 200 parameterArray[index++] = fastStrDup(parameter.value.utf8().data()); |
| 201 } | 201 } |
| 202 parameterArray[index] = 0; | 202 parameterArray[index] = 0; |
| 203 | 203 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 227 stylesheetRootNode->document().url().string(), | 227 stylesheetRootNode->document().url().string(), |
| 228 stylesheetRootNode->document().url()); // FIXME: Should we use baseU RL here? | 228 stylesheetRootNode->document().url()); // FIXME: Should we use baseU RL here? |
| 229 | 229 |
| 230 // According to Mozilla documentation, the node must be a Document node, | 230 // According to Mozilla documentation, the node must be a Document node, |
| 231 // an xsl:stylesheet or xsl:transform element. But we just use text | 231 // an xsl:stylesheet or xsl:transform element. But we just use text |
| 232 // content regardless of node type. | 232 // content regardless of node type. |
| 233 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); | 233 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 if (!cachedStylesheet || !cachedStylesheet->document()) | 236 if (!cachedStylesheet || !cachedStylesheet->document()) |
| 237 return 0; | 237 return nullptr; |
| 238 | 238 |
| 239 return cachedStylesheet->compileStyleSheet(); | 239 return cachedStylesheet->compileStyleSheet(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) | 242 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) |
| 243 { | 243 { |
| 244 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); | 244 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); |
| 245 bool sourceIsDocument = (sourceNode == ownerDocument.get()); | 245 bool sourceIsDocument = (sourceNode == ownerDocument.get()); |
| 246 | 246 |
| 247 xmlDocPtr sourceDoc = 0; | 247 xmlDocPtr sourceDoc = 0; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 | 344 |
| 345 sheet->method = origMethod; | 345 sheet->method = origMethod; |
| 346 setXSLTLoadCallBack(0, 0, 0); | 346 setXSLTLoadCallBack(0, 0, 0); |
| 347 xsltFreeStylesheet(sheet); | 347 xsltFreeStylesheet(sheet); |
| 348 m_stylesheet = nullptr; | 348 m_stylesheet = nullptr; |
| 349 | 349 |
| 350 return success; | 350 return success; |
| 351 } | 351 } |
| 352 | 352 |
| 353 } // namespace blink | 353 } // namespace blink |
| OLD | NEW |