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

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

Issue 1045353002: Avoid srcset upscaling for 1x DPR scenarios (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | Source/core/html/parser/HTMLSrcsetParserTest.cpp » ('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 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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/parser/HTMLSrcsetParserTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698