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

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

Issue 290203002: <picture>: Update the <img> element when a <source> changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: with tests Created 6 years, 7 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 2c3e81bccccf9f0a8de6b19c88014fb46acdf243..c5d3e210e18b51b7c42cd7e0aeecf5dd465bf5b7 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -172,12 +172,7 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
if (renderer() && renderer()->isImage())
toRenderImage(renderer())->updateAltText();
} else if (name == srcAttr || name == srcsetAttr || name == sizesAttr) {
- unsigned effectiveSize = 0;
- if (RuntimeEnabledFeatures::pictureSizesEnabled())
- effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttribute(sizesAttr), MediaValuesCached::create(document()));
- ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
- setBestFitURLAndDPRFromImageCandidate(candidate);
- m_imageLoader.updateFromElementIgnoringPreviousError();
+ selectSourceURL(true);
} else if (name == usemapAttr) {
setIsLink(!value.isNull());
} else if (name == compositeAttr) {
@@ -543,4 +538,27 @@ FloatSize HTMLImageElement::defaultDestinationSize() const
return size;
}
+void HTMLImageElement::selectSourceURL(bool ignorePreviousError)
Yoav Weiss 2014/05/23 07:39:17 Maybe replace the bool with an enum?
cbiesinger 2014/05/23 19:30:37 Done.
+{
+ bool foundURL = false;
+ if (RuntimeEnabledFeatures::pictureEnabled()) {
+ ImageCandidate candidate = findBestFitImageFromPictureParent();
+ if (!candidate.isEmpty()) {
+ setBestFitURLAndDPRFromImageCandidate(candidate);
+ foundURL = true;
+ }
+ }
+
+ if (!foundURL) {
+ unsigned effectiveSize = 0;
+ if (RuntimeEnabledFeatures::pictureSizesEnabled())
+ effectiveSize = SizesAttributeParser::findEffectiveSize(fastGetAttribute(sizesAttr), MediaValuesCached::create(document()));
+ ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr));
+ setBestFitURLAndDPRFromImageCandidate(candidate);
+ }
+ if (ignorePreviousError)
+ m_imageLoader.updateFromElementIgnoringPreviousError();
+ else
+ m_imageLoader.updateFromElement();
+}
}

Powered by Google App Engine
This is Rietveld 408576698