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

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

Issue 1060483003: Add ImageLoader support for sizes based Client-Hints RW values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix test failures Created 5 years, 8 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/loader/ImageLoader.cpp » ('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 db192613c5c750cdb22c3ce84d94dc12debf0d24..b03b7e8d7d7badec7c3245a05ffc324f2db7c821 100644
--- a/Source/core/html/HTMLImageElement.cpp
+++ b/Source/core/html/HTMLImageElement.cpp
@@ -320,12 +320,7 @@ ImageCandidate HTMLImageElement::findBestFitImageFromPictureParent()
if (!source->mediaQueryMatches())
continue;
- String sizes = source->fastGetAttribute(sizesAttr);
- if (!sizes.isNull())
- UseCounter::count(document(), UseCounter::Sizes);
- SizesAttributeParser parser = SizesAttributeParser(MediaValuesDynamic::create(document()), sizes);
- float effectiveSize = parser.length();
- ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().devicePixelRatio(), effectiveSize, source->fastGetAttribute(srcsetAttr), &document());
+ ImageCandidate candidate = bestFitSourceForSrcsetAttribute(document().devicePixelRatio(), sourceSize(*source), source->fastGetAttribute(srcsetAttr), &document());
if (candidate.isEmpty())
continue;
return candidate;
@@ -635,6 +630,14 @@ FloatSize HTMLImageElement::defaultDestinationSize() const
return FloatSize(size);
}
+float HTMLImageElement::sourceSize(Element& element)
+{
+ String sizes = element.fastGetAttribute(sizesAttr);
+ if (!sizes.isNull())
+ UseCounter::count(document(), UseCounter::Sizes);
+ return SizesAttributeParser(MediaValuesDynamic::create(document()), sizes).length();
+}
+
void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior behavior)
{
if (!document().isActive())
@@ -650,12 +653,7 @@ void HTMLImageElement::selectSourceURL(ImageLoader::UpdateFromElementBehavior be
}
if (!foundURL) {
- String sizes = fastGetAttribute(sizesAttr);
- if (!sizes.isNull())
- UseCounter::count(document(), UseCounter::Sizes);
- SizesAttributeParser parser = SizesAttributeParser(MediaValuesDynamic::create(document()), sizes);
- float effectiveSize = parser.length();
- ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), effectiveSize, fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), &document());
+ ImageCandidate candidate = bestFitSourceForImageAttributes(document().devicePixelRatio(), sourceSize(*this), fastGetAttribute(srcAttr), fastGetAttribute(srcsetAttr), &document());
setBestFitURLAndDPRFromImageCandidate(candidate);
}
if (m_intrinsicSizingViewportDependant && !m_listener) {
« no previous file with comments | « Source/core/html/HTMLImageElement.h ('k') | Source/core/loader/ImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698