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

Unified Diff: Source/core/html/parser/HTMLPreloadScanner.cpp

Issue 1121263002: Add Accept-CH meta http-equiv support to the preloader. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review nits Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.h ('k') | Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLPreloadScanner.cpp
diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp
index 999a380ce8d899fc172e46b34e7027c1f284c8d9..b15a9f7b9bbead7ddc91f4641b48e30ff3980563 100644
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -166,7 +166,7 @@ public:
setUrlToLoad(sourceURL, AllowURLReplacement);
}
- PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL, const SegmentedString& source)
+ PassOwnPtr<PreloadRequest> createPreloadRequest(const KURL& predictedBaseURL, const SegmentedString& source, const ClientHintsPreferences& clientHintsPreferences)
{
if (!shouldPreload() || !m_matchedMediaAttribute)
return nullptr;
@@ -177,7 +177,7 @@ public:
resourceWidth.width = m_sourceSize;
resourceWidth.isSet = true;
}
- OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth);
+ OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth, clientHintsPreferences);
if (isCORSEnabled())
request->setCrossOriginEnabled(allowStoredCredentials());
request->setCharset(charset());
@@ -436,6 +436,17 @@ void TokenPreloadScanner::scan(const CompactHTMLToken& token, const SegmentedStr
scanCommon(token, source, requests);
}
+static void handleMetaViewport(const String& attributeValue, CachedDocumentParameters* documentParameters)
+{
+ ViewportDescription description(ViewportDescription::ViewportMeta);
+ HTMLMetaElement::getViewportDescriptionFromContentAttribute(attributeValue, description, nullptr, documentParameters->viewportMetaZeroValuesQuirk);
+ FloatSize initialViewport(documentParameters->mediaValues->viewportHeight(), documentParameters->mediaValues->viewportWidth());
+ PageScaleConstraints constraints = description.resolve(initialViewport, documentParameters->defaultViewportMinWidth);
+ MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(documentParameters->mediaValues.get());
+ cachedMediaValues->setViewportHeight(constraints.layoutSize.height());
+ cachedMediaValues->setViewportWidth(constraints.layoutSize.width());
+}
+
template<typename Token>
void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& source, PreloadRequestStream& requests)
{
@@ -496,23 +507,20 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
}
if (match(tagImpl, metaTag)) {
const typename Token::Attribute* equivAttribute = token.getAttributeItem(http_equivAttr);
- if (equivAttribute && equalIgnoringCase(String(equivAttribute->value), "content-security-policy")) {
- m_isCSPEnabled = true;
+ if (equivAttribute) {
+ String equivAttributeValue(equivAttribute->value);
+ if (equalIgnoringCase(equivAttributeValue, "content-security-policy"))
+ m_isCSPEnabled = true;
+ else if (equalIgnoringCase(equivAttributeValue, "accept-ch"))
+ handleAcceptClientHintsHeader(equivAttributeValue, m_clientHintsPreferences);
return;
}
const typename Token::Attribute* nameAttribute = token.getAttributeItem(nameAttr);
if (nameAttribute && equalIgnoringCase(String(nameAttribute->value), "viewport")) {
const typename Token::Attribute* contentAttribute = token.getAttributeItem(contentAttr);
-
- if (contentAttribute) {
- ViewportDescription description(ViewportDescription::ViewportMeta);
- HTMLMetaElement::getViewportDescriptionFromContentAttribute(String(contentAttribute->value), description, nullptr, m_documentParameters->viewportMetaZeroValuesQuirk);
- FloatSize initialViewport(m_documentParameters->mediaValues->viewportHeight(), m_documentParameters->mediaValues->viewportWidth());
- PageScaleConstraints constraints = description.resolve(initialViewport, m_documentParameters->defaultViewportMinWidth);
- MediaValuesCached* cachedMediaValues = static_cast<MediaValuesCached*>(m_documentParameters->mediaValues.get());
- cachedMediaValues->setViewportHeight(constraints.layoutSize.height());
- cachedMediaValues->setViewportWidth(constraints.layoutSize.width());
- }
+ if (contentAttribute)
+ handleMetaViewport(String(contentAttribute->value), m_documentParameters.get());
+ return;
}
}
@@ -526,7 +534,7 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString&
scanner.processAttributes(token.attributes());
if (m_inPicture)
scanner.handlePictureSourceURL(m_pictureSourceURL);
- OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predictedBaseElementURL, source);
+ OwnPtr<PreloadRequest> request = scanner.createPreloadRequest(m_predictedBaseElementURL, source, m_clientHintsPreferences);
if (request)
requests.append(request.release());
return;
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.h ('k') | Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698