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

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

Issue 23819007: Have Node::document() return a reference instead of a pointer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/xml/XSLTProcessor.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 fastFree((void*)*(temp++)); 219 fastFree((void*)*(temp++));
220 fastFree((void*)*(temp++)); 220 fastFree((void*)*(temp++));
221 } 221 }
222 fastFree(params); 222 fastFree(params);
223 } 223 }
224 224
225 static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStyl esheet, Node* stylesheetRootNode) 225 static xsltStylesheetPtr xsltStylesheetPointer(RefPtr<XSLStyleSheet>& cachedStyl esheet, Node* stylesheetRootNode)
226 { 226 {
227 if (!cachedStylesheet && stylesheetRootNode) { 227 if (!cachedStylesheet && stylesheetRootNode) {
228 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor(stylesheetRootN ode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode, 228 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor(stylesheetRootN ode->parentNode() ? stylesheetRootNode->parentNode() : stylesheetRootNode,
229 stylesheetRootNode->document()->url().string(), 229 stylesheetRootNode->document().url().string(),
230 stylesheetRootNode->document()->url()); // FIXME: Should we use base URL here? 230 stylesheetRootNode->document().url()); // FIXME: Should we use baseU RL here?
231 231
232 // According to Mozilla documentation, the node must be a Document node, an xsl:stylesheet or xsl:transform element. 232 // According to Mozilla documentation, the node must be a Document node, an xsl:stylesheet or xsl:transform element.
233 // But we just use text content regardless of node type. 233 // But we just use text content regardless of node type.
234 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); 234 cachedStylesheet->parseString(createMarkup(stylesheetRootNode));
235 } 235 }
236 236
237 if (!cachedStylesheet || !cachedStylesheet->document()) 237 if (!cachedStylesheet || !cachedStylesheet->document())
238 return 0; 238 return 0;
239 239
240 return cachedStylesheet->compileStyleSheet(); 240 return cachedStylesheet->compileStyleSheet();
241 } 241 }
242 242
243 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) 243 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete)
244 { 244 {
245 RefPtr<Document> ownerDocument = sourceNode->document(); 245 RefPtr<Document> ownerDocument = &sourceNode->document();
246 bool sourceIsDocument = (sourceNode == ownerDocument.get()); 246 bool sourceIsDocument = (sourceNode == ownerDocument.get());
247 247
248 xmlDocPtr sourceDoc = 0; 248 xmlDocPtr sourceDoc = 0;
249 if (sourceIsDocument && ownerDocument->transformSource()) 249 if (sourceIsDocument && ownerDocument->transformSource())
250 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource( ); 250 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource( );
251 if (!sourceDoc) { 251 if (!sourceDoc) {
252 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->fetcher(), crea teMarkup(sourceNode), 252 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument->fetcher(), crea teMarkup(sourceNode),
253 sourceIsDocument ? ownerDocument->url().string() : String()); 253 sourceIsDocument ? ownerDocument->url().string() : String());
254 shouldDelete = sourceDoc; 254 shouldDelete = sourceDoc;
255 } 255 }
(...skipping 14 matching lines...) Expand all
270 if (xmlStrEqual(resultType, (const xmlChar*)"html")) 270 if (xmlStrEqual(resultType, (const xmlChar*)"html"))
271 return "text/html"; 271 return "text/html";
272 if (xmlStrEqual(resultType, (const xmlChar*)"text")) 272 if (xmlStrEqual(resultType, (const xmlChar*)"text"))
273 return "text/plain"; 273 return "text/plain";
274 274
275 return "application/xml"; 275 return "application/xml";
276 } 276 }
277 277
278 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String & resultString, String& resultEncoding) 278 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String & resultString, String& resultEncoding)
279 { 279 {
280 RefPtr<Document> ownerDocument = sourceNode->document(); 280 RefPtr<Document> ownerDocument = &sourceNode->document();
281 281
282 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher()); 282 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher());
283 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRo otNode.get()); 283 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRo otNode.get());
284 if (!sheet) { 284 if (!sheet) {
285 setXSLTLoadCallBack(0, 0, 0); 285 setXSLTLoadCallBack(0, 0, 0);
286 m_stylesheet = 0; 286 m_stylesheet = 0;
287 return false; 287 return false;
288 } 288 }
289 m_stylesheet->clearDocuments(); 289 m_stylesheet->clearDocuments();
290 290
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 sheet->method = origMethod; 342 sheet->method = origMethod;
343 setXSLTLoadCallBack(0, 0, 0); 343 setXSLTLoadCallBack(0, 0, 0);
344 xsltFreeStylesheet(sheet); 344 xsltFreeStylesheet(sheet);
345 m_stylesheet = 0; 345 m_stylesheet = 0;
346 346
347 return success; 347 return success;
348 } 348 }
349 349
350 } // namespace WebCore 350 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/xml/XSLTProcessor.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698