Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: Source/core/xml/XSLTProcessorLibxslt.cpp

Issue 1161323007: Use nullptr instead of 0 in xml and xmlhttprequest. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated as per review comment & modified in other files which assigned "0" to ptr. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/xml/XSLStyleSheetLibxslt.cpp ('k') | Source/core/xml/XSLTUnicodeSort.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 case XML_ERR_FATAL: 76 case XML_ERR_FATAL:
77 default: 77 default:
78 level = ErrorMessageLevel; 78 level = ErrorMessageLevel;
79 break; 79 break;
80 } 80 }
81 81
82 console->addMessage(ConsoleMessage::create(XMLMessageSource, level, error->m essage, error->file, error->line)); 82 console->addMessage(ConsoleMessage::create(XMLMessageSource, level, error->m essage, error->file, error->line));
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 = nullptr;
87 static ResourceFetcher* globalResourceFetcher = 0; 87 static ResourceFetcher* globalResourceFetcher = nullptr;
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 = 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) : nullptr;
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
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
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 = nullptr;
248 if (sourceIsDocument && ownerDocument->transformSource()) 248 if (sourceIsDocument && ownerDocument->transformSource())
249 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource( ); 249 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource( );
250 if (!sourceDoc) { 250 if (!sourceDoc) {
251 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument.get(), createMar kup(sourceNode), 251 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument.get(), createMar kup(sourceNode),
252 sourceIsDocument ? ownerDocument->url().string() : String()); 252 sourceIsDocument ? ownerDocument->url().string() : String());
253 shouldDelete = sourceDoc; 253 shouldDelete = sourceDoc;
254 } 254 }
255 return sourceDoc; 255 return sourceDoc;
256 } 256 }
257 257
258 static inline String resultMIMEType(xmlDocPtr resultDoc, xsltStylesheetPtr sheet ) 258 static inline String resultMIMEType(xmlDocPtr resultDoc, xsltStylesheetPtr sheet )
259 { 259 {
260 // There are three types of output we need to be able to deal with: 260 // There are three types of output we need to be able to deal with:
261 // HTML (create an HTML document), XML (create an XML document), 261 // HTML (create an HTML document), XML (create an XML document),
262 // and text (wrap in a <pre> and create an XML document). 262 // and text (wrap in a <pre> and create an XML document).
263 263
264 const xmlChar* resultType = 0; 264 const xmlChar* resultType = nullptr;
265 XSLT_GET_IMPORT_PTR(resultType, sheet, method); 265 XSLT_GET_IMPORT_PTR(resultType, sheet, method);
266 if (!resultType && resultDoc->type == XML_HTML_DOCUMENT_NODE) 266 if (!resultType && resultDoc->type == XML_HTML_DOCUMENT_NODE)
267 resultType = (const xmlChar*)"html"; 267 resultType = (const xmlChar*)"html";
268 268
269 if (xmlStrEqual(resultType, (const xmlChar*)"html")) 269 if (xmlStrEqual(resultType, (const xmlChar*)"html"))
270 return "text/html"; 270 return "text/html";
271 if (xmlStrEqual(resultType, (const xmlChar*)"text")) 271 if (xmlStrEqual(resultType, (const xmlChar*)"text"))
272 return "text/plain"; 272 return "text/plain";
273 273
274 return "application/xml"; 274 return "application/xml";
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « Source/core/xml/XSLStyleSheetLibxslt.cpp ('k') | Source/core/xml/XSLTUnicodeSort.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698