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

Unified Diff: Source/core/fetch/ImageResource.cpp

Issue 46313002: Support the DPR header for client hints. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: with cache tests Created 7 years, 2 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/fetch/ImageResource.h ('k') | Source/core/rendering/RenderImage.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ImageResource.cpp
diff --git a/Source/core/fetch/ImageResource.cpp b/Source/core/fetch/ImageResource.cpp
index cf30c06908a9227131fe9947f4ce56341849675f..4827b2eb63154470a9c9b962c30b829709ea0a9d 100644
--- a/Source/core/fetch/ImageResource.cpp
+++ b/Source/core/fetch/ImageResource.cpp
@@ -24,6 +24,7 @@
#include "config.h"
#include "core/fetch/ImageResource.h"
+#include "RuntimeEnabledFeatures.h"
#include "core/fetch/ImageResourceClient.h"
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceClient.h"
@@ -44,8 +45,10 @@ namespace WebCore {
ImageResource::ImageResource(const ResourceRequest& resourceRequest)
: Resource(resourceRequest, Image)
+ , m_devicePixelRatioHeaderValue(1.0)
, m_image(0)
, m_loadingMultipartContent(false)
+ , m_hasDevicePixelRatioHeaderValue(false)
{
setStatus(Unknown);
setCustomAcceptHeader();
@@ -377,6 +380,13 @@ void ImageResource::responseReceived(const ResourceResponse& response)
finishOnePart();
else if (response.isMultipart())
m_loadingMultipartContent = true;
+ if (RuntimeEnabledFeatures::clientHintsDprEnabled()) {
+ m_devicePixelRatioHeaderValue = response.httpHeaderField("DPR").toFloat(&m_hasDevicePixelRatioHeaderValue);
+ if (!m_hasDevicePixelRatioHeaderValue || m_devicePixelRatioHeaderValue <= 0.0) {
+ m_devicePixelRatioHeaderValue = 1.0;
+ m_hasDevicePixelRatioHeaderValue = false;
+ }
+ }
Resource::responseReceived(response);
}
« no previous file with comments | « Source/core/fetch/ImageResource.h ('k') | Source/core/rendering/RenderImage.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698