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, 2008, 2012 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
L, const KURL& finalURL) | 41 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
L, const KURL& finalURL) |
42 : m_ownerNode(0) | 42 : m_ownerNode(0) |
43 , m_originalURL(originalURL) | 43 , m_originalURL(originalURL) |
44 , m_finalURL(finalURL) | 44 , m_finalURL(finalURL) |
45 , m_isDisabled(false) | 45 , m_isDisabled(false) |
46 , m_embedded(false) | 46 , m_embedded(false) |
47 , m_processed(false) // Child sheets get marked as processed when the libxsl
t engine has finally seen them. | 47 , m_processed(false) // Child sheets get marked as processed when the libxsl
t engine has finally seen them. |
48 , m_stylesheetDoc(0) | 48 , m_stylesheetDoc(0) |
49 , m_stylesheetDocTaken(false) | 49 , m_stylesheetDocTaken(false) |
| 50 , m_compilationFailed(false) |
50 , m_parentStyleSheet(parentRule ? parentRule->parentStyleSheet() : 0) | 51 , m_parentStyleSheet(parentRule ? parentRule->parentStyleSheet() : 0) |
51 { | 52 { |
52 } | 53 } |
53 | 54 |
54 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const
KURL& finalURL, bool embedded) | 55 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const
KURL& finalURL, bool embedded) |
55 : m_ownerNode(parentNode) | 56 : m_ownerNode(parentNode) |
56 , m_originalURL(originalURL) | 57 , m_originalURL(originalURL) |
57 , m_finalURL(finalURL) | 58 , m_finalURL(finalURL) |
58 , m_isDisabled(false) | 59 , m_isDisabled(false) |
59 , m_embedded(embedded) | 60 , m_embedded(embedded) |
60 , m_processed(true) // The root sheet starts off processed. | 61 , m_processed(true) // The root sheet starts off processed. |
61 , m_stylesheetDoc(0) | 62 , m_stylesheetDoc(0) |
62 , m_stylesheetDocTaken(false) | 63 , m_stylesheetDocTaken(false) |
| 64 , m_compilationFailed(false) |
63 , m_parentStyleSheet(0) | 65 , m_parentStyleSheet(0) |
64 { | 66 { |
65 } | 67 } |
66 | 68 |
67 XSLStyleSheet::~XSLStyleSheet() | 69 XSLStyleSheet::~XSLStyleSheet() |
68 { | 70 { |
69 if (!m_stylesheetDocTaken) | 71 if (!m_stylesheetDocTaken) |
70 xmlFreeDoc(m_stylesheetDoc); | 72 xmlFreeDoc(m_stylesheetDoc); |
71 | 73 |
72 for (unsigned i = 0; i < m_children.size(); ++i) { | 74 for (unsigned i = 0; i < m_children.size(); ++i) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 m_children.append(childRule.release()); | 221 m_children.append(childRule.release()); |
220 c->loadSheet(); | 222 c->loadSheet(); |
221 } | 223 } |
222 | 224 |
223 xsltStylesheetPtr XSLStyleSheet::compileStyleSheet() | 225 xsltStylesheetPtr XSLStyleSheet::compileStyleSheet() |
224 { | 226 { |
225 // FIXME: Hook up error reporting for the stylesheet compilation process. | 227 // FIXME: Hook up error reporting for the stylesheet compilation process. |
226 if (m_embedded) | 228 if (m_embedded) |
227 return xsltLoadStylesheetPI(document()); | 229 return xsltLoadStylesheetPI(document()); |
228 | 230 |
| 231 // Certain libxslt versions are corrupting the xmlDoc on compilation failure
s - |
| 232 // hence attempting to recompile after a failure is unsafe. |
| 233 if (m_compilationFailed) |
| 234 return 0; |
| 235 |
229 // xsltParseStylesheetDoc makes the document part of the stylesheet | 236 // xsltParseStylesheetDoc makes the document part of the stylesheet |
230 // so we have to release our pointer to it. | 237 // so we have to release our pointer to it. |
231 ASSERT(!m_stylesheetDocTaken); | 238 ASSERT(!m_stylesheetDocTaken); |
232 xsltStylesheetPtr result = xsltParseStylesheetDoc(m_stylesheetDoc); | 239 xsltStylesheetPtr result = xsltParseStylesheetDoc(m_stylesheetDoc); |
233 if (result) | 240 if (result) |
234 m_stylesheetDocTaken = true; | 241 m_stylesheetDocTaken = true; |
| 242 else |
| 243 m_compilationFailed = true; |
235 return result; | 244 return result; |
236 } | 245 } |
237 | 246 |
238 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent) | 247 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent) |
239 { | 248 { |
240 m_parentStyleSheet = parent; | 249 m_parentStyleSheet = parent; |
241 } | 250 } |
242 | 251 |
243 Document* XSLStyleSheet::ownerDocument() | 252 Document* XSLStyleSheet::ownerDocument() |
244 { | 253 { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 297 |
289 void XSLStyleSheet::markAsProcessed() | 298 void XSLStyleSheet::markAsProcessed() |
290 { | 299 { |
291 ASSERT(!m_processed); | 300 ASSERT(!m_processed); |
292 ASSERT(!m_stylesheetDocTaken); | 301 ASSERT(!m_stylesheetDocTaken); |
293 m_processed = true; | 302 m_processed = true; |
294 m_stylesheetDocTaken = true; | 303 m_stylesheetDocTaken = true; |
295 } | 304 } |
296 | 305 |
297 } // namespace WebCore | 306 } // namespace WebCore |
OLD | NEW |