OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 #include "core/fetch/FetchInitiatorTypeNames.h" | 31 #include "core/fetch/FetchInitiatorTypeNames.h" |
32 #include "core/html/parser/HTMLParserIdioms.h" | 32 #include "core/html/parser/HTMLParserIdioms.h" |
33 #include "platform/text/SegmentedString.h" | 33 #include "platform/text/SegmentedString.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 CSSPreloadScanner::CSSPreloadScanner() | 37 CSSPreloadScanner::CSSPreloadScanner() |
38 : m_state(Initial) | 38 : m_state(Initial) |
39 , m_requests(0) | 39 , m_requests(0) |
| 40 , m_referrerPolicy(ReferrerPolicyDefault) |
40 { | 41 { |
41 } | 42 } |
42 | 43 |
43 CSSPreloadScanner::~CSSPreloadScanner() | 44 CSSPreloadScanner::~CSSPreloadScanner() |
44 { | 45 { |
45 } | 46 } |
46 | 47 |
47 void CSSPreloadScanner::reset() | 48 void CSSPreloadScanner::reset() |
48 { | 49 { |
49 m_state = Initial; | 50 m_state = Initial; |
(...skipping 19 matching lines...) Expand all Loading... |
69 { | 70 { |
70 if (tagName.is8Bit()) { | 71 if (tagName.is8Bit()) { |
71 const LChar* begin = tagName.characters8(); | 72 const LChar* begin = tagName.characters8(); |
72 scanCommon(begin, begin + tagName.length(), source, requests); | 73 scanCommon(begin, begin + tagName.length(), source, requests); |
73 return; | 74 return; |
74 } | 75 } |
75 const UChar* begin = tagName.characters16(); | 76 const UChar* begin = tagName.characters16(); |
76 scanCommon(begin, begin + tagName.length(), source, requests); | 77 scanCommon(begin, begin + tagName.length(), source, requests); |
77 } | 78 } |
78 | 79 |
| 80 void CSSPreloadScanner::setReferrerPolicy(const ReferrerPolicy policy) |
| 81 { |
| 82 m_referrerPolicy = policy; |
| 83 } |
| 84 |
79 inline void CSSPreloadScanner::tokenize(UChar c, const SegmentedString& source) | 85 inline void CSSPreloadScanner::tokenize(UChar c, const SegmentedString& source) |
80 { | 86 { |
81 // We are just interested in @import rules, no need for real tokenization he
re | 87 // We are just interested in @import rules, no need for real tokenization he
re |
82 // Searching for other types of resources is probably low payoff. | 88 // Searching for other types of resources is probably low payoff. |
83 switch (m_state) { | 89 switch (m_state) { |
84 case Initial: | 90 case Initial: |
85 if (isHTMLSpace<UChar>(c)) | 91 if (isHTMLSpace<UChar>(c)) |
86 break; | 92 break; |
87 if (c == '@') | 93 if (c == '@') |
88 m_state = RuleStart; | 94 m_state = RuleStart; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return string.substring(offset, reducedLength); | 214 return string.substring(offset, reducedLength); |
209 } | 215 } |
210 | 216 |
211 void CSSPreloadScanner::emitRule(const SegmentedString& source) | 217 void CSSPreloadScanner::emitRule(const SegmentedString& source) |
212 { | 218 { |
213 if (equalIgnoringCase(m_rule, "import")) { | 219 if (equalIgnoringCase(m_rule, "import")) { |
214 String url = parseCSSStringOrURL(m_ruleValue.toString()); | 220 String url = parseCSSStringOrURL(m_ruleValue.toString()); |
215 if (!url.isEmpty()) { | 221 if (!url.isEmpty()) { |
216 KURL baseElementURL; // FIXME: This should be passed in from the HTM
LPreloadScaner via scan()! | 222 KURL baseElementURL; // FIXME: This should be passed in from the HTM
LPreloadScaner via scan()! |
217 TextPosition position = TextPosition(source.currentLine(), source.cu
rrentColumn()); | 223 TextPosition position = TextPosition(source.currentLine(), source.cu
rrentColumn()); |
218 OwnPtr<PreloadRequest> request = PreloadRequest::create(FetchInitiat
orTypeNames::css, position, url, baseElementURL, Resource::CSSStyleSheet); | 224 OwnPtr<PreloadRequest> request = PreloadRequest::create(FetchInitiat
orTypeNames::css, position, url, baseElementURL, Resource::CSSStyleSheet, m_refe
rrerPolicy); |
219 // FIXME: Should this be including the charset in the preload reques
t? | 225 // FIXME: Should this be including the charset in the preload reques
t? |
220 m_requests->append(request.release()); | 226 m_requests->append(request.release()); |
221 } | 227 } |
222 m_state = Initial; | 228 m_state = Initial; |
223 } else if (equalIgnoringCase(m_rule, "charset")) | 229 } else if (equalIgnoringCase(m_rule, "charset")) |
224 m_state = Initial; | 230 m_state = Initial; |
225 else | 231 else |
226 m_state = DoneParsingImportRules; | 232 m_state = DoneParsingImportRules; |
227 m_rule.clear(); | 233 m_rule.clear(); |
228 m_ruleValue.clear(); | 234 m_ruleValue.clear(); |
229 } | 235 } |
230 | 236 |
231 } | 237 } |
OLD | NEW |