| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 switch (type) { | 96 switch (type) { |
| 97 case XSLT_LOAD_DOCUMENT: { | 97 case XSLT_LOAD_DOCUMENT: { |
| 98 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; | 98 xsltTransformContextPtr context = (xsltTransformContextPtr)ctxt; |
| 99 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); | 99 xmlChar* base = xmlNodeGetBase(context->document->doc, context->node); |
| 100 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei
nterpret_cast<const char*>(uri)); | 100 KURL url(KURL(ParsedURLString, reinterpret_cast<const char*>(base)), rei
nterpret_cast<const char*>(uri)); |
| 101 xmlFree(base); | 101 xmlFree(base); |
| 102 | 102 |
| 103 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptio
ns()); | 103 ResourceLoaderOptions fetchOptions(ResourceFetcher::defaultResourceOptio
ns()); |
| 104 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml,
fetchOptions); | 104 FetchRequest request(ResourceRequest(url), FetchInitiatorTypeNames::xml,
fetchOptions); |
| 105 request.setOriginRestriction(FetchRequest::RestrictToSameOrigin); | 105 request.setOriginRestriction(FetchRequest::RestrictToSameOrigin); |
| 106 RefPtrWillBeRawPtr<Resource> resource = RawResource::fetchSynchronously(
request, globalResourceFetcher); | 106 RawPtr<Resource> resource = RawResource::fetchSynchronously(request, glo
balResourceFetcher); |
| 107 if (!resource || !globalProcessor) | 107 if (!resource || !globalProcessor) |
| 108 return nullptr; | 108 return nullptr; |
| 109 | 109 |
| 110 FrameConsole* console = nullptr; | 110 FrameConsole* console = nullptr; |
| 111 LocalFrame* frame = globalProcessor->xslStylesheet()->ownerDocument()->f
rame(); | 111 LocalFrame* frame = globalProcessor->xslStylesheet()->ownerDocument()->f
rame(); |
| 112 if (frame) | 112 if (frame) |
| 113 console = &frame->console(); | 113 console = &frame->console(); |
| 114 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc); | 114 xmlSetStructuredErrorFunc(console, XSLTProcessor::parseErrorFunc); |
| 115 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc); | 115 xmlSetGenericErrorFunc(console, XSLTProcessor::genericErrorFunc); |
| 116 | 116 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 if (!params) | 219 if (!params) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 while (*temp) { | 222 while (*temp) { |
| 223 WTF::Partitions::fastFree(const_cast<char*>(*(temp++))); | 223 WTF::Partitions::fastFree(const_cast<char*>(*(temp++))); |
| 224 WTF::Partitions::fastFree(const_cast<char*>(*(temp++))); | 224 WTF::Partitions::fastFree(const_cast<char*>(*(temp++))); |
| 225 } | 225 } |
| 226 WTF::Partitions::fastFree(params); | 226 WTF::Partitions::fastFree(params); |
| 227 } | 227 } |
| 228 | 228 |
| 229 static xsltStylesheetPtr xsltStylesheetPointer(Document* document, RefPtrWillBeM
ember<XSLStyleSheet>& cachedStylesheet, Node* stylesheetRootNode) | 229 static xsltStylesheetPtr xsltStylesheetPointer(Document* document, Member<XSLSty
leSheet>& cachedStylesheet, Node* stylesheetRootNode) |
| 230 { | 230 { |
| 231 if (!cachedStylesheet && stylesheetRootNode) { | 231 if (!cachedStylesheet && stylesheetRootNode) { |
| 232 // When using importStylesheet, we will use the given document as the im
ported stylesheet's owner. | 232 // When using importStylesheet, we will use the given document as the im
ported stylesheet's owner. |
| 233 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor( | 233 cachedStylesheet = XSLStyleSheet::createForXSLTProcessor( |
| 234 stylesheetRootNode->parentNode() ? &stylesheetRootNode->parentNode()
->document() : document, | 234 stylesheetRootNode->parentNode() ? &stylesheetRootNode->parentNode()
->document() : document, |
| 235 stylesheetRootNode, | 235 stylesheetRootNode, |
| 236 stylesheetRootNode->document().url().getString(), | 236 stylesheetRootNode->document().url().getString(), |
| 237 stylesheetRootNode->document().url()); // FIXME: Should we use baseU
RL here? | 237 stylesheetRootNode->document().url()); // FIXME: Should we use baseU
RL here? |
| 238 | 238 |
| 239 // According to Mozilla documentation, the node must be a Document node, | 239 // According to Mozilla documentation, the node must be a Document node, |
| 240 // an xsl:stylesheet or xsl:transform element. But we just use text | 240 // an xsl:stylesheet or xsl:transform element. But we just use text |
| 241 // content regardless of node type. | 241 // content regardless of node type. |
| 242 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); | 242 cachedStylesheet->parseString(createMarkup(stylesheetRootNode)); |
| 243 } | 243 } |
| 244 | 244 |
| 245 if (!cachedStylesheet || !cachedStylesheet->document()) | 245 if (!cachedStylesheet || !cachedStylesheet->document()) |
| 246 return nullptr; | 246 return nullptr; |
| 247 | 247 |
| 248 return cachedStylesheet->compileStyleSheet(); | 248 return cachedStylesheet->compileStyleSheet(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) | 251 static inline xmlDocPtr xmlDocPtrFromNode(Node* sourceNode, bool& shouldDelete) |
| 252 { | 252 { |
| 253 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); | 253 RawPtr<Document> ownerDocument(sourceNode->document()); |
| 254 bool sourceIsDocument = (sourceNode == ownerDocument.get()); | 254 bool sourceIsDocument = (sourceNode == ownerDocument.get()); |
| 255 | 255 |
| 256 xmlDocPtr sourceDoc = nullptr; | 256 xmlDocPtr sourceDoc = nullptr; |
| 257 if (sourceIsDocument && ownerDocument->transformSource()) | 257 if (sourceIsDocument && ownerDocument->transformSource()) |
| 258 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource(
); | 258 sourceDoc = (xmlDocPtr)ownerDocument->transformSource()->platformSource(
); |
| 259 if (!sourceDoc) { | 259 if (!sourceDoc) { |
| 260 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument.get(), createMar
kup(sourceNode), | 260 sourceDoc = (xmlDocPtr)xmlDocPtrForString(ownerDocument.get(), createMar
kup(sourceNode), |
| 261 sourceIsDocument ? ownerDocument->url().getString() : String()); | 261 sourceIsDocument ? ownerDocument->url().getString() : String()); |
| 262 shouldDelete = sourceDoc; | 262 shouldDelete = sourceDoc; |
| 263 } | 263 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 278 if (xmlStrEqual(resultType, (const xmlChar*)"html")) | 278 if (xmlStrEqual(resultType, (const xmlChar*)"html")) |
| 279 return "text/html"; | 279 return "text/html"; |
| 280 if (xmlStrEqual(resultType, (const xmlChar*)"text")) | 280 if (xmlStrEqual(resultType, (const xmlChar*)"text")) |
| 281 return "text/plain"; | 281 return "text/plain"; |
| 282 | 282 |
| 283 return "application/xml"; | 283 return "application/xml"; |
| 284 } | 284 } |
| 285 | 285 |
| 286 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
& resultString, String& resultEncoding) | 286 bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String
& resultString, String& resultEncoding) |
| 287 { | 287 { |
| 288 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); | 288 RawPtr<Document> ownerDocument(sourceNode->document()); |
| 289 | 289 |
| 290 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher()); | 290 setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->fetcher()); |
| 291 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_document.get(), m_styleshe
et, m_stylesheetRootNode.get()); | 291 xsltStylesheetPtr sheet = xsltStylesheetPointer(m_document.get(), m_styleshe
et, m_stylesheetRootNode.get()); |
| 292 if (!sheet) { | 292 if (!sheet) { |
| 293 setXSLTLoadCallBack(0, 0, 0); | 293 setXSLTLoadCallBack(0, 0, 0); |
| 294 m_stylesheet = nullptr; | 294 m_stylesheet = nullptr; |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 m_stylesheet->clearDocuments(); | 297 m_stylesheet->clearDocuments(); |
| 298 | 298 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 sheet->method = origMethod; | 354 sheet->method = origMethod; |
| 355 setXSLTLoadCallBack(0, 0, 0); | 355 setXSLTLoadCallBack(0, 0, 0); |
| 356 xsltFreeStylesheet(sheet); | 356 xsltFreeStylesheet(sheet); |
| 357 m_stylesheet = nullptr; | 357 m_stylesheet = nullptr; |
| 358 | 358 |
| 359 return success; | 359 return success; |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace blink | 362 } // namespace blink |
| OLD | NEW |