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