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/fetch/IntegrityMetadata.h" | |
37 #include "core/frame/Settings.h" | 38 #include "core/frame/Settings.h" |
39 #include "core/frame/SubresourceIntegrity.h" | |
38 #include "core/html/CrossOriginAttribute.h" | 40 #include "core/html/CrossOriginAttribute.h" |
39 #include "core/html/HTMLImageElement.h" | 41 #include "core/html/HTMLImageElement.h" |
40 #include "core/html/HTMLMetaElement.h" | 42 #include "core/html/HTMLMetaElement.h" |
41 #include "core/html/LinkRelAttribute.h" | 43 #include "core/html/LinkRelAttribute.h" |
42 #include "core/html/parser/HTMLParserIdioms.h" | 44 #include "core/html/parser/HTMLParserIdioms.h" |
43 #include "core/html/parser/HTMLSrcsetParser.h" | 45 #include "core/html/parser/HTMLSrcsetParser.h" |
44 #include "core/html/parser/HTMLTokenizer.h" | 46 #include "core/html/parser/HTMLTokenizer.h" |
45 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
46 #include "platform/TraceEvent.h" | 48 #include "platform/TraceEvent.h" |
47 #include "wtf/MainThread.h" | 49 #include "wtf/MainThread.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 resourceWidth.width = sourceSize; | 197 resourceWidth.width = sourceSize; |
196 resourceWidth.isSet = true; | 198 resourceWidth.isSet = true; |
197 } | 199 } |
198 | 200 |
199 // The element's 'referrerpolicy' attribute (if present) takes precedenc e over the document's referrer policy. | 201 // The element's 'referrerpolicy' attribute (if present) takes precedenc e over the document's referrer policy. |
200 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau lt && RuntimeEnabledFeatures::referrerPolicyAttributeEnabled()) ? m_referrerPoli cy : documentReferrerPolicy; | 202 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau lt && RuntimeEnabledFeatures::referrerPolicyAttributeEnabled()) ? m_referrerPoli cy : documentReferrerPolicy; |
201 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy , resourceWidth, clientHintsPreferences, requestType); | 203 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy , resourceWidth, clientHintsPreferences, requestType); |
202 request->setCrossOrigin(m_crossOrigin); | 204 request->setCrossOrigin(m_crossOrigin); |
203 request->setCharset(charset()); | 205 request->setCharset(charset()); |
204 request->setDefer(m_defer); | 206 request->setDefer(m_defer); |
207 request->setIntegrityMetadata(m_integrityMetadata); | |
205 return request.release(); | 208 return request.release(); |
206 } | 209 } |
207 | 210 |
208 private: | 211 private: |
209 template<typename NameType> | 212 template<typename NameType> |
210 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) | 213 void processScriptAttribute(const NameType& attributeName, const String& att ributeValue) |
211 { | 214 { |
212 // FIXME - Don't set crossorigin multiple times. | 215 // FIXME - Don't set crossorigin multiple times. |
213 if (match(attributeName, srcAttr)) | 216 if (match(attributeName, srcAttr)) |
214 setUrlToLoad(attributeValue, DisallowURLReplacement); | 217 setUrlToLoad(attributeValue, DisallowURLReplacement); |
215 else if (match(attributeName, crossoriginAttr)) | 218 else if (match(attributeName, crossoriginAttr)) |
216 setCrossOrigin(attributeValue); | 219 setCrossOrigin(attributeValue); |
217 else if (match(attributeName, asyncAttr)) | 220 else if (match(attributeName, asyncAttr)) |
218 setDefer(FetchRequest::LazyLoad); | 221 setDefer(FetchRequest::LazyLoad); |
219 else if (match(attributeName, deferAttr)) | 222 else if (match(attributeName, deferAttr)) |
220 setDefer(FetchRequest::LazyLoad); | 223 setDefer(FetchRequest::LazyLoad); |
224 else if (match(attributeName, integrityAttr)) | |
225 SubresourceIntegrity::parseIntegrityAttribute(attributeValue, m_inte grityMetadata); | |
221 } | 226 } |
222 | 227 |
223 template<typename NameType> | 228 template<typename NameType> |
224 void processImgAttribute(const NameType& attributeName, const String& attrib uteValue) | 229 void processImgAttribute(const NameType& attributeName, const String& attrib uteValue) |
225 { | 230 { |
226 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { | 231 if (match(attributeName, srcAttr) && m_imgSrcUrl.isNull()) { |
227 m_imgSrcUrl = attributeValue; | 232 m_imgSrcUrl = attributeValue; |
228 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla cement); | 233 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, attributeValue, m_srcsetImageCandidate), AllowURLRepla cement); |
229 } else if (match(attributeName, crossoriginAttr)) { | 234 } else if (match(attributeName, crossoriginAttr)) { |
230 setCrossOrigin(attributeValue); | 235 setCrossOrigin(attributeValue); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 return true; | 375 return true; |
371 } | 376 } |
372 void setCrossOrigin(const String& corsSetting) | 377 void setCrossOrigin(const String& corsSetting) |
373 { | 378 { |
374 m_crossOrigin = crossOriginAttributeValue(corsSetting); | 379 m_crossOrigin = crossOriginAttributeValue(corsSetting); |
375 } | 380 } |
376 | 381 |
377 void setDefer(FetchRequest::DeferOption defer) | 382 void setDefer(FetchRequest::DeferOption defer) |
378 { | 383 { |
379 m_defer = defer; | 384 m_defer = defer; |
385 | |
sof
2016/01/06 07:38:13
accidental edit?
jww
2016/01/06 18:37:53
Done.
| |
380 } | 386 } |
381 | 387 |
382 bool defer() const | 388 bool defer() const |
383 { | 389 { |
384 return m_defer; | 390 return m_defer; |
385 } | 391 } |
386 | 392 |
387 const StringImpl* m_tagImpl; | 393 const StringImpl* m_tagImpl; |
388 String m_urlToLoad; | 394 String m_urlToLoad; |
389 ImageCandidate m_srcsetImageCandidate; | 395 ImageCandidate m_srcsetImageCandidate; |
390 String m_charset; | 396 String m_charset; |
391 bool m_linkIsStyleSheet; | 397 bool m_linkIsStyleSheet; |
392 bool m_linkIsPreconnect; | 398 bool m_linkIsPreconnect; |
393 bool m_linkIsImport; | 399 bool m_linkIsImport; |
394 bool m_matchedMediaAttribute; | 400 bool m_matchedMediaAttribute; |
395 bool m_inputIsImage; | 401 bool m_inputIsImage; |
396 String m_imgSrcUrl; | 402 String m_imgSrcUrl; |
397 String m_srcsetAttributeValue; | 403 String m_srcsetAttributeValue; |
398 float m_sourceSize; | 404 float m_sourceSize; |
399 bool m_sourceSizeSet; | 405 bool m_sourceSizeSet; |
400 FetchRequest::DeferOption m_defer; | 406 FetchRequest::DeferOption m_defer; |
401 CrossOriginAttributeValue m_crossOrigin; | 407 CrossOriginAttributeValue m_crossOrigin; |
402 RefPtrWillBeMember<MediaValues> m_mediaValues; | 408 RefPtrWillBeMember<MediaValues> m_mediaValues; |
403 bool m_referrerPolicySet; | 409 bool m_referrerPolicySet; |
404 ReferrerPolicy m_referrerPolicy; | 410 ReferrerPolicy m_referrerPolicy; |
411 IntegrityMetadataSet m_integrityMetadata; | |
405 }; | 412 }; |
406 | 413 |
407 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac hedDocumentParameters> documentParameters) | 414 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac hedDocumentParameters> documentParameters) |
408 : m_documentURL(documentURL) | 415 : m_documentURL(documentURL) |
409 , m_inStyle(false) | 416 , m_inStyle(false) |
410 , m_inPicture(false) | 417 , m_inPicture(false) |
411 , m_isAppCacheEnabled(false) | 418 , m_isAppCacheEnabled(false) |
412 , m_isCSPEnabled(false) | 419 , m_isCSPEnabled(false) |
413 , m_templateCount(0) | 420 , m_templateCount(0) |
414 , m_documentParameters(documentParameters) | 421 , m_documentParameters(documentParameters) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 else | 659 else |
653 mediaValues = MediaValuesCached::create(*document); | 660 mediaValues = MediaValuesCached::create(*document); |
654 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 661 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
655 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 662 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
656 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); | 663 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); |
657 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); | 664 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); |
658 referrerPolicy = ReferrerPolicyDefault; | 665 referrerPolicy = ReferrerPolicyDefault; |
659 } | 666 } |
660 | 667 |
661 } | 668 } |
OLD | NEW |