| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 if (!isLoading()) { | 186 if (!isLoading()) { |
| 187 if (!DocumentXSLT::sheetLoaded(document(), this)) | 187 if (!DocumentXSLT::sheetLoaded(document(), this)) |
| 188 document().styleEngine().removePendingSheet(this, m_styleEngineConte
xt); | 188 document().styleEngine().removePendingSheet(this, m_styleEngineConte
xt); |
| 189 return true; | 189 return true; |
| 190 } | 190 } |
| 191 return false; | 191 return false; |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) | 194 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) |
| 195 { | 195 { |
| 196 if (!inShadowIncludingDocument()) { | 196 if (!isConnected()) { |
| 197 DCHECK(!m_sheet); | 197 DCHECK(!m_sheet); |
| 198 return; | 198 return; |
| 199 } | 199 } |
| 200 | 200 |
| 201 DCHECK(m_isCSS); | 201 DCHECK(m_isCSS); |
| 202 CSSParserContext parserContext(document(), nullptr, baseURL, charset); | 202 CSSParserContext parserContext(document(), nullptr, baseURL, charset); |
| 203 | 203 |
| 204 StyleSheetContents* newSheet = StyleSheetContents::create(href, parserContex
t); | 204 StyleSheetContents* newSheet = StyleSheetContents::create(href, parserContex
t); |
| 205 | 205 |
| 206 CSSStyleSheet* cssSheet = CSSStyleSheet::create(newSheet, this); | 206 CSSStyleSheet* cssSheet = CSSStyleSheet::create(newSheet, this); |
| 207 cssSheet->setDisabled(m_alternate); | 207 cssSheet->setDisabled(m_alternate); |
| 208 cssSheet->setTitle(m_title); | 208 cssSheet->setTitle(m_title); |
| 209 if (!m_alternate && !m_title.isEmpty()) | 209 if (!m_alternate && !m_title.isEmpty()) |
| 210 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(m_title); | 210 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(m_title); |
| 211 cssSheet->setMediaQueries(MediaQuerySet::create(m_media)); | 211 cssSheet->setMediaQueries(MediaQuerySet::create(m_media)); |
| 212 | 212 |
| 213 m_sheet = cssSheet; | 213 m_sheet = cssSheet; |
| 214 | 214 |
| 215 // We don't need the cross-origin security check here because we are | 215 // We don't need the cross-origin security check here because we are |
| 216 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME | 216 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME |
| 217 // type. | 217 // type. |
| 218 parseStyleSheet(sheet->sheetText()); | 218 parseStyleSheet(sheet->sheetText()); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas
eURL, const String& sheet) | 221 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas
eURL, const String& sheet) |
| 222 { | 222 { |
| 223 if (!inShadowIncludingDocument()) { | 223 if (!isConnected()) { |
| 224 DCHECK(!m_sheet); | 224 DCHECK(!m_sheet); |
| 225 return; | 225 return; |
| 226 } | 226 } |
| 227 | 227 |
| 228 DCHECK(m_isXSL); | 228 DCHECK(m_isXSL); |
| 229 m_sheet = XSLStyleSheet::create(this, href, baseURL); | 229 m_sheet = XSLStyleSheet::create(this, href, baseURL); |
| 230 std::unique_ptr<IncrementLoadEventDelayCount> delay = IncrementLoadEventDela
yCount::create(document()); | 230 std::unique_ptr<IncrementLoadEventDelayCount> delay = IncrementLoadEventDela
yCount::create(document()); |
| 231 parseStyleSheet(sheet); | 231 parseStyleSheet(sheet); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void ProcessingInstruction::parseStyleSheet(const String& sheet) | 234 void ProcessingInstruction::parseStyleSheet(const String& sheet) |
| 235 { | 235 { |
| 236 if (m_isCSS) | 236 if (m_isCSS) |
| 237 toCSSStyleSheet(m_sheet.get())->contents()->parseString(sheet); | 237 toCSSStyleSheet(m_sheet.get())->contents()->parseString(sheet); |
| 238 else if (m_isXSL) | 238 else if (m_isXSL) |
| 239 toXSLStyleSheet(m_sheet.get())->parseString(sheet); | 239 toXSLStyleSheet(m_sheet.get())->parseString(sheet); |
| 240 | 240 |
| 241 clearResource(); | 241 clearResource(); |
| 242 m_loading = false; | 242 m_loading = false; |
| 243 | 243 |
| 244 if (m_isCSS) | 244 if (m_isCSS) |
| 245 toCSSStyleSheet(m_sheet.get())->contents()->checkLoaded(); | 245 toCSSStyleSheet(m_sheet.get())->contents()->checkLoaded(); |
| 246 else if (m_isXSL) | 246 else if (m_isXSL) |
| 247 toXSLStyleSheet(m_sheet.get())->checkLoaded(); | 247 toXSLStyleSheet(m_sheet.get())->checkLoaded(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) | 250 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) |
| 251 { | 251 { |
| 252 CharacterData::insertedInto(insertionPoint); | 252 CharacterData::insertedInto(insertionPoint); |
| 253 if (!insertionPoint->inShadowIncludingDocument()) | 253 if (!insertionPoint->isConnected()) |
| 254 return InsertionDone; | 254 return InsertionDone; |
| 255 | 255 |
| 256 String href; | 256 String href; |
| 257 String charset; | 257 String charset; |
| 258 bool isValid = checkStyleSheet(href, charset); | 258 bool isValid = checkStyleSheet(href, charset); |
| 259 if (!DocumentXSLT::processingInstructionInsertedIntoDocument(document(), thi
s)) | 259 if (!DocumentXSLT::processingInstructionInsertedIntoDocument(document(), thi
s)) |
| 260 document().styleEngine().addStyleSheetCandidateNode(this); | 260 document().styleEngine().addStyleSheetCandidateNode(this); |
| 261 if (isValid) | 261 if (isValid) |
| 262 process(href, charset); | 262 process(href, charset); |
| 263 return InsertionDone; | 263 return InsertionDone; |
| 264 } | 264 } |
| 265 | 265 |
| 266 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) | 266 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
| 267 { | 267 { |
| 268 CharacterData::removedFrom(insertionPoint); | 268 CharacterData::removedFrom(insertionPoint); |
| 269 if (!insertionPoint->inShadowIncludingDocument()) | 269 if (!insertionPoint->isConnected()) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 // No need to remove XSLStyleSheet from StyleEngine. | 272 // No need to remove XSLStyleSheet from StyleEngine. |
| 273 if (!DocumentXSLT::processingInstructionRemovedFromDocument(document(), this
)) | 273 if (!DocumentXSLT::processingInstructionRemovedFromDocument(document(), this
)) |
| 274 document().styleEngine().removeStyleSheetCandidateNode(this); | 274 document().styleEngine().removeStyleSheetCandidateNode(this); |
| 275 | 275 |
| 276 StyleSheet* removedSheet = m_sheet; | 276 StyleSheet* removedSheet = m_sheet; |
| 277 if (m_sheet) { | 277 if (m_sheet) { |
| 278 DCHECK_EQ(m_sheet->ownerNode(), this); | 278 DCHECK_EQ(m_sheet->ownerNode(), this); |
| 279 clearSheet(); | 279 clearSheet(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 297 | 297 |
| 298 DEFINE_TRACE(ProcessingInstruction) | 298 DEFINE_TRACE(ProcessingInstruction) |
| 299 { | 299 { |
| 300 visitor->trace(m_sheet); | 300 visitor->trace(m_sheet); |
| 301 visitor->trace(m_listenerForXSLT); | 301 visitor->trace(m_listenerForXSLT); |
| 302 CharacterData::trace(visitor); | 302 CharacterData::trace(visitor); |
| 303 ResourceOwner<StyleSheetResource>::trace(visitor); | 303 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace blink | 306 } // namespace blink |
| OLD | NEW |