Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, const String& srcsetAttribute, float& intrinsicSizeFactor) |
| 158 { | 158 { |
| 159 if (srcsetAttribute.isNull()) | 159 if (srcsetAttribute.isNull()) |
| 160 return srcAttribute; | 160 return srcAttribute; |
| 161 | 161 |
| 162 Vector<ImageCandidate> imageCandidates; | 162 Vector<ImageCandidate> imageCandidates; |
| 163 | 163 |
| 164 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates); | 164 parseImageCandidatesFromSrcsetAttribute(srcsetAttribute, imageCandidates); |
| 165 | 165 |
| 166 if (!srcAttribute.isEmpty()) | 166 if (!srcAttribute.isEmpty()) |
| 167 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0)); | 167 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng th(), 1.0)); |
| 168 | 168 |
| 169 return pickBestImageCandidate(deviceScaleFactor, imageCandidates).toString() ; | 169 ImageCandidate candidate = pickBestImageCandidate(deviceScaleFactor, imageCa ndidates); |
| 170 intrinsicSizeFactor = 1 / candidate.scaleFactor(); | |
|
pdr.
2013/10/11 05:17:33
Do we need to check that scaleFactor is non-zero h
Yoav Weiss
2013/10/11 07:22:32
Yes, we should. Will fix.
| |
| 171 | |
| 172 return candidate.toString(); | |
| 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 } |
| OLD | NEW |