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" |
37 #include "core/fetch/IntegrityMetadata.h" | 38 #include "core/fetch/IntegrityMetadata.h" |
38 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
39 #include "core/frame/Settings.h" | 40 #include "core/frame/Settings.h" |
40 #include "core/frame/SubresourceIntegrity.h" | 41 #include "core/frame/SubresourceIntegrity.h" |
41 #include "core/html/CrossOriginAttribute.h" | 42 #include "core/html/CrossOriginAttribute.h" |
42 #include "core/html/HTMLImageElement.h" | 43 #include "core/html/HTMLImageElement.h" |
43 #include "core/html/HTMLMetaElement.h" | 44 #include "core/html/HTMLMetaElement.h" |
44 #include "core/html/LinkRelAttribute.h" | 45 #include "core/html/LinkRelAttribute.h" |
45 #include "core/html/parser/HTMLParserIdioms.h" | 46 #include "core/html/parser/HTMLParserIdioms.h" |
46 #include "core/html/parser/HTMLSrcsetParser.h" | 47 #include "core/html/parser/HTMLSrcsetParser.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 requestType = PreloadRequest::RequestTypePreconnect; | 215 requestType = PreloadRequest::RequestTypePreconnect; |
215 } else { | 216 } else { |
216 if (isLinkRelPreload()) { | 217 if (isLinkRelPreload()) { |
217 requestType = PreloadRequest::RequestTypeLinkRelPreload; | 218 requestType = PreloadRequest::RequestTypeLinkRelPreload; |
218 } | 219 } |
219 if (!shouldPreload()) { | 220 if (!shouldPreload()) { |
220 return nullptr; | 221 return nullptr; |
221 } | 222 } |
222 } | 223 } |
223 | 224 |
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; |
275 } | 279 } |
276 | 280 |
277 template<typename NameType> | 281 template<typename NameType> |
278 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) | 282 void processImgAttribute(const NameType& attributeName, const String& attrib
uteValue) |
279 { | 283 { |
280 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 284 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
281 m_imgSrcUrl = attributeValue; | 285 m_imgSrcUrl = attributeValue; |
282 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); | 286 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi
xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla
cement); |
283 } else if (match(attributeName, crossoriginAttr)) { | 287 } else if (match(attributeName, crossoriginAttr)) { |
284 setCrossOrigin(attributeValue); | 288 setCrossOrigin(attributeValue); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 bool shouldPreload() const | 437 bool shouldPreload() const |
434 { | 438 { |
435 if (m_urlToLoad.isEmpty()) | 439 if (m_urlToLoad.isEmpty()) |
436 return false; | 440 return false; |
437 if (!m_matched) | 441 if (!m_matched) |
438 return false; | 442 return false; |
439 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) | 443 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport
&& !m_linkIsPreload) |
440 return false; | 444 return false; |
441 if (match(m_tagImpl, inputTag) && !m_inputIsImage) | 445 if (match(m_tagImpl, inputTag) && !m_inputIsImage) |
442 return false; | 446 return false; |
| 447 if (match(m_tagImpl, scriptTag) && !ScriptLoader::isValidScriptTypeAndLa
nguage(m_typeAttributeValue, m_languageAttributeValue, ScriptLoader::AllowLegacy
TypeInTypeAttribute)) |
| 448 return false; |
443 return true; | 449 return true; |
444 } | 450 } |
445 | 451 |
446 void setCrossOrigin(const String& corsSetting) | 452 void setCrossOrigin(const String& corsSetting) |
447 { | 453 { |
448 m_crossOrigin = crossOriginAttributeValue(corsSetting); | 454 m_crossOrigin = crossOriginAttributeValue(corsSetting); |
449 } | 455 } |
450 | 456 |
451 void setDefer(FetchRequest::DeferOption defer) | 457 void setDefer(FetchRequest::DeferOption defer) |
452 { | 458 { |
(...skipping 11 matching lines...) Expand all Loading... |
464 String m_charset; | 470 String m_charset; |
465 bool m_linkIsStyleSheet; | 471 bool m_linkIsStyleSheet; |
466 bool m_linkIsPreconnect; | 472 bool m_linkIsPreconnect; |
467 bool m_linkIsPreload; | 473 bool m_linkIsPreload; |
468 bool m_linkIsImport; | 474 bool m_linkIsImport; |
469 bool m_matched; | 475 bool m_matched; |
470 bool m_inputIsImage; | 476 bool m_inputIsImage; |
471 String m_imgSrcUrl; | 477 String m_imgSrcUrl; |
472 String m_srcsetAttributeValue; | 478 String m_srcsetAttributeValue; |
473 String m_asAttributeValue; | 479 String m_asAttributeValue; |
| 480 String m_typeAttributeValue; |
| 481 String m_languageAttributeValue; |
474 float m_sourceSize; | 482 float m_sourceSize; |
475 bool m_sourceSizeSet; | 483 bool m_sourceSizeSet; |
476 FetchRequest::DeferOption m_defer; | 484 FetchRequest::DeferOption m_defer; |
477 CrossOriginAttributeValue m_crossOrigin; | 485 CrossOriginAttributeValue m_crossOrigin; |
478 Member<MediaValuesCached> m_mediaValues; | 486 Member<MediaValuesCached> m_mediaValues; |
479 bool m_referrerPolicySet; | 487 bool m_referrerPolicySet; |
480 ReferrerPolicy m_referrerPolicy; | 488 ReferrerPolicy m_referrerPolicy; |
481 IntegrityMetadataSet m_integrityMetadata; | 489 IntegrityMetadataSet m_integrityMetadata; |
482 }; | 490 }; |
483 | 491 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 ASSERT(document); | 817 ASSERT(document); |
810 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); | 818 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm
lPreloadScanning(); |
811 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); | 819 doDocumentWritePreloadScanning = doHtmlPreloadScanning && document->frame()
&& document->frame()->isMainFrame(); |
812 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 820 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
813 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); | 821 viewportMetaZeroValuesQuirk = document->settings() && document->settings()->
viewportMetaZeroValuesQuirk(); |
814 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); | 822 viewportMetaEnabled = document->settings() && document->settings()->viewport
MetaEnabled(); |
815 referrerPolicy = document->getReferrerPolicy(); | 823 referrerPolicy = document->getReferrerPolicy(); |
816 } | 824 } |
817 | 825 |
818 } // namespace blink | 826 } // namespace blink |
OLD | NEW |