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

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

Issue 1186333004: Add support for `width` based Width Client Hint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moar comments Created 5 years, 6 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/HTMLImageElementTest.cpp ('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 d1e7e7976057d1b121a7547560d8f084cc57e31b..9fa599f8fa85bc6c2e28b532639ea76fcb840380 100644
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp
@@ -36,6 +36,7 @@
#include "core/css/parser/SizesAttributeParser.h"
#include "core/dom/Document.h"
#include "core/frame/Settings.h"
+#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLMetaElement.h"
#include "core/html/LinkRelAttribute.h"
#include "core/html/parser/HTMLParserIdioms.h"
@@ -117,6 +118,9 @@ public:
, m_sourceSize(0)
, m_sourceSizeSet(false)
, m_isCORSEnabled(false)
+ , m_widthValue(0)
+ , m_widthValueSet(false)
+ , m_widthPresent(false)
, m_defer(FetchRequest::NoDefer)
, m_allowCredentials(DoNotAllowStoredCredentials)
, m_mediaValues(mediaValues)
@@ -180,7 +184,11 @@ public:
if (m_sourceSizeSet && m_srcsetImageCandidate.resourceWidth() != UninitializedDescriptor) {
resourceWidth.width = m_sourceSize;
resourceWidth.isSet = true;
+ } else {
+ resourceWidth.isSet = m_widthValueSet;
+ resourceWidth.width = m_widthValue;
}
+
OwnPtr<PreloadRequest> request = PreloadRequest::create(initiatorFor(m_tagImpl), position, m_urlToLoad, predictedBaseURL, resourceType(), resourceWidth, clientHintsPreferences, requestType);
if (isCORSEnabled())
request->setCrossOriginEnabled(allowStoredCredentials());
@@ -223,6 +231,9 @@ private:
m_srcsetImageCandidate = bestFitSourceForSrcsetAttribute(m_mediaValues->devicePixelRatio(), m_sourceSize, m_srcsetAttributeValue);
setUrlToLoad(bestFitSourceForImageAttributes(m_mediaValues->devicePixelRatio(), m_sourceSize, m_imgSrcUrl, m_srcsetImageCandidate), AllowURLReplacement);
}
+ } else if (match(attributeName, widthAttr) && !m_widthPresent) {
+ m_widthPresent = true;
+ m_widthValue = HTMLImageElement::widthAttributeToInt(attributeValue, m_widthValueSet);
}
}
@@ -390,6 +401,9 @@ private:
float m_sourceSize;
bool m_sourceSizeSet;
bool m_isCORSEnabled;
+ int m_widthValue;
+ bool m_widthValueSet;
+ bool m_widthPresent;
FetchRequest::DeferOption m_defer;
StoredCredentials m_allowCredentials;
RefPtr<MediaValues> m_mediaValues;
« no previous file with comments | « Source/core/html/HTMLImageElementTest.cpp ('k') | Source/core/html/parser/HTMLPreloadScannerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698