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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "core/html/parser/HTMLPreloadScanner.h" | 28 #include "core/html/parser/HTMLPreloadScanner.h" |
29 | 29 |
30 #include "core/HTMLNames.h" | 30 #include "core/HTMLNames.h" |
31 #include "core/InputTypeNames.h" | 31 #include "core/InputTypeNames.h" |
32 #include "core/css/MediaList.h" | 32 #include "core/css/MediaList.h" |
33 #include "core/css/MediaQueryEvaluator.h" | 33 #include "core/css/MediaQueryEvaluator.h" |
34 #include "core/css/MediaValuesCached.h" | 34 #include "core/css/MediaValuesCached.h" |
35 #include "core/css/parser/SizesAttributeParser.h" | 35 #include "core/css/parser/SizesAttributeParser.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/ScriptLoader.h" | |
38 #include "core/fetch/IntegrityMetadata.h" | 37 #include "core/fetch/IntegrityMetadata.h" |
39 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
40 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
41 #include "core/frame/SubresourceIntegrity.h" | 40 #include "core/frame/SubresourceIntegrity.h" |
42 #include "core/html/CrossOriginAttribute.h" | 41 #include "core/html/CrossOriginAttribute.h" |
43 #include "core/html/HTMLImageElement.h" | 42 #include "core/html/HTMLImageElement.h" |
44 #include "core/html/HTMLMetaElement.h" | 43 #include "core/html/HTMLMetaElement.h" |
45 #include "core/html/LinkRelAttribute.h" | 44 #include "core/html/LinkRelAttribute.h" |
46 #include "core/html/parser/HTMLParserIdioms.h" | 45 #include "core/html/parser/HTMLParserIdioms.h" |
47 #include "core/html/parser/HTMLSrcsetParser.h" | 46 #include "core/html/parser/HTMLSrcsetParser.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 requestType = PreloadRequest::RequestTypePreconnect; | 214 requestType = PreloadRequest::RequestTypePreconnect; |
216 } else { | 215 } else { |
217 if (isLinkRelPreload()) { | 216 if (isLinkRelPreload()) { |
218 requestType = PreloadRequest::RequestTypeLinkRelPreload; | 217 requestType = PreloadRequest::RequestTypeLinkRelPreload; |
219 } | 218 } |
220 if (!shouldPreload()) { | 219 if (!shouldPreload()) { |
221 return nullptr; | 220 return nullptr; |
222 } | 221 } |
223 } | 222 } |
224 | 223 |
| 224 |
225 TextPosition position = TextPosition(source.currentLine(), source.curren
tColumn()); | 225 TextPosition position = TextPosition(source.currentLine(), source.curren
tColumn()); |
226 FetchRequest::ResourceWidth resourceWidth; | 226 FetchRequest::ResourceWidth resourceWidth; |
227 float sourceSize = m_sourceSize; | 227 float sourceSize = m_sourceSize; |
228 bool sourceSizeSet = m_sourceSizeSet; | 228 bool sourceSizeSet = m_sourceSizeSet; |
229 if (pictureData.picked) { | 229 if (pictureData.picked) { |
230 sourceSizeSet = pictureData.sourceSizeSet; | 230 sourceSizeSet = pictureData.sourceSizeSet; |
231 sourceSize = pictureData.sourceSize; | 231 sourceSize = pictureData.sourceSize; |
232 } | 232 } |
233 if (sourceSizeSet) { | 233 if (sourceSizeSet) { |
234 resourceWidth.width = sourceSize; | 234 resourceWidth.width = sourceSize; |
(...skipping 30 matching lines...) Expand all Loading... |
265 // Note that only scripts need to have the integrity metadata set on | 265 // Note that only scripts need to have the integrity metadata set on |
266 // preloads. This is because script resources fetches, and only script | 266 // preloads. This is because script resources fetches, and only script |
267 // resource fetches, need to re-request resources if a cached version | 267 // resource fetches, need to re-request resources if a cached version |
268 // has different metadata (including empty) from the metadata on the | 268 // has different metadata (including empty) from the metadata on the |
269 // request. See the comment before the call to | 269 // request. See the comment before the call to |
270 // mustRefetchDueToIntegrityMismatch() in | 270 // mustRefetchDueToIntegrityMismatch() in |
271 // Source/core/fetch/ResourceFetcher.cpp for a more complete | 271 // Source/core/fetch/ResourceFetcher.cpp for a more complete |
272 // explanation. | 272 // explanation. |
273 else if (match(attributeName, integrityAttr)) | 273 else if (match(attributeName, integrityAttr)) |
274 SubresourceIntegrity::parseIntegrityAttribute(attributeValue, m_inte
grityMetadata); | 274 SubresourceIntegrity::parseIntegrityAttribute(attributeValue, m_inte
grityMetadata); |
275 else if (match(attributeName, typeAttr)) | |
276 m_typeAttributeValue = attributeValue; | |
277 else if (match(attributeName, languageAttr)) | |
278 m_languageAttributeValue = attributeValue; | |
279 } | 275 } |
280 | 276 |
281 template<typename NameType> | 277 template<typename NameType> |
282 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) | 278 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) |
283 { | 279 { |
284 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 280 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
285 m_imgSrcUrl = attributeValue; | 281 m_imgSrcUrl = attributeValue; |
286 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); | 282 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); |
287 } else if (match(attributeName, crossoriginAttr)) { | 283 } else if (match(attributeName, crossoriginAttr)) { |
288 setCrossOrigin(attributeValue); | 284 setCrossOrigin(attributeValue); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 bool shouldPreload() const | 433 bool shouldPreload() const |
438 { | 434 { |
439 if (m_urlToLoad.isEmpty()) | 435 if (m_urlToLoad.isEmpty()) |
440 return false; | 436 return false; |
441 if (!m_matched) | 437 if (!m_matched) |
442 return false; | 438 return false; |
443 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) | 439 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) |
444 return false; | 440 return false; |
445 if (match(m_tagImpl, inputTag) && !m_inputIsImage) | 441 if (match(m_tagImpl, inputTag) && !m_inputIsImage) |
446 return false; | 442 return false; |
447 if (match(m_tagImpl, scriptTag) && !ScriptLoader::isValidScriptTypeAndLa
nguage(m_typeAttributeValue, m_languageAttributeValue, ScriptLoader::AllowLegacy
TypeInTypeAttribute)) | |
448 return false; | |
449 return true; | 443 return true; |
450 } | 444 } |
451 | 445 |
452 void setCrossOrigin(const String& corsSetting) | 446 void setCrossOrigin(const String& corsSetting) |
453 { | 447 { |
454 m_crossOrigin = crossOriginAttributeValue(corsSetting); | 448 m_crossOrigin = crossOriginAttributeValue(corsSetting); |
455 } | 449 } |
456 | 450 |
457 void setDefer(FetchRequest::DeferOption defer) | 451 void setDefer(FetchRequest::DeferOption defer) |
458 { | 452 { |
(...skipping 11 matching lines...) Expand all Loading... |
470 String m_charset; | 464 String m_charset; |
471 bool m_linkIsStyleSheet; | 465 bool m_linkIsStyleSheet; |
472 bool m_linkIsPreconnect; | 466 bool m_linkIsPreconnect; |
473 bool m_linkIsPreload; | 467 bool m_linkIsPreload; |
474 bool m_linkIsImport; | 468 bool m_linkIsImport; |
475 bool m_matched; | 469 bool m_matched; |
476 bool m_inputIsImage; | 470 bool m_inputIsImage; |
477 String m_imgSrcUrl; | 471 String m_imgSrcUrl; |
478 String m_srcsetAttributeValue; | 472 String m_srcsetAttributeValue; |
479 String m_asAttributeValue; | 473 String m_asAttributeValue; |
480 String m_typeAttributeValue; | |
481 String m_languageAttributeValue; | |
482 float m_sourceSize; | 474 float m_sourceSize; |
483 bool m_sourceSizeSet; | 475 bool m_sourceSizeSet; |
484 FetchRequest::DeferOption m_defer; | 476 FetchRequest::DeferOption m_defer; |
485 CrossOriginAttributeValue m_crossOrigin; | 477 CrossOriginAttributeValue m_crossOrigin; |
486 Member<MediaValuesCached> m_mediaValues; | 478 Member<MediaValuesCached> m_mediaValues; |
487 bool m_referrerPolicySet; | 479 bool m_referrerPolicySet; |
488 ReferrerPolicy m_referrerPolicy; | 480 ReferrerPolicy m_referrerPolicy; |
489 IntegrityMetadataSet m_integrityMetadata; | 481 IntegrityMetadataSet m_integrityMetadata; |
490 }; | 482 }; |
491 | 483 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 ASSERT(document); | 809 ASSERT(document); |
818 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); | 810 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); |
819 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); | 811 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); |
820 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 812 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
821 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 813 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
822 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 814 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
823 referrerPolicy = document->getReferrerPolicy(); | 815 referrerPolicy = document->getReferrerPolicy(); |
824 } | 816 } |
825 | 817 |
826 } // namespace blink | 818 } // namespace blink |
OLD | NEW |