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

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: Fixed a flaky test 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 30c86681dd7a5c4561fa6e1be5360d6ddb0eec71..a386da6fbe276f9941034c21ab9b9622c116a390 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -25,6 +25,7 @@
#include "CSSPropertyNames.h"
#include "HTMLNames.h"
+#include "RuntimeEnabledFeatures.h"
#include "bindings/v8/ScriptEventListener.h"
#include "core/dom/Attribute.h"
#include "core/dom/EventNames.h"
@@ -32,6 +33,7 @@
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
+#include "core/html/parser/HTMLSrcsetParser.h"
#include "core/rendering/RenderImage.h"
using namespace std;
@@ -107,13 +109,21 @@ void HTMLImageElement::collectStyleForPresentationAttribute(const QualifiedName&
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
+const AtomicString HTMLImageElement::imageSourceURL() const
+{
+ return m_bestFitImageURL.isNull() ? 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) {
+ if (RuntimeEnabledFeatures::srcsetEnabled())
+ m_bestFitImageURL = bestFitSourceForImageAttributes(document().devicePixelRatio(), 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