| 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 } | 53 } |
| 54 | 54 |
| 55 XSLTProcessor::~XSLTProcessor() | 55 XSLTProcessor::~XSLTProcessor() |
| 56 { | 56 { |
| 57 #if !ENABLE(OILPAN) | 57 #if !ENABLE(OILPAN) |
| 58 // Stylesheet shouldn't outlive its root node. | 58 // Stylesheet shouldn't outlive its root node. |
| 59 ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef()); | 59 ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef()); |
| 60 #endif | 60 #endif |
| 61 } | 61 } |
| 62 | 62 |
| 63 PassRefPtrWillBeRawPtr<Document> XSLTProcessor::createDocumentFromSource(const S
tring& sourceString, | 63 RawPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceStr
ing, |
| 64 const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode
, LocalFrame* frame) | 64 const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode
, LocalFrame* frame) |
| 65 { | 65 { |
| 66 RefPtrWillBeRawPtr<Document> ownerDocument(sourceNode->document()); | 66 RawPtr<Document> ownerDocument(sourceNode->document()); |
| 67 bool sourceIsDocument = (sourceNode == ownerDocument.get()); | 67 bool sourceIsDocument = (sourceNode == ownerDocument.get()); |
| 68 String documentSource = sourceString; | 68 String documentSource = sourceString; |
| 69 | 69 |
| 70 RefPtrWillBeRawPtr<Document> result = nullptr; | 70 RawPtr<Document> result = nullptr; |
| 71 DocumentInit init(sourceIsDocument ? ownerDocument->url() : KURL(), frame); | 71 DocumentInit init(sourceIsDocument ? ownerDocument->url() : KURL(), frame); |
| 72 | 72 |
| 73 bool forceXHTML = sourceMIMEType == "text/plain"; | 73 bool forceXHTML = sourceMIMEType == "text/plain"; |
| 74 if (forceXHTML) | 74 if (forceXHTML) |
| 75 transformTextStringToXHTMLDocumentString(documentSource); | 75 transformTextStringToXHTMLDocumentString(documentSource); |
| 76 | 76 |
| 77 if (frame) { | 77 if (frame) { |
| 78 RefPtrWillBeRawPtr<Document> oldDocument = frame->document(); | 78 RawPtr<Document> oldDocument = frame->document(); |
| 79 // Before parsing, we need to save & detach the old document and get the
new document | 79 // Before parsing, we need to save & detach the old document and get the
new document |
| 80 // in place. Document::detach() tears down the FrameView, so remember wh
ether or not | 80 // in place. Document::detach() tears down the FrameView, so remember wh
ether or not |
| 81 // there was one. | 81 // there was one. |
| 82 bool hasView = frame->view(); | 82 bool hasView = frame->view(); |
| 83 oldDocument->detach(); | 83 oldDocument->detach(); |
| 84 // Re-create the FrameView if needed. | 84 // Re-create the FrameView if needed. |
| 85 if (hasView) | 85 if (hasView) |
| 86 frame->loader().client()->transitionToCommittedForNewPage(); | 86 frame->loader().client()->transitionToCommittedForNewPage(); |
| 87 result = frame->localDOMWindow()->installNewDocument(sourceMIMEType, ini
t, forceXHTML); | 87 result = frame->localDOMWindow()->installNewDocument(sourceMIMEType, ini
t, forceXHTML); |
| 88 | 88 |
| 89 if (oldDocument) { | 89 if (oldDocument) { |
| 90 DocumentXSLT::from(*result).setTransformSourceDocument(oldDocument.g
et()); | 90 DocumentXSLT::from(*result).setTransformSourceDocument(oldDocument.g
et()); |
| 91 result->updateSecurityOrigin(oldDocument->getSecurityOrigin()); | 91 result->updateSecurityOrigin(oldDocument->getSecurityOrigin()); |
| 92 result->setCookieURL(oldDocument->cookieURL()); | 92 result->setCookieURL(oldDocument->cookieURL()); |
| 93 | 93 |
| 94 RefPtrWillBeRawPtr<ContentSecurityPolicy> csp = ContentSecurityPolic
y::create(); | 94 RawPtr<ContentSecurityPolicy> csp = ContentSecurityPolicy::create(); |
| 95 csp->copyStateFrom(oldDocument->contentSecurityPolicy()); | 95 csp->copyStateFrom(oldDocument->contentSecurityPolicy()); |
| 96 result->initContentSecurityPolicy(csp); | 96 result->initContentSecurityPolicy(csp); |
| 97 } | 97 } |
| 98 } else { | 98 } else { |
| 99 result = LocalDOMWindow::createDocument(sourceMIMEType, init, forceXHTML
); | 99 result = LocalDOMWindow::createDocument(sourceMIMEType, init, forceXHTML
); |
| 100 } | 100 } |
| 101 | 101 |
| 102 DocumentEncodingData data; | 102 DocumentEncodingData data; |
| 103 data.setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : WTF::TextEncodi
ng(sourceEncoding)); | 103 data.setEncoding(sourceEncoding.isEmpty() ? UTF8Encoding() : WTF::TextEncodi
ng(sourceEncoding)); |
| 104 result->setEncodingData(data); | 104 result->setEncodingData(data); |
| 105 result->setContent(documentSource); | 105 result->setContent(documentSource); |
| 106 | 106 |
| 107 return result.release(); | 107 return result.release(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 PassRefPtrWillBeRawPtr<Document> XSLTProcessor::transformToDocument(Node* source
Node) | 110 RawPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode) |
| 111 { | 111 { |
| 112 String resultMIMEType; | 112 String resultMIMEType; |
| 113 String resultString; | 113 String resultString; |
| 114 String resultEncoding; | 114 String resultEncoding; |
| 115 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) | 115 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) |
| 116 return nullptr; | 116 return nullptr; |
| 117 return createDocumentFromSource(resultString, resultEncoding, resultMIMEType
, sourceNode, 0); | 117 return createDocumentFromSource(resultString, resultEncoding, resultMIMEType
, sourceNode, 0); |
| 118 } | 118 } |
| 119 | 119 |
| 120 PassRefPtrWillBeRawPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node
* sourceNode, Document* outputDoc) | 120 RawPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Do
cument* outputDoc) |
| 121 { | 121 { |
| 122 String resultMIMEType; | 122 String resultMIMEType; |
| 123 String resultString; | 123 String resultString; |
| 124 String resultEncoding; | 124 String resultEncoding; |
| 125 | 125 |
| 126 // If the output document is HTML, default to HTML method. | 126 // If the output document is HTML, default to HTML method. |
| 127 if (outputDoc->isHTMLDocument()) | 127 if (outputDoc->isHTMLDocument()) |
| 128 resultMIMEType = "text/html"; | 128 resultMIMEType = "text/html"; |
| 129 | 129 |
| 130 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) | 130 if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncod
ing)) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 DEFINE_TRACE(XSLTProcessor) | 162 DEFINE_TRACE(XSLTProcessor) |
| 163 { | 163 { |
| 164 visitor->trace(m_stylesheet); | 164 visitor->trace(m_stylesheet); |
| 165 visitor->trace(m_stylesheetRootNode); | 165 visitor->trace(m_stylesheetRootNode); |
| 166 visitor->trace(m_document); | 166 visitor->trace(m_document); |
| 167 } | 167 } |
| 168 | 168 |
| 169 } // namespace blink | 169 } // namespace blink |
| OLD | NEW |