OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 float nextDensity; | 331 float nextDensity; |
332 float currentDensity; | 332 float currentDensity; |
333 float geometricMean; | 333 float geometricMean; |
334 | 334 |
335 nextDensity = imageCandidates[next]->density(); | 335 nextDensity = imageCandidates[next]->density(); |
336 if (nextDensity < deviceScaleFactor) | 336 if (nextDensity < deviceScaleFactor) |
337 continue; | 337 continue; |
338 | 338 |
339 currentDensity = imageCandidates[i]->density(); | 339 currentDensity = imageCandidates[i]->density(); |
340 geometricMean = sqrt(currentDensity * nextDensity); | 340 geometricMean = sqrt(currentDensity * nextDensity); |
341 if (deviceScaleFactor >= geometricMean) | 341 if (((deviceScaleFactor <= 1.0) && (deviceScaleFactor > currentDensity))
|| (deviceScaleFactor >= geometricMean)) |
342 return next; | 342 return next; |
343 break; | 343 break; |
344 } | 344 } |
345 return i; | 345 return i; |
346 } | 346 } |
347 | 347 |
348 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) | 348 static unsigned avoidDownloadIfHigherDensityResourceIsInCache(Vector<ImageCandid
ate*>& imageCandidates, unsigned winner, Document* document) |
349 { | 349 { |
350 if (!document) | 350 if (!document) |
351 return winner; | 351 return winner; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 Vector<ImageCandidate> imageCandidates; | 431 Vector<ImageCandidate> imageCandidates; |
432 imageCandidates.append(srcsetImageCandidate); | 432 imageCandidates.append(srcsetImageCandidate); |
433 | 433 |
434 if (!srcAttribute.isEmpty()) | 434 if (!srcAttribute.isEmpty()) |
435 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 435 imageCandidates.append(ImageCandidate(srcAttribute, 0, srcAttribute.leng
th(), DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
436 | 436 |
437 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); | 437 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates
).toString(); |
438 } | 438 } |
439 | 439 |
440 } | 440 } |
OLD | NEW |