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

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: Added a run-time flag, marking this feature as experimental 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
Index: Source/core/html/HTMLImageElement.cpp
diff --git a/Source/core/html/HTMLImageElement.cpp b/Source/core/html/HTMLImageElement.cpp
index bf88109ed9ecad7b640245f02d5216edaa77a176..6d82685bff8ff07cb43ddfbe62d3c047eb49e375 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"
@@ -107,13 +108,21 @@ void HTMLImageElement::collectStyleForPresentationAttribute(const QualifiedName&
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
+const AtomicString HTMLImageElement::imageSourceURL() const
+{
+ return m_bestFitImageURL.isEmpty() ? fastGetAttribute(srcAttr) : m_bestFitImageURL;
do-not-use 2013/09/12 08:23:53 Wouldn't isNull() suffice? Can bestFitSourceForIma
Yoav Weiss 2013/09/12 09:30:20 m_bestFitImageURL is initialized as an empty strin
do-not-use 2013/09/12 09:56:37 To be clear the default constructor for String cre
+}
+
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)

Powered by Google App Engine
This is Rietveld 408576698