| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return true; | 178 return true; |
| 179 if (!m_sheet) | 179 if (!m_sheet) |
| 180 return false; | 180 return false; |
| 181 return m_sheet->isLoading(); | 181 return m_sheet->isLoading(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 bool ProcessingInstruction::sheetLoaded() | 184 bool ProcessingInstruction::sheetLoaded() |
| 185 { | 185 { |
| 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_styleEngineCont
ext); |
| 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 (!isConnected()) { | 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,
StyleEngine::DontUpdateActiveSheets); | 210 document().styleEngine().setPreferredStylesheetSetNameIfNotSet(m_title,
StyleEngine::DontUpdateActiveSheets); |
| 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 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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->isConnected()) | 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->isConnected()) | 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(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // No need to remove pending sheets. | 282 // No need to remove pending sheets. |
| 283 clearResource(); | 283 clearResource(); |
| 284 | 284 |
| 285 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. | 285 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. |
| 286 if (document().isActive()) | 286 if (document().isActive()) |
| 287 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); | 287 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void ProcessingInstruction::clearSheet() | 290 void ProcessingInstruction::clearSheet() |
| 291 { | 291 { |
| 292 DCHECK(m_sheet); | 292 DCHECK(m_sheet); |
| 293 if (m_sheet->isLoading()) | 293 if (m_sheet->isLoading()) |
| 294 document().styleEngine().removePendingSheet(this, m_styleEngineContext); | 294 document().styleEngine().removePendingSheet(*this, m_styleEngineContext)
; |
| 295 m_sheet.release()->clearOwnerNode(); | 295 m_sheet.release()->clearOwnerNode(); |
| 296 } | 296 } |
| 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 |