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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 , m_linkIsPreconnect(false) | 116 , m_linkIsPreconnect(false) |
117 , m_linkIsImport(false) | 117 , m_linkIsImport(false) |
118 , m_matchedMediaAttribute(true) | 118 , m_matchedMediaAttribute(true) |
119 , m_inputIsImage(false) | 119 , m_inputIsImage(false) |
120 , m_sourceSize(0) | 120 , m_sourceSize(0) |
121 , m_sourceSizeSet(false) | 121 , m_sourceSizeSet(false) |
122 , m_isCORSEnabled(false) | 122 , m_isCORSEnabled(false) |
123 , m_defer(FetchRequest::NoDefer) | 123 , m_defer(FetchRequest::NoDefer) |
124 , m_allowCredentials(DoNotAllowStoredCredentials) | 124 , m_allowCredentials(DoNotAllowStoredCredentials) |
125 , m_mediaValues(mediaValues) | 125 , m_mediaValues(mediaValues) |
126 , m_referrerPolicy(ReferrerPolicyDefault) | |
126 { | 127 { |
127 ASSERT(m_mediaValues->isCached()); | 128 ASSERT(m_mediaValues->isCached()); |
128 if (match(m_tagImpl, imgTag) | 129 if (match(m_tagImpl, imgTag) |
129 || match(m_tagImpl, sourceTag)) { | 130 || match(m_tagImpl, sourceTag)) { |
130 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).length( ); | 131 m_sourceSize = SizesAttributeParser(m_mediaValues, String()).length( ); |
131 return; | 132 return; |
132 } | 133 } |
133 if ( !match(m_tagImpl, inputTag) | 134 if ( !match(m_tagImpl, inputTag) |
134 && !match(m_tagImpl, linkTag) | 135 && !match(m_tagImpl, linkTag) |
135 && !match(m_tagImpl, scriptTag) | 136 && !match(m_tagImpl, scriptTag) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureDat a.sourceURL.isEmpty()) { | 168 if (match(m_tagImpl, sourceTag) && m_matchedMediaAttribute && pictureDat a.sourceURL.isEmpty()) { |
168 pictureData.sourceURL = m_srcsetImageCandidate.toString(); | 169 pictureData.sourceURL = m_srcsetImageCandidate.toString(); |
169 pictureData.sourceSizeSet = m_sourceSizeSet; | 170 pictureData.sourceSizeSet = m_sourceSizeSet; |
170 pictureData.sourceSize = m_sourceSize; | 171 pictureData.sourceSize = m_sourceSize; |
171 pictureData.picked = true; | 172 pictureData.picked = true; |
172 } else if (match(m_tagImpl, imgTag) && !pictureData.sourceURL.isEmpty()) { | 173 } else if (match(m_tagImpl, imgTag) && !pictureData.sourceURL.isEmpty()) { |
173 setUrlToLoad(pictureData.sourceURL, AllowURLReplacement); | 174 setUrlToLoad(pictureData.sourceURL, AllowURLReplacement); |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer ences, const PictureData& pictureData, const ReferrerPolicy referrerPolicy) | 178 PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL , const SegmentedString& source, const ClientHintsPreferences& clientHintsPrefer ences, const PictureData& pictureData, const ReferrerPolicy documentReferrerPoli cy) |
178 { | 179 { |
179 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre load; | 180 PreloadRequest::RequestType requestType = PreloadRequest::RequestTypePre load; |
180 if (shouldPreconnect()) | 181 if (shouldPreconnect()) |
181 requestType = PreloadRequest::RequestTypePreconnect; | 182 requestType = PreloadRequest::RequestTypePreconnect; |
182 else if (!shouldPreload() || !m_matchedMediaAttribute) | 183 else if (!shouldPreload() || !m_matchedMediaAttribute) |
183 return nullptr; | 184 return nullptr; |
184 | 185 |
185 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); | 186 TextPosition position = TextPosition(source.currentLine(), source.curren tColumn()); |
186 FetchRequest::ResourceWidth resourceWidth; | 187 FetchRequest::ResourceWidth resourceWidth; |
187 float sourceSize = m_sourceSize; | 188 float sourceSize = m_sourceSize; |
188 bool sourceSizeSet = m_sourceSizeSet; | 189 bool sourceSizeSet = m_sourceSizeSet; |
189 if (pictureData.picked) { | 190 if (pictureData.picked) { |
190 sourceSizeSet = pictureData.sourceSizeSet; | 191 sourceSizeSet = pictureData.sourceSizeSet; |
191 sourceSize = pictureData.sourceSize; | 192 sourceSize = pictureData.sourceSize; |
192 } | 193 } |
193 if (sourceSizeSet) { | 194 if (sourceSizeSet) { |
194 resourceWidth.width = sourceSize; | 195 resourceWidth.width = sourceSize; |
195 resourceWidth.isSet = true; | 196 resourceWidth.isSet = true; |
196 } | 197 } |
197 | 198 |
199 // The element's 'referrerpolicy' attribute (if present) takes | |
200 // precedence over the document's referrer policy. | |
201 ReferrerPolicy referrerPolicy = m_referrerPolicy != ReferrerPolicyDefaul t ? m_referrerPolicy : documentReferrerPolicy; | |
198 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy , resourceWidth, clientHintsPreferences, requestType); | 202 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), referrerPolicy , resourceWidth, clientHintsPreferences, requestType); |
199 if (isCORSEnabled()) | 203 if (isCORSEnabled()) |
200 request->setCrossOriginEnabled(allowStoredCredentials()); | 204 request->setCrossOriginEnabled(allowStoredCredentials()); |
201 request->setCharset(charset()); | 205 request->setCharset(charset()); |
202 request->setDefer(m_defer); | 206 request->setDefer(m_defer); |
203 return request.release(); | 207 return request.release(); |
204 } | 208 } |
205 | 209 |
206 private: | 210 private: |
207 template<typename NameType> | 211 template<typename NameType> |
(...skipping 22 matching lines...) Expand all Loading... | |
230 m_srcsetAttributeValue = attributeValue; | 234 m_srcsetAttributeValue = attributeValue; |
231 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue); | 235 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue); |
232 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem ent); | 236 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem ent); |
233 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { | 237 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { |
234 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l ength(); | 238 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l ength(); |
235 m_sourceSizeSet = true; | 239 m_sourceSizeSet = true; |
236 if (!m_srcsetImageCandidate.isEmpty()) { | 240 if (!m_srcsetImageCandidate.isEmpty()) { |
237 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); | 241 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); |
238 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement); | 242 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement); |
239 } | 243 } |
244 } else if (match(attributeName, referrerpolicyAttr) && !attributeValue.i sNull()) { | |
Yoav Weiss
2015/08/19 06:23:04
Sorry for missing it earlier, but we need to prote
estark
2015/08/19 16:17:01
Done.
| |
245 m_referrerPolicy = ReferrerPolicyDefault; | |
Yoav Weiss
2015/08/19 06:23:04
Is there a scenario where initialization at the co
estark
2015/08/19 16:17:01
No, removed.
| |
246 SecurityPolicy::referrerPolicyFromString(attributeValue, &m_referrer Policy); | |
240 } | 247 } |
241 } | 248 } |
242 | 249 |
243 template<typename NameType> | 250 template<typename NameType> |
244 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue) | 251 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue) |
245 { | 252 { |
246 // FIXME - Don't set rel/media/crossorigin multiple times. | 253 // FIXME - Don't set rel/media/crossorigin multiple times. |
247 if (match(attributeName, hrefAttr)) { | 254 if (match(attributeName, hrefAttr)) { |
248 setUrlToLoad(attributeValue, DisallowURLReplacement); | 255 setUrlToLoad(attributeValue, DisallowURLReplacement); |
249 } else if (match(attributeName, relAttr)) { | 256 } else if (match(attributeName, relAttr)) { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 bool m_matchedMediaAttribute; | 411 bool m_matchedMediaAttribute; |
405 bool m_inputIsImage; | 412 bool m_inputIsImage; |
406 String m_imgSrcUrl; | 413 String m_imgSrcUrl; |
407 String m_srcsetAttributeValue; | 414 String m_srcsetAttributeValue; |
408 float m_sourceSize; | 415 float m_sourceSize; |
409 bool m_sourceSizeSet; | 416 bool m_sourceSizeSet; |
410 bool m_isCORSEnabled; | 417 bool m_isCORSEnabled; |
411 FetchRequest::DeferOption m_defer; | 418 FetchRequest::DeferOption m_defer; |
412 StoredCredentials m_allowCredentials; | 419 StoredCredentials m_allowCredentials; |
413 RefPtrWillBeMember<MediaValues> m_mediaValues; | 420 RefPtrWillBeMember<MediaValues> m_mediaValues; |
421 ReferrerPolicy m_referrerPolicy; | |
414 }; | 422 }; |
415 | 423 |
416 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac hedDocumentParameters> documentParameters) | 424 TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassOwnPtr<Cac hedDocumentParameters> documentParameters) |
417 : m_documentURL(documentURL) | 425 : m_documentURL(documentURL) |
418 , m_inStyle(false) | 426 , m_inStyle(false) |
419 , m_inPicture(false) | 427 , m_inPicture(false) |
420 , m_isAppCacheEnabled(false) | 428 , m_isAppCacheEnabled(false) |
421 , m_isCSPEnabled(false) | 429 , m_isCSPEnabled(false) |
422 , m_templateCount(0) | 430 , m_templateCount(0) |
423 , m_documentParameters(documentParameters) | 431 , m_documentParameters(documentParameters) |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 else | 669 else |
662 mediaValues = MediaValuesCached::create(*document); | 670 mediaValues = MediaValuesCached::create(*document); |
663 ASSERT(mediaValues->isSafeToSendToAnotherThread()); | 671 ASSERT(mediaValues->isSafeToSendToAnotherThread()); |
664 defaultViewportMinWidth = document->viewportDefaultMinWidth(); | 672 defaultViewportMinWidth = document->viewportDefaultMinWidth(); |
665 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); | 673 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); |
666 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); | 674 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); |
667 referrerPolicy = ReferrerPolicyDefault; | 675 referrerPolicy = ReferrerPolicyDefault; |
668 } | 676 } |
669 | 677 |
670 } | 678 } |
OLD | NEW |