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

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

Issue 23861003: Enable srcset support in HTMLImageElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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/HTMLImageElement.idl » ('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 bf88109ed9ecad7b640245f02d5216edaa77a176..a9238a28571ddb4e1f7268e09392227f9c259a44 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -32,6 +32,7 @@
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
+#include "core/page/Page.h"
#include "core/rendering/RenderImage.h"
using namespace std;
@@ -107,13 +108,23 @@ void HTMLImageElement::collectStyleForPresentationAttribute(const QualifiedName&
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
+const AtomicString HTMLImageElement::imageSourceURL() const
+{
+ return m_bestFitImageURL.isEmpty() ? fastGetAttribute(srcAttr) : m_bestFitImageURL;
+}
+
void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == altAttr) {
if (renderer() && renderer()->isImage())
toRenderImage(renderer())->updateAltText();
- } else if (name == srcAttr)
+ } else if (name == srcAttr || name == srcsetAttr) {
+ float deviceScaleFactor = 1.0;
+ if (Page* page = document().page())
+ deviceScaleFactor = page->deviceScaleFactor();
johnme 2013/09/04 09:50:22 As discussed on blink-dev, you probably want: flo
+ m_bestFitImageURL = bestFitSourceForImageAttributes(deviceScaleFactor, fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
m_imageLoader.updateFromElementIgnoringPreviousError();
+ }
else if (name == usemapAttr)
setIsLink(!value.isNull());
else if (name == onbeforeloadAttr)
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLImageElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698