| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 "</body>\n" | 53 "</body>\n" |
| 54 "</html>\n"; | 54 "</html>\n"; |
| 55 } | 55 } |
| 56 | 56 |
| 57 XSLTProcessor::~XSLTProcessor() | 57 XSLTProcessor::~XSLTProcessor() |
| 58 { | 58 { |
| 59 // Stylesheet shouldn't outlive its root node. | 59 // Stylesheet shouldn't outlive its root node. |
| 60 ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef()); | 60 ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef()); |
| 61 } | 61 } |
| 62 | 62 |
| 63 PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourc
eString, | 63 PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourc
eString, const String& sourceEncoding, const String& sourceMIMEType, Node* sourc
eNode, Frame* frame, CustomElementRegistrationContextualizer::DocumentCreationRe
ason reason) |
| 64 const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode
, Frame* frame) | |
| 65 { | 64 { |
| 66 RefPtr<Document> ownerDocument = sourceNode->document(); | 65 RefPtr<Document> ownerDocument = sourceNode->document(); |
| 67 bool sourceIsDocument = (sourceNode == ownerDocument.get()); | 66 bool sourceIsDocument = (sourceNode == ownerDocument.get()); |
| 68 String documentSource = sourceString; | 67 String documentSource = sourceString; |
| 69 | 68 |
| 70 RefPtr<Document> result; | 69 RefPtr<Document> result; |
| 71 if (sourceMIMEType == "text/plain") { | 70 if (sourceMIMEType == "text/plain") { |
| 72 result = Document::create(frame, sourceIsDocument ? ownerDocument->url()
: KURL()); | 71 result = Document::create(frame, sourceIsDocument ? ownerDocument->url()
: KURL()); |
| 73 transformTextStringToXHTMLDocumentString(documentSource); | 72 transformTextStringToXHTMLDocumentString(documentSource); |
| 74 } else | 73 } else |
| 75 result = DOMImplementation::createDocument(sourceMIMEType, frame, source
IsDocument ? ownerDocument->url() : KURL(), false); | 74 result = DOMImplementation::createDocument(sourceMIMEType, frame, source
IsDocument ? ownerDocument->url() : KURL(), false); |
| 76 | 75 |
| 76 CustomElementRegistrationContextualizer::didCreateDocument(reason, result.ge
t()); |
| 77 |
| 77 // Before parsing, we need to save & detach the old document and get the new
document | 78 // Before parsing, we need to save & detach the old document and get the new
document |
| 78 // in place. We have to do this only if we're rendering the result document. | 79 // in place. We have to do this only if we're rendering the result document. |
| 79 if (frame) { | 80 if (frame) { |
| 80 if (FrameView* view = frame->view()) | 81 if (FrameView* view = frame->view()) |
| 81 view->clear(); | 82 view->clear(); |
| 82 | 83 |
| 83 if (Document* oldDocument = frame->document()) { | 84 if (Document* oldDocument = frame->document()) { |
| 84 result->setTransformSourceDocument(oldDocument); | 85 result->setTransformSourceDocument(oldDocument); |
| 85 result->setSecurityOrigin(oldDocument->securityOrigin()); | 86 result->setSecurityOrigin(oldDocument->securityOrigin()); |
| 86 result->setCookieURL(oldDocument->cookieURL()); | 87 result->setCookieURL(oldDocument->cookieURL()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 103 PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode) | 104 PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode) |
| 104 { | 105 { |
| 105 if (!sourceNode) | 106 if (!sourceNode) |
| 106 return 0; | 107 return 0; |
| 107 | 108 |
| 108 String resultMIMEType; | 109 String resultMIMEType; |
| 109 String resultString; | 110 String resultString; |
| 110 String resultEncoding; | 111 String resultEncoding; |
| 111 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) | 112 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) |
| 112 return 0; | 113 return 0; |
| 113 return createDocumentFromSource(resultString, resultEncoding, resultMIMEType
, sourceNode, 0); | 114 return createDocumentFromSource(resultString, resultEncoding, resultMIMEType
, sourceNode, 0, CustomElementRegistrationContextualizer::XSLTProcessor_transfor
mToDocument); |
| 114 } | 115 } |
| 115 | 116 |
| 116 PassRefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode
, Document* outputDoc) | 117 PassRefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode
, Document* outputDoc) |
| 117 { | 118 { |
| 118 if (!sourceNode || !outputDoc) | 119 if (!sourceNode || !outputDoc) |
| 119 return 0; | 120 return 0; |
| 120 | 121 |
| 121 String resultMIMEType; | 122 String resultMIMEType; |
| 122 String resultString; | 123 String resultString; |
| 123 String resultEncoding; | 124 String resultEncoding; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 152 } | 153 } |
| 153 | 154 |
| 154 void XSLTProcessor::reset() | 155 void XSLTProcessor::reset() |
| 155 { | 156 { |
| 156 m_stylesheet.clear(); | 157 m_stylesheet.clear(); |
| 157 m_stylesheetRootNode.clear(); | 158 m_stylesheetRootNode.clear(); |
| 158 m_parameters.clear(); | 159 m_parameters.clear(); |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace WebCore | 162 } // namespace WebCore |
| OLD | NEW |