| 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 Apple Inc. All rights reserved. | 4 * Copyright (C) 2004, 2005, 2006, 2008 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 SOFT_LINK(libxslt, xsltIsBlank, int, (xmlChar *str), (str)) | 49 SOFT_LINK(libxslt, xsltIsBlank, int, (xmlChar *str), (str)) |
| 50 SOFT_LINK(libxslt, xsltGetNsProp, xmlChar *, (xmlNodePtr node, const xmlChar *na
me, const xmlChar *nameSpace), (node, name, nameSpace)) | 50 SOFT_LINK(libxslt, xsltGetNsProp, xmlChar *, (xmlNodePtr node, const xmlChar *na
me, const xmlChar *nameSpace), (node, name, nameSpace)) |
| 51 SOFT_LINK(libxslt, xsltParseStylesheetDoc, xsltStylesheetPtr, (xmlDocPtr doc), (
doc)) | 51 SOFT_LINK(libxslt, xsltParseStylesheetDoc, xsltStylesheetPtr, (xmlDocPtr doc), (
doc)) |
| 52 SOFT_LINK(libxslt, xsltLoadStylesheetPI, xsltStylesheetPtr, (xmlDocPtr doc), (do
c)) | 52 SOFT_LINK(libxslt, xsltLoadStylesheetPI, xsltStylesheetPtr, (xmlDocPtr doc), (do
c)) |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 namespace WebCore { | 55 namespace WebCore { |
| 56 | 56 |
| 57 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
L, const KURL& finalURL) | 57 XSLStyleSheet::XSLStyleSheet(XSLImportRule* parentRule, const String& originalUR
L, const KURL& finalURL) |
| 58 : StyleSheet(parentRule, originalURL, finalURL) | 58 : StyleSheet(parentRule, originalURL, finalURL) |
| 59 , m_ownerDocument(0) | |
| 60 , m_embedded(false) | 59 , m_embedded(false) |
| 61 , m_processed(false) // Child sheets get marked as processed when the libxsl
t engine has finally seen them. | 60 , m_processed(false) // Child sheets get marked as processed when the libxsl
t engine has finally seen them. |
| 62 , m_stylesheetDoc(0) | 61 , m_stylesheetDoc(0) |
| 63 , m_stylesheetDocTaken(false) | 62 , m_stylesheetDocTaken(false) |
| 64 , m_parentStyleSheet(0) | 63 , m_parentStyleSheet(0) |
| 65 { | 64 { |
| 66 } | 65 } |
| 67 | 66 |
| 68 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const
KURL& finalURL, bool embedded) | 67 XSLStyleSheet::XSLStyleSheet(Node* parentNode, const String& originalURL, const
KURL& finalURL, bool embedded) |
| 69 : StyleSheet(parentNode, originalURL, finalURL) | 68 : StyleSheet(parentNode, originalURL, finalURL) |
| 70 , m_ownerDocument(parentNode->document()) | |
| 71 , m_embedded(embedded) | 69 , m_embedded(embedded) |
| 72 , m_processed(true) // The root sheet starts off processed. | 70 , m_processed(true) // The root sheet starts off processed. |
| 73 , m_stylesheetDoc(0) | 71 , m_stylesheetDoc(0) |
| 74 , m_stylesheetDocTaken(false) | 72 , m_stylesheetDocTaken(false) |
| 75 , m_parentStyleSheet(0) | 73 , m_parentStyleSheet(0) |
| 76 { | 74 { |
| 77 } | 75 } |
| 78 | 76 |
| 79 XSLStyleSheet::~XSLStyleSheet() | 77 XSLStyleSheet::~XSLStyleSheet() |
| 80 { | 78 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 if (rule->isImportRule()) { | 120 if (rule->isImportRule()) { |
| 123 XSLImportRule* import = static_cast<XSLImportRule*>(rule); | 121 XSLImportRule* import = static_cast<XSLImportRule*>(rule); |
| 124 if (import->styleSheet()) | 122 if (import->styleSheet()) |
| 125 import->styleSheet()->clearDocuments(); | 123 import->styleSheet()->clearDocuments(); |
| 126 } | 124 } |
| 127 } | 125 } |
| 128 } | 126 } |
| 129 | 127 |
| 130 CachedResourceLoader* XSLStyleSheet::cachedResourceLoader() | 128 CachedResourceLoader* XSLStyleSheet::cachedResourceLoader() |
| 131 { | 129 { |
| 132 if (!m_ownerDocument) | 130 Document* document = ownerDocument(); |
| 131 if (!document) |
| 133 return 0; | 132 return 0; |
| 134 return m_ownerDocument->cachedResourceLoader(); | 133 return document->cachedResourceLoader(); |
| 135 } | 134 } |
| 136 | 135 |
| 137 bool XSLStyleSheet::parseString(const String& string, bool) | 136 bool XSLStyleSheet::parseString(const String& string, bool) |
| 138 { | 137 { |
| 139 // Parse in a single chunk into an xmlDocPtr | 138 // Parse in a single chunk into an xmlDocPtr |
| 140 const UChar BOM = 0xFEFF; | 139 const UChar BOM = 0xFEFF; |
| 141 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&B
OM); | 140 const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&B
OM); |
| 142 if (!m_stylesheetDocTaken) | 141 if (!m_stylesheetDocTaken) |
| 143 xmlFreeDoc(m_stylesheetDoc); | 142 xmlFreeDoc(m_stylesheetDoc); |
| 144 m_stylesheetDocTaken = false; | 143 m_stylesheetDocTaken = false; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 ASSERT(!m_stylesheetDocTaken); | 249 ASSERT(!m_stylesheetDocTaken); |
| 251 xsltStylesheetPtr result = xsltParseStylesheetDoc(m_stylesheetDoc); | 250 xsltStylesheetPtr result = xsltParseStylesheetDoc(m_stylesheetDoc); |
| 252 if (result) | 251 if (result) |
| 253 m_stylesheetDocTaken = true; | 252 m_stylesheetDocTaken = true; |
| 254 return result; | 253 return result; |
| 255 } | 254 } |
| 256 | 255 |
| 257 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent) | 256 void XSLStyleSheet::setParentStyleSheet(XSLStyleSheet* parent) |
| 258 { | 257 { |
| 259 m_parentStyleSheet = parent; | 258 m_parentStyleSheet = parent; |
| 260 if (parent) | 259 } |
| 261 m_ownerDocument = parent->ownerDocument(); | 260 |
| 261 Document* XSLStyleSheet::ownerDocument() |
| 262 { |
| 263 for (XSLStyleSheet* styleSheet = this; styleSheet; styleSheet = styleSheet->
parentStyleSheet()) { |
| 264 Node* node = styleSheet->ownerNode(); |
| 265 if (node) |
| 266 return node->document(); |
| 267 } |
| 268 return 0; |
| 262 } | 269 } |
| 263 | 270 |
| 264 xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const
xmlChar* uri) | 271 xmlDocPtr XSLStyleSheet::locateStylesheetSubResource(xmlDocPtr parentDoc, const
xmlChar* uri) |
| 265 { | 272 { |
| 266 bool matchedParent = (parentDoc == document()); | 273 bool matchedParent = (parentDoc == document()); |
| 267 unsigned len = length(); | 274 unsigned len = length(); |
| 268 for (unsigned i = 0; i < len; ++i) { | 275 for (unsigned i = 0; i < len; ++i) { |
| 269 StyleBase* rule = item(i); | 276 StyleBase* rule = item(i); |
| 270 if (rule->isImportRule()) { | 277 if (rule->isImportRule()) { |
| 271 XSLImportRule* import = static_cast<XSLImportRule*>(rule); | 278 XSLImportRule* import = static_cast<XSLImportRule*>(rule); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 { | 312 { |
| 306 ASSERT(!m_processed); | 313 ASSERT(!m_processed); |
| 307 ASSERT(!m_stylesheetDocTaken); | 314 ASSERT(!m_stylesheetDocTaken); |
| 308 m_processed = true; | 315 m_processed = true; |
| 309 m_stylesheetDocTaken = true; | 316 m_stylesheetDocTaken = true; |
| 310 } | 317 } |
| 311 | 318 |
| 312 } // namespace WebCore | 319 } // namespace WebCore |
| 313 | 320 |
| 314 #endif // ENABLE(XSLT) | 321 #endif // ENABLE(XSLT) |
| OLD | NEW |