Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: Source/core/dom/ProcessingInstruction.cpp

Issue 429363004: Should clear sheet when ProcessingInstruction's removedFrom or attributeChanged (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ProcessingInstruction.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 PassRefPtrWillBeRawPtr<ProcessingInstruction> ProcessingInstruction::create(Docu ment& document, const String& target, const String& data) 51 PassRefPtrWillBeRawPtr<ProcessingInstruction> ProcessingInstruction::create(Docu ment& document, const String& target, const String& data)
52 { 52 {
53 return adoptRefWillBeNoop(new ProcessingInstruction(document, target, data)) ; 53 return adoptRefWillBeNoop(new ProcessingInstruction(document, target, data)) ;
54 } 54 }
55 55
56 ProcessingInstruction::~ProcessingInstruction() 56 ProcessingInstruction::~ProcessingInstruction()
57 { 57 {
58 #if !ENABLE(OILPAN) 58 #if !ENABLE(OILPAN)
59 if (m_sheet) 59 if (m_sheet)
60 m_sheet->clearOwnerNode(); 60 clearSheet();
61 61
62 // FIXME: ProcessingInstruction should not be in document here. 62 // FIXME: ProcessingInstruction should not be in document here.
63 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml 63 // However, if we add ASSERT(!inDocument()), fast/xsl/xslt-entity.xml
64 // crashes. We need to investigate ProcessingInstruction lifetime. 64 // crashes. We need to investigate ProcessingInstruction lifetime.
65 if (inDocument()) { 65 if (inDocument()) {
66 if (m_isCSS) 66 if (m_isCSS)
67 document().styleEngine()->removeStyleSheetCandidateNode(this); 67 document().styleEngine()->removeStyleSheetCandidateNode(this);
68 else if (m_isXSL) 68 else if (m_isXSL)
69 document().styleEngine()->removeXSLStyleSheet(this); 69 document().styleEngine()->removeXSLStyleSheet(this);
70 } 70 }
(...skipping 12 matching lines...) Expand all
83 83
84 PassRefPtrWillBeRawPtr<Node> ProcessingInstruction::cloneNode(bool /*deep*/) 84 PassRefPtrWillBeRawPtr<Node> ProcessingInstruction::cloneNode(bool /*deep*/)
85 { 85 {
86 // FIXME: Is it a problem that this does not copy m_localHref? 86 // FIXME: Is it a problem that this does not copy m_localHref?
87 // What about other data members? 87 // What about other data members?
88 return create(document(), m_target, m_data); 88 return create(document(), m_target, m_data);
89 } 89 }
90 90
91 void ProcessingInstruction::didAttributeChanged() 91 void ProcessingInstruction::didAttributeChanged()
92 { 92 {
93 ASSERT(!m_sheet); 93 if (m_sheet)
94 ASSERT(!isLoading()); 94 clearSheet();
95
95 String href; 96 String href;
96 String charset; 97 String charset;
97 if (!checkStyleSheet(href, charset)) 98 if (!checkStyleSheet(href, charset))
98 return; 99 return;
99 process(href, charset); 100 process(href, charset);
100 } 101 }
101 102
102 bool ProcessingInstruction::checkStyleSheet(String& href, String& charset) 103 bool ProcessingInstruction::checkStyleSheet(String& href, String& charset)
103 { 104 {
104 if (m_target != "xml-stylesheet" || !document().frame() || parentNode() != d ocument()) 105 if (m_target != "xml-stylesheet" || !document().frame() || parentNode() != d ocument())
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 m_sheet = cssSheet.release(); 205 m_sheet = cssSheet.release();
205 206
206 // We don't need the cross-origin security check here because we are 207 // We don't need the cross-origin security check here because we are
207 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME 208 // getting the sheet text in "strict" mode. This enforces a valid CSS MIME
208 // type. 209 // type.
209 parseStyleSheet(sheet->sheetText(true)); 210 parseStyleSheet(sheet->sheetText(true));
210 } 211 }
211 212
212 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas eURL, const String& sheet) 213 void ProcessingInstruction::setXSLStyleSheet(const String& href, const KURL& bas eURL, const String& sheet)
213 { 214 {
215 if (!inDocument()) {
216 ASSERT(!m_sheet);
217 return;
218 }
219
214 ASSERT(m_isXSL); 220 ASSERT(m_isXSL);
215 m_sheet = XSLStyleSheet::create(this, href, baseURL); 221 m_sheet = XSLStyleSheet::create(this, href, baseURL);
216 parseStyleSheet(sheet); 222 parseStyleSheet(sheet);
217 } 223 }
218 224
219 void ProcessingInstruction::parseStyleSheet(const String& sheet) 225 void ProcessingInstruction::parseStyleSheet(const String& sheet)
220 { 226 {
221 if (m_isCSS) 227 if (m_isCSS)
222 toCSSStyleSheet(m_sheet.get())->contents()->parseString(sheet); 228 toCSSStyleSheet(m_sheet.get())->contents()->parseString(sheet);
223 else if (m_isXSL) 229 else if (m_isXSL)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 273
268 if (m_isCSS) 274 if (m_isCSS)
269 document().styleEngine()->removeStyleSheetCandidateNode(this); 275 document().styleEngine()->removeStyleSheetCandidateNode(this);
270 else if (m_isXSL) 276 else if (m_isXSL)
271 document().styleEngine()->removeXSLStyleSheet(this); 277 document().styleEngine()->removeXSLStyleSheet(this);
272 278
273 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet; 279 RefPtrWillBeRawPtr<StyleSheet> removedSheet = m_sheet;
274 280
275 if (m_sheet) { 281 if (m_sheet) {
276 ASSERT(m_sheet->ownerNode() == this); 282 ASSERT(m_sheet->ownerNode() == this);
277 m_sheet->clearOwnerNode(); 283 clearSheet();
278 m_sheet = nullptr;
279 } 284 }
280 285
281 // If we're in document teardown, then we don't need to do any notification of our sheet's removal. 286 // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
282 if (document().isActive()) 287 if (document().isActive())
283 document().removedStyleSheet(removedSheet.get()); 288 document().removedStyleSheet(removedSheet.get());
284 } 289 }
285 290
291 void ProcessingInstruction::clearSheet()
292 {
293 ASSERT(m_sheet);
294 if (m_sheet->isLoading())
295 document().styleEngine()->removePendingSheet(this);
296 m_sheet.release()->clearOwnerNode();
297 }
298
286 void ProcessingInstruction::trace(Visitor* visitor) 299 void ProcessingInstruction::trace(Visitor* visitor)
287 { 300 {
288 visitor->trace(m_sheet); 301 visitor->trace(m_sheet);
289 CharacterData::trace(visitor); 302 CharacterData::trace(visitor);
290 } 303 }
291 304
292 } // namespace 305 } // namespace
OLDNEW
« no previous file with comments | « Source/core/dom/ProcessingInstruction.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698