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/IncrementLoadEventDelayCount.h" | 30 #include "core/dom/IncrementLoadEventDelayCount.h" |
30 #include "core/dom/StyleEngine.h" | 31 #include "core/dom/StyleEngine.h" |
31 #include "core/fetch/CSSStyleSheetResource.h" | 32 #include "core/fetch/CSSStyleSheetResource.h" |
32 #include "core/fetch/FetchRequest.h" | 33 #include "core/fetch/FetchRequest.h" |
33 #include "core/fetch/ResourceFetcher.h" | 34 #include "core/fetch/ResourceFetcher.h" |
34 #include "core/fetch/XSLStyleSheetResource.h" | 35 #include "core/fetch/XSLStyleSheetResource.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() |
| 38 #include "platform/EventDispatchForbiddenScope.h" |
37 | 39 |
38 namespace blink { | 40 namespace blink { |
39 | 41 |
40 inline ProcessingInstruction::ProcessingInstruction(Document& document, const St
ring& target, const String& data) | 42 inline ProcessingInstruction::ProcessingInstruction(Document& document, const St
ring& target, const String& data) |
41 : CharacterData(document, data, CreateOther) | 43 : CharacterData(document, data, CreateOther) |
42 , m_target(target) | 44 , m_target(target) |
43 , m_loading(false) | 45 , m_loading(false) |
44 , m_alternate(false) | 46 , m_alternate(false) |
45 , m_createdByParser(false) | 47 , m_createdByParser(false) |
46 , m_isCSS(false) | 48 , m_isCSS(false) |
(...skipping 11 matching lines...) Expand all Loading... |
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()) { |
66 if (m_isCSS) | 68 if (m_isCSS) |
67 document().styleEngine()->removeStyleSheetCandidateNode(this); | 69 document().styleEngine()->removeStyleSheetCandidateNode(this); |
68 else if (m_isXSL) | |
69 document().styleEngine()->removeXSLStyleSheet(this); | |
70 } | 70 } |
71 #endif | 71 #endif |
72 } | 72 } |
73 | 73 |
74 String ProcessingInstruction::nodeName() const | 74 String ProcessingInstruction::nodeName() const |
75 { | 75 { |
76 return m_target; | 76 return m_target; |
77 } | 77 } |
78 | 78 |
79 Node::NodeType ProcessingInstruction::nodeType() const | 79 Node::NodeType ProcessingInstruction::nodeType() const |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (m_loading) | 172 if (m_loading) |
173 return true; | 173 return true; |
174 if (!m_sheet) | 174 if (!m_sheet) |
175 return false; | 175 return false; |
176 return m_sheet->isLoading(); | 176 return m_sheet->isLoading(); |
177 } | 177 } |
178 | 178 |
179 bool ProcessingInstruction::sheetLoaded() | 179 bool ProcessingInstruction::sheetLoaded() |
180 { | 180 { |
181 if (!isLoading()) { | 181 if (!isLoading()) { |
182 document().styleEngine()->removePendingSheet(this); | 182 if (m_isCSS) |
| 183 document().styleEngine()->removePendingSheet(this); |
183 return true; | 184 return true; |
184 } | 185 } |
185 return false; | 186 return false; |
186 } | 187 } |
187 | 188 |
188 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) | 189 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) |
189 { | 190 { |
190 if (!inDocument()) { | 191 if (!inDocument()) { |
191 ASSERT(!m_sheet); | 192 ASSERT(!m_sheet); |
192 return; | 193 return; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 252 |
252 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) | 253 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) |
253 { | 254 { |
254 CharacterData::insertedInto(insertionPoint); | 255 CharacterData::insertedInto(insertionPoint); |
255 if (!insertionPoint->inDocument()) | 256 if (!insertionPoint->inDocument()) |
256 return InsertionDone; | 257 return InsertionDone; |
257 | 258 |
258 String href; | 259 String href; |
259 String charset; | 260 String charset; |
260 bool isValid = checkStyleSheet(href, charset); | 261 bool isValid = checkStyleSheet(href, charset); |
| 262 if (m_isXSL) { |
| 263 EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents; |
| 264 V8ProcessingInstruction::PrivateScript::onProcessingInstructionAvailable
Method(document().frame(), this, href, document().parsing()); |
| 265 return InsertionDone; |
| 266 } |
261 if (m_isCSS) | 267 if (m_isCSS) |
262 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa
rser); | 268 document().styleEngine()->addStyleSheetCandidateNode(this, m_createdByPa
rser); |
263 else if (m_isXSL) | |
264 document().styleEngine()->addXSLStyleSheet(this, m_createdByParser); | |
265 if (isValid) | 269 if (isValid) |
266 process(href, charset); | 270 process(href, charset); |
267 return InsertionDone; | 271 return InsertionDone; |
268 } | 272 } |
269 | 273 |
270 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) | 274 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
271 { | 275 { |
272 CharacterData::removedFrom(insertionPoint); | 276 CharacterData::removedFrom(insertionPoint); |
273 if (!insertionPoint->inDocument()) | 277 if (!insertionPoint->inDocument()) |
274 return; | 278 return; |
275 | 279 |
276 if (m_isCSS) | 280 if (m_isCSS) |
277 document().styleEngine()->removeStyleSheetCandidateNode(this); | 281 document().styleEngine()->removeStyleSheetCandidateNode(this); |
278 else if (m_isXSL) | |
279 document().styleEngine()->removeXSLStyleSheet(this); | |
280 | 282 |
281 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; | 283 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; |
282 | 284 |
283 if (m_sheet) { | 285 if (m_sheet) { |
284 ASSERT(m_sheet->ownerNode() == this); | 286 ASSERT(m_sheet->ownerNode() == this); |
285 clearSheet(); | 287 clearSheet(); |
286 } | 288 } |
287 | 289 |
288 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. | 290 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. |
289 if (document().isActive()) | 291 if (document().isActive()) |
290 document().removedStyleSheet(removedSheet.get()); | 292 document().removedStyleSheet(removedSheet.get()); |
291 } | 293 } |
292 | 294 |
293 void ProcessingInstruction::clearSheet() | 295 void ProcessingInstruction::clearSheet() |
294 { | 296 { |
295 ASSERT(m_sheet); | 297 ASSERT(m_sheet); |
296 if (m_sheet->isLoading()) | 298 if (m_sheet->isLoading()) |
297 document().styleEngine()->removePendingSheet(this); | 299 document().styleEngine()->removePendingSheet(this); |
298 m_sheet.release()->clearOwnerNode(); | 300 m_sheet.release()->clearOwnerNode(); |
299 } | 301 } |
300 | 302 |
301 void ProcessingInstruction::trace(Visitor* visitor) | 303 void ProcessingInstruction::trace(Visitor* visitor) |
302 { | 304 { |
303 visitor->trace(m_sheet); | 305 visitor->trace(m_sheet); |
304 CharacterData::trace(visitor); | 306 CharacterData::trace(visitor); |
305 } | 307 } |
306 | 308 |
307 } // namespace | 309 } // namespace |
OLD | NEW |