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 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 } |
OLD | NEW |