OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 | 103 |
104 class TokenPreloadScanner::StartTagScanner { | 104 class TokenPreloadScanner::StartTagScanner { |
105 public: | 105 public: |
106 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es) | 106 StartTagScanner(const StringImpl* tagImpl, PassRefPtr<MediaValues> mediaValu es) |
107 : m_tagImpl(tagImpl) | 107 : m_tagImpl(tagImpl) |
108 , m_linkIsStyleSheet(false) | 108 , m_linkIsStyleSheet(false) |
109 , m_matchedMediaAttribute(true) | 109 , m_matchedMediaAttribute(true) |
110 , m_inputIsImage(false) | 110 , m_inputIsImage(false) |
111 , m_sourceSize(0) | 111 , m_sourceSize(0) |
112 , m_sourceSizeSet(false) | 112 , m_sourceSizeSet(false) |
113 , m_execAsync(false) | |
113 , m_isCORSEnabled(false) | 114 , m_isCORSEnabled(false) |
114 , m_allowCredentials(DoNotAllowStoredCredentials) | 115 , m_allowCredentials(DoNotAllowStoredCredentials) |
115 , m_mediaValues(mediaValues) | 116 , m_mediaValues(mediaValues) |
116 { | 117 { |
117 if (match(m_tagImpl, imgTag) | 118 if (match(m_tagImpl, imgTag) |
118 || match(m_tagImpl, sourceTag)) { | 119 || match(m_tagImpl, sourceTag)) { |
119 if (RuntimeEnabledFeatures::pictureSizesEnabled()) | 120 if (RuntimeEnabledFeatures::pictureSizesEnabled()) |
120 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).len gth(); | 121 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).len gth(); |
121 return; | 122 return; |
122 } | 123 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 { | 164 { |
164 if (!shouldPreload() || !m_matchedMediaAttribute) | 165 if (!shouldPreload() || !m_matchedMediaAttribute) |
165 return nullptr; | 166 return nullptr; |
166 | 167 |
167 TRACE_EVENT_INSTANT1("net", "PreloadRequest", "url", m_urlToLoad.ascii() ); | 168 TRACE_EVENT_INSTANT1("net", "PreloadRequest", "url", m_urlToLoad.ascii() ); |
168 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); | 169 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); |
169 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType()); | 170 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType()); |
170 if (isCORSEnabled()) | 171 if (isCORSEnabled()) |
171 request->setCrossOriginEnabled(allowStoredCredentials()); | 172 request->setCrossOriginEnabled(allowStoredCredentials()); |
172 request->setCharset(charset()); | 173 request->setCharset(charset()); |
174 request->setExecAsync(m_execAsync); | |
173 return request.release(); | 175 return request.release(); |
174 } | 176 } |
175 | 177 |
176 private: | 178 private: |
177 template<typename NameType> | 179 template<typename NameType> |
178 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) | 180 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) |
179 { | 181 { |
180 // FIXME - Don't set crossorigin multiple times. | 182 // FIXME - Don't set crossorigin multiple times. |
181 if (match(attributeName, srcAttr)) | 183 if (match(attributeName, srcAttr)) |
182 setUrlToLoad(attributeValue, DisallowURLReplacement); | 184 setUrlToLoad(attributeValue, DisallowURLReplacement); |
183 else if (match(attributeName, crossoriginAttr)) | 185 else if (match(attributeName, crossoriginAttr)) |
184 setCrossOriginAllowed(attributeValue); | 186 setCrossOriginAllowed(attributeValue); |
187 else if (match(attributeName, asyncAttr)) | |
188 setExecAsync(true); | |
189 else if (match(attributeName, deferAttr)) | |
190 setExecAsync(true); | |
185 } | 191 } |
186 | 192 |
187 template<typename NameType> | 193 template<typename NameType> |
188 void processImgAttribute(const NameType& attributeName, const String& attrib uteValue) | 194 void processImgAttribute(const NameType& attributeName, const String& attrib uteValue) |
189 { | 195 { |
190 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 196 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
191 m_imgSrcUrl = attributeValue; | 197 m_imgSrcUrl = attributeValue; |
192 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla cement); | 198 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla cement); |
193 } else if (match(attributeName, crossoriginAttr)) { | 199 } else if (match(attributeName, crossoriginAttr)) { |
194 setCrossOriginAllowed(attributeValue); | 200 setCrossOriginAllowed(attributeValue); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 | 336 |
331 void setCrossOriginAllowed(const String& corsSetting) | 337 void setCrossOriginAllowed(const String& corsSetting) |
332 { | 338 { |
333 m_isCORSEnabled = true; | 339 m_isCORSEnabled = true; |
334 if (!corsSetting.isNull() && equalIgnoringCase(stripLeadingAndTrailingHT MLSpaces(corsSetting), "use-credentials")) | 340 if (!corsSetting.isNull() && equalIgnoringCase(stripLeadingAndTrailingHT MLSpaces(corsSetting), "use-credentials")) |
335 m_allowCredentials = AllowStoredCredentials; | 341 m_allowCredentials = AllowStoredCredentials; |
336 else | 342 else |
337 m_allowCredentials = DoNotAllowStoredCredentials; | 343 m_allowCredentials = DoNotAllowStoredCredentials; |
338 } | 344 } |
339 | 345 |
346 void setExecAsync(const bool execAsync) | |
eseidel
2014/09/03 15:15:38
const bool?
Pat Meenan
2014/09/03 16:16:17
Doh, sorry - fixed.
| |
347 { | |
348 m_execAsync = execAsync; | |
349 } | |
350 | |
351 bool execAsync() const | |
352 { | |
353 return m_execAsync; | |
354 } | |
355 | |
340 const StringImpl* m_tagImpl; | 356 const StringImpl* m_tagImpl; |
341 String m_urlToLoad; | 357 String m_urlToLoad; |
342 ImageCandidate m_srcsetImageCandidate; | 358 ImageCandidate m_srcsetImageCandidate; |
343 String m_charset; | 359 String m_charset; |
344 bool m_linkIsStyleSheet; | 360 bool m_linkIsStyleSheet; |
345 bool m_matchedMediaAttribute; | 361 bool m_matchedMediaAttribute; |
346 bool m_inputIsImage; | 362 bool m_inputIsImage; |
347 String m_imgSrcUrl; | 363 String m_imgSrcUrl; |
348 String m_srcsetAttributeValue; | 364 String m_srcsetAttributeValue; |
349 unsigned m_sourceSize; | 365 unsigned m_sourceSize; |
350 bool m_sourceSizeSet; | 366 bool m_sourceSizeSet; |
351 bool m_isCORSEnabled; | 367 bool m_isCORSEnabled; |
368 bool m_execAsync; | |
352 StoredCredentials m_allowCredentials; | 369 StoredCredentials m_allowCredentials; |
353 RefPtr<MediaValues> m_mediaValues; | 370 RefPtr<MediaValues> m_mediaValues; |
354 }; | 371 }; |
355 | 372 |
356 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med iaValues> mediaValues) | 373 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med iaValues> mediaValues) |
357 : m_documentURL(documentURL) | 374 : m_documentURL(documentURL) |
358 , m_inStyle(false) | 375 , m_inStyle(false) |
359 , m_inPicture(false) | 376 , m_inPicture(false) |
360 , m_templateCount(0) | 377 , m_templateCount(0) |
361 , m_mediaValues(mediaValues) | 378 , m_mediaValues(mediaValues) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 if (m_token.type() == HTMLToken::StartTag) | 517 if (m_token.type() == HTMLToken::StartTag) |
501 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit)); | 518 m_tokenizer->updateStateFor(attemptStaticStringCreation(m_token.name (), Likely8Bit)); |
502 m_scanner.scan(m_token, m_source, requests); | 519 m_scanner.scan(m_token, m_source, requests); |
503 m_token.clear(); | 520 m_token.clear(); |
504 } | 521 } |
505 | 522 |
506 preloader->takeAndPreload(requests); | 523 preloader->takeAndPreload(requests); |
507 } | 524 } |
508 | 525 |
509 } | 526 } |
OLD | NEW |