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

Unified Diff: Source/core/html/HTMLImageElement.cpp

Issue 25105004: Use srcset's resource pixel density to determine intrinsic size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleantests
Patch Set: Fixed crash+rebased 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/html/HTMLImageElement.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLImageElement.cpp
diff --git a/Source/core/html/HTMLImageElement.cpp b/Source/core/html/HTMLImageElement.cpp
index 28d8ae179ee4442b667a65a95cabef5d3f25fb80..6df885516f8751794a38cd8ab4f5d1f2e85ef46f 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -47,6 +47,7 @@ HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
, m_imageLoader(this)
, m_form(form)
, m_compositeOperator(CompositeSourceOver)
+ , m_imageDevicePixelRatio(1.0f)
{
ASSERT(hasTagName(imgTag));
ScriptWrappable::init(this);
@@ -120,8 +121,15 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
if (renderer() && renderer()->isImage())
toRenderImage(renderer())->updateAltText();
} else if (name == srcAttr || name == srcsetAttr) {
- if (RuntimeEnabledFeatures::srcsetEnabled())
- m_bestFitImageURL = bestFitSourceForImageAttributes(document().devicePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
+ if (RuntimeEnabledFeatures::srcsetEnabled()) {
+ ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
+ m_bestFitImageURL = candidate.toString();
+ float candidateScaleFactor = candidate.scaleFactor();
+ if (candidateScaleFactor > 0)
+ m_imageDevicePixelRatio = 1 / candidateScaleFactor;
+ if (renderer() && renderer()->isImage())
+ toRenderImage(renderer())->setImageDevicePixelRatio(m_imageDevicePixelRatio);
+ }
m_imageLoader.updateFromElementIgnoringPreviousError();
}
else if (name == usemapAttr)
@@ -156,6 +164,7 @@ RenderObject* HTMLImageElement::createRenderer(RenderStyle* style)
RenderImage* image = new RenderImage(this);
image->setImageResource(RenderImageResource::create());
+ image->setImageDevicePixelRatio(m_imageDevicePixelRatio);
return image;
}
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/canvas/CanvasRenderingContext2D.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698