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

Side by Side Diff: Source/core/html/parser/HTMLSrcsetParser.cpp

Issue 25105004: Use srcset's resource pixel density to determine intrinsic size (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cleantests
Patch Set: Fixed crash+rebased Created 7 years, 2 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.h ('k') | Source/core/rendering/RenderImage.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const St ring& srcsetAttribute) 148 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const St ring& srcsetAttribute)
149 { 149 {
150 Vector<ImageCandidate> imageCandidates; 150 Vector<ImageCandidate> imageCandidates;
151 151
152 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates); 152 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates);
153 153
154 return pickBestImageCandidate(deviceScaleFactor, imageCandidates); 154 return pickBestImageCandidate(deviceScaleFactor, imageCandidates);
155 } 155 }
156 156
157 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, const String& srcsetAttribute) 157 ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, const St ring& srcAttribute, const String& srcsetAttribute)
158 { 158 {
159 if (srcsetAttribute.isNull()) 159 if (srcsetAttribute.isNull()) {
160 return srcAttribute; 160 if (srcAttribute.isNull())
161 return ImageCandidate();
162 return ImageCandidate(srcAttribute, 0, srcAttribute.length(), 1);
163 }
161 164
162 Vector<ImageCandidate> imageCandidates; 165 Vector<ImageCandidate> imageCandidates;
163 166
164 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates); 167 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates);
165 168
166 if (!srcAttribute.isEmpty()) 169 if (!srcAttribute.isEmpty())
167 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0)); 170 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0));
168 171
169 return pickBestImageCandidate(deviceScaleFactor, imageCandidates).toString() ; 172 return pickBestImageCandidate(deviceScaleFactor, imageCandidates);
170 } 173 }
171 174
172 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, ImageCandidate& srcsetImageCandidate) 175 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, ImageCandidate& srcsetImageCandidate)
173 { 176 {
174 if (srcsetImageCandidate.isEmpty()) 177 if (srcsetImageCandidate.isEmpty())
175 return srcAttribute; 178 return srcAttribute;
176 179
177 Vector<ImageCandidate> imageCandidates; 180 Vector<ImageCandidate> imageCandidates;
178 imageCandidates.append(srcsetImageCandidate); 181 imageCandidates.append(srcsetImageCandidate);
179 182
180 if (!srcAttribute.isEmpty()) 183 if (!srcAttribute.isEmpty())
181 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0)); 184 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0));
182 185
183 return pickBestImageCandidate(deviceScaleFactor, imageCandidates).toString() ; 186 return pickBestImageCandidate(deviceScaleFactor, imageCandidates).toString() ;
184 } 187 }
185 188
186 } 189 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLSrcsetParser.h ('k') | Source/core/rendering/RenderImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698