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

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: review comments addressed 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
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLPictureElement.h » ('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 0bb541829b789f1f920d8483d08bc9e4d2054c3d..133f05ac8e72288999949420e5e9800e9ce11342 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -192,12 +192,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(UpdateIgnorePreviousError);
} else if (name == usemapAttr) {
setIsLink(!value.isNull());
} else if (name == compositeAttr) {
@@ -563,4 +558,27 @@ FloatSize HTMLImageElement::defaultDestinationSize() const
return size;
}
+void HTMLImageElement::selectSourceURL(UpdateFromElementBehavior behavior)
+{
+ 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 (behavior == UpdateIgnorePreviousError)
+ m_imageLoader.updateFromElementIgnoringPreviousError();
+ else
+ m_imageLoader.updateFromElement();
+}
}
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/html/HTMLPictureElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698