| 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 document->frame()->console().addMessage(ConsoleMessage::create( | 327 document->frame()->console().addMessage(ConsoleMessage::create( |
| 328 OtherMessageSource, ErrorMessageLevel, | 328 OtherMessageSource, ErrorMessageLevel, |
| 329 String("Dropped srcset candidate ") + | 329 String("Dropped srcset candidate ") + |
| 330 JSONValue::quoteString( | 330 JSONValue::quoteString( |
| 331 String(imageURLStart, imageURLEnd - imageURLStart)))); | 331 String(imageURLStart, imageURLEnd - imageURLStart)))); |
| 332 } | 332 } |
| 333 continue; | 333 continue; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 ASSERT(imageURLEnd > attributeStart); | 337 DCHECK_GT(imageURLEnd, attributeStart); |
| 338 unsigned imageURLStartingPosition = imageURLStart - attributeStart; | 338 unsigned imageURLStartingPosition = imageURLStart - attributeStart; |
| 339 ASSERT(imageURLEnd > imageURLStart); | 339 DCHECK_GT(imageURLEnd, imageURLStart); |
| 340 unsigned imageURLLength = imageURLEnd - imageURLStart; | 340 unsigned imageURLLength = imageURLEnd - imageURLStart; |
| 341 imageCandidates.push_back( | 341 imageCandidates.push_back( |
| 342 ImageCandidate(attribute, imageURLStartingPosition, imageURLLength, | 342 ImageCandidate(attribute, imageURLStartingPosition, imageURLLength, |
| 343 result, ImageCandidate::SrcsetOrigin)); | 343 result, ImageCandidate::SrcsetOrigin)); |
| 344 // 11. Return to the step labeled splitting loop. | 344 // 11. Return to the step labeled splitting loop. |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 static void parseImageCandidatesFromSrcsetAttribute( | 348 static void parseImageCandidatesFromSrcsetAttribute( |
| 349 const String& attribute, | 349 const String& attribute, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 compareByDensity); | 427 compareByDensity); |
| 428 | 428 |
| 429 Vector<ImageCandidate*> deDupedImageCandidates; | 429 Vector<ImageCandidate*> deDupedImageCandidates; |
| 430 float prevDensity = -1.0; | 430 float prevDensity = -1.0; |
| 431 for (ImageCandidate& image : imageCandidates) { | 431 for (ImageCandidate& image : imageCandidates) { |
| 432 if (image.density() != prevDensity && (!ignoreSrc || !image.srcOrigin())) | 432 if (image.density() != prevDensity && (!ignoreSrc || !image.srcOrigin())) |
| 433 deDupedImageCandidates.push_back(&image); | 433 deDupedImageCandidates.push_back(&image); |
| 434 prevDensity = image.density(); | 434 prevDensity = image.density(); |
| 435 } | 435 } |
| 436 unsigned winner = selectionLogic(deDupedImageCandidates, deviceScaleFactor); | 436 unsigned winner = selectionLogic(deDupedImageCandidates, deviceScaleFactor); |
| 437 ASSERT(winner < deDupedImageCandidates.size()); | 437 DCHECK_LT(winner, deDupedImageCandidates.size()); |
| 438 winner = avoidDownloadIfHigherDensityResourceIsInCache(deDupedImageCandidates, | 438 winner = avoidDownloadIfHigherDensityResourceIsInCache(deDupedImageCandidates, |
| 439 winner, document); | 439 winner, document); |
| 440 | 440 |
| 441 float winningDensity = deDupedImageCandidates[winner]->density(); | 441 float winningDensity = deDupedImageCandidates[winner]->density(); |
| 442 // 16. If an entry b in candidates has the same associated ... pixel density | 442 // 16. If an entry b in candidates has the same associated ... pixel density |
| 443 // as an earlier entry a in candidates, | 443 // as an earlier entry a in candidates, |
| 444 // then remove entry b | 444 // then remove entry b |
| 445 while ((winner > 0) && | 445 while ((winner > 0) && |
| 446 (deDupedImageCandidates[winner - 1]->density() == winningDensity)) | 446 (deDupedImageCandidates[winner - 1]->density() == winningDensity)) |
| 447 --winner; | 447 --winner; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 if (!srcAttribute.isEmpty()) | 501 if (!srcAttribute.isEmpty()) |
| 502 imageCandidates.push_back( | 502 imageCandidates.push_back( |
| 503 ImageCandidate(srcAttribute, 0, srcAttribute.length(), | 503 ImageCandidate(srcAttribute, 0, srcAttribute.length(), |
| 504 DescriptorParsingResult(), ImageCandidate::SrcOrigin)); | 504 DescriptorParsingResult(), ImageCandidate::SrcOrigin)); |
| 505 | 505 |
| 506 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates) | 506 return pickBestImageCandidate(deviceScaleFactor, sourceSize, imageCandidates) |
| 507 .toString(); | 507 .toString(); |
| 508 } | 508 } |
| 509 | 509 |
| 510 } // namespace blink | 510 } // namespace blink |
| OLD | NEW |