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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 if (!params) | 211 if (!params) |
212 return; | 212 return; |
213 | 213 |
214 while (*temp) { | 214 while (*temp) { |
215 fastFree(const_cast<char*>(*(temp++))); | 215 fastFree(const_cast<char*>(*(temp++))); |
216 fastFree(const_cast<char*>(*(temp++))); | 216 fastFree(const_cast<char*>(*(temp++))); |
217 } | 217 } |
218 fastFree(params); | 218 fastFree(params); |
219 } | 219 } |
220 | 220 |
221 static xsltStylesheetPtr xsltStylesheetPointer(RefPtrWillBeMember<XSLStyleSheet>
& cachedStylesheet, Node* stylesheetRootNode) | 221 static xsltStylesheetPtr xsltStylesheetPointer(Document* document, RefPtrWillBeM
ember<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode) |
222 { | 222 { |
223 if (!cachedStylesheet && stylesheetRootNode) { | 223 if (!cachedStylesheet && stylesheetRootNode) { |
| 224 // When using importStylesheet, we will use the given document as the im
ported stylesheet's owner. |
224 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor( | 225 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor( |
225 stylesheetRootNode->parentNode() ? stylesheetRootNode->parentNode()
: stylesheetRootNode, | 226 stylesheetRootNode->parentNode() ? &stylesheetRootNode->parentNode()
->document() : document, |
| 227 stylesheetRootNode, |
226 stylesheetRootNode->document().url().string(), | 228 stylesheetRootNode->document().url().string(), |
227 stylesheetRootNode->document().url()); // FIXME: Should we use baseU
RL here? | 229 stylesheetRootNode->document().url()); // FIXME: Should we use baseU
RL here? |
228 | 230 |
229 // According to Mozilla documentation, the node must be a Document node, | 231 // According to Mozilla documentation, the node must be a Document node, |
230 // an xsl:stylesheet or xsl:transform element. But we just use text | 232 // an xsl:stylesheet or xsl:transform element. But we just use text |
231 // content regardless of node type. | 233 // content regardless of node type. |
232 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); | 234 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); |
233 } | 235 } |
234 | 236 |
235 if (!cachedStylesheet || !cachedStylesheet->document()) | 237 if (!cachedStylesheet || !cachedStylesheet->document()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 return "text/plain"; | 273 return "text/plain"; |
272 | 274 |
273 return "application/xml"; | 275 return "application/xml"; |
274 } | 276 } |
275 | 277 |
276 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
& resultString, String& resultEncoding) | 278 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
& resultString, String& resultEncoding) |
277 { | 279 { |
278 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); | 280 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); |
279 | 281 |
280 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher()); | 282 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher()); |
281 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRo
otNode.get()); | 283 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_document.get(), m_styleshe
et, m_stylesheetRootNode.get()); |
282 if (!sheet) { | 284 if (!sheet) { |
283 setXSLTLoadCallBack(0, 0, 0); | 285 setXSLTLoadCallBack(0, 0, 0); |
284 m_stylesheet = nullptr; | 286 m_stylesheet = nullptr; |
285 return false; | 287 return false; |
286 } | 288 } |
287 m_stylesheet->clearDocuments(); | 289 m_stylesheet->clearDocuments(); |
288 | 290 |
289 xmlChar* origMethod = sheet->method; | 291 xmlChar* origMethod = sheet->method; |
290 if (!origMethod && mimeType == "text/html") | 292 if (!origMethod && mimeType == "text/html") |
291 sheet->method = (xmlChar*)"html"; | 293 sheet->method = (xmlChar*)"html"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 345 |
344 sheet->method = origMethod; | 346 sheet->method = origMethod; |
345 setXSLTLoadCallBack(0, 0, 0); | 347 setXSLTLoadCallBack(0, 0, 0); |
346 xsltFreeStylesheet(sheet); | 348 xsltFreeStylesheet(sheet); |
347 m_stylesheet = nullptr; | 349 m_stylesheet = nullptr; |
348 | 350 |
349 return success; | 351 return success; |
350 } | 352 } |
351 | 353 |
352 } // namespace blink | 354 } // namespace blink |
OLD | NEW |