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 20 matching lines...) Expand all Loading... |
31 #include "core/frame/LocalFrame.h" | 31 #include "core/frame/LocalFrame.h" |
32 #include "core/frame/csp/ContentSecurityPolicy.h" | 32 #include "core/frame/csp/ContentSecurityPolicy.h" |
33 #include "core/loader/FrameLoaderClient.h" | 33 #include "core/loader/FrameLoaderClient.h" |
34 #include "core/xml/DocumentXSLT.h" | 34 #include "core/xml/DocumentXSLT.h" |
35 #include "platform/weborigin/SecurityOrigin.h" | 35 #include "platform/weborigin/SecurityOrigin.h" |
36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 static inline void transformTextStringToXHTMLDocumentString(String& text) { | 40 static inline void transformTextStringToXHTMLDocumentString(String& text) { |
41 // Modify the output so that it is a well-formed XHTML document with a <pre> t
ag enclosing the text. | 41 // Modify the output so that it is a well-formed XHTML document with a <pre> |
| 42 // tag enclosing the text. |
42 text.replace('&', "&"); | 43 text.replace('&', "&"); |
43 text.replace('<', "<"); | 44 text.replace('<', "<"); |
44 text = | 45 text = |
45 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | 46 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
46 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " | 47 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" " |
47 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" | 48 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" |
48 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" | 49 "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" |
49 "<head><title/></head>\n" | 50 "<head><title/></head>\n" |
50 "<body>\n" | 51 "<body>\n" |
51 "<pre>" + | 52 "<pre>" + |
(...skipping 16 matching lines...) Expand all Loading... |
68 | 69 |
69 Document* result = nullptr; | 70 Document* result = nullptr; |
70 DocumentInit init(sourceIsDocument ? ownerDocument->url() : KURL(), frame); | 71 DocumentInit init(sourceIsDocument ? ownerDocument->url() : KURL(), frame); |
71 | 72 |
72 bool forceXHTML = sourceMIMEType == "text/plain"; | 73 bool forceXHTML = sourceMIMEType == "text/plain"; |
73 if (forceXHTML) | 74 if (forceXHTML) |
74 transformTextStringToXHTMLDocumentString(documentSource); | 75 transformTextStringToXHTMLDocumentString(documentSource); |
75 | 76 |
76 if (frame) { | 77 if (frame) { |
77 Document* oldDocument = frame->document(); | 78 Document* oldDocument = frame->document(); |
78 // 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 |
79 // in place. Document::shutdown() tears down the FrameView, so remember whet
her or not | 80 // document in place. Document::shutdown() tears down the FrameView, so |
80 // there was one. | 81 // remember whether or not there was one. |
81 bool hasView = frame->view(); | 82 bool hasView = frame->view(); |
82 oldDocument->shutdown(); | 83 oldDocument->shutdown(); |
83 // Re-create the FrameView if needed. | 84 // Re-create the FrameView if needed. |
84 if (hasView) | 85 if (hasView) |
85 frame->loader().client()->transitionToCommittedForNewPage(); | 86 frame->loader().client()->transitionToCommittedForNewPage(); |
86 result = frame->localDOMWindow()->installNewDocument(sourceMIMEType, init, | 87 result = frame->localDOMWindow()->installNewDocument(sourceMIMEType, init, |
87 forceXHTML); | 88 forceXHTML); |
88 | 89 |
89 if (oldDocument) { | 90 if (oldDocument) { |
90 DocumentXSLT::from(*result).setTransformSourceDocument(oldDocument); | 91 DocumentXSLT::from(*result).setTransformSourceDocument(oldDocument); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 m_parameters.clear(); | 165 m_parameters.clear(); |
165 } | 166 } |
166 | 167 |
167 DEFINE_TRACE(XSLTProcessor) { | 168 DEFINE_TRACE(XSLTProcessor) { |
168 visitor->trace(m_stylesheet); | 169 visitor->trace(m_stylesheet); |
169 visitor->trace(m_stylesheetRootNode); | 170 visitor->trace(m_stylesheetRootNode); |
170 visitor->trace(m_document); | 171 visitor->trace(m_document); |
171 } | 172 } |
172 | 173 |
173 } // namespace blink | 174 } // namespace blink |
OLD | NEW |