| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "core/dom/ProcessingInstruction.h" | 22 #include "core/dom/ProcessingInstruction.h" |
| 23 | 23 |
| 24 #include "bindings/core/v8/V8ProcessingInstruction.h" |
| 24 #include "core/FetchInitiatorTypeNames.h" | 25 #include "core/FetchInitiatorTypeNames.h" |
| 25 #include "core/css/CSSStyleSheet.h" | 26 #include "core/css/CSSStyleSheet.h" |
| 26 #include "core/css/MediaList.h" | 27 #include "core/css/MediaList.h" |
| 27 #include "core/css/StyleSheetContents.h" | 28 #include "core/css/StyleSheetContents.h" |
| 28 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 29 #include "core/dom/StyleEngine.h" | 30 #include "core/dom/StyleEngine.h" |
| 30 #include "core/fetch/CSSStyleSheetResource.h" | 31 #include "core/fetch/CSSStyleSheetResource.h" |
| 31 #include "core/fetch/FetchRequest.h" | 32 #include "core/fetch/FetchRequest.h" |
| 32 #include "core/fetch/ResourceFetcher.h" | 33 #include "core/fetch/ResourceFetcher.h" |
| 33 #include "core/fetch/XSLStyleSheetResource.h" | 34 #include "core/fetch/XSLStyleSheetResource.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 58 #if !ENABLE(OILPAN) | 59 #if !ENABLE(OILPAN) |
| 59 if (m_sheet) | 60 if (m_sheet) |
| 60 m_sheet->clearOwnerNode(); | 61 m_sheet->clearOwnerNode(); |
| 61 | 62 |
| 62 // FIXME: ProcessingInstruction should not be in document here. | 63 // FIXME: ProcessingInstruction should not be in document here. |
| 63 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml | 64 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml |
| 64 // crashes. We need to investigate ProcessingInstruction lifetime. | 65 // crashes. We need to investigate ProcessingInstruction lifetime. |
| 65 if (inDocument()) { | 66 if (inDocument()) { |
| 66 if (m_isCSS) | 67 if (m_isCSS) |
| 67 document().styleEngine()->removeStyleSheetCandidateNode(this); | 68 document().styleEngine()->removeStyleSheetCandidateNode(this); |
| 68 else if (m_isXSL) | |
| 69 document().styleEngine()->removeXSLStyleSheet(this); | |
| 70 } | 69 } |
| 71 #endif | 70 #endif |
| 72 } | 71 } |
| 73 | 72 |
| 74 String ProcessingInstruction::nodeName() const | 73 String ProcessingInstruction::nodeName() const |
| 75 { | 74 { |
| 76 return m_target; | 75 return m_target; |
| 77 } | 76 } |
| 78 | 77 |
| 79 Node::NodeType ProcessingInstruction::nodeType() const | 78 Node::NodeType ProcessingInstruction::nodeType() const |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 if (m_loading) | 170 if (m_loading) |
| 172 return true; | 171 return true; |
| 173 if (!m_sheet) | 172 if (!m_sheet) |
| 174 return false; | 173 return false; |
| 175 return m_sheet->isLoading(); | 174 return m_sheet->isLoading(); |
| 176 } | 175 } |
| 177 | 176 |
| 178 bool ProcessingInstruction::sheetLoaded() | 177 bool ProcessingInstruction::sheetLoaded() |
| 179 { | 178 { |
| 180 if (!isLoading()) { | 179 if (!isLoading()) { |
| 181 document().styleEngine()->removePendingSheet(this); | 180 if (m_isCSS) { |
| 181 document().styleEngine()->removePendingSheet(this); |
| 182 } else if (RuntimeEnabledFeatures::xsltEnabled() && m_isXSL) { |
| 183 V8ProcessingInstruction::sheetLoadedCallbackMethodImplementedInPriva
teScript(document().frame(), this); |
| 184 } |
| 182 return true; | 185 return true; |
| 183 } | 186 } |
| 184 return false; | 187 return false; |
| 185 } | 188 } |
| 186 | 189 |
| 187 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) | 190 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) |
| 188 { | 191 { |
| 189 if (!inDocument()) { | 192 if (!inDocument()) { |
| 190 ASSERT(!m_sheet); | 193 ASSERT(!m_sheet); |
| 191 return; | 194 return; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 { | 248 { |
| 246 CharacterData::insertedInto(insertionPoint); | 249 CharacterData::insertedInto(insertionPoint); |
| 247 if (!insertionPoint->inDocument()) | 250 if (!insertionPoint->inDocument()) |
| 248 return InsertionDone; | 251 return InsertionDone; |
| 249 | 252 |
| 250 String href; | 253 String href; |
| 251 String charset; | 254 String charset; |
| 252 bool isValid = checkStyleSheet(href, charset); | 255 bool isValid = checkStyleSheet(href, charset); |
| 253 if (m_isCSS) | 256 if (m_isCSS) |
| 254 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa
rser); | 257 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa
rser); |
| 255 else if (m_isXSL) | |
| 256 document().styleEngine()->addXSLStyleSheet(this, m_createdByParser); | |
| 257 if (isValid) | 258 if (isValid) |
| 258 process(href, charset); | 259 process(href, charset); |
| 260 |
| 261 if (RuntimeEnabledFeatures::xsltEnabled() && m_isXSL) { |
| 262 V8ProcessingInstruction::registerSheetMethodImplementedInPrivateScript(d
ocument().frame(), this, document().parsing()); |
| 263 if (!m_loading) |
| 264 V8ProcessingInstruction::sheetLoadedCallbackMethodImplementedInPriva
teScript(document().frame(), this); |
| 265 } |
| 259 return InsertionDone; | 266 return InsertionDone; |
| 260 } | 267 } |
| 261 | 268 |
| 262 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) | 269 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
| 263 { | 270 { |
| 264 CharacterData::removedFrom(insertionPoint); | 271 CharacterData::removedFrom(insertionPoint); |
| 265 if (!insertionPoint->inDocument()) | 272 if (!insertionPoint->inDocument()) |
| 266 return; | 273 return; |
| 267 | 274 |
| 268 if (m_isCSS) | 275 if (m_isCSS) { |
| 269 document().styleEngine()->removeStyleSheetCandidateNode(this); | 276 document().styleEngine()->removeStyleSheetCandidateNode(this); |
| 270 else if (m_isXSL) | 277 } else if (RuntimeEnabledFeatures::xsltEnabled() && m_isXSL) { |
| 271 document().styleEngine()->removeXSLStyleSheet(this); | 278 V8ProcessingInstruction::unregisterSheetMethodImplementedInPrivateScript
(document().frame(), this); |
| 279 } |
| 272 | 280 |
| 273 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; | 281 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; |
| 274 | 282 |
| 275 if (m_sheet) { | 283 if (m_sheet) { |
| 276 ASSERT(m_sheet->ownerNode() == this); | 284 ASSERT(m_sheet->ownerNode() == this); |
| 277 m_sheet->clearOwnerNode(); | 285 m_sheet->clearOwnerNode(); |
| 278 m_sheet = nullptr; | 286 m_sheet = nullptr; |
| 279 } | 287 } |
| 280 | 288 |
| 281 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. | 289 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. |
| 282 if (document().isActive()) | 290 if (document().isActive()) |
| 283 document().removedStyleSheet(removedSheet.get()); | 291 document().removedStyleSheet(removedSheet.get()); |
| 284 } | 292 } |
| 285 | 293 |
| 286 void ProcessingInstruction::trace(Visitor* visitor) | 294 void ProcessingInstruction::trace(Visitor* visitor) |
| 287 { | 295 { |
| 288 visitor->trace(m_sheet); | 296 visitor->trace(m_sheet); |
| 289 CharacterData::trace(visitor); | 297 CharacterData::trace(visitor); |
| 290 } | 298 } |
| 291 | 299 |
| 292 } // namespace | 300 } // namespace |
| OLD | NEW |