| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) |
| 3 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2008, 2009 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 inline ProcessingInstruction::ProcessingInstruction(Document* document, const St
ring& target, const String& data) | 41 inline ProcessingInstruction::ProcessingInstruction(Document* document, const St
ring& target, const String& data) |
| 42 : Node(document, CreateOther) | 42 : Node(document, CreateOther) |
| 43 , m_target(target) | 43 , m_target(target) |
| 44 , m_data(data) | 44 , m_data(data) |
| 45 , m_cachedSheet(0) | 45 , m_cachedSheet(0) |
| 46 , m_loading(false) | 46 , m_loading(false) |
| 47 , m_alternate(false) | 47 , m_alternate(false) |
| 48 , m_createdByParser(false) | 48 , m_createdByParser(false) |
| 49 , m_isCSS(false) | 49 , m_isCSS(false) |
| 50 #if ENABLE(XSLT) | |
| 51 , m_isXSL(false) | 50 , m_isXSL(false) |
| 52 #endif | |
| 53 { | 51 { |
| 54 ScriptWrappable::init(this); | 52 ScriptWrappable::init(this); |
| 55 } | 53 } |
| 56 | 54 |
| 57 PassRefPtr<ProcessingInstruction> ProcessingInstruction::create(Document* docume
nt, const String& target, const String& data) | 55 PassRefPtr<ProcessingInstruction> ProcessingInstruction::create(Document* docume
nt, const String& target, const String& data) |
| 58 { | 56 { |
| 59 return adoptRef(new ProcessingInstruction(document, target, data)); | 57 return adoptRef(new ProcessingInstruction(document, target, data)); |
| 60 } | 58 } |
| 61 | 59 |
| 62 ProcessingInstruction::~ProcessingInstruction() | 60 ProcessingInstruction::~ProcessingInstruction() |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 bool attrsOk; | 114 bool attrsOk; |
| 117 const HashMap<String, String> attrs = parseAttributes(m_data, attrsOk); | 115 const HashMap<String, String> attrs = parseAttributes(m_data, attrsOk); |
| 118 if (!attrsOk) | 116 if (!attrsOk) |
| 119 return; | 117 return; |
| 120 HashMap<String, String>::const_iterator i = attrs.find("type"); | 118 HashMap<String, String>::const_iterator i = attrs.find("type"); |
| 121 String type; | 119 String type; |
| 122 if (i != attrs.end()) | 120 if (i != attrs.end()) |
| 123 type = i->value; | 121 type = i->value; |
| 124 | 122 |
| 125 m_isCSS = type.isEmpty() || type == "text/css"; | 123 m_isCSS = type.isEmpty() || type == "text/css"; |
| 126 #if ENABLE(XSLT) | |
| 127 m_isXSL = (type == "text/xml" || type == "text/xsl" || type == "applicat
ion/xml" || | 124 m_isXSL = (type == "text/xml" || type == "text/xsl" || type == "applicat
ion/xml" || |
| 128 type == "application/xhtml+xml" || type == "application/rss+x
ml" || type == "application/atom+xml"); | 125 type == "application/xhtml+xml" || type == "application/rss+x
ml" || type == "application/atom+xml"); |
| 129 if (!m_isCSS && !m_isXSL) | 126 if (!m_isCSS && !m_isXSL) |
| 130 #else | |
| 131 if (!m_isCSS) | |
| 132 #endif | |
| 133 return; | 127 return; |
| 134 | 128 |
| 135 String href = attrs.get("href"); | 129 String href = attrs.get("href"); |
| 136 String alternate = attrs.get("alternate"); | 130 String alternate = attrs.get("alternate"); |
| 137 m_alternate = alternate == "yes"; | 131 m_alternate = alternate == "yes"; |
| 138 m_title = attrs.get("title"); | 132 m_title = attrs.get("title"); |
| 139 m_media = attrs.get("media"); | 133 m_media = attrs.get("media"); |
| 140 | 134 |
| 141 if (m_alternate && m_title.isEmpty()) | 135 if (m_alternate && m_title.isEmpty()) |
| 142 return; | 136 return; |
| 143 | 137 |
| 144 if (href.length() > 1 && href[0] == '#') { | 138 if (href.length() > 1 && href[0] == '#') { |
| 145 m_localHref = href.substring(1); | 139 m_localHref = href.substring(1); |
| 146 #if ENABLE(XSLT) | |
| 147 // We need to make a synthetic XSLStyleSheet that is embedded. It n
eeds to be able | 140 // We need to make a synthetic XSLStyleSheet that is embedded. It n
eeds to be able |
| 148 // to kick off import/include loads that can hang off some parent sh
eet. | 141 // to kick off import/include loads that can hang off some parent sh
eet. |
| 149 if (m_isXSL) { | 142 if (m_isXSL) { |
| 150 KURL finalURL(ParsedURLString, m_localHref); | 143 KURL finalURL(ParsedURLString, m_localHref); |
| 151 m_sheet = XSLStyleSheet::createEmbedded(this, finalURL); | 144 m_sheet = XSLStyleSheet::createEmbedded(this, finalURL); |
| 152 m_loading = false; | 145 m_loading = false; |
| 153 } | 146 } |
| 154 #endif | |
| 155 } else { | 147 } else { |
| 156 if (m_cachedSheet) { | 148 if (m_cachedSheet) { |
| 157 m_cachedSheet->removeClient(this); | 149 m_cachedSheet->removeClient(this); |
| 158 m_cachedSheet = 0; | 150 m_cachedSheet = 0; |
| 159 } | 151 } |
| 160 | 152 |
| 161 String url = document()->completeURL(href).string(); | 153 String url = document()->completeURL(href).string(); |
| 162 if (!dispatchBeforeLoadEvent(url)) | 154 if (!dispatchBeforeLoadEvent(url)) |
| 163 return; | 155 return; |
| 164 | 156 |
| 165 m_loading = true; | 157 m_loading = true; |
| 166 document()->styleSheetCollection()->addPendingSheet(); | 158 document()->styleSheetCollection()->addPendingSheet(); |
| 167 | 159 |
| 168 CachedResourceRequest request(ResourceRequest(document()->completeUR
L(href))); | 160 CachedResourceRequest request(ResourceRequest(document()->completeUR
L(href))); |
| 169 #if ENABLE(XSLT) | |
| 170 if (m_isXSL) | 161 if (m_isXSL) |
| 171 m_cachedSheet = document()->cachedResourceLoader()->requestXSLSt
yleSheet(request); | 162 m_cachedSheet = document()->cachedResourceLoader()->requestXSLSt
yleSheet(request); |
| 172 else | 163 else |
| 173 #endif | |
| 174 { | 164 { |
| 175 String charset = attrs.get("charset"); | 165 String charset = attrs.get("charset"); |
| 176 if (charset.isEmpty()) | 166 if (charset.isEmpty()) |
| 177 charset = document()->charset(); | 167 charset = document()->charset(); |
| 178 request.setCharset(charset); | 168 request.setCharset(charset); |
| 179 | 169 |
| 180 m_cachedSheet = document()->cachedResourceLoader()->requestCSSSt
yleSheet(request); | 170 m_cachedSheet = document()->cachedResourceLoader()->requestCSSSt
yleSheet(request); |
| 181 } | 171 } |
| 182 if (m_cachedSheet) | 172 if (m_cachedSheet) |
| 183 m_cachedSheet->addClient(this); | 173 m_cachedSheet->addClient(this); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 cssSheet->setMediaQueries(MediaQuerySet::create(m_media)); | 216 cssSheet->setMediaQueries(MediaQuerySet::create(m_media)); |
| 227 | 217 |
| 228 m_sheet = cssSheet.release(); | 218 m_sheet = cssSheet.release(); |
| 229 | 219 |
| 230 // We don't need the cross-origin security check here because we are | 220 // We don't need the cross-origin security check here because we are |
| 231 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME | 221 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME |
| 232 // type. | 222 // type. |
| 233 parseStyleSheet(sheet->sheetText(true)); | 223 parseStyleSheet(sheet->sheetText(true)); |
| 234 } | 224 } |
| 235 | 225 |
| 236 #if ENABLE(XSLT) | |
| 237 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas
eURL, const String& sheet) | 226 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas
eURL, const String& sheet) |
| 238 { | 227 { |
| 239 ASSERT(m_isXSL); | 228 ASSERT(m_isXSL); |
| 240 m_sheet = XSLStyleSheet::create(this, href, baseURL); | 229 m_sheet = XSLStyleSheet::create(this, href, baseURL); |
| 241 parseStyleSheet(sheet); | 230 parseStyleSheet(sheet); |
| 242 } | 231 } |
| 243 #endif | |
| 244 | 232 |
| 245 void ProcessingInstruction::parseStyleSheet(const String& sheet) | 233 void ProcessingInstruction::parseStyleSheet(const String& sheet) |
| 246 { | 234 { |
| 247 if (m_isCSS) | 235 if (m_isCSS) |
| 248 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->parseString(shee
t); | 236 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->parseString(shee
t); |
| 249 #if ENABLE(XSLT) | |
| 250 else if (m_isXSL) | 237 else if (m_isXSL) |
| 251 static_cast<XSLStyleSheet*>(m_sheet.get())->parseString(sheet); | 238 static_cast<XSLStyleSheet*>(m_sheet.get())->parseString(sheet); |
| 252 #endif | |
| 253 | 239 |
| 254 if (m_cachedSheet) | 240 if (m_cachedSheet) |
| 255 m_cachedSheet->removeClient(this); | 241 m_cachedSheet->removeClient(this); |
| 256 m_cachedSheet = 0; | 242 m_cachedSheet = 0; |
| 257 | 243 |
| 258 m_loading = false; | 244 m_loading = false; |
| 259 | 245 |
| 260 if (m_isCSS) | 246 if (m_isCSS) |
| 261 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->checkLoaded(); | 247 static_cast<CSSStyleSheet*>(m_sheet.get())->contents()->checkLoaded(); |
| 262 #if ENABLE(XSLT) | |
| 263 else if (m_isXSL) | 248 else if (m_isXSL) |
| 264 static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded(); | 249 static_cast<XSLStyleSheet*>(m_sheet.get())->checkLoaded(); |
| 265 #endif | |
| 266 } | 250 } |
| 267 | 251 |
| 268 void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet) | 252 void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet) |
| 269 { | 253 { |
| 270 ASSERT(!m_cachedSheet); | 254 ASSERT(!m_cachedSheet); |
| 271 ASSERT(!m_loading); | 255 ASSERT(!m_loading); |
| 272 m_sheet = sheet; | 256 m_sheet = sheet; |
| 273 sheet->setTitle(m_title); | 257 sheet->setTitle(m_title); |
| 274 sheet->setDisabled(m_alternate); | 258 sheet->setDisabled(m_alternate); |
| 275 } | 259 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 document()->styleResolverChanged(DeferRecalcStyle); | 305 document()->styleResolverChanged(DeferRecalcStyle); |
| 322 } | 306 } |
| 323 | 307 |
| 324 void ProcessingInstruction::finishParsingChildren() | 308 void ProcessingInstruction::finishParsingChildren() |
| 325 { | 309 { |
| 326 m_createdByParser = false; | 310 m_createdByParser = false; |
| 327 Node::finishParsingChildren(); | 311 Node::finishParsingChildren(); |
| 328 } | 312 } |
| 329 | 313 |
| 330 } // namespace | 314 } // namespace |
| OLD | NEW |