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 19 matching lines...) Expand all Loading... |
30 #include "core/fetch/CSSStyleSheetResource.h" | 30 #include "core/fetch/CSSStyleSheetResource.h" |
31 #include "core/fetch/FetchRequest.h" | 31 #include "core/fetch/FetchRequest.h" |
32 #include "core/fetch/ResourceFetcher.h" | 32 #include "core/fetch/ResourceFetcher.h" |
33 #include "core/fetch/XSLStyleSheetResource.h" | 33 #include "core/fetch/XSLStyleSheetResource.h" |
34 #include "core/xml/XSLStyleSheet.h" | 34 #include "core/xml/XSLStyleSheet.h" |
35 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() | 35 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 inline ProcessingInstruction::ProcessingInstruction(Document* document, const St
ring& target, const String& data) | 39 inline ProcessingInstruction::ProcessingInstruction(Document* document, const St
ring& target, const String& data) |
40 : Node(document, CreateOther) | 40 : CharacterData(document, data, CreateOther) |
41 , m_target(target) | 41 , m_target(target) |
42 , m_data(data) | |
43 , m_resource(0) | 42 , m_resource(0) |
44 , m_loading(false) | 43 , m_loading(false) |
45 , m_alternate(false) | 44 , m_alternate(false) |
46 , m_createdByParser(false) | 45 , m_createdByParser(false) |
47 , m_isCSS(false) | 46 , m_isCSS(false) |
48 , m_isXSL(false) | 47 , m_isXSL(false) |
49 { | 48 { |
50 ScriptWrappable::init(this); | 49 ScriptWrappable::init(this); |
51 } | 50 } |
52 | 51 |
53 PassRefPtr<ProcessingInstruction> ProcessingInstruction::create(Document* docume
nt, const String& target, const String& data) | 52 PassRefPtr<ProcessingInstruction> ProcessingInstruction::create(Document* docume
nt, const String& target, const String& data) |
54 { | 53 { |
55 return adoptRef(new ProcessingInstruction(document, target, data)); | 54 return adoptRef(new ProcessingInstruction(document, target, data)); |
56 } | 55 } |
57 | 56 |
58 ProcessingInstruction::~ProcessingInstruction() | 57 ProcessingInstruction::~ProcessingInstruction() |
59 { | 58 { |
60 if (m_sheet) | 59 if (m_sheet) |
61 m_sheet->clearOwnerNode(); | 60 m_sheet->clearOwnerNode(); |
62 | 61 |
63 if (m_resource) | 62 if (m_resource) |
64 m_resource->removeClient(this); | 63 m_resource->removeClient(this); |
65 | 64 |
66 if (inDocument()) | 65 if (inDocument()) |
67 document()->styleSheetCollection()->removeStyleSheetCandidateNode(this); | 66 document()->styleSheetCollection()->removeStyleSheetCandidateNode(this); |
68 } | 67 } |
69 | 68 |
70 void ProcessingInstruction::setData(const String& data) | |
71 { | |
72 int oldLength = m_data.length(); | |
73 m_data = data; | |
74 document()->textRemoved(this, 0, oldLength); | |
75 checkStyleSheet(); | |
76 } | |
77 | |
78 String ProcessingInstruction::nodeName() const | 69 String ProcessingInstruction::nodeName() const |
79 { | 70 { |
80 return m_target; | 71 return m_target; |
81 } | 72 } |
82 | 73 |
83 Node::NodeType ProcessingInstruction::nodeType() const | 74 Node::NodeType ProcessingInstruction::nodeType() const |
84 { | 75 { |
85 return PROCESSING_INSTRUCTION_NODE; | 76 return PROCESSING_INSTRUCTION_NODE; |
86 } | 77 } |
87 | 78 |
88 String ProcessingInstruction::nodeValue() const | |
89 { | |
90 return m_data; | |
91 } | |
92 | |
93 void ProcessingInstruction::setNodeValue(const String& nodeValue) | |
94 { | |
95 setData(nodeValue); | |
96 } | |
97 | |
98 PassRefPtr<Node> ProcessingInstruction::cloneNode(bool /*deep*/) | 79 PassRefPtr<Node> ProcessingInstruction::cloneNode(bool /*deep*/) |
99 { | 80 { |
100 // FIXME: Is it a problem that this does not copy m_localHref? | 81 // FIXME: Is it a problem that this does not copy m_localHref? |
101 // What about other data members? | 82 // What about other data members? |
102 return create(document(), m_target, m_data); | 83 return create(document(), m_target, m_data); |
103 } | 84 } |
104 | 85 |
105 void ProcessingInstruction::checkStyleSheet() | 86 void ProcessingInstruction::checkStyleSheet() |
106 { | 87 { |
107 if (m_target == "xml-stylesheet" && document()->frame() && parentNode() == d
ocument()) { | 88 if (m_target == "xml-stylesheet" && document()->frame() && parentNode() == d
ocument()) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 228 |
248 void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet) | 229 void ProcessingInstruction::setCSSStyleSheet(PassRefPtr<CSSStyleSheet> sheet) |
249 { | 230 { |
250 ASSERT(!m_resource); | 231 ASSERT(!m_resource); |
251 ASSERT(!m_loading); | 232 ASSERT(!m_loading); |
252 m_sheet = sheet; | 233 m_sheet = sheet; |
253 sheet->setTitle(m_title); | 234 sheet->setTitle(m_title); |
254 sheet->setDisabled(m_alternate); | 235 sheet->setDisabled(m_alternate); |
255 } | 236 } |
256 | 237 |
257 bool ProcessingInstruction::offsetInCharacters() const | |
258 { | |
259 return true; | |
260 } | |
261 | |
262 int ProcessingInstruction::maxCharacterOffset() const | |
263 { | |
264 return static_cast<int>(m_data.length()); | |
265 } | |
266 | |
267 void ProcessingInstruction::addSubresourceAttributeURLs(ListHashSet<KURL>& urls)
const | 238 void ProcessingInstruction::addSubresourceAttributeURLs(ListHashSet<KURL>& urls)
const |
268 { | 239 { |
269 if (!sheet()) | 240 if (!sheet()) |
270 return; | 241 return; |
271 | 242 |
272 addSubresourceURL(urls, sheet()->baseURL()); | 243 addSubresourceURL(urls, sheet()->baseURL()); |
273 } | 244 } |
274 | 245 |
275 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) | 246 Node::InsertionNotificationRequest ProcessingInstruction::insertedInto(Container
Node* insertionPoint) |
276 { | 247 { |
277 Node::insertedInto(insertionPoint); | 248 CharacterData::insertedInto(insertionPoint); |
278 if (!insertionPoint->inDocument()) | 249 if (!insertionPoint->inDocument()) |
279 return InsertionDone; | 250 return InsertionDone; |
280 document()->styleSheetCollection()->addStyleSheetCandidateNode(this, m_creat
edByParser); | 251 document()->styleSheetCollection()->addStyleSheetCandidateNode(this, m_creat
edByParser); |
281 checkStyleSheet(); | 252 checkStyleSheet(); |
282 return InsertionDone; | 253 return InsertionDone; |
283 } | 254 } |
284 | 255 |
285 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) | 256 void ProcessingInstruction::removedFrom(ContainerNode* insertionPoint) |
286 { | 257 { |
287 Node::removedFrom(insertionPoint); | 258 CharacterData::removedFrom(insertionPoint); |
288 if (!insertionPoint->inDocument()) | 259 if (!insertionPoint->inDocument()) |
289 return; | 260 return; |
290 | 261 |
291 document()->styleSheetCollection()->removeStyleSheetCandidateNode(this); | 262 document()->styleSheetCollection()->removeStyleSheetCandidateNode(this); |
292 | 263 |
293 RefPtr<StyleSheet> removedSheet = m_sheet; | 264 RefPtr<StyleSheet> removedSheet = m_sheet; |
294 | 265 |
295 if (m_sheet) { | 266 if (m_sheet) { |
296 ASSERT(m_sheet->ownerNode() == this); | 267 ASSERT(m_sheet->ownerNode() == this); |
297 m_sheet->clearOwnerNode(); | 268 m_sheet->clearOwnerNode(); |
298 m_sheet = 0; | 269 m_sheet = 0; |
299 } | 270 } |
300 | 271 |
301 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. | 272 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. |
302 if (document()->renderer()) | 273 if (document()->renderer()) |
303 document()->removedStyleSheet(removedSheet.get()); | 274 document()->removedStyleSheet(removedSheet.get()); |
304 } | 275 } |
305 | 276 |
306 void ProcessingInstruction::finishParsingChildren() | 277 void ProcessingInstruction::finishParsingChildren() |
307 { | 278 { |
308 m_createdByParser = false; | 279 m_createdByParser = false; |
309 Node::finishParsingChildren(); | 280 CharacterData::finishParsingChildren(); |
310 } | 281 } |
311 | 282 |
312 } // namespace | 283 } // namespace |
OLD | NEW |