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 23 matching lines...) Expand all Loading... |
34 #include "core/xml/DocumentXSLT.h" | 34 #include "core/xml/DocumentXSLT.h" |
35 #include "core/xml/XSLStyleSheet.h" | 35 #include "core/xml/XSLStyleSheet.h" |
36 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() | 36 #include "core/xml/parser/XMLDocumentParser.h" // for parseAttributes() |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 inline ProcessingInstruction::ProcessingInstruction(Document& document, const St
ring& target, const String& data) | 40 inline ProcessingInstruction::ProcessingInstruction(Document& document, const St
ring& target, const String& data) |
41 : CharacterData(document, data, CreateOther) | 41 : CharacterData(document, data, CreateOther) |
42 , m_target(target) | 42 , m_target(target) |
43 , m_loading(false) | 43 , m_loading(false) |
| 44 , m_beforeBody(false) |
44 , m_alternate(false) | 45 , m_alternate(false) |
45 , m_isCSS(false) | 46 , m_isCSS(false) |
46 , m_isXSL(false) | 47 , m_isXSL(false) |
47 , m_listenerForXSLT(nullptr) | 48 , m_listenerForXSLT(nullptr) |
48 { | 49 { |
49 } | 50 } |
50 | 51 |
51 ProcessingInstruction* ProcessingInstruction::create(Document& document, const S
tring& target, const String& data) | 52 ProcessingInstruction* ProcessingInstruction::create(Document& document, const S
tring& target, const String& data) |
52 { | 53 { |
53 return new ProcessingInstruction(document, target, data); | 54 return new ProcessingInstruction(document, target, data); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 if (m_isXSL) { | 159 if (m_isXSL) { |
159 if (RuntimeEnabledFeatures::xsltEnabled()) | 160 if (RuntimeEnabledFeatures::xsltEnabled()) |
160 resource = XSLStyleSheetResource::fetch(request, document().fetcher(
)); | 161 resource = XSLStyleSheetResource::fetch(request, document().fetcher(
)); |
161 } else { | 162 } else { |
162 request.setCharset(charset.isEmpty() ? document().characterSet() : chars
et); | 163 request.setCharset(charset.isEmpty() ? document().characterSet() : chars
et); |
163 resource = CSSStyleSheetResource::fetch(request, document().fetcher()); | 164 resource = CSSStyleSheetResource::fetch(request, document().fetcher()); |
164 } | 165 } |
165 | 166 |
166 if (resource) { | 167 if (resource) { |
167 m_loading = true; | 168 m_loading = true; |
168 if (!m_isXSL) | 169 if (!m_isXSL) { |
169 document().styleEngine().addPendingSheet(); | 170 m_beforeBody = m_beforeBody || !document().body(); |
| 171 document().styleEngine().addPendingSheet(m_beforeBody); |
| 172 } |
170 setResource(resource); | 173 setResource(resource); |
171 } | 174 } |
172 } | 175 } |
173 | 176 |
174 bool ProcessingInstruction::isLoading() const | 177 bool ProcessingInstruction::isLoading() const |
175 { | 178 { |
176 if (m_loading) | 179 if (m_loading) |
177 return true; | 180 return true; |
178 if (!m_sheet) | 181 if (!m_sheet) |
179 return false; | 182 return false; |
180 return m_sheet->isLoading(); | 183 return m_sheet->isLoading(); |
181 } | 184 } |
182 | 185 |
183 bool ProcessingInstruction::sheetLoaded() | 186 bool ProcessingInstruction::sheetLoaded() |
184 { | 187 { |
185 if (!isLoading()) { | 188 if (!isLoading()) { |
186 if (!DocumentXSLT::sheetLoaded(document(), this)) | 189 if (!DocumentXSLT::sheetLoaded(document(), this)) |
187 document().styleEngine().removePendingSheet(this); | 190 document().styleEngine().removePendingSheet(this, m_beforeBody); |
188 return true; | 191 return true; |
189 } | 192 } |
190 return false; | 193 return false; |
191 } | 194 } |
192 | 195 |
193 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) | 196 void ProcessingInstruction::setCSSStyleSheet(const String& href, const KURL& bas
eURL, const String& charset, const CSSStyleSheetResource* sheet) |
194 { | 197 { |
195 if (!inShadowIncludingDocument()) { | 198 if (!inShadowIncludingDocument()) { |
196 DCHECK(!m_sheet); | 199 DCHECK(!m_sheet); |
197 return; | 200 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 284 |
282 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. | 285 // If we're in document teardown, then we don't need to do any notification
of our sheet's removal. |
283 if (document().isActive()) | 286 if (document().isActive()) |
284 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); | 287 document().styleEngine().setNeedsActiveStyleUpdate(removedSheet, FullSty
leUpdate); |
285 } | 288 } |
286 | 289 |
287 void ProcessingInstruction::clearSheet() | 290 void ProcessingInstruction::clearSheet() |
288 { | 291 { |
289 DCHECK(m_sheet); | 292 DCHECK(m_sheet); |
290 if (m_sheet->isLoading()) | 293 if (m_sheet->isLoading()) |
291 document().styleEngine().removePendingSheet(this); | 294 document().styleEngine().removePendingSheet(this, m_beforeBody); |
292 m_sheet.release()->clearOwnerNode(); | 295 m_sheet.release()->clearOwnerNode(); |
293 } | 296 } |
294 | 297 |
295 DEFINE_TRACE(ProcessingInstruction) | 298 DEFINE_TRACE(ProcessingInstruction) |
296 { | 299 { |
297 visitor->trace(m_sheet); | 300 visitor->trace(m_sheet); |
298 visitor->trace(m_listenerForXSLT); | 301 visitor->trace(m_listenerForXSLT); |
299 CharacterData::trace(visitor); | 302 CharacterData::trace(visitor); |
300 ResourceOwner<StyleSheetResource>::trace(visitor); | 303 ResourceOwner<StyleSheetResource>::trace(visitor); |
301 } | 304 } |
302 | 305 |
303 } // namespace blink | 306 } // namespace blink |
OLD | NEW |