Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 1755803002: Ship `referrerpolicy` attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update webexposed layout tests Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 29 matching lines...) Expand all
40 #include "core/html/CrossOriginAttribute.h" 40 #include "core/html/CrossOriginAttribute.h"
41 #include "core/html/HTMLImageElement.h" 41 #include "core/html/HTMLImageElement.h"
42 #include "core/html/HTMLMetaElement.h" 42 #include "core/html/HTMLMetaElement.h"
43 #include "core/html/LinkRelAttribute.h" 43 #include "core/html/LinkRelAttribute.h"
44 #include "core/html/parser/HTMLParserIdioms.h" 44 #include "core/html/parser/HTMLParserIdioms.h"
45 #include "core/html/parser/HTMLSrcsetParser.h" 45 #include "core/html/parser/HTMLSrcsetParser.h"
46 #include "core/html/parser/HTMLTokenizer.h" 46 #include "core/html/parser/HTMLTokenizer.h"
47 #include "core/loader/LinkLoader.h" 47 #include "core/loader/LinkLoader.h"
48 #include "platform/ContentType.h" 48 #include "platform/ContentType.h"
49 #include "platform/MIMETypeRegistry.h" 49 #include "platform/MIMETypeRegistry.h"
50 #include "platform/RuntimeEnabledFeatures.h"
51 #include "platform/TraceEvent.h" 50 #include "platform/TraceEvent.h"
52 #include "wtf/MainThread.h" 51 #include "wtf/MainThread.h"
53 52
54 namespace blink { 53 namespace blink {
55 54
56 using namespace HTMLNames; 55 using namespace HTMLNames;
57 56
58 static bool match(const StringImpl* impl, const QualifiedName& qName) 57 static bool match(const StringImpl* impl, const QualifiedName& qName)
59 { 58 {
60 return impl == qName.localName().impl(); 59 return impl == qName.localName().impl();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (sourceSizeSet) { 201 if (sourceSizeSet) {
203 resourceWidth.width = sourceSize; 202 resourceWidth.width = sourceSize;
204 resourceWidth.isSet = true; 203 resourceWidth.isSet = true;
205 } 204 }
206 205
207 Resource::Type type; 206 Resource::Type type;
208 if (!resourceType(type)) 207 if (!resourceType(type))
209 return nullptr; 208 return nullptr;
210 209
211 // The element's 'referrerpolicy' attribute (if present) takes precedenc e over the document's referrer policy. 210 // The element's 'referrerpolicy' attribute (if present) takes precedenc e over the document's referrer policy.
212 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau lt && RuntimeEnabledFeatures::referrerPolicyAttributeEnabled()) ? m_referrerPoli cy : documentReferrerPolicy; 211 ReferrerPolicy referrerPolicy = (m_referrerPolicy != ReferrerPolicyDefau lt) ? m_referrerPolicy : documentReferrerPolicy;
213 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, type, referrerPolicy, resource Width, clientHintsPreferences, requestType); 212 OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_t agImpl), position, m_urlToLoad, predictedBaseURL, type, referrerPolicy, resource Width, clientHintsPreferences, requestType);
214 request->setCrossOrigin(m_crossOrigin); 213 request->setCrossOrigin(m_crossOrigin);
215 request->setCharset(charset()); 214 request->setCharset(charset());
216 request->setDefer(m_defer); 215 request->setDefer(m_defer);
217 request->setIntegrityMetadata(m_integrityMetadata); 216 request->setIntegrityMetadata(m_integrityMetadata);
218 return request.release(); 217 return request.release();
219 } 218 }
220 219
221 private: 220 private:
222 template<typename NameType> 221 template<typename NameType>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 m_srcsetAttributeValue = attributeValue; 254 m_srcsetAttributeValue = attributeValue;
256 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue); 255 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValu es->devicePixelRatio(), m_sourceSize, attributeValue);
257 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem ent); 256 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePi xelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacem ent);
258 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) { 257 } else if (match(attributeName, sizesAttr) && !m_sourceSizeSet) {
259 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l ength(); 258 m_sourceSize = SizesAttributeParser(m_mediaValues, attributeValue).l ength();
260 m_sourceSizeSet = true; 259 m_sourceSizeSet = true;
261 if (!m_srcsetImageCandidate.isEmpty()) { 260 if (!m_srcsetImageCandidate.isEmpty()) {
262 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue); 261 m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_media Values->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue);
263 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement); 262 setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devi cePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLRepl acement);
264 } 263 }
265 } else if (!m_referrerPolicySet && RuntimeEnabledFeatures::referrerPolic yAttributeEnabled() && match(attributeName, referrerpolicyAttr) && !attributeVal ue.isNull()) { 264 } else if (!m_referrerPolicySet && match(attributeName, referrerpolicyAt tr) && !attributeValue.isNull()) {
266 m_referrerPolicySet = true; 265 m_referrerPolicySet = true;
267 SecurityPolicy::referrerPolicyFromString(attributeValue, &m_referrer Policy); 266 SecurityPolicy::referrerPolicyFromString(attributeValue, &m_referrer Policy);
268 } 267 }
269 } 268 }
270 269
271 template<typename NameType> 270 template<typename NameType>
272 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue) 271 void processLinkAttribute(const NameType& attributeName, const String& attri buteValue)
273 { 272 {
274 // FIXME - Don't set rel/media/crossorigin multiple times. 273 // FIXME - Don't set rel/media/crossorigin multiple times.
275 if (match(attributeName, hrefAttr)) { 274 if (match(attributeName, hrefAttr)) {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 ASSERT(isMainThread()); 690 ASSERT(isMainThread());
692 ASSERT(document); 691 ASSERT(document);
693 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning(); 692 doHtmlPreloadScanning = !document->settings() || document->settings()->doHtm lPreloadScanning();
694 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 693 defaultViewportMinWidth = document->viewportDefaultMinWidth();
695 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk(); 694 viewportMetaZeroValuesQuirk = document->settings() && document->settings()-> viewportMetaZeroValuesQuirk();
696 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled(); 695 viewportMetaEnabled = document->settings() && document->settings()->viewport MetaEnabled();
697 referrerPolicy = ReferrerPolicyDefault; 696 referrerPolicy = ReferrerPolicyDefault;
698 } 697 }
699 698
700 } // namespace blink 699 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLImageElement.idl ('k') | third_party/WebKit/Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698