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 14 matching lines...) Expand all Loading... | |
25 #include "core/css/CSSStyleSheet.h" | 25 #include "core/css/CSSStyleSheet.h" |
26 #include "core/css/MediaList.h" | 26 #include "core/css/MediaList.h" |
27 #include "core/css/StyleSheetContents.h" | 27 #include "core/css/StyleSheetContents.h" |
28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
29 #include "core/dom/IncrementLoadEventDelayCount.h" | 29 #include "core/dom/IncrementLoadEventDelayCount.h" |
30 #include "core/dom/StyleEngine.h" | 30 #include "core/dom/StyleEngine.h" |
31 #include "core/fetch/CSSStyleSheetResource.h" | 31 #include "core/fetch/CSSStyleSheetResource.h" |
32 #include "core/fetch/FetchRequest.h" | 32 #include "core/fetch/FetchRequest.h" |
33 #include "core/fetch/ResourceFetcher.h" | 33 #include "core/fetch/ResourceFetcher.h" |
34 #include "core/fetch/XSLStyleSheetResource.h" | 34 #include "core/fetch/XSLStyleSheetResource.h" |
35 #include "core/xml/DocumentXSLT.h" | |
35 #include "core/xml/XSLStyleSheet.h" | 36 #include "core/xml/XSLStyleSheet.h" |
36 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() | 37 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 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) |
41 : CharacterData(document, data, CreateOther) | 42 : CharacterData(document, data, CreateOther) |
42 , m_target(target) | 43 , m_target(target) |
43 , m_loading(false) | 44 , m_loading(false) |
44 , m_alternate(false) | 45 , m_alternate(false) |
45 , m_createdByParser(false) | 46 , m_createdByParser(false) |
46 , m_isCSS(false) | 47 , m_isCSS(false) |
47 , m_isXSL(false) | 48 , m_isXSL(false) |
49 , m_listenerForXSLT(nullptr) | |
48 { | 50 { |
49 } | 51 } |
50 | 52 |
51 PassRefPtrWillBeRawPtr<ProcessingInstruction> ProcessingInstruction::create(Docu ment& document, const String& target, const String& data) | 53 PassRefPtrWillBeRawPtr<ProcessingInstruction> ProcessingInstruction::create(Docu ment& document, const String& target, const String& data) |
52 { | 54 { |
53 return adoptRefWillBeNoop(new ProcessingInstruction(document, target, data)) ; | 55 return adoptRefWillBeNoop(new ProcessingInstruction(document, target, data)) ; |
54 } | 56 } |
55 | 57 |
56 ProcessingInstruction::~ProcessingInstruction() | 58 ProcessingInstruction::~ProcessingInstruction() |
57 { | 59 { |
58 #if !ENABLE(OILPAN) | 60 #if !ENABLE(OILPAN) |
59 if (m_sheet) | 61 if (m_sheet) |
60 clearSheet(); | 62 clearSheet(); |
61 | 63 |
62 // FIXME: ProcessingInstruction should not be in document here. | 64 // FIXME: ProcessingInstruction should not be in document here. |
63 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml | 65 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml |
64 // crashes. We need to investigate ProcessingInstruction lifetime. | 66 // crashes. We need to investigate ProcessingInstruction lifetime. |
65 if (inDocument()) { | 67 if (inDocument() && m_isCSS) |
66 if (m_isCSS) | 68 document().styleEngine()->removeStyleSheetCandidateNode(this); |
67 document().styleEngine()->removeStyleSheetCandidateNode(this); | |
68 else if (m_isXSL) | |
69 document().styleEngine()->removeXSLStyleSheet(this); | |
70 } | |
71 #endif | 69 #endif |
72 } | 70 } |
73 | 71 |
74 String ProcessingInstruction::nodeName() const | 72 String ProcessingInstruction::nodeName() const |
75 { | 73 { |
76 return m_target; | 74 return m_target; |
77 } | 75 } |
78 | 76 |
79 Node::NodeType ProcessingInstruction::nodeType() const | 77 Node::NodeType ProcessingInstruction::nodeType() const |
80 { | 78 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 FetchRequest request(ResourceRequest(document().completeURL(href)), FetchIni tiatorTypeNames::processinginstruction); | 153 FetchRequest request(ResourceRequest(document().completeURL(href)), FetchIni tiatorTypeNames::processinginstruction); |
156 if (m_isXSL) { | 154 if (m_isXSL) { |
157 resource = document().fetcher()->fetchXSLStyleSheet(request); | 155 resource = document().fetcher()->fetchXSLStyleSheet(request); |
158 } else { | 156 } else { |
159 request.setCharset(charset.isEmpty() ? document().charset() : charset); | 157 request.setCharset(charset.isEmpty() ? document().charset() : charset); |
160 resource = document().fetcher()->fetchCSSStyleSheet(request); | 158 resource = document().fetcher()->fetchCSSStyleSheet(request); |
161 } | 159 } |
162 | 160 |
163 if (resource) { | 161 if (resource) { |
164 m_loading = true; | 162 m_loading = true; |
165 document().styleEngine()->addPendingSheet(); | 163 if (!m_isXSL) |
164 document().styleEngine()->addPendingSheet(); | |
166 setResource(resource); | 165 setResource(resource); |
167 } | 166 } |
168 } | 167 } |
169 | 168 |
170 bool ProcessingInstruction::isLoading() const | 169 bool ProcessingInstruction::isLoading() const |
171 { | 170 { |
172 if (m_loading) | 171 if (m_loading) |
173 return true; | 172 return true; |
174 if (!m_sheet) | 173 if (!m_sheet) |
175 return false; | 174 return false; |
176 return m_sheet->isLoading(); | 175 return m_sheet->isLoading(); |
177 } | 176 } |
178 | 177 |
179 bool ProcessingInstruction::sheetLoaded() | 178 bool ProcessingInstruction::sheetLoaded() |
180 { | 179 { |
181 if (!isLoading()) { | 180 if (!isLoading()) { |
181 if (m_isXSL) { | |
182 DocumentXSLT::sheetLoaded(document(), this); | |
183 return true; | |
184 } | |
182 document().styleEngine()->removePendingSheet(this); | 185 document().styleEngine()->removePendingSheet(this); |
183 return true; | 186 return true; |
184 } | 187 } |
185 return false; | 188 return false; |
186 } | 189 } |
187 | 190 |
188 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas eURL, const String& charset, const CSSStyleSheetResource* sheet) | 191 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas eURL, const String& charset, const CSSStyleSheetResource* sheet) |
189 { | 192 { |
190 if (!inDocument()) { | 193 if (!inDocument()) { |
191 ASSERT(!m_sheet); | 194 ASSERT(!m_sheet); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 | 254 |
252 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container Node* insertionPoint) | 255 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container Node* insertionPoint) |
253 { | 256 { |
254 CharacterData::insertedInto(insertionPoint); | 257 CharacterData::insertedInto(insertionPoint); |
255 if (!insertionPoint->inDocument()) | 258 if (!insertionPoint->inDocument()) |
256 return InsertionDone; | 259 return InsertionDone; |
257 | 260 |
258 String href; | 261 String href; |
259 String charset; | 262 String charset; |
260 bool isValid = checkStyleSheet(href, charset); | 263 bool isValid = checkStyleSheet(href, charset); |
261 if (m_isCSS) | 264 if (m_isCSS) { |
262 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa rser); | 265 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa rser); |
263 else if (m_isXSL) | 266 } else if (m_isXSL) { |
264 document().styleEngine()->addXSLStyleSheet(this, m_createdByParser); | 267 // No need to register XSLStyleSheet to StyleEngine. |
268 m_listenerForXSLT = DocumentXSLT::addDOMContentLoadedListenerForXSLT(doc ument(), this); | |
269 ASSERT(m_listenerForXSLT); | |
tasak
2014/11/19 09:23:03
Should be ASSERT(m_listenerForXSLT || !RuntimeEnab
| |
270 } | |
265 if (isValid) | 271 if (isValid) |
266 process(href, charset); | 272 process(href, charset); |
267 return InsertionDone; | 273 return InsertionDone; |
268 } | 274 } |
269 | 275 |
270 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) | 276 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
271 { | 277 { |
272 CharacterData::removedFrom(insertionPoint); | 278 CharacterData::removedFrom(insertionPoint); |
273 if (!insertionPoint->inDocument()) | 279 if (!insertionPoint->inDocument()) |
274 return; | 280 return; |
275 | 281 |
276 if (m_isCSS) | 282 if (m_isCSS) { |
277 document().styleEngine()->removeStyleSheetCandidateNode(this); | 283 document().styleEngine()->removeStyleSheetCandidateNode(this); |
278 else if (m_isXSL) | 284 } else if (m_isXSL) { |
tasak
2014/11/19 09:23:03
Should be (m_isXSL && m_listenerForXSLT)
| |
279 document().styleEngine()->removeXSLStyleSheet(this); | 285 document().removeEventListener(EventTypeNames::DOMContentLoaded, m_liste nerForXSLT, false); |
286 m_listenerForXSLT.clear(); | |
287 } | |
280 | 288 |
289 // No need to remove XSLStyleSheet from StyleEngine. | |
281 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; | 290 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; |
282 | 291 |
283 if (m_sheet) { | 292 if (m_sheet) { |
284 ASSERT(m_sheet->ownerNode() == this); | 293 ASSERT(m_sheet->ownerNode() == this); |
285 clearSheet(); | 294 clearSheet(); |
286 } else if (resource()) { | 295 } else if (resource()) { |
287 ASSERT(m_loading); | 296 ASSERT(m_loading); |
288 document().styleEngine()->removePendingSheet(this); | 297 document().styleEngine()->removePendingSheet(this); |
289 clearResource(); | 298 clearResource(); |
290 } | 299 } |
(...skipping 11 matching lines...) Expand all Loading... | |
302 m_sheet.release()->clearOwnerNode(); | 311 m_sheet.release()->clearOwnerNode(); |
303 } | 312 } |
304 | 313 |
305 void ProcessingInstruction::trace(Visitor* visitor) | 314 void ProcessingInstruction::trace(Visitor* visitor) |
306 { | 315 { |
307 visitor->trace(m_sheet); | 316 visitor->trace(m_sheet); |
308 CharacterData::trace(visitor); | 317 CharacterData::trace(visitor); |
309 } | 318 } |
310 | 319 |
311 } // namespace | 320 } // namespace |
OLD | NEW |